Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """
- I ran into this issue when trying to bot a site with emails. I tried to mass send with an address like 'hello@gmail.com' but after some sends they banned hello from sending mail. My first instinct was to use a +str alias onto the email which usually works but this site prevented special characters from being inputted.
- The idea after this point was to encode dots into the gmail username. Personal gmail accounts ignore dots in email usernames so the emails 'alias@gmail.com' and 'a.lias@gmail.com' point to the same person. By exploiting this trick we can encode in binary, any integer. So, the number '5' is '101' in binary, and encoded into 'alias@gmail.com' becomes 'a.li.as@gmail.com' where 1's are dots.
- This allows me to bot the contact form with the same email with the maximum integer allowed inside being equal to 2^len(username). Any integer larger than that will just wrap to the beginning. Please note that this DOES NOT work with non-gmail accounts; even gSuite accounts will be invalid. Only mail going to `gmail.com` will allow for this method.
- """
- import itertools
- def dot_encode_email_username(username: str, member_id: int):
- stripped_username = username.replace('.', '').rstrip('+')
- max_id = pow(2, len(stripped_username)) - 1
- bounded_id = member_id % max_id
- bin_id = bin(bounded_id)[2:]
- i_username = [c for c in stripped_username]
- i_bin_id = ['.' if bool(int(n)) else '' for n in bin_id] #remove b0 from binary string
- i_encoded_username = [x for x in itertools.chain.from_iterable(itertools.zip_longest(i_username,i_bin_id)) if x]
- return ''.join(i_encoded_username).rstrip('.')
- for member in members:
- username = dot_encode_email_username(member['name'], member['id'])
- encoded_email = f'{username}@gmail.com'
- # do something with encoded_email
Add Comment
Please, Sign In to add comment