wmsuper 发表于 2018-12-1 12:03

python写的一个简单的ctf

本帖最后由 wmsuper 于 2018-12-1 12:19 编辑

flag以“@52pojie.cn"结尾。题目来源于某个ctf,稍微改了一下,最先做出来有500CB的奖励,希望大家喜欢。
enjoy it {:301_978:}

链接:https://pan.baidu.com/s/1qClRQhH4pNSHc7YrjbNnwQ

onmiuncai 发表于 2018-12-1 14:38

{:17_1083:} 不懂python,没法愉快的玩耍了 看来是。

lvcaolhx 发表于 2018-12-1 14:40

import struct
import sys
import base64
import zlib
code = []
pc = 0

def exec_instruction(a, b, c):
    global code
    code -= code
    code &= 4294967295L
    ret = False
    if code & 2147483648L != 0 or code == 0:
      ret = True
    if c != 0:
      return ret
    else:
      return False


def exec_vm(entry, size):
    global pc
    pc = entry
    while pc + 3 <= size:
      if exec_instruction(code, code, code):
            if code == -1:
                return
            pc = code
      else:
            pc += 3
      if code == 1:
            sys.stdout.write(chr(code))
            code = 0
            code = 0
      if code == 1:
            c = sys.stdin.read(1)
            code = ord(c)
            code = 0


def main():
    code_base64 = 'eJztWmuMVdUV3jNzn3Nnzr2F2lb/eB3TxKaDVgeqgkGUQTF9ODg0VmsqM8NrUMYpAzNME2migCA4xCdabIo6irHaFOXRNNZXRaBtSqQRRGmxaNRSwFYQHyDTvbvW4q6z7trn3hv52S/5cs7Z61trr73245y5YEwxrracZnmjZYflTZazsS1vORfb3H23ZT+2zcT2LrT14fMcjDXV8gy01VpOQO1cjD2HxZ/J+nN9tFn2IHlcF3M06gz6zUV2o+0cZLtlJ9puxLzPFmN0ugstL7D8Dl5dHhOVOv0fJwe/sLzGwBzMMzCX2tpwVznfZ1YZM9lUtl6cphNt7r6D2amfDux79Eke6yjL8zBH1+cszMX1eTbmMxLv3R7hdaH9cQPq+03xfuzFeB2sfQ7T0rh5DceVkZeL14X3BnNzSFnWWJ5m56HX8iXLb1cbM2i513KSNb5X88XnqBP7j5orqp8RYyZdrymspR6WyzSMPYP1M41pO5md6s3H0s40baJvPjdT2ZhoHDwn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9q0B0GGT8NmqxJd9apqDAVCzH1T0LwZADb52h6Noq80CNT21c3wWADVo7dR2Kot1uiduA2v/OruflIU9WM20HNWmGDGkw7hssc2HS7LhtTQBn5tFjHJq6/AD9J+cLazBGVmgg1yXM5TazMkCNfjaJfpQ15sFan33RsS6TdiWZcN7YgXaB7JAh9uFz4ASX/apaZ7JAjX7M4p+cRaowdfu8IKwvWyfP2dj3IL2zVmgwx+Ez+Yyxqhp9meBmn2/on8+C9Tga3f4VNg+z4b/r3lVLmyP2efTkQ6fCP/ThZ76p3a6nsp0ecXH4e/YXoN0OEdoa4wf38rh3s0hTXgvG1No57g2B9Ts1yr6Y9lCO10nMd3Vnj5+xNrv5P3h/S05oINcp7coMW/NATX9rYp+aQ6o6Zd65uQEStkZ3DyuR2p9rVdibcgBNf0GRf9sDqjpnz2JY9mEa+pl4RN1jmxHn1eFj9w7HHzf7UX/f+QKZ/ThHNBBntuHlfEM5YAafO2E/wKRsNEX'
    bin_code = zlib.decompress(base64.b64decode(code_base64))
    for i in range(0, len(bin_code), 4):
      code.append(struct.unpack('I', bin_code))

    back_code = code
    exec_vm(1123, len(code))


if __name__ == '__main__':
    main()
源代码,flag弄不出来,水平有限

NSNSDHS 发表于 2018-12-1 14:29

学会了,谢谢楼主

wmsuper 发表于 2018-12-1 14:56

onmiuncai 发表于 2018-12-1 14:38
不懂python,没法愉快的玩耍了 看来是。
c版的,密钥和算法一样的,希望大佬玩得开心:https://pan.baidu.com/s/1efeTLJ_ME-0bSMdTAlJ-ug

充电室 发表于 2018-12-1 16:13

呃,刚学会hello Word

guidao 发表于 2018-12-2 00:39

lvcaolhx 发表于 2018-12-1 14:40
import struct
import sys
import base64


老哥,这源码咋弄得啊?,我照网上先转pyc,结果转了一大堆,也不知道是哪个

lvcaolhx 发表于 2018-12-2 09:01

guidao 发表于 2018-12-2 00:39
老哥,这源码咋弄得啊?,我照网上先转pyc,结果转了一大堆,也不知道是哪个

用pyinstxtractor.py生成py4py.exe_extracted文件夹,里面有py4py没后缀名的这个

一个人的ye 发表于 2018-12-2 11:42

这个零基础怎么学,难不难啊

woaijiajia 发表于 2018-12-2 11:57

不错不错
页: [1] 2 3
查看完整版本: python写的一个简单的ctf