Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # added color dict[1]
- # 1. http://stackoverflow.com/questions/2453344/find-the-colour-name-from-a-hexadecimal-colour-code
- # how to use : python antimatripheantispamcolor.py link username email
- # e.g : python http://localhost/matriphe tes tes@gmail.com
- import urllib
- import urllib2
- import cookielib
- import re
- import sys
- colors = {
- 'ff0000' : 'red',
- '008000' : 'green',
- '0060b6' : 'blue',
- 'ffd700' : 'yellow',
- '000000' : 'black',
- 'ffffff' : 'white',
- 'ff69b4' : 'pink',
- 'ffa500' : 'orange',
- '800080' : 'purple',
- '7f7f7f' : 'grey',
- }
- def get_color_name(hx):
- # if color is found in dict
- if colors.has_key(hx):return colors[hx]
- # else return its closest available color
- m = 16777215
- k = '000000'
- for key in colors.keys():
- a = int(hx[:2],16)-int(key[:2],16)
- b = int(hx[2:4],16)-int(key[2:4],16)
- c = int(hx[4:],16)-int(key[4:],16)
- v = a*a+b*b+c*c # simple measure for distance between colors
- # v = (r1 - r2)^2 + (g1 - g2)^2 + (b1 - b2)^2
- if v <= m:
- m = v
- k = key
- return colors[k]
- cj = cookielib.CookieJar()
- opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
- temp = opener.open('%s/wp-login.php?action=register' %sys.argv[1])
- resp = temp.read()
- re2='background-color:\((#{1}(?:[A-F0-9]){6})(?![0-9A-F])\);border-color:#ddd' # HTML Color 1
- search_color = re.findall(r'background-color:(.*); border-color: #ddd', resp)
- search_color_id = re.findall(r'<input type="hidden" name="color_id" value="(.?)" />',resp)
- search_color_hash = re.findall(r'<input type="hidden" name="color_hash" value="(.*)" />',resp)
- search_color = re.sub(r"#",'',search_color[0])
- color_name =get_color_name(search_color)
- post_date = urllib.urlencode({'user_login':sys.argv[2], 'user_email':sys.argv[3], 'color_name':color_name, 'color_id':search_color_id[0], 'color_hash':search_color_hash[0], 'redirect_to':'', 'wp-submit':'Register'})
- print post_date
- final = opener.open('%s/wp-login.php?action=register' %sys.argv[1], post_date)
- final_resp = final.read()
- if re.search(r"Registration complete. Please check your e-mail.", final_resp):
- print "register complete, please check your email"
- else:
- print "error register"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement