Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import telnetlib
- from time import sleep
- # Host and port number for emulator
- # Emulators only listen on localhost
- # PORT can be found in the window title bar
- # for the emulator you want to spam, default is 5554.
- HOST = "localhost"
- PORT = 5554
- # Phone number criteria
- COUNTRY_CODE = 1
- AREA_CODE = 123
- PREFIX = 555
- LEADING = str(COUNTRY_CODE) + str(AREA_CODE) + str(PREFIX)
- SUFFIX_START = 1111
- # SUFFIX, initalized as SUFFIX_START, will be incremented for each COUNT
- # and concatenated with LEADING to form a phone number.
- '''
- For example:
- 11235551111
- 11235551112
- 11235551113
- '''
- # MESSAGES will be looped through, sending each COUNT times
- MESSAGES = ["Subscribe", "Unsubscribe"]
- COUNT = 30
- # Number of seconds to wait between messages
- # Floating point values are allowed; e.g. 0.5 = 500 ms
- DELAY = 1
- def send_sms(number, message):
- tn.write(bytes("sms send {} {}\n".format(number, message), "ascii"))
- def loop_send(message):
- for i in range(COUNT):
- suffix = SUFFIX_START + i
- number = LEADING + str(suffix)
- print("Sending message \"{}\" to {}".format(message, number))
- send_sms(number, message)
- sleep(DELAY)
- print("Initiating connection...")
- tn = telnetlib.Telnet(HOST, PORT)
- tn.read_until(b"OK")
- print("Connection established.")
- for message in MESSAGES:
- loop_send(tn, message)
Advertisement
Add Comment
Please, Sign In to add comment