You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

106 lines
4.7 KiB

  1. from selenium import webdriver
  2. from selenium.common.exceptions import TimeoutException
  3. from selenium.webdriver.support.ui import WebDriverWait # available since 2.4.0
  4. from selenium.webdriver.support import expected_conditions as EC # available since 2.26.0
  5. from selenium.webdriver.common.keys import Keys
  6. from selenium.webdriver.common.by import By
  7. import json
  8. import time
  9. # read botnetConfig.json data
  10. with open('botnetConfig.json') as data_file:
  11. botnet = json.load(data_file)
  12. print(botnet)
  13. bots = botnet["bots"]
  14. for bot in bots:
  15. # Create a new instance of the Firefox driver
  16. driver = webdriver.Firefox(executable_path='/home/nau/sourceProgramsToInstall/geckodriver')
  17. # TEMP MAIL GENERATE
  18. print "Opening temp-mail.org to create an email account"
  19. driver.get("https://temp-mail.org/en/")
  20. email = driver.find_element_by_id("mail").get_attribute("value")
  21. print email
  22. # Save the window opener (current window, do not mistaken with tab... not the same)
  23. window_email = driver.window_handles[0]
  24. # open new tab
  25. #driver.find_element_by_tag_name('body').send_keys(Keys.CONTROL + "t")
  26. #
  27. # TWITTER SIGNUP
  28. #
  29. print "Opening twitter.com/signup to create a twitter account"
  30. driver.execute_script('''window.open("http://www.twitter.com/signup","_blank");''')
  31. # Save the window opener (current window, do not mistaken with tab... not the same)
  32. window_twitter = driver.window_handles[1]
  33. # Put focus on current window which will, in fact, put focus on the current visible tab
  34. driver.switch_to_window(window_twitter)
  35. delay = 10 # seconds
  36. # wait until the page is loaded, in this case, wait unitl the element with id='full-name' is loaded
  37. myElem = WebDriverWait(driver, delay).until(EC.presence_of_element_located((By.ID, 'full-name')))
  38. print driver.title
  39. driver.find_element_by_id("full-name").send_keys(bot["full-name"])
  40. driver.find_element_by_id("email").send_keys(email)
  41. driver.find_element_by_id("password").send_keys(bot["password"])
  42. driver.find_element_by_id("submit_button").submit()
  43. # PHONE Verification
  44. myElem = WebDriverWait(driver, delay).until(EC.presence_of_element_located((By.ID, 'phone_number')))
  45. driver.find_element_by_id("phone_number").send_keys(botnet["phone-number"])
  46. driver.find_element_by_name("discoverable_by_mobile_phone").click()#checkbox click
  47. driver.find_element_by_name("call_me").submit()
  48. code = raw_input('input something!: ')
  49. driver.find_element_by_id("code").send_keys(code)
  50. driver.find_element_by_id("code").submit()
  51. #
  52. # TWITTER APPS TOKEN GENERATION
  53. #
  54. print "Opening https://apps.twitter.com/ to generate a twitter API tokens"
  55. driver.execute_script('''window.open("https://apps.twitter.com/","_blank");''')
  56. # Save the window opener (current window, do not mistaken with tab... not the same)
  57. window_twitterApps = driver.window_handles[2]
  58. # Put focus on current window which will, in fact, put focus on the current visible tab
  59. driver.switch_to_window(window_twitterApps)
  60. driver.find_elements_by_xpath("//*[contains(text(), 'Create New App')]")[0].click()
  61. driver.find_element_by_id("edit-name").send_keys(bot["full-name"] + "App")
  62. driver.find_element_by_id("edit-description").send_keys(bot["full-name"] + " is a good app")
  63. driver.find_element_by_id("edit-url").send_keys("http://twitter.com")
  64. driver.find_element_by_name("edit-tos-agreement").click()#checkbox click
  65. driver.find_element_by_id("edit-submit").submit()
  66. #generate tokens
  67. driver.find_elements_by_xpath("//*[contains(text(), 'Keys and Access Tokens')]")[0].click()
  68. myElem = WebDriverWait(driver, delay).until(EC.presence_of_element_located((By.ID, 'edit-submit-owner-token')))
  69. driver.find_element_by_id("edit-submit-owner-token").submit()
  70. # get the tokens
  71. myElem = WebDriverWait(driver, delay).until(EC.presence_of_element_located((By.ID, 'edit-token-actions')))
  72. consumerKey = driver.find_elements_by_xpath("//*[contains(text(), 'Consumer Key (API Key)')]/following-sibling::span")[0].text
  73. consumerSecret = driver.find_elements_by_xpath("//*[contains(text(), 'Consumer Secret (API Secret)')]/following-sibling::span")[0].text
  74. accessToken = driver.find_elements_by_xpath("//*[contains(text(), 'Access Token')]/following-sibling::span")[0].text
  75. accessTokenSecret = driver.find_elements_by_xpath("//*[contains(text(), 'Access Token Secret')]/following-sibling::span")[0].text
  76. botnetConfig["consumerKey"] = consumerKey
  77. botnetConfig["consumerSecret"] = consumerSecret
  78. botnetConfig["accessToken"] = accessToken
  79. botnetConfig["accessTokenSecret"] = accessTokenSecret
  80. with open('results.txt', 'w') as outfile:
  81. json.dump(botnetConfig, outfile)