#!/usr/bin/env python # Usage: xangareg.py username pass email import urllib, urllib2, re, sys, os, time pwntcha = "/path/to/pwntcha/src/pwntcha -q -m xanga -s /path/to/pwntcha/share" user_agent = "Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/125.5.5 (KHTML, like Gecko) Safari/125.12" username = sys.argv[1] password = sys.argv[2] email = sys.argv[3] print "Filing Xanga form:", username, password, email data = {} firstpass = 1 pic = "" while True: # Request registration page r = urllib2.Request("http://www.xanga.com/register.aspx", urllib.urlencode(data)) r.add_header('User-Agent', user_agent) f = urllib2.build_opener().open(r) # Parse registration page to get form data re_input = re.compile(".*]*>(<[^>]*>)*([^<]*)(<[^>]*>)*") error = "" while True: l = f.readline() if not l: break m = re_input.match(l) if m: data[m.group(1)] = m.group(2) m = re_image.match(l) if m: pic = m.group(1).replace("&", "&") m = re_error.match(l.strip()) if m: error = m.group(2) if "Please type in the code" in error: print "Captcha cracking failed, trying again." else: print "Xanga error:", m.group(2) sys.exit(0) f.close() if not firstpass and not error: print "Success." break firstpass = 0 # Fill in our form data['txtUsername'] = username data['txtPassword1'] = password data['txtPassword2'] = password data['txtEmail'] = email data['chkOver13'] = 1 data['chkReadTerms'] = 1 # Get the captcha print "Cracking captcha..." filename = re.compile("[^0-9]*([0-9a-z]*).*").match(pic).group(1) + ".jpeg" r = urllib2.Request("http://www.xanga.com/" + pic) r.add_header('User-Agent', user_agent) f = urllib2.build_opener().open(r) image = file(filename, "w+") image.write(f.read()) image.close() # Crack captcha using pwntcha -- Sam's pwntcha is so <3 fd = os.popen(pwntcha + " " + filename) while True: l = fd.readline() if not l: break data['txtLetters'] = l.strip() fd.close() # Remove captcha os.unlink(filename) print "Submitting data..."