print(greeting) print('hey n00b!! you know how CBC bit flipping works?\nIf you flip the bit correctly i will reward you fl4g!') msg = "adm1n=0" print("Current Auth Message is : " + msg) print("Encryption of auth Message in hex : " + iv.encode('hex') + encrypt_data(msg)) enc_msg = raw_input("Give me Encrypted msg in hex : ") try: final_dec_msg = decrypt_data(enc_msg)
if"admin=1"in final_dec_msg: print('Whoa!! you got it!! Now its reward time!!') print(flag) else: print('Try again you can do it!!') exit() except: print('bye bye!!')
import random import sys import string from hashlib import sha256 import socketserver from Crypto.Cipher import AES import os import hashlib import time
defadminLogin(self, username): self.request.send(b'1. pic1\n2. pic2\n3. flag\n') c = self.request.recv(2).decode('utf-8')[0] if c == '1': self.request.send(bytes('your gun:\n▄︻┻═┳一\n', 'UTF-8')) elif c == '2': self.request.send(bytes('your Tu Long Knife:\n━╋▇▇▇◤\n', 'UTF-8')) elif c == '3': with open('flag') as f: flag = f.readline() self.request.send(flag.encode('utf-8') + b'\n') else: self.request.send(b'wrong num')
defuserLogin(self, username): self.request.send(b'1. pic1\n2. pic2\n') c = self.request.recv(2).decode('utf-8')[0] if c == '1': self.request.send(bytes('your gun:\n▄︻┻═┳一', 'UTF-8')) elif c == '2': self.request.send(bytes('your Tu Long Knife:\n━╋▇▇▇◤', 'UTF-8')) else: self.request.send(b'wrong num')
defhandle(self): # self.justWaite()
whileTrue: self.isAdmin = False self.request.send(wel) wel_choice = self.request.recv(2).decode('utf-8')[0] if wel_choice == '1': self.request.send(b'input your cookie:>>') cookie = self.request.recv(513).decode('utf-8')[:-1] msg = bytes.fromhex(cookie) msg = self.decrypt(msg) print(msg) print(len(msg)) try: for i in range(len(msg) - 3): if msg[i:i + 3] == 'un=': username = msg[i + 3:] username = username.split(';')[0] print(username)
for i in range(len(msg) - 3): if msg[i:i + 3] == 'pw=': passwd = msg[i + 3:] passwd = passwd.split(';')[0] print(passwd)
for i in range(len(msg) - 8): if msg[i:i + 8] == 'isAdmin=': if msg[i + 8:i + 13] == 'True;': self.isAdmin = True except Exception as e: print('error detected\n') print(e)
self.request.send(b'input your password:>>') pw_t = self.request.recv(37).decode('utf-8')[:-1] if pw_t != passwd: self.request.send(b'wrong passwd!') break self.request.send(b'welcome! %s\n' % (username.encode('utf-8'))) if self.isAdmin: self.adminLogin(username) else: self.userLogin(username)
elif wel_choice == '2': self.request.send(b'welcome! are you an admin?(Y/N)\n') reg_c = self.request.recv(2).decode('utf-8')[0] if reg_c == 'Y': self.request.send(b'input admin key:>>') u_key = self.request.recv(33).decode('utf-8')[:-1] if u_key != admin_key: break else: self.isAdmin = True self.request.send(b'input your name:>>\n') username = self.request.recv(37).decode('utf-8')[:-1] if'admin'in username.lower(): self.request.send(b'no admin in username\n') continue self.request.send(b'input your pw:>>\n') passwd = self.request.recv(37).decode('utf-8')[:-1] if'admin'in passwd.lower(): self.request.send(b'no admin in password\n') continue cookie = self.encrypt( 'isAdmin=False' + ';pw=' + passwd + ';un=' + username).hex() self.request.send(b'your cookie:>>\n' + cookie.encode('utf-8') + b'\n') else: break