Guest User

Untitled

a guest
Oct 8th, 2018
356
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.78 KB | None | 0 0
  1. """
  2. 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.
  3.  
  4. 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.
  5.  
  6. 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.
  7. """
  8. import itertools
  9.  
  10. def dot_encode_email_username(username: str, member_id: int):
  11. stripped_username = username.replace('.', '').rstrip('+')
  12.  
  13. max_id = pow(2, len(stripped_username)) - 1
  14. bounded_id = member_id % max_id
  15. bin_id = bin(bounded_id)[2:]
  16.  
  17. i_username = [c for c in stripped_username]
  18. i_bin_id = ['.' if bool(int(n)) else '' for n in bin_id] #remove b0 from binary string
  19.  
  20. i_encoded_username = [x for x in itertools.chain.from_iterable(itertools.zip_longest(i_username,i_bin_id)) if x]
  21. return ''.join(i_encoded_username).rstrip('.')
  22.  
  23. for member in members:
  24. username = dot_encode_email_username(member['name'], member['id'])
  25. encoded_email = f'{username}@gmail.com'
  26. # do something with encoded_email
Add Comment
Please, Sign In to add comment