This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# install http-screenshot script for 32bit BackTrack | |
wget http://wkhtmltopdf.googlecode.com/files/wkhtmltoimage-0.11.0_rc1-static-i386.tar.bz2 | |
tar -jxvf wkhtmltoimage-0.11.0_rc1-static-i386.tar.bz2 | |
cp wkhtmltoimage-i386 /usr/local/bin/ | |
git clone git://github.com/SpiderLabs/Nmap-Tools.git | |
cd Nmap-Tools/NSE/ | |
sed -i 's/wkhtmltoimage-i386 -n/timeout 5 wkhtmltoimage-i386 -n/' http-screenshot.nse |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sometimes you want a timer indepdent of the system clock, in case the system clock changes (e.g. ntpdate). | |
os.times() is the solution under Linux: | |
"Return a 5-tuple of floating point numbers indicating accumulated (processor or other) times, in seconds. The items are: user time, system time, children’s user time, children’s system time, and elapsed real time since a fixed point in the past, in that order. See the Unix manual page times(2) or the corresponding Windows Platform API documentation. On Windows, only the first two items are filled, the others are zero." | |
Under Windows, you could use time.clock(), which will return seconds since the process started. But on Linux the same function returns CPU usage. | |
Window One: | |
>>> import time |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
restarting the *program* on unknown exception is probably a better start | |
this would typically be implemented/configured by your init system | |
in upstart, it's just a matter of adding "respawn" to the config file | |
(there's options for saying how many times to try, with what sort of delay, etc) | |
systemd will have something as well | |
with an old-style shell-script based system, you'd probably want to look into the help "start-stop-daemon", which again has options for this sort of thing | |
Also: | |
http://supervisord.org/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ python -m SimpleHTTPServer | |
Serving HTTP on 0.0.0.0 port 8000 ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if you want the process's exitcode, subprocess.call() returns that. If you want to execute something and raise an exception if it fails, subprocess.check_call() does that. If you want something more complicated, including a conversation with the process you're starting or simply not waiting for the process to end, subprocess.Popen is what you want. | |
import subprocess | |
r=subprocess.check_call(["ls"]) | |
r=subprocess.call(["ls"]) | |
r = subprocess.Popen(["ls"]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Created and send a client probe request | |
iface="mon0" | |
ssid="helloWorld" | |
mac="11:22:33:44:55" | |
p=RadioTap()/Dot11(addr1='ff:ff:ff:ff:ff:ff', addr3='ff:ff:ff:ff:ff:ff',addr2=mac)/Dot11ProbeReq() / Dot11Elt(ID='SSID', info=ssid) | |
sendp(p,iface=iface) | |
#Signal strength |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Setup | |
git config --global user.name "My Name" | |
git config --global user.email "[email protected]" | |
#Initial commit | |
cd my_project | |
git init | |
git commit -m "My initial commit message" | |
git remote add origin [email protected]:my_project.git | |
git push -u origin master |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#BAD: | |
if tbl not in all_data: | |
all_data[tbl] = data | |
else: | |
all_data[tbl] += data | |
#GOOD: | |
all_data.setdefault(tbl, []).extend(data) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:set expandtab | |
:retab | |
:w | |
cat >> ~/.vimrc | |
set listchars=tab:>-,trail:_ list " Show tabs and trailing characters |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import netifaces | |
iface='wlan0' | |
mac=netifaces.ifaddresses(iface)[netifaces.AF_LINK][0]['addr'] |
NewerOlder