Skip to content

Instantly share code, notes, and snippets.

@syndbg
Last active July 27, 2020 02:32
Show Gist options
  • Save syndbg/1e025b5b37b61604ccc9 to your computer and use it in GitHub Desktop.
Save syndbg/1e025b5b37b61604ccc9 to your computer and use it in GitHub Desktop.
Just a super simple spam bot for educational purposes. If you're using *nix, you should pip install selenium.If you're using Windows, you don't deserve to use this anyway. (joke!) Dependencies: Python 2.7 - 3.4, selenium, chromewebdriver (Note: It'll download, extract and make it executable if you don't have it)
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select
from selenium.webdriver.common.keys import Keys
from subprocess import call
from os.path import exists
from urllib.request import urlretrieve
from os import remove
from subprocess import call
from random import randint
import zipfile
import os
def launch_web_driver(choice):
if choice == 1:
current_folder = os.path.dirname(os.path.realpath(__file__))
# Latest Chrome webdriver will be downloaded if not existant
try:
return webdriver.Chrome()
except Exception:
if not exists("/usr/bin/chromedriver") and not exists(current_folder + "/chromedriver"):
urlretrieve("http://chromedriver.storage.googleapis.com/2.10/chromedriver_linux64.zip", "chromedriver.zip")
with zipfile.ZipFile("chromedriver.zip", "r") as z:
z.extractall()
os.remove("chromedriver.zip")
# must be executable
call("chmod u+x chromedriver", shell=True)
return webdriver.Chrome(current_folder + "/chromedriver")
elif choice == 2:
return webdriver.Firefox(str(call("which firefox", shell=True)))
elif choice == 3:
return webdriver.Opera(str(call("which opera", shell=True)))
else:
print("Invalid choice")
sys.exit()
def submit_entry(driver, email_name):
select_email = Select(driver.find_element_by_id("giveaways_answer")).select_by_visible_text("Sublime Text!!!")
enter_email = driver.find_element_by_id("giveaways_email").send_keys(email_name)
submit_button = driver.find_element_by_tag_name("button")
# Workaround: stupid selenium can't/won't click on buttons 90% of the times.
submit_button.send_keys("\n")
def get_email(driver):
email_domains = list(element.text for element in driver.find_elements_by_tag_name("option"))
email_name = driver.find_element_by_id("inbox-id")
email_address = "%s@%s" % (email_name.text, email_domains[randint(0, len(email_domains) - 1)])
print(email_address)
return email_address
def dispose_email_and_renew(driver):
forget_button = driver.find_element_by_id("forget_button")
forget_button.send_keys("\n")
driver.get("https://www.guerrillamail.com/")
def main():
webdriver_choice = int(input("Web browser of choice (1:Chrome, 2:Firefox 3:Opera/Crazy)?: "));
if webdriver_choice not in [1, 2, 3]:
print("Invalid browser choice")
return
submit_driver = launch_web_driver(webdriver_choice)
submit_driver.get("http://sublimetexttips.com/giveaways/sublime-text-giveaway/?lucky=139418")
email_driver = launch_web_driver(webdriver_choice)
email_driver.get("https://www.guerrillamail.com/")
submit_entry(submit_driver, get_email(email_driver))
dispose_email_and_renew(email_driver)
submit_driver.close()
email_driver.close()
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment