forked from gretaline/DarkSpread
-
Notifications
You must be signed in to change notification settings - Fork 4
/
main.py
80 lines (66 loc) · 2.76 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import time
import json
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
emails = []
def readMails():
with open("emails.txt", "r") as ins:
for line in ins:
emails.append(line)
def initBrowser():
browser = False
options = webdriver.ChromeOptions()
options.add_argument("--user-data-dir=assets\\Browsers\\Chrome\\User Data")
browser = webdriver.Chrome(executable_path="assets\\webdriver\\chromedriver.exe",chrome_options=options)
browser.get('https://mail.google.com')
return browser
def gmail(browser,email,config):
if("mail.google.com" not in browser.current_url ):
print("Bot is waiting for Login or Gmail Tab is not Active")
time.sleep(5)
else:
#print("We are on Gmail, wait a bit")
time.sleep(10)
browser.find_element_by_xpath("//div[@gh='cm']").click()
mailto = browser.find_element_by_xpath("//textarea[@role='combobox']")
mailto.clear()
mailto.send_keys(email)
time.sleep(5)
subjectBox = browser.find_element_by_xpath("//input[@name='subjectbox']")
subjectBox.clear()
subjectBox.send_keys(config["botconfig"]["subject"])
time.sleep(5)
maintext = browser.find_element_by_xpath("//div[@role='textbox']")
maintext.clear()
with open(config["botconfig"]["mailbodyFile"], 'r') as myfile:
html = myfile.read()
maintext.send_keys(html.strip(' \t\n\r'))
time.sleep(5)
browser.find_element_by_xpath("//tr[@class='btC']/td[1]").click()
print("Mail Send to "+ email)
if __name__ == "__main__":
spider = """
______ _ _____ _
| _ \ | | / ___| | |
| | | |__ _ _ __| | _\ `--. _ __ _ __ ___ __ _ __| |
| | | / _` | '__| |/ /`--. \ '_ \| '__/ _ \/ _` |/ _` |
| |/ / (_| | | | </\__/ / |_) | | | __/ (_| | (_| |
|___/ \__,_|_| |_|\_\____/| .__/|_| \___|\__,_|\__,_|
| |
|_| v1.0
"""
print(spider)
with open('config.ini') as data_file:
config = json.load(data_file)
print("Reading Emails...")
readMails()
print("Start Browser...")
browser = initBrowser()
if(browser == False):
print("Failed to Start Web Browser\n")
exit()
while(1):
print("Start Work...")
for email in emails:
print("Current: "+email.strip(' \t\n\r'))
gmail(browser,email.strip(' \t\n\r'),config)