-
Notifications
You must be signed in to change notification settings - Fork 0
/
sms_spam.py
72 lines (60 loc) · 1.73 KB
/
sms_spam.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
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time
from selenium.common.exceptions import NoSuchElementException
driver=None
flag=False
username='9777885566'
password='xxxxx'
tgt='9999999999'
mssg='vjvdgfqwvjhbfskhdb'
def load():
global driver
driver=webdriver.Firefox(executable_path="/home/rakesh/py/selenium_drivers/geckodriver")
def login(user,passw):
driver.get('http://www.way2sms.com/content/index.html?')
driver.find_element_by_xpath('//*[@id="username"]').send_keys(user)
driver.find_element_by_xpath('//*[@id="password"]').send_keys(passw)
driver.find_element_by_xpath('//*[@id="loginBTN"]').click()
while(1):
try:
if driver.find_element_by_xpath('//*[@id="mlocator"]'):
flag=True
print('logged in')
time.sleep(1.5)
break
except NoSuchElementException:
time.sleep(1)
pass
finally:
if (flag==False):
print('Trying to login')
else:
print('.')
def sendSms(target,msg,t): #takes 3 argument target_no(str),text(str),dump no(int)
flag1=False
while(1):
try:
driver.find_element_by_xpath('//*[@id="sendSMS"]/a').click()
time.sleep(1)
driver.switch_to_frame("frame")
driver.find_element_by_xpath('//input[@name="mobile"]').send_keys(target)
driver.find_element_by_xpath('//*[@id="message"]').send_keys(msg)
driver.find_element_by_xpath('//*[@id="Send"]').click()
except NoSuchElementException:
pass
flag1=True
finally:
if (flag1!=True):
print('sms sent '+str(t+1)+' times')
break
else:
print('sms not sent')
time.sleep(1)
def spam(t):
for i in range(0,t):
sendSms(tgt,mssg,i)
if __name__ == '__main__':
load()
login(username,password)
spam(1) #no of times you want to send text