initial commit
This commit is contained in:
7
源码/source/task-src/get-marshaled.py
Normal file
7
源码/source/task-src/get-marshaled.py
Normal file
@@ -0,0 +1,7 @@
|
||||
import marshal
|
||||
import dis
|
||||
|
||||
code = compile(open('plain.py').read(), "<frozen>", "exec")
|
||||
dis.dis(code)
|
||||
print(code.co_code, len(code.co_code))
|
||||
marshal.dump(code, open("plain.marshal", "wb"))
|
30
源码/source/task-src/get-obfuscated.py
Normal file
30
源码/source/task-src/get-obfuscated.py
Normal file
@@ -0,0 +1,30 @@
|
||||
from Crypto.Cipher import AES
|
||||
from Crypto.Util.Padding import pad
|
||||
import marshal
|
||||
import os
|
||||
|
||||
aes_key = os.urandom(17)
|
||||
with open('../obfuscator/build/lib.win-amd64-cpython-310/pyhumor_runtime.cp310-win_amd64.pyd', 'rb') as fin:
|
||||
filled = fin.read().replace(b'WAIT_TO_BE_FILLED', aes_key)
|
||||
with open('pyhumor_runtime.cp310-win_amd64.pyd', 'wb') as fout:
|
||||
fout.write(filled)
|
||||
|
||||
code = compile(open('plain.py').read(), "<frozen>", "exec")
|
||||
raw = marshal.dumps(code)
|
||||
|
||||
code_len = len(code.co_code)
|
||||
encrypt_len = (code_len - 8) - (code_len - 8) % 16
|
||||
cipher = AES.new(aes_key[1:], AES.MODE_ECB)
|
||||
encrypted = cipher.encrypt(raw[38:38+encrypt_len])
|
||||
assert len(encrypted) == encrypt_len
|
||||
raw = raw[:38] + encrypted + raw[38+encrypt_len:]
|
||||
raw = pad(raw, 16)
|
||||
|
||||
cipher = AES.new(aes_key[:16], AES.MODE_ECB)
|
||||
encrypted = cipher.encrypt(raw)
|
||||
structured = b'PYHUMOR\x00\x00\x03\x0A\x00' + len(encrypted).to_bytes(4, 'little') + encrypted
|
||||
|
||||
open("pyhumor.py", "w").write(f'''from pyhumor_runtime import __pyhumor__
|
||||
|
||||
__pyhumor__(__name__, __file__, {repr(structured)})
|
||||
''')
|
3
源码/source/task-src/get-task-pyc.py
Normal file
3
源码/source/task-src/get-task-pyc.py
Normal file
@@ -0,0 +1,3 @@
|
||||
import py_compile
|
||||
|
||||
py_compile.compile('pyhumor.py', 'pyhumor.pyc')
|
35
源码/source/task-src/plain.py
Normal file
35
源码/source/task-src/plain.py
Normal file
@@ -0,0 +1,35 @@
|
||||
# flag{9bc74ce3-a56d-467f-eb52-d5f3d8923c6f}
|
||||
|
||||
__humor_enter__()
|
||||
|
||||
try:
|
||||
from hashlib import sha256
|
||||
from functools import reduce
|
||||
|
||||
flag = input('Enter your flag: ')
|
||||
|
||||
group_1 = [
|
||||
int.from_bytes(flag[1::3].encode(), 'big') % 998244353 == 156881262,
|
||||
sha256(flag[-16:].encode()).hexdigest().endswith('dcf56476457880bf5b39b295416f267b7a636324baeae1fd'),
|
||||
reduce(lambda x, y: x ^ y, map(ord, flag)) == 2,
|
||||
]
|
||||
|
||||
if not all(group_1):
|
||||
print('Wrong')
|
||||
exit(1)
|
||||
|
||||
acc = 0
|
||||
for i in flag:
|
||||
i = ord(i) ^ 0x55
|
||||
acc |= i
|
||||
acc <<= (7 if i & 1 else 8)
|
||||
|
||||
if acc == 27473331342481820165679397757145329260017933200691317902624657196062576436414763023083043884214272:
|
||||
print('Right')
|
||||
else:
|
||||
print('Wrong')
|
||||
exit(1)
|
||||
|
||||
except:
|
||||
print('Stop reverse engineering me, enjoy your day :)')
|
||||
exit(1)
|
Reference in New Issue
Block a user