Last active
February 10, 2018 03:58
-
-
Save montarion/668d07fc60308d8218274cbe0624a8dc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def email(): | |
| import poplib | |
| #server credentials | |
| Mailbox = poplib.POP3_SSL('pop.googlemail.com', '995') | |
| Mailbox.user('[email protected]') | |
| Mailbox.pass_('password') | |
| numMessages = len(Mailbox.list()[1]) | |
| mailbestand = open('lastemail.txt', 'w') | |
| for i in range(numMessages): | |
| for msg in Mailbox.retr(i+1)[1]: | |
| #print(msg) | |
| mailbestand.write(str(msg)) | |
| Mailbox.quit() | |
| mailbestand = open('lastemail.txt', 'r') | |
| auth = mailbestand.read() | |
| if auth == '': | |
| print('failure') | |
| final = False | |
| else: | |
| print('pass') | |
| final = True | |
| mailbestand.close() | |
| if final == True: | |
| return True | |
| if email() == True: | |
| from random import choice | |
| from string import ascii_letters | |
| def twofactorauthentication(): | |
| rndmlettercode = ''.join(choice(ascii_letters)for x in range(9)) | |
| infile = open('bestand', 'w') | |
| infile.write(rndmlettercode) | |
| infile.close() | |
| file = open('bestand', 'r') | |
| file = file.read() | |
| outfile = open('bestanduit', 'w') | |
| deletword = '=' | |
| for line in file: | |
| for word in deletword: | |
| line = line.replace(word, '') | |
| outfile.write(line) | |
| outfile.close() | |
| outfile = open('bestanduit', 'r') | |
| outfile = outfile.read() | |
| #print(outfile) | |
| emailto = input('Geef u email op: ') | |
| while emailto == '': | |
| emailto = input('Geef u email op: ') | |
| else: | |
| print('Er wordt een email gestuurd naar '+ emailto +', check u spam en normale inbox.') | |
| import smtplib | |
| fromaddress = 'specselect@gmailcom' | |
| toaddress = emailto | |
| message = '\r\n'.join(['from: [email protected]', | |
| 'to: '+emailto, | |
| 'subject: Authenticatiecode', | |
| '', | |
| 'Uw authenticatiecode is: '+outfile]) | |
| gebruikersnaam = '[email protected]' | |
| wachtwoord = 'password' | |
| server = smtplib.SMTP('smtp.gmail.com:587') | |
| server.ehlo() | |
| server.starttls() | |
| server.login(gebruikersnaam,wachtwoord) | |
| server.sendmail(fromaddress,toaddress,message) | |
| server.quit() | |
| authfile = input('Geef u authenticatiecode op, u heeft 4 kansen: ') | |
| counter = 0 | |
| while True: | |
| if authfile == outfile: | |
| print('Authenticatiecode correct, fijne dag verder! ') | |
| break | |
| else: | |
| counter += 1 | |
| print('Authenticatiecode incorrect, probeer het nogmaals') | |
| authfile = input('Geef u authenticatiecode op: ') | |
| if counter == 3 and authfile != outfile: | |
| print('U heeft te vaak de verkeerde authenticatiecode opgegeven, probeer het nog eens over 10 minuten. ') | |
| break | |
| twofactorauthentication() | |
| else: | |
| print("U bent niet in de buurt van de NS fietsenstalling, er zal geen email worden verstuurd.") #hier t nummer van een van ons neerzetten? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment