Attempt number one at making a throwaway mail generator
First of all, some context : I made a bot (yet another one, yes I know, I spend too much time automating stuff) for a game. I had great results which allowed me to play as many characters as I wanted. So I came up with a simple plan : Play an army of 200 characters at the same time.
- earn the reward of the work of basically 200 people 24/7.
- Sell the rewards (and break the in-game economy but that's another issue).
- ???
- profit.
So first of all I needed 200 accounts and I couldn't use like 10 minutemails because it's blacklisted. I needed actual mails like gmail or outlook.
Nowadays there is an evil trend to validate accounts with a phone number, so I had to dig for email accounts without this phone verification.
I decided to automate all that in selenium (see my post about it)
easy.com
The first that I found is easy mail, basically the mail service of the easy giant. (y'know easyjet etc). https://easy.com/free-email
email and password generation
I used the python package names to generate a mail with the form [email protected] with 5 random characters at the end to have an unique address. Easy !
import names first_name = names.get_first_name() last_name = names.get_last_name() username = first_name + '.' + last_name +''.join(random.choice(string.ascii_lowercase+string.digits) for i in range(5))
The password is just 10 random characters :
def gen_pwd(self, length): chars = string.ascii_letters + string.digits + '!@#$%^&*()' random.seed = (os.urandom(1024)) return ''.join(random.choice(chars) for i in range(length))
Automate all that
Pretty easy, we simply fill all the fields :
from selenium import webdriver import names driver = webdriver.Firefox() driver.get("https://easy.com/free-email") first_name = names.get_first_name() last_name = names.get_last_name() driver.find_element_by_id("firstname").send_keys(first_name) driver.find_element_by_id("lastname").send_keys(last_name) username =first_name + '.' + last_name +''.join(random.choice(string.ascii_lowercase+string.digits) for i in range(5)) driver.find_element_by_id("user").send_keys(username) password = self.gen_pwd(10) driver.find_element_by_id("pwd").send_keys(password) driver.find_element_by_id("repwd").send_keys(password)
The captcha
There is a captcha but luckily I have some credit lying around on http://2captcha.com/ (a place where poor souls solve captcha all days for a few cents). To interact with their api you simply need to send the captcha image as base64 and they return to you the text.
So do that, I found the image element, got the direct link to the image :
capcha_url = driver.find_element_by_id("siimage").get_attribute("src")
and then got the image itself :
content = requests.get(capcha_url).content
And encoded that into base 64 :
b64_capcha = base64.b64encode(content)
The api works like this : you submit the image, you get an id, and then you can use that id to get the status of your request, and at some point the status will be "ok" and you get the text.
So we get the id :
result = requests.post("http://2captcha.com/in.php", data={'method': "base64", 'key': apikey, 'body': b64_capcha, 'json' : 1}).text id = json.loads(result)['request']
And then wait for the result :
capchat_text = requests.get("http://2captcha.com/res.php?key=" + apikey + "&action=get&id=" + id).text while ( capchat_text == 'CAPCHA_NOT_READY'): time.sleep(5) print("2capchat not ready, waiting") capchat_text = requests.get("http://2captcha.com/res.php?key=" + apikey + "&action=get&id=" + id).text
And after some time when you exit the loop you can get the text :
capcha_text = requests.get("http://2captcha.com/res.php?action=get&id="+id).text
And fill the corresponding box :
driver.find_element_by_id("captcha_code").send_keys(capcha_text)
Submit everything annnnnnnnd...
driver.find_element_by_class_name("checkbox").click()
driver.find_element_by_name("register_now").click()
It works !
now let's try to login !
Whaaaaaaaat ?
The fatal mistake
After a bit of debugging, I realized that I never tried to register manually. And it was at this moment that I realized that the form isn't actually working. So I made a bot to automate a broken form :)
if you're curious about the code I've put all of it into a python class : https://gist.github.com/drov0/69600a83c5686798f21a4790274a3f42
But I'm not done yet ! I know the russian webmail https://yandex.ru/ doesn't ask for a phone either. I naturally made a bot for it too. But you'll see how I did it on my next post.
Spoiler alert : It ended just as badly.
See you soon !