def signup(): form = RegistrationForm(request.form) if request.method == 'POST' and form.validate(): #user = User(form.username.data, form.email.data, # form.password.data) t1 = Email() recp=form.email.data if t1(recp): prefix = request.url_root.split('/')[2].split('.')[0] if prefix == "localhost:5000": prefix = "asdf" keyid=get_val('corp.cf.zone',":%s" % prefix, second)[:-(len(prefix)+1)] add_state(keyid, 'corp-userdata', json.dumps({'name':form.name.data, 'email':form.email.data, 'country':form.country.data, 'address':form.address.data, 'company':form.company.data, 'dept':form.dept.data, 'pos':form.pos.data, 'serno':form.serno.data, 'password':form.password.data, })) #flash("Thanks for registering, you will receive further instruction at %s." % recp) msg = Message("registration successful, welcome at Corporation.", sender = "*****@*****.**", recipients = [recp]) msg.body = render_template('welcome.txt', name=form.name.data, host=request.url_root.split('/')[2]) mail.send(msg) return redirect(url_for('login')) return render_template('register.html', form=form)
def login(): form = LoginForm(request.form) if request.method == 'POST' and form.validate(): prefix = request.url_root.split('/')[2].split('.')[0] if prefix == "localhost:5000": prefix = "asdf" keyid=get_val('corp.cf.zone',":%s" % prefix, second)[:-(len(prefix)+1)] rec=json.loads(get_state(keyid, 'corp-userdata') or '') if(form.email.data==rec['email'] and form.password.data==rec['password']): # f**k yeah plaintext passwords ftw! add_state(keyid, 'corp-login', '') response = make_response(redirect('/')) response.set_cookie('login', True) return response return render_template('login.html', form=form)
def main(window): renderer.initialize() curses.curs_set(0) dimens = window.getmaxyx() main_window = window.subwin(22, 20, dimens[0] // 2 - 11, dimens[1] // 2 - 10) main_window.nodelay(1) main_window.keypad(1) game.init() game.add_state_and_switch("main_menu", MainMenuState(main_window)) game.add_state("paused", PauseState(main_window)) game.add_state("game", GameState(main_window)) game.run()
def doxer(msg, mailid=None, host=None): try: keyid=get_val('dox-mailid',":%s" % mailid, second)[:-(len(mailid)+1)] except TypeError: #print >>sys.stderr, 'nomailid' return # no such mailid pwd=get_state(keyid, 'prod.pdf.pass') #logging.info("pwd "+pwd) if not pwd: add_state(keyid, 'prod.pdf.err',"I got a mail, but i was not aware of the password at that time. try to resend it after telling me the password please.") return err = None for mpart in msg.walk(): part=to_message(mpart) #if part.get_content_maintype() == 'multipart' or len(part.get_payload(decode=True)) < 268125: if part.get_content_maintype() == 'multipart': #print >>sys.stderr, 'skip', len(part.get_payload(decode=True) or ''), part.get_content_maintype() continue size = len(part.get_payload(decode=True)) if (size < 200000 or size > 310000): continue hash=hashlib.sha256() def hupdate(data): # workaround for http://bugs.python.org/issue17481 hash.update(data) ret=gpg('-d', '--passphrase', pwd, _ok_code=[0,2], _in=part.get_payload(decode=True), _out=hupdate) if ret.exit_code!=0: add_state(keyid, 'prod.pdf.err',"got a mail, but gpg had problems, try fixing the problem and resend the mail. gpg said this\n"+err) break #logging.info('ret '+str(ret)) #logging.info('stderr '+ret.stderr) err=str(ret.stderr) # for flushing the process? #print >>sys.stderr, 'err', err if hash.hexdigest() == '658be96015645fe1d646fd167c1ac3bd372360530191d574ace5870c5aeb132f': add_state(keyid, 'prod.pdf.done','1') break else: add_state(keyid, 'prod.pdf.err',"got a mail, but it wasn't quite what i expected, so i dropped it.") break else: add_state(keyid, 'prod.pdf.err',"got a mail, but there was nothing found that looked like a reasonably sized pgp payload")