Uncategorised
- Details
- Written by Sonny Yu
opkg update opkg install python-openssl #adds ssl support to python opkg install distribute #it contains the easy_install command line tool (this can take some time) easy_install pip #installs pip (this can take some time) pip install pytz
nano getdatetime.py
#!/usr/bin/python import datetime import pytz def getdatetime_with_timezone(): fmt = '%Y-%m-%d %H:%M:%S %Z' d = datetime.datetime.now(pytz.timezone("America/New_York")) d_string = d.strftime(fmt) return d_string print getdatetime_with_timezone()
chmod 755 getdatetime.py
./getdatetime.py 2024-09-30 15:30:58 EDT
Write comment (0 Comments)
- Details
- Written by Sonny Yu
opkg update opkg install python-openssl #adds ssl support to python opkg install distribute #it contains the easy_install command line tool (this can take some time) easy_install pip #installs pip (this can take some time) pip install requests
nano ipinfo.py
#!/usr/bin/python import json import requests def getipinfo(): result = requests.get('http://ipinfo.io/json/') json_result = json.loads(result.text) tmpstr='' for key, value in json_result.items(): tmpstr=tmpstr+'"'+value+'",' return tmpstr[:-1] print getipinfo()
chmod 755 ipinfo.py
./ipinfo.py
"39.0437,-77.4875","Ashburn","US","Virginia","ec2-54-211-19-103.compute-1.amazonaws.com","54.211.19.103","AS14618 Amazon.com, Inc.","20147"
Write comment (0 Comments)
- Details
- Written by Sonny Yu
1. Reset Yun to factory default by:
reset-to-factory-anyway reboot
( backup your own data )
2. Setup WIFI STA mode:
3. SSH to wifi ip address:
nano setwanstaticip.sh
#!/bin/ash uci set network.wan.proto=static uci set network.wan.ipaddr=192.168.241.1 uci set network.wan.netmask=255.255.255.0 uci commit network /etc/init.d/network restart
root@Arduino:~# /bin/ash setwanstaticip.sh Successfully initialized wpa_supplicant root@Arduino:~#
4.Setup 192.168.241.2 at PC
5.Entering http://192.168.241.1/ goto firewall setting edit both zone.
Make sure lan to wan, wan to lan forwardings and masquerading enabled.
Write comment (0 Comments)
- Details
- Written by Sonny Yu
Install 2.6 python-crypto
opkg update opkg remove python-crypto wget http://www.ibuyopenwrt.com/images/software/python-crypto_2.6-1_ar71xx.ipk opkg install python-crypto_2.6-1_ar71xx.ipk Installing python-crypto (2.6-1) to root... Configuring python-crypto.
nano rsa.py
from Crypto.PublicKey import RSA from Crypto.Util.randpool import RandomPool def encrypt_RSA(message,public_key): encrypted = public_key.encrypt(message,64) return encrypted[0] def decrypt_RSA(package,private_key): decrypted = private_key.decrypt(package) return decrypted pool = RandomPool() pool.stir() rsa_key = RSA.generate(1024,pool.get_bytes) print rsa_key.publickey().exportKey("PEM") print rsa_key.exportKey("PEM") test = encrypt_RSA("Hello World!",rsa_key.publickey()) print test print decrypt_RSA(test,rsa_key)
python rsa.py
-----BEGIN PUBLIC KEY----- MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDVlXuJ3LaJ4E6v5Iis+ULjddX7 BeYW2XKgXlUbzma6Sx4jbyGOim1bCKc+IauXl8RvcPCKS7DVmhL7b9v82YX6XMC8 /Mx0SQ5UHkIbhYyWNU/+Tddu2BBaRZIStzKO7O6LT1GpjgqO9fFmhvp6nNSRakZr S5a5TP+7zhksHmeXawIDAQAB -----END PUBLIC KEY----- -----BEGIN RSA PRIVATE KEY----- MIICXgIBAAKBgQDVlXuJ3LaJ4E6v5Iis+ULjddX7BeYW2XKgXlUbzma6Sx4jbyGO im1bCKc+IauXl8RvcPCKS7DVmhL7b9v82YX6XMC8/Mx0SQ5UHkIbhYyWNU/+Tddu 2BBaRZIStzKO7O6LT1GpjgqO9fFmhvp6nNSRakZrS5a5TP+7zhksHmeXawIDAQAB AoGABU/oeK9Sou8/RcSrWZIBheLCZbHp3RufbDmsaDqj93Iy17LF5OOwgJkgf70a pXSS4Cqw8N+dEFL6seJAWHOYj2vkz6hu+ccvw8Q2O/Wi7D71LqNhUk3/jBPE1rvZ UWSbvZ++MjAxlYk6saaD+vnJjAzu5jiTL+tNbS9GE62Yj1ECQQDdJKR/d1HmSAeY vdClpdPsJ/sFP3UY+t3mUACNKaLcXeOA1DNQsAZn/fx0ePpiCw9uvsQxxHY/vOfl WElJ1Uj/AkEA9z/RTh3RUeJrTtyH1RVECDmqnblSHkhcIErJfyaRTGHRCUHKrJWg 7Wd/Pek8u32Eu+4vgeKEn71BHBHG7QjllQJBAJCwC8y2ReiUUhwWfTAUKm8FzZAm b7fzU0IAMAwsJLln2JUOwbBWKyrZG9cc3D1PnT5JJFangvK650LAG9tp6AMCQQDR g9uqdWv+Fn7WOdxEvZuD2NHyi6rBjJG8r4Ml4xm2/yCy1nSXYMgYxN43KWDUhB2p XsIVL00xS59T2OCX1jUtAkEAk/ogaS9dO2ap+llHcmsQ5sD/lcoaVMFCNBrcN9EC 2ZXR8QCT1geuELuOzREuGW/SmBzuj0IHBpSuHmNQ2l6KXQ== -----END RSA PRIVATE KEY----- ▒▒▒w▒Т▒~l▒;.▒▒▒▒Q▒▒\xѳy`;N▒▒%▒▒E▒f֙▒▒|▒▒1 ▒▒٣@▒▒▒ l▒hk1nW▒▒~▒▒d▒ Hello World!
Write comment (0 Comments)
Page 1 of 16