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