pyc re

Author Avatar
Xzhah 9月 05, 2017
  • 在其它设备中阅读本文章

这是一道pyc题目
cflag.png

*反编译

反编译如下

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
data = "M,\x1d-\x18}E'\x1ezN~\x1b*\x19+\x12%\x1d-" + 'I\x7fM(I{I\x7fJ.\x16wWcRj\x0e6\x0fn' + 'Zo\nn\x0fk\t1R7\x03g\x067\x00eUb\x043' + '\x014\x071Rr\x14x\x19~D?q"a5s,A%' + "\x10'\x11uLyA%\x1d|DrFv\x12t\x11#B&" + 'GsKzK*O)\x1c%GuC>\x1e\x7f\x1b+\x19*' + '\x1e&\x14-\x1f/\x1axAqBq@yO-LtE}' + '\x1b,MuBp\x12'
import os
import sys
import struct
import cStringIO
import string
import dis
import marshal
import types
import random
count = 0
def reverse(string):
return string[::-1]
data_list = list(reverse(data)[1:])
def decrpyt(c, key2):
global count
data_list[count] = c ^ key2
count += 1
def GetFlag1():
key = struct.unpack('B', data[len(data) - 8])[0]
for c in data_list:
if count == 0:
decrpyt(struct.unpack('B', c)[0], key)
continue
key = struct.unpack('B', data[len(data) - 3])[0]
decrpyt(struct.unpack('B', c)[0], key)
for c in data_list[::-1]:
print chr(c),
def GetFlag2():
key = struct.unpack('B', data[len(data) - 11])[0]
for c in data_list:
if count == 0:
decrpyt(struct.unpack('B', c)[0], key)
continue
key = struct.unpack('B', data[len(data) - 4 - count])[0]
decrpyt(struct.unpack('B', c)[0], key)
for c in data_list[::-1]:
print chr(c),
def GetFlag3():
key = struct.unpack('B', data[len(data) - 5])[0]
for c in data_list:
if count == 0:
decrpyt(struct.unpack('B', c)[0], key)
continue
key = struct.unpack('B', data[len(data) - 2 - count])[0]
decrpyt(struct.unpack('B', c)[0], key)
for c in data_list[::-1]:
print chr(c),
def GetFlag4():
global count
key = struct.unpack('B', data[len(data) - 1])[0]
for c in data_list:
if count == 0:
decrpyt(struct.unpack('B', c)[0], key)
continue
key = struct.unpack('B', data[len(data) - 1 - count])[0]
decrpyt(struct.unpack('B', c)[0], key)
count = 0
for c in data_list[::-1]:
print chr(c),
def GetFlag5():
key = struct.unpack('B', data[len(data) - 9])[0]
for c in data_list:
if count == 0:
decrpyt(struct.unpack('B', c)[0], key)
continue
key = struct.unpack('B', data[len(data) - 3 - count])[0]
decrpyt(struct.unpack('B', c)[0], key)
for c in data_list[::-12]:
print chr(c),
GetFlag1()

*结果

直接把几个GetFlag运行一遍就行了
最终结果在GetFlag4里面
1.png