stream wp 及近期学习

stream wp 及近期学习

在做stream题目的时候 顺便学的东西

首先stream.exe文件,看图标 考虑python解包

 

 

解包后尝试寻找stream文件,并在PYZ-00.pyz_extracted文件中找到pyc文件,随便点开一个用hex打开找到前十六个字节 magic number

``` 6F 0D 0D 0A 00 00 00 00 00 00 00 00 00 00 00 00 ```

将stream改后缀为stream.pyc 并将magic number 添加进去

 

 

 

 

 

 

 

 

 

 

 

 

 

然后尝试uncompyle6反编译stream.pyc文件,发现不行(uncompyle6 只能编译版本低的python 这是用python3.10写的,无法编译,后来发现可以在线。。。)

反编译后得出

import base64
​
def gen(key):
    s = list(range(256))
    j = 0
    for i in range(256):
        j = (j + s[i] + ord(key[i % len(key)])) % 256
        tmp = s[i]
        s[i] = s[j]
        s[j] = tmp
    i = j = 0
    data = []
    for _ in range(50):
        i = (i + 1) % 256
        j = (j + s[i]) % 256
        tmp = s[i]
        s[i] = s[j]
        s[j] = tmp
        data.append(s[(s[i] + s[j]) % 256])
    return data
​
​
def encrypt(text, key):
    result = ''
    for c, k in zip(text, gen(key)):
        result += chr(ord(c) ^ k)
    result = base64.b64encode(result.encode()).decode()
    return result
​
text = input('Flag: ')
key = 'As_we_do_as_you_know'
enc = encrypt(text, key)
if enc == 'wr3ClVcSw7nCmMOcHcKgacOtMkvDjxZ6asKWw4nChMK8IsK7KMOOasOrdgbDlx3DqcKqwr0hw701Ly57w63CtcOl':
    print('yes!')
    return None
None('try again...')

 

base64 加rc4(在线解也可)解得

 

posted @ 2023-02-22 21:56  kayoki  阅读(46)  评论(0)    收藏  举报