Friday, November 4, 2011
Simple Python Portscan Function
Here's a basic portscan function written in python - http://pastebin.com/v6ntptfT
Thursday, November 3, 2011
Python Curses Example / Tutorial
I wanted to make a small example tutorial on getting started with a curses UI in python. We'll get started by creating our screen and adding a simple string;
import curses
screen = curses.initscr() # Creates our screen
curses.noecho() # Keeps the keys we press from
curses.cbreak() # Takes input right away
screen.keypad(1)
screen.addstr(10,0,"Resist Monsanto!") # Add a string at 10,0
screen.refresh() # Refresh screen now that strings added
# While loop to wait for key events, then
while 1:
key = screen.getch() # Get presse keys
if key == ord("q"): break
curses.endwin() # Closes curses environment
This should result in a screen with the string "Resist Monsanto" in it. If we wanted to use colors we can create color pairs to use like so:
First we initiate the color scheme and than we will create a color pair;
curses.init_pair(1, curses.COLOR_CYAN, curses.COLOR_BLACK) # Creates a color pair as 1 with foreground cyan and background black
We can now use this color pair when adding a string for example;
This would result in the following script - http://pastebin.com/0EU7UKqZ
But lets say we wanted to get user input rather than just the key event and create a variable out of it, in this case we would use curses.getstr() function. Here we'll create a simple function to get our input called command().
def command():
curses.echo() # Allows out input to be echo'd to the screen
cmd = screen.getstr(0,1,15) # Creates an "input box" at the location (0,1) with an input buffer of 15
def command(): # Press "c" to start user input
curses.echo() # Allows out input to be echo'd to the screen
cmd = screen.getstr(0,1,15) # Creates an "input box" at the location (0,1) with an input buffer of 15 charscurses.noecho() # Turns echo back off
screen.addstr(2,0,cmd,curses.color_pair(2)) # Adds users input
This would result in the following - http://pastebin.com/zVzrGz0n
Thursday, October 27, 2011
Python Script for Monitoring a site to see whether it's up or down
Quick script I coded to save me time checking to see if a site was down, so I wrote this script to do it for me and to send me an alert using "libnotify-bin" if it happens to go down.
Two methods are available, Ping and HTTP Requests.
If I decide to add more methods, or add more sites to the HTTP request (to insure accuracy) than I'll post an update.. until then I hope you find this useful!
Monday, October 24, 2011
Python Script to Parse Files for MD5 Hashes
This script demonstrates basic usage of regular expressions in order to look for MD5's (AKA [0-9a-f]{32}) and write them to an output file.
Usage :
Python # python md5parser.py SomeFile.txt MD5list
File parsed ~ 6 hashes found.
Python # cat MD5list
aad3b435b51404eeaad3b435b51404ee
9a5760252b7455deaad3b435b51404ee
0d7f1f2bdeac6e574d6e18ca85fb58a7
9a5760252b7455deaad3b435b51404ee
0d7f1f2bdeac6e574d6e18ca85fb58a7
098f6bcd4621d373cade4e832627b4f6
Script: http://pastebin.com/PPnDs6AU
Subscribe to:
Posts (Atom)