forked from laudarch/Shellsploit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstackconvert.py
More file actions
193 lines (156 loc) · 4.52 KB
/
Copy pathstackconvert.py
File metadata and controls
193 lines (156 loc) · 4.52 KB
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
179
180
181
182
183
184
185
186
187
188
189
190
191
#------------------Bombermans Team---------------------------------#
#Author : B3mB4m
#Concat : [email protected]
#Project : https://github.com/b3mb4m/Shellsploit
#LICENSE : https://github.com/b3mb4m/Shellsploit/blob/master/LICENSE
#------------------------------------------------------------------#
import sys
import re
import codecs
#In py3 not like py2, byte-like objects will fuck up your strings.So you must decode before use them ..
def plaintext( string):
string = codecs.encode(str.encode(string), 'hex')
string = string.decode('utf-8')
db = re.findall("..?", string)
return "\\x"+"\\x".join(db)
def plaintextreverse( string):
string = codecs.encode(str.encode(string), 'hex')
string = string.decode('utf-8')
db = re.findall("..?", string)
return "\\x"+"\\x".join(db[::-1])
def PORT( port):
from convertoffset import decimaltohex
db = []
fixmesempai = re.findall('..?', decimaltohex(str(port)))
for x in fixmesempai:
if len(x) == 1:
x = "0"+x
db.append(x)
return "\\x"+"\\x".join(db)
def IP( ip):
from convertoffset import decimaltohex
#0x101017f : 127.1.1.1
ip = str(ip).split(".")
db = []
db2 = []
for x in ip:
db.append(decimaltohex( int(x)))
for x in db:
if len(x) == 1:
x = "0"+x
db2.append(x)
return "\\x"+"\\x".join(db2)
def rawSTR( string):
db = []
for x in string:
first = codecs.encode(str.encode(x), 'hex')
x = x.decode('utf-8')
db.append("\\x"+x)
return "".join(db)
def ARM( string):
db = []
if "/" in string:
if len(string) % 4 == 0:
string = string
elif len(string) % 4 == 1:
string = filler( string, 4)
elif len(string) % 4 == 2:
string = filler( string, 3)
elif len(string) % 4 == 3:
string = filler( string, 2)
for x in range(0,len(string),4):
db.append(ARMsplitter(string[x:x+4]))
return "".join(db)
def ARMsplitter( hexdump, pushdword="None"):
db = []
if pushdword == "None":
fixmesempai = re.findall('....?', hexdump)
for x in fixmesempai[::-1]:
first = codecs.encode(str.encode(x[::-1]), 'hex')
first = first.decode('utf-8')
second = re.findall("..?", first)[::-1]
db.append("\\x"+"\\x".join(second))
return "".join(db)
def stackconvertSTR( string, win=False):
db = []
if len(string) == 1:
string = codecs.encode(str.encode(string), 'hex')
string = string.decode('utf-8')
return r"\x6a"+r"\x"+string
if "/" in string:
if len(string) % 4 == 0:
string = string
elif len(string) % 4 == 1:
string = filler( string, 4)
elif len(string) % 4 == 2:
string = filler( string, 3)
elif len(string) % 4 == 3:
string = filler( string, 2)
for x in range(0,len(string),4):
db.append(splitter(string[x:x+4]))
return "".join(db[::-1])
#return "".join(db)
#Linux_x86
#68 PUSH DWORD
#6668 PUSH WORD
#6A PUSH BYTE
if len(string) == 4:
first = codecs.encode(str.encode(string[::-1]), 'hex')
stack = first.decode('utf-8')
data = re.findall("..?", stack)
return "\\x68\\x"+"\\x".join(data)
elif len(string) % 4 == 0:
for x in range(0,len(string),4):
db.append(splitter(string[x:x+4]))
if win == True:
return "".join(db[::-1]) #Windows
else:
return "".join(db) #Unix,Linux etc..
elif 2 < len(string) < 4:
first = codecs.encode(str.encode(hexdump[::-1]), 'hex')
first = first.decode('utf-8')
second = re.findall("..?", first)[::-1]
for x in second:
db.append("\\x"+x)
return "\\x66\\x68"+"".join(db)
else:
db = []
for x in range(0,len(string),4):
if len(string[x:x+4]) == 4:
db.append(splitter(string[x:x+4]))
else:
db.append(splitter(string[x:x+4], "WordTime"))
if win == True:
return "".join(db[::-1]) #Windows
else:
return "".join(db) #Unix,Linux etc..)
def filler( string, number):
string = [x for x in string]
for x in range(0, len(string)):
if string[x] == "/":
string[x] = "/"*number
break
return "".join(string)
def splitter( hexdump, pushdword="None"):
db = []
if pushdword == "None":
fixmesempai = re.findall('....?', hexdump)
for x in fixmesempai[::-1]:
first = codecs.encode(str.encode(x[::-1]), 'hex')
first = first.decode('utf-8')
second = re.findall("..?", first)[::-1]
db.append("\\x"+"\\x".join(second))
return "\\x68"+"".join(db)
else:
#Byte ..
if len(hexdump) == 1:
string = codecs.encode(str.encode(hexdump), 'hex')
string = string.decode('utf-8')
return r"\x6a"+r"\x"+string
else:
first = codecs.encode(str.encode(hexdump[::-1]), 'hex')
first = first.decode('utf-8')
second = re.findall("..?", first)[::-1]
for x in second:
db.append("\\x"+x)
return "\\x66\\x68"+"".join(db)