Advertisement
Guest User

antimatripheantispamcolor.py

a guest
Jan 29th, 2014
352
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/env python
  2. # added color dict[1]
  3. # 1. http://stackoverflow.com/questions/2453344/find-the-colour-name-from-a-hexadecimal-colour-code
  4. # how to use : python antimatripheantispamcolor.py link username email
  5. # e.g : python http://localhost/matriphe tes tes@gmail.com
  6.  
  7. import urllib
  8. import urllib2
  9. import cookielib
  10. import re
  11. import sys
  12.  
  13. colors = {
  14.     'ff0000' : 'red',
  15.     '008000' : 'green',
  16.     '0060b6' : 'blue',
  17.     'ffd700' : 'yellow',
  18.     '000000' : 'black',
  19.     'ffffff' : 'white',
  20.     'ff69b4' : 'pink',
  21.     'ffa500' : 'orange',
  22.     '800080' : 'purple',
  23.     '7f7f7f' : 'grey',
  24. }
  25.  
  26. def get_color_name(hx):
  27.     # if color is found in dict
  28.     if colors.has_key(hx):return colors[hx]
  29.  
  30.     # else return its closest available color
  31.     m = 16777215
  32.     k = '000000'
  33.     for key in colors.keys():
  34.         a = int(hx[:2],16)-int(key[:2],16)
  35.         b = int(hx[2:4],16)-int(key[2:4],16)
  36.         c = int(hx[4:],16)-int(key[4:],16)
  37.  
  38.         v = a*a+b*b+c*c # simple measure for distance between colors
  39.  
  40.         # v = (r1 - r2)^2 + (g1 - g2)^2 + (b1 - b2)^2
  41.  
  42.         if v <= m:
  43.             m = v
  44.             k = key
  45.  
  46.     return colors[k]
  47.  
  48.  
  49. cj = cookielib.CookieJar()
  50. opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
  51. temp = opener.open('%s/wp-login.php?action=register' %sys.argv[1])
  52. resp = temp.read()
  53. re2='background-color:\((#{1}(?:[A-F0-9]){6})(?![0-9A-F])\);border-color:#ddd'    # HTML Color 1
  54. search_color = re.findall(r'background-color:(.*); border-color: #ddd', resp)
  55. search_color_id = re.findall(r'<input type="hidden" name="color_id" value="(.?)" />',resp)
  56. search_color_hash = re.findall(r'<input type="hidden" name="color_hash" value="(.*)" />',resp)
  57. search_color = re.sub(r"#",'',search_color[0])
  58. color_name =get_color_name(search_color)
  59. 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'})
  60. print post_date
  61. final = opener.open('%s/wp-login.php?action=register' %sys.argv[1], post_date)
  62. final_resp = final.read()
  63.  
  64. if re.search(r"Registration complete. Please check your e-mail.", final_resp):
  65.     print "register complete, please check your email"
  66. else:
  67.     print "error register"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement