print "There was an error getting the signup value!" sys.exit(1) signup = signup_value[0] # Download the verification image print "Downloading picture..." data = opener.open(IMAGE_LINK).read() # Write it to a temporary image open("temp.png","wb").write(data) #os.startfile("temp.png") # Remove shadow and turn to monochrome print "Fixing image..." tb_image.tb_fix_image("temp.png","temp.bmp") code = Image.open("temp.bmp") # Scan the columns first = True for x in xrange(code.size[0]-1): # Get the current column and the next one col1 = [xlate_col(code.getpixel((x,y))) for y in xrange(code.size[1])] col2 = [xlate_col(code.getpixel((x+1,y))) for y in xrange(code.size[1])] # Skip a white column if 1 not in col1: continue # If this is our first column with a letter, add it to the column cut list if first:
def register_to_torrent_bytes(opener, username, password, email): global g_reached_timeout # Read the signup temporary variable print_message(MSG_INFO, "Opening signup page...") html = opener.open(SIGNUP_LINK).read() # Check to see if we got the hidden variable signup_value = re.findall(SIGNUP_REGEX, html) if (not signup_value): print_message(MSG_CRITICAL, "There was an error getting the signup value!") signup = signup_value[0] # Download the verification image print_message(MSG_INFO, "Downloading confirmation code picture...") data = opener.open(CONFIRMATION_CODE_IMAGE_LINK).read() # Write it to a temporary image open("temp.png", "wb").write(data) # Remove shadow and turn to monochrome print_message(MSG_INFO, "Fixing image...") tb_image.tb_fix_image("temp.png", "temp.bmp") code = Image.open("temp.bmp") confirmation_code = tb_image.find_confirmation_code(code) print_message(MSG_INFO, "Confirmation code: %s" % confirmation_code) # Make sure we got 8 letters total if (len(confirmation_code) != 8): print_message( MSG_ERROR, "Wrong number of letters detected (%d instead of 8)!" % (len(confirmation_code))) return False # Create the query string query_string = "confirmation_code_enter=%s&signup=%s&btnsignup=Sign+Up!" % ( confirmation_code, signup) # Resend the signup page with a POST of the confirmation code next_html = opener.open(SIGNUP_LINK, query_string).read() # Check to see if we can register now if (USER_LIMIT_REACHED in next_html): print_message(MSG_ERROR, "Registration limit reached.") return False elif (ENTER_CONFIRMATION in next_html): # Uh oh, something went wrong... print_message(MSG_ERROR, "There was an error, reached confirmation code screen!") return False else: # We can probably register now... so we wait. print_message(MSG_INFO, "Reached registration form. Entering user details...") # Start the registration timer. g_reached_timeout = False timer = Timer(REGISTRATION_TIMEOUT, reached_timeout) timer.start() # Download the verification image print_message(MSG_INFO, "Downloading second confirmation code picture...") data = opener.open(CONFIRMATION_CODE_IMAGE_LINK).read() # Write it to a temporary image open("temp.png", "wb").write(data) # Remove shadow and turn to monochrome print_message(MSG_INFO, "Fixing image...") tb_image.tb_fix_image("temp.png", "temp.bmp") code = Image.open("temp.bmp") confirmation_code = tb_image.find_confirmation_code(code) print_message(MSG_INFO, "Confirmation code: %s" % confirmation_code) # Make sure we got 8 letters total if (len(confirmation_code) != 8): print_message( MSG_ERROR, "Wrong number of letters detected (%d instead of 8)!" % (len(confirmation_code))) return False print_message(MSG_INFO, "Reading rules page...") # Read the rules page. rules_html = opener.open(RULES_LINK).read() # Read the FAQ page. print_message(MSG_INFO, "Reading FAQ page...") faq_html = opener.open(FAQ_LINK).read() print_message( MSG_INFO, "Waiting for %d seconds to pass..." % (REGISTRATION_TIMEOUT)) while (not g_reached_timeout): sleep(1) # Create the query string query_string = "confirmation_code=%s&signup=%s&btnsignup=Sign+Up!&wantusername=%s&wantpassword=%s&passagain=%s&email=%s&rulesverify=yes&faqverify=yes&ageverify=yes" % ( confirmation_code, signup, username, password, password, email) print_message(MSG_INFO, "Posting registration info...") # Send the registration info page with a POST of the confirmation code and user details sign_up_html = opener.open(TAKE_SIGNUP_LINK, query_string).read() if (USER_LIMIT_REACHED in sign_up_html) or (USER_LIMIT_REACHED2 in sign_up_html): print_message(MSG_ERROR, "Registration limit reached.") return False elif (IP_EXISTS in sign_up_html): ip = re.findall(SAME_IP_REGEX, sign_up_html) if (ip): print_message( MSG_ERROR, "Seems like someone with the same IP address (%s) is already registered at Torrentbytes." % ip[0]) else: print_message( MSG_ERROR, "Seems like someone with the same IP address is already registered at Torrentbytes." ) print_message(MSG_ERROR, "Replace IP and press Enter to continue...") raw_input() return False elif (REGISTRATION_SUCCESSFUL in sign_up_html): email = re.findall(CONFIRMATION_EMAIL_REGEX, sign_up_html) if (email): print_message( MSG_INFO, "Registration successful! Confirmation email sent to: %s" % email[0]) else: print_message(MSG_INFO, "Registration successful!") print_message(MSG_INFO, "Press Enter to continue...") raw_input() return True else: print_message(MSG_ERROR, "Unknown response:") print sign_up_html print_message(MSG_ERROR, "Press Enter to continue...") raw_input() return False
def register_to_torrent_bytes(opener, username, password, email): global g_reached_timeout # Read the signup temporary variable print_message(MSG_INFO, "Opening signup page...") html = opener.open(SIGNUP_LINK).read() # Check to see if we got the hidden variable signup_value = re.findall(SIGNUP_REGEX, html) if (not signup_value): print_message(MSG_CRITICAL, "There was an error getting the signup value!") signup = signup_value[0] # Download the verification image print_message(MSG_INFO, "Downloading confirmation code picture...") data = opener.open(CONFIRMATION_CODE_IMAGE_LINK).read() # Write it to a temporary image open("temp.png","wb").write(data) # Remove shadow and turn to monochrome print_message(MSG_INFO, "Fixing image...") tb_image.tb_fix_image("temp.png","temp.bmp") code = Image.open("temp.bmp") confirmation_code = tb_image.find_confirmation_code(code) print_message(MSG_INFO, "Confirmation code: %s" % confirmation_code) # Make sure we got 8 letters total if (len(confirmation_code) != 8): print_message(MSG_ERROR, "Wrong number of letters detected (%d instead of 8)!" % (len(confirmation_code))) return False # Create the query string query_string = "confirmation_code_enter=%s&signup=%s&btnsignup=Sign+Up!" % (confirmation_code, signup) # Resend the signup page with a POST of the confirmation code next_html = opener.open(SIGNUP_LINK, query_string).read() # Check to see if we can register now if (USER_LIMIT_REACHED in next_html): print_message(MSG_ERROR, "Registration limit reached.") return False elif (ENTER_CONFIRMATION in next_html): # Uh oh, something went wrong... print_message(MSG_ERROR, "There was an error, reached confirmation code screen!") return False else: # We can probably register now... so we wait. print_message(MSG_INFO, "Reached registration form. Entering user details...") # Start the registration timer. g_reached_timeout = False timer = Timer(REGISTRATION_TIMEOUT, reached_timeout) timer.start() # Download the verification image print_message(MSG_INFO, "Downloading second confirmation code picture...") data = opener.open(CONFIRMATION_CODE_IMAGE_LINK).read() # Write it to a temporary image open("temp.png","wb").write(data) # Remove shadow and turn to monochrome print_message(MSG_INFO, "Fixing image...") tb_image.tb_fix_image("temp.png","temp.bmp") code = Image.open("temp.bmp") confirmation_code = tb_image.find_confirmation_code(code) print_message(MSG_INFO, "Confirmation code: %s" % confirmation_code) # Make sure we got 8 letters total if (len(confirmation_code) != 8): print_message(MSG_ERROR, "Wrong number of letters detected (%d instead of 8)!" % (len(confirmation_code))) return False print_message(MSG_INFO, "Reading rules page...") # Read the rules page. rules_html = opener.open(RULES_LINK).read() # Read the FAQ page. print_message(MSG_INFO, "Reading FAQ page...") faq_html = opener.open(FAQ_LINK).read() print_message(MSG_INFO, "Waiting for %d seconds to pass..." % (REGISTRATION_TIMEOUT)) while (not g_reached_timeout): sleep(1) # Create the query string query_string = "confirmation_code=%s&signup=%s&btnsignup=Sign+Up!&wantusername=%s&wantpassword=%s&passagain=%s&email=%s&rulesverify=yes&faqverify=yes&ageverify=yes" % (confirmation_code, signup, username, password, password, email) print_message(MSG_INFO, "Posting registration info...") # Send the registration info page with a POST of the confirmation code and user details sign_up_html = opener.open(TAKE_SIGNUP_LINK, query_string).read() if (USER_LIMIT_REACHED in sign_up_html) or (USER_LIMIT_REACHED2 in sign_up_html): print_message(MSG_ERROR, "Registration limit reached.") return False elif (IP_EXISTS in sign_up_html): ip = re.findall(SAME_IP_REGEX, sign_up_html) if (ip): print_message(MSG_ERROR, "Seems like someone with the same IP address (%s) is already registered at Torrentbytes." % ip[0]) else: print_message(MSG_ERROR, "Seems like someone with the same IP address is already registered at Torrentbytes.") print_message(MSG_ERROR, "Replace IP and press Enter to continue...") raw_input() return False elif (REGISTRATION_SUCCESSFUL in sign_up_html): email = re.findall(CONFIRMATION_EMAIL_REGEX, sign_up_html) if (email): print_message(MSG_INFO, "Registration successful! Confirmation email sent to: %s" % email[0]) else: print_message(MSG_INFO, "Registration successful!") print_message(MSG_INFO, "Press Enter to continue...") raw_input() return True else: print_message(MSG_ERROR, "Unknown response:") print sign_up_html print_message(MSG_ERROR, "Press Enter to continue...") raw_input() return False