Saturday, 7 January 2012

Solve any Captcha

This method is: 95.9% accurate(last time I checked). This program uses the site captchatrader.com and you'll need an account there.

import urllib, urllib2, sys

if len(sys.argv )<2:
    sys.exit("the first argument should be the captcha file")
url = "http://api.captchatrader.com/submit"
api_key = "API_KEY"
passwd = "PASSWORD"
user = "USERNAME"
img = base64.b64encode(open(sys.argv[1]).read())

values = {'api_key' : api_key,'password' : passwd,'username' : user, 'value':img}
data = urllib.urlencode(values)
req = urllib2.Request(url, data)
response = urllib2.urlopen(req)
the_page = response.read().split(",")
the_page = the_page.replace("\"", "")
the_page = the_page.replace("]", "")
print the_page[1]
Just change the variables the top to your credentials then run it using these arguments:
python captcha.py '/image/location/image.jpg'
My Def for clicking and controlling the mouse in windows mac and linux

If you are in windows you'll need to install pywin32 and if you are in linux or OSX then you'll need to install xdotool

def click(x, y):
    if os.name == "posix":
        os.system("xdotool mousemove " + str(x) + " " + str(y))
        os.system("xdotool click 1")
    else:
        win32api.SetCursorPos((x,y))
        win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,x,y,0,0)
        win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,x,y,0,0)

in the code it's basically saying if the operating system is posix (linux/mac) then run the nesseary terminal commands the move the mouse to x,y then click it. but if the operating system is not Linux or windows then use win32api (part of pywin32) to move the mouse then click it.

in windows you must:
import win32api, win32con
in Linux/Mac you must:
import os

Friday, 6 January 2012

Generate real random urls in python
This will create a random ip address using random.randint(0, 255) like this:

        ip0 = str(random.randint(0, 255))
        ip1 = str(random.randint(0, 255))
        ip2 = str(random.randint(0, 255))
        ip3 = str(random.randint(0, 255))
        url = ip0 + '.' + ip1 + '.'+ ip2 + '.'+ ip3
It will then try to get the hosts address by using socket.gethostbyaddr(url) and if it's good/real it will print the address and write it to the file links.txt


import random, urllib2, os, socket, time
from threading import Thread, active_count

f=open("links.txt", 'w')
global p
global done
global alinks
alinks = []
maxurls = 100
p=0
def main():
    global alinks
    global done
    global p
    while p != maxurls:
        ip0 = str(random.randint(0, 255))
        ip1 = str(random.randint(0, 255))
        ip2 = str(random.randint(0, 255))
        ip3 = str(random.randint(0, 255))
        url = ip0 + '.' + ip1 + '.'+ ip2 + '.'+ ip3
        try:
            link = socket.gethostbyaddr(url)
            print link[0]
            f.write(link[0])
            f.write("\n")
            p=p+1
            try:
                urlContent = urllib2.urlopen(url).read()
                if urlContent.find('<html') > -1 or urlContent.find('<HTML') > -1:
                    break
            except:
                pass
        except:
            pass
    done = done - 1
   

maxi = 55
done = maxi
hhh = 0
while hhh != maxi:
    hhh=hhh+1
    Thread(target=main, args=()).start()

while done != 0 or done > 0:
        time.sleep(1.2)

print "Writing to File"
alinks.tofile(f)
print "Done exiting"

Download - mediafire.com
Download - codepanel.net

Wednesday, 4 January 2012

Bruteforce dictionary creator.

Need a dictionary file but don't want to download 36GB? Just use the script to create of for your self.

Download

it takes no arguments, it will ask you for the specs in program.
How to compile python in linux

In this tutorial we'll be using freeze ,  just use your python script as the first argument see:
python freeze.py yourfile.py

Tuesday, 3 January 2012

Convert Images to text and text back to images

When we convert images to/from text we use base64 and import python you can use base64 by 
import base64
 So this script will open the image from the first argument and save to readable text version as output.txt


import sys, base64

img = open(sys.argv[1], 'r')
txt = img.read()
txt2 = base64.b64encode(txt)
txtfile = open("output.txt", 'w')
txtfile.write(txt2)
#print txt2

If you uncomment the last line by removing the '#' it will print out the text value of the image.

And this 

import sys, base64

img = open(sys.argv[1], 'r')
txt = img.read()
txt2 = base64.b64decode(txt)
txtfile = open("output.png", 'w')
txtfile.write(txt2)
Will open the text file as the first argument and output the image to 'output.png'

Download

Monday, 2 January 2012

Controlling the CD/DVD drive in python

This program requires pygame to be installed

import pygame.cdrom as cdrom
cdrom.init()
cd = cdrom.CD(0) # 0 = first cdrom device
cd.init()
cd.eject()
cd.quit()
cdrom.quit()