forked from nickvourd/Responder-Parser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathResponder-Parser.py
1188 lines (893 loc) · 49.4 KB
/
Responder-Parser.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
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
##############################################
# Responder-Parser.py #
# Author: Nikos Vourdas (@nickvourd) #
# Co-Author: Prithvi Chintha #
# License: MIT #
# Required Dependencies: None #
##############################################
import argparse
from platform import system
from os import walk, path, remove, getcwd
from shutil import copyfile, rmtree
from sys import exit, argv
#Global variables
__authors__ = ["@nickvourd", "Prithvi Chintha"]
__version__ = "3.0"
__license__ = "MIT"
__github__ = "https://github.com/nickvourd/Responder-Parser"
__ascii__ = '''
_____ _ _____
| __ \ | | | __ \
| |__) |___ ___ _ __ ___ _ __ __| | ___ _ __ ______| |__) |_ _ _ __ ___ ___ _ __
| _ // _ \/ __| '_ \ / _ \| '_ \ / _` |/ _ \ '__|______| ___/ _` | '__/ __|/ _ \ '__|
| | \ \ __/\__ \ |_) | (_) | | | | (_| | __/ | | | | (_| | | \__ \ __/ |
|_| \_\___||___/ .__/ \___/|_| |_|\__,_|\___|_| |_| \__,_|_| |___/\___|_|
| |
|_|
Responder-Parser v.{} - Responder's parsing tool.
Responder-Parser is an open source tool licensed under {}.
Written with <3 by {} && {}...
Please visit {} for more...
'''.format(__version__, __license__, __authors__[0], __authors__[1], __github__)
#Arguments function
def Arguments(argv):
parser = argparse.ArgumentParser(formatter_class=argparse.RawDescriptionHelpFormatter, prog="Responder-Parser", usage='%(prog)s [options]')
parser.add_argument('--cleardb', action='store_true', required=False, help="clear Responder.db data")
parser.add_argument('--clearlogs', action='store_true', required=False, help="clear Responder's logs")
parser.add_argument('-v', '--version', action='version', version='%(prog)s 3.0, Version Name: Rolling Stone')
parser.add_argument('-b', '--backup', action='store_true', required=False, help="keep backup of Responder.conf, Responder.py and settings.py")
parser.add_argument('-r', '--restore', action='store_true', required=False, help="restore backup of Responder.conf, Responder.py and settings.py to original")
parser.add_argument('-c', '--challenge', type=str, dest='NUMBER', required=False, help="set challenge to Repsonder.conf")
parser.add_argument('-m', '--machinename', type=str, dest='MACHINENAME', required=False, help="set machine name to settings.py")
parser.add_argument('-d', '--domain', type=str, dest='DOMAIN', required=False, help="set domain name to settings.py")
parser.add_argument('-u', '--username', type=str, dest='USERNAME', required=False, help="set username to settings.py")
parser.add_argument('--dhcp', type=str, dest='HOSTNAME', required=False, help="set DHCP Hostname to settings.py")
parser.add_argument('--rpcport', type=int, dest='PORT', required=False, help="set RPC port to settings.py")
parser.add_argument('--sql', type=str, dest='SQLSWITCH', required=False, help="set SQL server ON/OFF to Responder.conf")
parser.add_argument('--smb', type=str, dest='SMBSWITCH', required=False, help="set SMB server ON/OFF to Responder.conf")
parser.add_argument('--rdp', type=str, dest='RDPSWITCH', required=False, help="set RDP server ON/OFF to Responder.conf")
parser.add_argument('--kerberos', type=str, dest='KERBEROSSWITCH', required=False, help="set Kerberos server ON/OFF to Responder.conf")
parser.add_argument('--ftp', type=str, dest='FTPSWITCH', required=False, help="set FTP server ON/OFF to Responder.conf")
parser.add_argument('--pop', type=str, dest='POPSWITCH', required=False, help="set POP server ON/OFF to Responder.conf")
parser.add_argument('--smtp', type=str, dest='SMTPSWITCH', required=False, help="set SMTP server ON/OFF to Responder.conf")
parser.add_argument('--imap', type=str, dest='IMAPSWITCH', required=False, help="set IMAP server ON/OFF to Responder.conf")
parser.add_argument('--http', type=str, dest='HTTPSWITCH', required=False, help="set HTTP server ON/OFF to Responder.conf")
parser.add_argument('--https', type=str, dest='HTTPSSWITCH', required=False, help="set HTTPS server ON/OFF to Responder.conf")
parser.add_argument('--dns', type=str, dest='DNSSWITCH', required=False, help="set DNS server ON/OFF to Responder.conf")
parser.add_argument('--ldap', type=str, dest='LDAPSWITCH', required=False, help="set LDAP server ON/OFF to Responder.conf")
parser.add_argument('--dcerpc', type=str, dest='DCERPCSWITCH', required=False, help="set DCERPC server ON/OFF to Responder.conf")
parser.add_argument('--winrm', type=str, dest='WINRMSWITCH', required=False, help="set WINRM server ON/OFF to Responder.conf")
parser.add_argument('--mqtt', type=str, dest='MQTTSWITCH', required=False, help="set MQTT server ON/OFF to Responder.conf")
parser.add_argument('--snmp', type=str, dest='SNMPSWITCH', required=False, help="set SNMP server ON/OFF to Responder.conf")
parser.add_argument('--setdb', type=str, dest='DATABASENAME', required=False, help="set Database file to Responder.conf")
parser.add_argument('--sessionlog', type=str, dest='SESSIONLOG', required=False, help="set Session log file to Responder.conf"),
parser.add_argument('--poisonlog', type=str, dest='POISONERSLOG', required=False, help="set Poisoners log file to Responder.conf")
parser.add_argument('--analyzelog', type=str, dest='ANALYZELOG', required=False, help="set Analyze mode log file to Responder.conf")
parser.add_argument('--configdumplog', type=str, dest='CONFIGDUMPLOG', required=False, help="set Confing Dump log file to Responder.conf")
parser.add_argument('--autoignore', type=str, dest='AUTOIGNORE', required=False, help="set option AutoIgnoreAfterSuccess ON/OFF to Responder.conf")
parser.add_argument('--capturemulticreds', type=str, dest='CAPTUREMULTICREDS', required=False, help="set option CaptureMultipleCredentials ON/OFF to Responder.conf")
parser.add_argument('--capturemultihash', type=str, dest='CAPTUREMULTIHASH', required=False, help="set option CaptureMultipleHashFromSameHost ON/OFF to Responder.conf")
parser.add_argument('--servealways', type=str, dest='SERVEALWAYS', required=False, help="set option Serve-Always for HTTP Server ON/OFF to Responder.conf")
parser.add_argument('--serveexe', type=str, dest='SERVEEXE', required=False, help="set option Serve-Exe for HTTP Server ON/OFF to Responder.conf")
parser.add_argument('--servehtml', type=str, dest='SERVEHTML', required=False, help="set option Serve-Html for HTTP Server ON/OFF to Responder.conf")
parser.add_argument('--htmlfilename', type=str, dest='HTMLFILENAME', required=False, help="set HtmlFilename file for HTTP Server to Responder.conf")
parser.add_argument('--exefilename', type=str, dest='EXEFILENAME', required=False, help="set ExeFilename file for HTTP Server to Responder.conf")
parser.add_argument('--exedownloadname', type=str, dest='EXEDOWNLOADNAME', required=False, help="set ExeDownloadName file for HTTP Server to Responder.conf")
#parser.add_argument('--wpadscript', type=str, dest='WPADSCRIPT', required=False, help="set WPADScript file for HTTP Server to Responder conf")
#parser.add_argument('--htmltoinject', type=str, dest='HTMLTOINJECT', required=False, help="set HTMLToInject file for HTTP Server to Responder conf")
parser.add_argument('--sslcert', type=str, dest='SSLCERT', required=False, help="set SSL Certificate for HTTPS to Responder.conf")
parser.add_argument('--sslkey', type=str, dest='SSLKEY', required=False, help="set SSL Key for HTTPS Server to Responder.conf")
parser.add_argument('--http-port', type=str, dest='HTTPPORT', required=False, help="set HTTP port to Responder.py")
parser.add_argument('--https-port', type=str, dest='HTTPSPORT', required=False, help="set HTTPS port to Responder.py")
parser.add_argument('--ftp-port', type=str, dest='FTPPORT', required=False, help="set FTP port to Responder.py")
parser.add_argument('--winrm-port', type=str, dest='WINRMPORT', required=False, help="set WinRM port to Responder.py")
parser.add_argument('--rdp-port', type=str, dest='RDPPORT', required=False, help="set RDP port to Responder.py")
parser.add_argument('--mssql-port', type=str, dest='MSSQLPORT', required=False, help="set MSSQL port to Responder.py")
parser.add_argument('--pop3-port', type=str, dest='POP3PORT', required=False, help="set POP3 port to Responder.py")
parser.add_argument('--smtp-port', type=str, dest='SMTPPORT', required=False, help="set SMTP port to Responder.py")
parser.add_argument('--imap-port', type=str, dest='IMAPPORT', required=False, help="set IMAP port to Responder.py")
parser.add_argument('--ldap-port', type=str, dest='LDAPPORT', required=False, help="set LDAP port to Responder.py")
parser.add_argument('--ldaps-port', type=str, dest='LDAPSPORT', required=False, help="set LDAPS port to Responder.py")
parser.add_argument('--mqtt-port', type=str, dest='MQTTPORT', required=False, help="set MQTT port to Responder.py")
parser.add_argument('--dns-tcp-port', type=str, dest='DNSTCPPORT', required=False, help="set DNS TCP port to Responder.py")
parser.add_argument('--dns-udp-port', type=str, dest='DNSUDPPORT', required=False, help="set DNS UDP port to Responder.py")
parser.add_argument('--snmp-port', type=str, dest='SNMPPORT', required=False, help="set SNMP port to Responder.py")
parser.add_argument('--http-proxy-port', type=str, dest='HTTPPROXYPORT', required=False, help="set HTTP proxy port to Responder.py")
parser.add_argument('--auth-proxy-port', type=str, dest='AUTHPROXYPORT', required=False, help="set Auth proxy port to Responder.py")
parser.add_argument('--kerberos-tcp-port', type=str, dest='KERBEROSTCPPORT', required=False, help="set Kerberos TCP port to Responder.py")
parser.add_argument('--kerberos-udp-port', type=str, dest='KERBEROSUDPPORT', required=False, help="set Kerberos UDP port to Responder.py")
args = parser.parse_args()
#check the number of arguments
if len(argv) == 1:
parser.print_help()
print("\n")
exit(1)
return args
#ValidatePort Function
def ValidatePort(Port_Value):
try:
value = int(Port_Value)
except ValueError:
# If conversion fails, print error and exit
print("[ERROR] " + Port_Value + " is not a valid port number")
exit(1)
#FindOS function
def FindOS(candidateOS):
match candidateOS:
case "windows":
myOS = "windows"
case "linux":
myOS = "linux"
case _:
myOS = "not supported"
print("[!] Not supported operating system...\n")
exit(1)
return myOS
#SearchPath function
def SearchPath(directory):
foundPath = path.exists(directory)
return foundPath
#SearchFolder function
def SearchFolder(myOS, folder):
foundFolderFlag = False
match myOS:
case "linux":
#Using default directory
defaultDir = "/usr/share/responder"
#Call function named SearchPath
foundPath = SearchPath(defaultDir)
#If defaultDir not exist use "/"
if foundPath != True:
defaultDir = "/"
#Search file in directories
for root, dirs, files in walk(defaultDir):
if folder in dirs:
foundFolderFlag = True
foundFolder = path.join(root, folder)
case "windows":
#Exfiltrate local drive sumbol
currentDirectory = getcwd().split(":")
localDrive = currentDirectory[0] + ":\\"
#Search file starting from local drive
for root, dirs, files in walk(localDrive):
if "Responder" in root:
if folder in dirs:
foundFolderFlag = True
foundFolder = path.join(root, folder)
#print(foundFolder)
case _:
foundFolder = "not supported"
print("[!] Not supported operating system...\n")
exit(1)
if foundFolderFlag != True:
print("[!] " + "File" + " does not exist in the system...\n")
exit(1)
return foundFolder
#SearchFile function
def SearchFile(myOS, file):
foundFileFlag = False
match myOS:
case "linux":
#Using default directory
defaultDir = "/usr/share/responder"
#Call function named SearchPath
foundPath = SearchPath(defaultDir)
#If defaultDir not exist use "/"
if foundPath != True:
defaultDir = "/"
#Search file in directories
for root, dirs, files in walk(defaultDir):
if file in files:
foundFileFlag = True
foundFile = path.join(root, file)
case "windows":
#Exfiltrate local drive sumbol
currentDirectory = getcwd().split(":")
localDrive = currentDirectory[0] + ":\\"
#Search file starting from local drive
for root, dirs, files in walk(localDrive):
if "Responder" in root:
if file in files:
foundFileFlag = True
foundFile = path.join(root, file)
#print(foundFile)
case _:
foundFile = "not supported"
print("[!] Not supported operating system...\n")
exit(1)
if foundFileFlag != True:
print("[!] " + file + " does not exist in the system...\n")
exit(1)
return foundFile
#FindString funtion
def FindString(foundFile, searchingWord):
with open(foundFile, 'r') as file:
content = file.read()
if searchingWord not in content:
print("[!] " + foundFile + " does not support this configuration\n")
exit(1)
#FindLineWithParts function
def FindLineWithParts(foundFile, firstPart, thirdPart):
with open(foundFile, 'r') as file:
for line in file:
# Check if both parts are in the line
if firstPart in line and thirdPart in line:
return True
print("[!] " + foundFile + " does not support this configuration\n")
exit(1)
#ModifyFile function
def ModifyFile(foundFile, searchingWord, candidateValue, statement):
#Read file and find line
with open(foundFile, 'r') as file:
for index, line in enumerate(file):
if searchingWord in line:
lineNumber = index + 1
#Read file and save tha value to specific line
with open(foundFile, 'r') as file:
fileContents = file.readlines()
fileContents[lineNumber - 1] = searchingWord + candidateValue + "\n"
#Modify changes
with open(foundFile, 'w') as file:
file.writelines(fileContents)
print("[+] " + statement + " has been set to " + "'" + candidateValue + "'" + " in " + foundFile + "...\n")
#ModifyFileWithTab function
def ModifyFileWithTab(foundFile, searchingWord, candidateValue, statement):
#Read file and find line
with open(foundFile, 'r') as file:
for index, line in enumerate(file):
if searchingWord in line:
lineNumber = index + 1
#Read file and save tha value to specific line
with open(foundFile, 'r') as file:
fileContents = file.readlines()
fileContents[lineNumber - 1] = searchingWord + " = '" + candidateValue + "'" + "\n"
#Modify changes
with open(foundFile, 'w') as file:
file.writelines(fileContents)
print("[+] " + statement + " has been set to " + "'" + candidateValue + "'" + " in " + foundFile + "...\n")
#ModifyFileResponder function
def ModifyFileResponder(foundFile, check_one, check_two, candidateValue):
#Read file and find line
with open(foundFile, 'r') as file:
for index, line in enumerate(file):
if check_one in line and check_two in line:
lineNumber = index + 1
#Read file and save tha value to specific line
with open(foundFile, 'r') as file:
fileContents = file.readlines()
# Modify the target line
original_line = fileContents[lineNumber - 1]
parts2 = original_line.split(',')
second_part2 = parts2[2].strip()
modified_line = original_line.replace(second_part2, str(candidateValue))
fileContents[lineNumber - 1] = modified_line
with open(foundFile, 'w') as file:
file.writelines(fileContents)
#DetermineSwitch function
def DetermineSwitch(statement, candidateValue):
if candidateValue.lower() != "on" and candidateValue.lower() != "off":
newValue = "nothing"
print("[!] " + statement + " parameter accepts only ON/OFF values...")
exit(1)
match candidateValue.lower():
case "on":
newValue = "On"
case "off":
newValue = "Off"
return newValue
#ConfigureOnOff function
def ConfigureOnOff(foundFile, searchingWord, candidateServer, statement):
#Call function named DetermineSwitch
foundSwitch = DetermineSwitch(statement, candidateServer)
#Call function FindString
FindString(foundFile, searchingWord)
#Call function named ModifyFile
ModifyFile(foundFile, searchingWord, foundSwitch, statement)
#ConfigureString function
def ConfigureString(keyword, optionNumber):
searchingWord = keyword + " = "
match optionNumber:
case 1:
statement = keyword + " Server"
case 2:
statement = keyword
return searchingWord, statement
#ConfigureStringWithTab function
def ConfigureStringWithTab(keyword):
searchingWord = "\t\t" + keyword
#Splitting keyword
splitKeyword = keyword.split(".")
statement = splitKeyword[1]
return searchingWord, statement
#ConfigureValues function
def ConfigureValues(foundFile, searchingWord, candidateValue, statement):
#Call function FindString
FindString(foundFile, searchingWord)
#Call function named ModifyFile
ModifyFile(foundFile, searchingWord, candidateValue, statement)
#ConfigureValuesWithTab function
def ConfigureValuesWithTab(foundFile, searchingWord, candidateValue, statement):
#Call function FindString
FindString(foundFile, searchingWord)
#Call function named ModifyFile
ModifyFileWithTab(foundFile, searchingWord, candidateValue, statement)
#DetermineChallenge function
def DetermineChallenge(candidateValue):
if len(candidateValue) != 16:
print("[!] The challenge must be exactly 16 chars long.\n\nExample: 1122334455667788\n")
exit(1)
#DeterminePortRange
def DeterminePortRange(candidateValue):
#Determine if the candidate value is betwwen the range 45000 and 49999
if candidateValue < 45000 or candidateValue > 49999:
print("[!] The RPC Port must be between the ranges 45000 and 49999\n")
exit(1)
#KeepBackup function
def KeepBackup(foundFile, statement):
#Set backup filenames
foundFileBackup = foundFile + ".bak"
#Copy values to backup files
copyfile(foundFile, foundFileBackup)
#Print success message
print("[+] Backup for " + foundFile + " saved to: " + foundFileBackup + "\n")
#RestoreBackup function
def RestoreBackup(foundFile, foundFileBackup):
#Copy values to original file
copyfile(foundFileBackup, foundFile)
#Delete .bak files
remove(foundFileBackup)
#Print success message
print("[+] Restore backup for " + foundFileBackup + " saved to: " + foundFile + "\n")
#main function
def main():
#Call function named Arguments
arguments = Arguments(argv)
#Print ascii art
print(__ascii__)
candidateOS = system().lower()
#Call function named FindOS
foundOS = FindOS(candidateOS)
#Call function named SearchFile
foundFile = SearchFile(foundOS, "Responder.conf")
#Call function named SearchFile
foundFileSettings = SearchFile(foundOS, "settings.py")
# Added New Vaiable to find Responder.py
foundFileResponder = SearchFile(foundOS, "Responder.py")
#If backup argument is enabled keep backup
if arguments.backup:
#Call function named KeepBackup
KeepBackup(foundFile, "Responder.conf")
#Call function named KeepBackup
KeepBackup(foundFileSettings, "Settings.py")
#Call function named KeepBackup
KeepBackup(foundFileResponder, "Responder.py")
#If restore argument is enabled restore from backup
if arguments.restore:
#Call function named SearchFile
foundFileBackup = SearchFile(foundOS, "Responder.conf.bak")
#Call function named SearchFile
foundFileSettingsBackup = SearchFile(foundOS, "settings.py.bak")
#Call function named SearchFile
foundFileResponderBackup = SearchFile(foundOS, "Responder.py.bak")
#Call function named RestoreBackup
RestoreBackup(foundFile, foundFileBackup)
#Call function named RestoreBackup
RestoreBackup(foundFileSettings, foundFileSettingsBackup)
#Call function named RestoreBackup
RestoreBackup(foundFileResponder, foundFileResponderBackup)
#Print success message for clear .bak files
print("[+] All backup files have been removed from the system...\n")
#Clear DB section
if arguments.cleardb:
#Call function named SearchFile
foundFileDB = SearchFile(foundOS, "Responder.db")
#If backup argument is enabled keep backup
if arguments.backup:
#Call function named KeepBackup
KeepBackup(foundFileDB, "Responder.db")
#Delete Responder.db
remove(foundFileDB)
#Print success message for clear db
print("[+] " + foundFileDB + " has been deleted...\n")
#Clear logs section
if arguments.clearlogs:
#Call function named SearchFolder
foundFolderLogs = SearchFolder(foundOS, "logs")
#Delete logs folder
rmtree(foundFolderLogs, ignore_errors=False, onerror=None)
#Print success message for clear logs folder
print("[+] " + foundFolderLogs + " has been deleted...\n")
#Machine Name Section
if arguments.MACHINENAME:
candidateValue = arguments.MACHINENAME
#Call function named ConfigureString
configuredStringsWithTab = ConfigureStringWithTab("self.MachineName")
#Call function ConfigureValues
ConfigureValuesWithTab(foundFileSettings, configuredStringsWithTab[0], candidateValue, configuredStringsWithTab[1])
#HTTP Port Section
if arguments.HTTPPORT:
candidateValue = arguments.HTTPPORT
ValidatePort(candidateValue)
line = "threads.append(Thread(target=serve_thread_tcp, args=(settings.Config.Bind_To, 80, HTTP,)))"
parts = line.split(',')
check_one = parts[0] + ',' + parts[1]
check_two = parts[3].strip() + ',' + parts[4]
FindLineWithParts(foundFileResponder, check_one, check_two)
ModifyFileResponder(foundFileResponder, check_one, check_two, candidateValue)
print("[+] " + parts[3].strip() + " server is running on port " + "'" + str(candidateValue) + "'" + " in " + foundFileResponder + "...\n")
#HTTPS Port Section
if arguments.HTTPSPORT:
candidateValue = arguments.HTTPSPORT
ValidatePort(candidateValue)
line = "threads.append(Thread(target=serve_thread_SSL, args=(settings.Config.Bind_To, 443, HTTP,)))"
parts = line.split(',')
check_one = parts[0] + ',' + parts[1]
check_two = parts[3].strip() + ',' + parts[4]
FindLineWithParts(foundFileResponder, check_one, check_two)
ModifyFileResponder(foundFileResponder, check_one, check_two, candidateValue)
print("[+] " + parts[3].strip() + "S server is running on port " + "'" + str(candidateValue) + "'" + " in " + foundFileResponder + "...\n")
#FTP Port Section
if arguments.FTPPORT:
candidateValue = arguments.FTPPORT
ValidatePort(candidateValue)
line = "threads.append(Thread(target=serve_thread_tcp, args=(settings.Config.Bind_To, 21, FTP,)))"
parts = line.split(',')
check_one = parts[0] + ',' + parts[1]
check_two = parts[3].strip() + ',' + parts[4]
FindLineWithParts(foundFileResponder, check_one, check_two)
ModifyFileResponder(foundFileResponder, check_one, check_two, candidateValue)
print("[+] " + parts[3].strip() + " server is running on port " + "'" + str(candidateValue) + "'" + " in " + foundFileResponder + "...\n")
#WinRM Port Section
if arguments.WINRMPORT:
candidateValue = arguments.WINRMPORT
ValidatePort(candidateValue)
line = "threads.append(Thread(target=serve_thread_tcp, args=(settings.Config.Bind_To, 5985, WinRM,)))"
parts = line.split(',')
check_one = parts[0] + ',' + parts[1]
check_two = parts[3].strip() + ',' + parts[4]
FindLineWithParts(foundFileResponder, check_one, check_two)
ModifyFileResponder(foundFileResponder, check_one, check_two, candidateValue)
print("[+] " + parts[3].strip() + " service is running on port " + "'" + str(candidateValue) + "'" + " in " + foundFileResponder + "...\n")
#RDP Port Section
if arguments.RDPPORT:
candidateValue = arguments.RDPPORT
ValidatePort(candidateValue)
line = "threads.append(Thread(target=serve_thread_tcp, args=(settings.Config.Bind_To, 3389, RDP,)))"
parts = line.split(',')
check_one = parts[0] + ',' + parts[1]
check_two = parts[3].strip() + ',' + parts[4]
FindLineWithParts(foundFileResponder, check_one, check_two)
ModifyFileResponder(foundFileResponder, check_one, check_two, candidateValue)
print("[+] " + parts[3].strip() + " service is running on port " + "'" + str(candidateValue) + "'" + " in " + foundFileResponder + "...\n")
#MSSQL Port Section
if arguments.MSSQLPORT:
candidateValue = arguments.MSSQLPORT
ValidatePort(candidateValue)
line = "threads.append(Thread(target=serve_thread_tcp, args=(settings.Config.Bind_To, 1433, MSSQL,)))"
parts = line.split(',')
check_one = parts[0] + ',' + parts[1]
check_two = parts[3].strip() + ',' + parts[4]
FindLineWithParts(foundFileResponder, check_one, check_two)
ModifyFileResponder(foundFileResponder, check_one, check_two, candidateValue)
print("[+] " + parts[3].strip() + " service is running on port " + "'" + str(candidateValue) + "'" + " in " + foundFileResponder + "...\n")
#POP3 Port Section
if arguments.POP3PORT:
candidateValue = arguments.POP3PORT
ValidatePort(candidateValue)
line = "threads.append(Thread(target=serve_thread_tcp, args=(settings.Config.Bind_To, 110, POP3,)))"
parts = line.split(',')
check_one = parts[0] + ',' + parts[1]
check_two = parts[3].strip() + ',' + parts[4]
FindLineWithParts(foundFileResponder, check_one, check_two)
ModifyFileResponder(foundFileResponder, check_one, check_two, candidateValue)
print("[+] " + parts[3].strip() + " service is running on port " + "'" + str(candidateValue) + "'" + " in " + foundFileResponder + "...\n")
#SMTP Port Section
if arguments.SMTPPORT:
candidateValue = arguments.SMTPPORT
ValidatePort(candidateValue)
line = "threads.append(Thread(target=serve_thread_tcp, args=(settings.Config.Bind_To, 25, ESMTP,)))"
parts = line.split(',')
check_one = parts[0] + ',' + parts[1]
check_two = parts[3].strip() + ',' + parts[4]
FindLineWithParts(foundFileResponder, check_one, check_two)
ModifyFileResponder(foundFileResponder, check_one, check_two, candidateValue)
print("[+] " + parts[3].strip() + " service is running on port " + "'" + str(candidateValue) + "'" + " in " + foundFileResponder + "...\n")
#IMAP Port Section
if arguments.IMAPPORT:
candidateValue = arguments.IMAPPORT
ValidatePort(candidateValue)
line = "threads.append(Thread(target=serve_thread_tcp, args=(settings.Config.Bind_To, 143, IMAP,)))"
parts = line.split(',')
check_one = parts[0] + ',' + parts[1]
check_two = parts[3].strip() + ',' + parts[4]
FindLineWithParts(foundFileResponder, check_one, check_two)
ModifyFileResponder(foundFileResponder, check_one, check_two, candidateValue)
print("[+] " + parts[3].strip() + " service is running on port " + "'" + str(candidateValue) + "'" + " in " + foundFileResponder + "...\n")
#LDAP Port Section
if arguments.LDAPPORT:
candidateValue = arguments.LDAPPORT
ValidatePort(candidateValue)
line = "threads.append(Thread(target=serve_thread_tcp, args=(settings.Config.Bind_To, 389, LDAP,)))"
parts = line.split(',')
check_one = parts[0] + ',' + parts[1]
check_two = parts[3].strip() + ',' + parts[4]
FindLineWithParts(foundFileResponder, check_one, check_two)
ModifyFileResponder(foundFileResponder, check_one, check_two, candidateValue)
print("[+] " + parts[3].strip() + " service is running on port " + "'" + str(candidateValue) + "'" + " in " + foundFileResponder + "...\n")
#LDAPS Port Section
if arguments.LDAPSPORT:
candidateValue = arguments.LDAPSPORT
ValidatePort(candidateValue)
line = "threads.append(Thread(target=serve_thread_SSL, args=(settings.Config.Bind_To, 636, LDAP,)))"
parts = line.split(',')
check_one = parts[0] + ',' + parts[1]
check_two = parts[3].strip() + ',' + parts[4]
FindLineWithParts(foundFileResponder, check_one, check_two)
ModifyFileResponder(foundFileResponder, check_one, check_two, candidateValue)
print("[+] " + parts[3].strip() + "S service is running on port " + "'" + str(candidateValue) + "'" + " in " + foundFileResponder + "...\n")
#MQTT Port Section
if arguments.MQTTPORT:
candidateValue = arguments.MQTTPORT
ValidatePort(candidateValue)
line = "threads.append(Thread(target=serve_thread_tcp, args=(settings.Config.Bind_To, 1883, MQTT,)))"
parts = line.split(',')
check_one = parts[0] + ',' + parts[1]
check_two = parts[3].strip() + ',' + parts[4]
FindLineWithParts(foundFileResponder, check_one, check_two)
ModifyFileResponder(foundFileResponder, check_one, check_two, candidateValue)
print("[+] " + parts[3].strip() + " service is running on port " + "'" + str(candidateValue) + "'" + " in " + foundFileResponder + "...\n")
#DNS TCP Port Section
if arguments.DNSTCPPORT:
candidateValue = arguments.DNSTCPPORT
ValidatePort(candidateValue)
line = "threads.append(Thread(target=serve_thread_tcp, args=(settings.Config.Bind_To, 53, DNSTCP,)))"
parts = line.split(',')
check_one = parts[0] + ',' + parts[1]
check_two = parts[3].strip() + ',' + parts[4]
FindLineWithParts(foundFileResponder, check_one, check_two)
ModifyFileResponder(foundFileResponder, check_one, check_two, candidateValue)
print("[+] " + "DNS protocol is running on TCP port " + "'" + str(candidateValue) + "'" + " in " + foundFileResponder + "...\n")
#DNS UDP Port Section
if arguments.DNSUDPPORT:
candidateValue = arguments.DNSUDPPORT
ValidatePort(candidateValue)
line = "threads.append(Thread(target=serve_thread_udp, args=('', 53, DNS,)))"
parts = line.split(',')
check_one = parts[0] + ',' + parts[1]
check_two = parts[3].strip() + ',' + parts[4]
FindLineWithParts(foundFileResponder, check_one, check_two)
ModifyFileResponder(foundFileResponder, check_one, check_two, candidateValue)
print("[+] " + "DNS protocol is running on UDP port " + "'" + str(candidateValue) + "'" + " in " + foundFileResponder + "...\n")
#SNMP Port Section
if arguments.SNMPPORT:
candidateValue = arguments.SNMPPORT
ValidatePort(candidateValue)
line = "threads.append(Thread(target=serve_thread_udp, args=('', 161, SNMP,)))"
parts = line.split(',')
check_one = parts[0] + ',' + parts[1]
check_two = parts[3].strip() + ',' + parts[4]
FindLineWithParts(foundFileResponder, check_one, check_two)
ModifyFileResponder(foundFileResponder, check_one, check_two, candidateValue)
print("[+] " + parts[3].strip() + " service is running on UDP port " + "'" + str(candidateValue) + "'" + " in " + foundFileResponder + "...\n")
#HTTP proxy Port Section
if arguments.HTTPPROXYPORT:
candidateValue = arguments.HTTPPROXYPORT
ValidatePort(candidateValue)
line = "threads.append(Thread(target=serve_thread_tcp, args=(settings.Config.Bind_To, 3128, HTTP_Proxy,)))"
parts = line.split(',')
check_one = parts[0] + ',' + parts[1]
check_two = parts[3].strip() + ',' + parts[4]
FindLineWithParts(foundFileResponder, check_one, check_two)
ModifyFileResponder(foundFileResponder, check_one, check_two, candidateValue)
print("[+] " + parts[3].strip() + " service is running on port " + "'" + str(candidateValue) + "'" + " in " + foundFileResponder + "...\n")
#Auth proxy Port Section
if arguments.AUTHPROXYPORT:
candidateValue = arguments.AUTHPROXYPORT
ValidatePort(candidateValue)
line = "threads.append(Thread(target=serve_thread_tcp_auth, args=(settings.Config.Bind_To, 3128, Proxy_Auth,)))"
parts = line.split(',')
check_one = parts[0] + ',' + parts[1]
check_two = parts[3].strip() + ',' + parts[4]
FindLineWithParts(foundFileResponder, check_one, check_two)
ModifyFileResponder(foundFileResponder, check_one, check_two, candidateValue)
print("[+] " + parts[3].strip() + " service is running on port " + "'" + str(candidateValue) + "'" + " in " + foundFileResponder + "...\n")
#Kerberos TCP Port Section
if arguments.KERBEROSTCPPORT:
candidateValue = arguments.KERBEROSTCPPORT
ValidatePort(candidateValue)
line = "threads.append(Thread(target=serve_thread_tcp, args=(settings.Config.Bind_To, 88, KerbTCP,)))"
parts = line.split(',')
check_one = parts[0] + ',' + parts[1]
check_two = parts[3].strip() + ',' + parts[4]
FindLineWithParts(foundFileResponder, check_one, check_two)
ModifyFileResponder(foundFileResponder, check_one, check_two, candidateValue)
print("[+] " + "Kerberos service is running on TCP port " + "'" + str(candidateValue) + "'" + " in " + foundFileResponder + "...\n")
#Kerberos UDP Port Section
if arguments.KERBEROSUDPPORT:
candidateValue = arguments.KERBEROSUDPPORT
ValidatePort(candidateValue)
line = "threads.append(Thread(target=serve_thread_udp, args=('', 88, KerbUDP,)))"
parts = line.split(',')
check_one = parts[0] + ',' + parts[1]
check_two = parts[3].strip() + ',' + parts[4]
FindLineWithParts(foundFileResponder, check_one, check_two)
ModifyFileResponder(foundFileResponder, check_one, check_two, candidateValue)
print("[+] " + "Kerberos service is running on UDP port " + "'" + str(candidateValue) + "'" + " in " + foundFileResponder + "...\n")
#Domain Name Section
if arguments.DOMAIN:
candidateValue = arguments.DOMAIN
#Call function named ConfigureString
configuredStringsWithTab = ConfigureStringWithTab("self.DomainName")
#Call function ConfigureValues
ConfigureValuesWithTab(foundFileSettings, configuredStringsWithTab[0], candidateValue, configuredStringsWithTab[1])
#Username Section
if arguments.USERNAME:
candidateValue = arguments.USERNAME
#Call function named ConfigureString
configuredStringsWithTab = ConfigureStringWithTab("self.Username")
#Call function ConfigureValues
ConfigureValuesWithTab(foundFileSettings, configuredStringsWithTab[0], candidateValue, configuredStringsWithTab[1])
#DHCP Hostname Section
if arguments.HOSTNAME:
candidateValue = arguments.HOSTNAME
#Call function named ConfigureString
configuredStringsWithTab = ConfigureStringWithTab("self.DHCPHostname")
#Call function ConfigureValues
ConfigureValuesWithTab(foundFileSettings, configuredStringsWithTab[0], candidateValue, configuredStringsWithTab[1])
#RPC Port Section
if arguments.PORT:
candidateValue = arguments.PORT
#Call function DeterminePortRange
DeterminePortRange(candidateValue)
#Call function named ConfigureString
configuredStringsWithTab = ConfigureStringWithTab("self.RPCPort")
#Call function FindString
FindString(foundFileSettings, configuredStringsWithTab[0])
#Read file and find line
with open(foundFileSettings, 'r') as file:
for index, line in enumerate(file):
if configuredStringsWithTab[0] in line:
lineNumber = index + 1
#Read file and save tha value to specific line
with open(foundFileSettings, 'r') as file:
fileContents = file.readlines()
fileContents[lineNumber - 1] = configuredStringsWithTab[0] + " = " + str(candidateValue) + "\n"
#Modify changes
with open(foundFileSettings, 'w') as file:
file.writelines(fileContents)
print("[+] " + configuredStringsWithTab[1] + " has been set to " + "'" + str(candidateValue) + "'" + " in " + foundFileSettings + "...\n")
#Challenge section
if arguments.NUMBER:
candidateValue = arguments.NUMBER
#Call function named DetermineChallenge
DetermineChallenge(candidateValue)
#Call function named ConfigureString
configuredStrings = ConfigureString("Challenge", 2)
#Call function ConfigureValues
ConfigureValues(foundFile, configuredStrings[0], candidateValue, configuredStrings[1])
#SSLCert section
if arguments.SSLCERT:
candidateValue = arguments.SSLCERT
#Call function named ConfigureString
configuredStrings = ConfigureString("SSLCert", 2)
#Call function ConfigureValues
ConfigureValues(foundFile, configuredStrings[0], candidateValue, configuredStrings[1])
#SSLKey section
if arguments.SSLKEY:
candidateValue = arguments.SSLKEY
#Call function named ConfigureString
configuredStrings = ConfigureString("SSLKey", 2)
#Call function ConfigureValues
ConfigureValues(foundFile, configuredStrings[0], candidateValue, configuredStrings[1])
#DatabaseName Section
if arguments.DATABASENAME:
candidateValue = arguments.DATABASENAME
#Call function named ConfigureString
configuredStrings = ConfigureString("Database", 2)
#Call function ConfigureValues
ConfigureValues(foundFile, configuredStrings[0], candidateValue, configuredStrings[1])
#Session log section
if arguments.SESSIONLOG:
candidateValue = arguments.SESSIONLOG
#Call function named ConfigureString
configuredStrings = ConfigureString("SessionLog", 2)
#Call function ConfigureValues
ConfigureValues(foundFile, configuredStrings[0], candidateValue, configuredStrings[1])
#Poisoners log section
if arguments.POISONERSLOG:
candidateValue = arguments.POISONERSLOG
#Call function named ConfigureString
configuredStrings = ConfigureString("PoisonersLog", 2)
#Call function ConfigureValues
ConfigureValues(foundFile, configuredStrings[0], candidateValue, configuredStrings[1])
#Analyze mode log section
if arguments.ANALYZELOG:
candidateValue = arguments.ANALYZELOG
#Call function named ConfigureString
configuredStrings = ConfigureString("AnalyzeLog", 2)
#Call function ConfigureValues
ConfigureValues(foundFile, configuredStrings[0], candidateValue, configuredStrings[1])
#Config Dump log section
if arguments.CONFIGDUMPLOG:
candidateValue = arguments.CONFIGDUMPLOG
#Call function named ConfigureString
configuredStrings = ConfigureString("ResponderConfigDump", 2)
#Call function ConfigureValues
ConfigureValues(foundFile, configuredStrings[0], candidateValue, configuredStrings[1])
#HtmlFilename section
if arguments.HTMLFILENAME:
candidateValue = arguments.HTMLFILENAME
#Call function named ConfigureString
configuredStrings = ConfigureString("HtmlFilename", 2)
#Call function ConfigureValues
ConfigureValues(foundFile, configuredStrings[0], candidateValue, configuredStrings[1])
#ExeFilename section
if arguments.EXEFILENAME:
candidateValue = arguments.EXEFILENAME
#Call function named ConfigureString
configuredStrings = ConfigureString("ExeFilename", 2)
#Call function ConfigureValues
ConfigureValues(foundFile, configuredStrings[0], candidateValue, configuredStrings[1])
#ExeDownloadName section
if arguments.EXEDOWNLOADNAME:
candidateValue = arguments.EXEDOWNLOADNAME
#Call function named ConfigureString
configuredStrings = ConfigureString("ExeDownloadName", 2)
#Call function ConfigureValues
ConfigureValues(foundFile, configuredStrings[0], candidateValue, configuredStrings[1])
#AutoIgnoreAfterSuccess section
if arguments.AUTOIGNORE:
candidateServer = arguments.AUTOIGNORE
#Call function named ConfigureString
configuredStrings = ConfigureString("AutoIgnoreAfterSuccess", 2)
#Call function named ConfigureOnOff
ConfigureOnOff(foundFile, configuredStrings[0], candidateServer, configuredStrings[1])
#CaptureMultipleCredentials section
if arguments.CAPTUREMULTICREDS:
candidateServer = arguments.CAPTUREMULTICREDS
#Call function named ConfigureString
configuredStrings = ConfigureString("CaptureMultipleCredentials", 2)
#Call function named ConfigureOnOff
ConfigureOnOff(foundFile, configuredStrings[0], candidateServer, configuredStrings[1])
#CaptureMultipleHashFromSameHost section
if arguments.CAPTUREMULTIHASH:
candidateServer = arguments.CAPTUREMULTIHASH
#Call function named ConfigureString
configuredStrings = ConfigureString("CaptureMultipleHashFromSameHost", 2)
#Call function named ConfigureOnOff
ConfigureOnOff(foundFile, configuredStrings[0], candidateServer, configuredStrings[1])
#Serve-Always section
if arguments.SERVEALWAYS:
candidateServer = arguments.SERVEALWAYS