def
decrypt(start,filename,key):
with
open
(
"encrypt"
,
"rb"
) as f:
data
=
f.read()[start:]
res
=
[]
for
i
in
range
(
32
,
127
):
res
=
[]
found
=
0
for
d
in
data:
byte
=
ord
(d)^i^key
res.append(
chr
(byte))
if
byte
=
=
0x90
and
res[
-
2
]
=
=
'\xfb'
:
print
"[*] key: "
,
chr
(i)
found
=
1
if
found
=
=
1
:
if
i
=
=
ord
(
'a'
):
pos1
=
"
".join(res).find("
\xfb\x90")
print
pos1
pos2
=
res[pos1
+
2
:].index(
'\x90'
)
print
pos2
pos
=
pos1
+
2
+
pos2
+
1
res
=
res[:pos1
+
2
+
pos2
+
1
]
with
open
(filename,
"wb"
) as f:
f.write("".join(res))
return
pos
def
decrypt_end(start,filename,key):
with
open
(
"encrypt"
,
"rb"
) as f:
data
=
f.read()[start:]
res
=
[]
for
i
in
range
(
32
,
127
):
res
=
[]
found
=
0
for
d
in
data:
byte
=
ord
(d)^i^key
res.append(
chr
(byte))
if
byte
=
=
0x90
:
print
"[*] key: "
,
chr
(i)
found
=
1
print
len
(res)
break
if
found
=
=
1
:
if
i
=
=
ord
(
'K'
):
pos
=
"
".join(res).find("
\x90")
print
pos
res
=
res[:pos
+
1
]
with
open
(filename,
"wb"
) as f:
f.write("".join(res))
return
pos
return
0
pos
=
decrypt(start
=
0
,filename
=
"decrypt_1"
,key
=
0
)
pos
=
decrypt(start
=
74
,filename
=
"decrypt_2"
,key
=
ord
(
'e'
))
pos
=
decrypt(start
=
74
+
71
,filename
=
"decrypt_3"
,key
=
ord
(
'e'
)^
ord
(
'v'
))
pos
=
decrypt(start
=
74
+
71
+
71
,filename
=
"decrypt_4"
,key
=
ord
(
'e'
)^
ord
(
'v'
)^
ord
(
'X'
))
pos
=
decrypt(start
=
74
+
71
+
71
+
71
,filename
=
"decrypt_5"
,key
=
ord
(
'e'
)^
ord
(
'v'
)^
ord
(
'X'
)^
ord
(
'n'
))
pos
=
decrypt_end(start
=
74
+
71
+
71
+
71
+
62
,filename
=
"decrypt_6"
,key
=
ord
(
'e'
)^
ord
(
'v'
)^
ord
(
'X'
)^
ord
(
'n'
)^
ord
(
'a'
))