forked from Quitten/Autorize
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAutorize.py
1628 lines (1320 loc) · 80.7 KB
/
Autorize.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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from burp import ITab
from burp import IBurpExtender
from burp import IHttpListener
from burp import IContextMenuFactory
from burp import IMessageEditorController
from burp import IHttpRequestResponse
from javax.swing import JList
from javax.swing import JTable
from javax.swing import JFrame
from javax.swing import JLabel
from javax.swing import JPanel
from javax.swing import JButton
from javax.swing import JToggleButton
from javax.swing import JComboBox
from javax.swing import JCheckBox
from javax.swing import JMenuItem
from javax.swing import JTextArea
from javax.swing import RowFilter
from javax.swing import JPopupMenu
from javax.swing import JSplitPane
from javax.swing import JOptionPane
from javax.swing import JScrollPane
from javax.swing import JTabbedPane
from javax.swing import JScrollPane
from javax.swing import JFileChooser
from javax.swing import SwingUtilities
from javax.swing import DefaultListModel
from javax.swing import JCheckBoxMenuItem
from javax.swing import DefaultComboBoxModel
from javax.swing.border import LineBorder
from javax.swing.table import TableRowSorter
from javax.swing.table import AbstractTableModel
from threading import Lock
from java.io import File
from java.net import URL
from java.awt import Font
from java.awt import Color
from java.awt import Toolkit
from java.awt.event import ItemListener
from java.awt.event import MouseAdapter
from java.awt.event import ActionListener
from java.awt.event import AdjustmentListener
from java.awt.datatransfer import Clipboard
from java.awt.datatransfer import StringSelection
from java.util import LinkedList
from java.util import ArrayList
from java.lang import Runnable
from java.lang import Integer
from java.lang import String
from java.lang import Math
from thread import start_new_thread
import re, csv, sys, base64
#TODO
# - Disable buttons when saving state/restoring state/export
# - Add full headers in addition to cookies
# This code is necessary to maximize the csv field limit for the save and
# restore functionality
maxInt = sys.maxsize
decrement = True
while decrement:
decrement = False
try:
csv.field_size_limit(maxInt)
except OverflowError:
maxInt = int(maxInt/10)
decrement = True
class BurpExtender(IBurpExtender, ITab, IHttpListener, IMessageEditorController,
AbstractTableModel, IContextMenuFactory):
def registerExtenderCallbacks(self, callbacks):
# keep a reference to our callbacks object
self._callbacks = callbacks
# obtain an extension helpers object
self._helpers = callbacks.getHelpers()
# set our extension name
callbacks.setExtensionName("Autorize")
# create the log and a lock on which to synchronize when adding log
# entries
self._log = ArrayList()
self._lock = Lock()
self.BYPASSSED_STR = "Bypassed!"
self.IS_ENFORCED_STR = "Is enforced??? (please configure enforcement detector)"
self.ENFORCED_STR = "Enforced!"
self.intercept = 0
self.lastCookies = ""
self.initInterceptionFilters()
self.initEnforcementDetector()
self.initEnforcementDetectorUnauthorized()
self.initExport()
self.initFilter()
self.initConfigurationTab()
self.initTabs()
self.initCallbacks()
self.currentRequestNumber = 1
print("""Thank you for installing Autorize v0.21 extension
Created by Barak Tawily
Contributors: Barak Tawily, Federico Dotta, mgeeky, Marcin Woloszyn
Github:\nhttps://github.com/Quitten/Autorize
""")
return
def initFilter(self):
"""
init show tab
"""
filterLModified = JLabel("Modified:")
filterLModified.setBounds(10, 10, 100, 30)
filterLUnauthenticated = JLabel("Unauthenticated:")
filterLUnauthenticated.setBounds(250, 10, 100, 30)
self.showAuthBypassModified = JCheckBox(self.BYPASSSED_STR)
self.showAuthBypassModified.setBounds(10, 35, 200, 30)
self.showAuthBypassModified.setSelected(True)
self.showAuthBypassModified.addItemListener(tabTableFilter(self))
self.showAuthPotentiallyEnforcedModified = JCheckBox("Is enforced???")
self.showAuthPotentiallyEnforcedModified.setBounds(10, 60, 200, 30)
self.showAuthPotentiallyEnforcedModified.setSelected(True)
self.showAuthPotentiallyEnforcedModified.addItemListener(tabTableFilter(self))
self.showAuthEnforcedModified = JCheckBox(self.ENFORCED_STR)
self.showAuthEnforcedModified.setBounds(10, 85, 200, 30)
self.showAuthEnforcedModified.setSelected(True)
self.showAuthEnforcedModified.addItemListener(tabTableFilter(self))
self.showAuthBypassUnauthenticated = JCheckBox(self.BYPASSSED_STR)
self.showAuthBypassUnauthenticated.setBounds(250, 35, 200, 30)
self.showAuthBypassUnauthenticated.setSelected(True)
self.showAuthBypassUnauthenticated.addItemListener(tabTableFilter(self))
self.showAuthPotentiallyEnforcedUnauthenticated = JCheckBox("Is enforced???")
self.showAuthPotentiallyEnforcedUnauthenticated.setBounds(250, 60, 200, 30)
self.showAuthPotentiallyEnforcedUnauthenticated.setSelected(True)
self.showAuthPotentiallyEnforcedUnauthenticated.addItemListener(tabTableFilter(self))
self.showAuthEnforcedUnauthenticated = JCheckBox(self.ENFORCED_STR)
self.showAuthEnforcedUnauthenticated.setBounds(250, 85, 200, 30)
self.showAuthEnforcedUnauthenticated.setSelected(True)
self.showAuthEnforcedUnauthenticated.addItemListener(tabTableFilter(self))
self.showDisabledUnauthenticated = JCheckBox("Disabled")
self.showDisabledUnauthenticated.setBounds(250, 110, 200, 30)
self.showDisabledUnauthenticated.setSelected(True)
self.showDisabledUnauthenticated.addItemListener(tabTableFilter(self))
self.filterPnl = JPanel()
self.filterPnl.setLayout(None)
self.filterPnl.setBounds(0, 0, 1000, 1000)
self.filterPnl.add(filterLModified)
self.filterPnl.add(filterLUnauthenticated)
self.filterPnl.add(self.showAuthBypassModified)
self.filterPnl.add(self.showAuthPotentiallyEnforcedModified)
self.filterPnl.add(self.showAuthEnforcedModified)
self.filterPnl.add(self.showAuthBypassUnauthenticated)
self.filterPnl.add(self.showAuthPotentiallyEnforcedUnauthenticated)
self.filterPnl.add(self.showAuthEnforcedUnauthenticated)
self.filterPnl.add(self.showDisabledUnauthenticated)
def initExport(self):
""" init Save/Restore
"""
exportLabel = JLabel("Export:")
exportLabel.setBounds(10, 10, 100, 30)
labelFont = exportLabel.getFont()
boldFont = Font(labelFont.getFontName(), Font.BOLD, labelFont.getSize())
exportLabel.setFont(boldFont)
exportLType = JLabel("File Type:")
exportLType.setBounds(10, 50, 100, 30)
exportFileTypes = ["HTML", "CSV"]
self.exportType = JComboBox(exportFileTypes)
self.exportType.setBounds(100, 50, 200, 30)
exportES = ["All Statuses", "As table filter",
self.BYPASSSED_STR,
self.IS_ENFORCED_STR,
self.ENFORCED_STR]
self.exportES = JComboBox(exportES)
self.exportES.setBounds(100, 90, 200, 30)
exportLES = JLabel("Statuses:")
exportLES.setBounds(10, 90, 100, 30)
self.exportButton = JButton("Export",
actionPerformed=self.export)
self.exportButton.setBounds(390, 50, 100, 30)
saveRestoreLabel = JLabel("Save / Restore:")
saveRestoreLabel.setBounds(10, 150, 100, 30)
saveRestoreLabel.setFont(boldFont)
self.saveStateButton = JButton("Save state",
actionPerformed=self.saveStateAction)
self.saveStateButton.setBounds(10, 200, 100, 30)
self.restoreStateButton = JButton("Restore state",
actionPerformed=self.restoreStateAction)
self.restoreStateButton.setBounds(390, 200, 100, 30)
self.exportPnl = JPanel()
self.exportPnl.setLayout(None)
self.exportPnl.setBounds(0, 0, 1000, 1000)
self.exportPnl.add(exportLabel)
self.exportPnl.add(exportLType)
self.exportPnl.add(self.exportType)
self.exportPnl.add(exportLES)
self.exportPnl.add(self.exportES)
self.exportPnl.add(self.exportButton)
self.exportPnl.add(saveRestoreLabel)
self.exportPnl.add(self.saveStateButton)
self.exportPnl.add(self.restoreStateButton)
def initEnforcementDetector(self):
"""
init enforcement detector tab
"""
EDLType = JLabel("Type:")
EDLType.setBounds(10, 10, 140, 30)
EDLContent = JLabel("Content:")
EDLContent.setBounds(10, 50, 140, 30)
EDLabelList = JLabel("Filter List:")
EDLabelList.setBounds(10, 165, 140, 30)
EDStrings = ["Headers (simple string): (enforced message headers contains)",
"Headers (regex): (enforced message headers contains)",
"Body (simple string): (enforced message body contains)",
"Body (regex): (enforced message body contains)",
"Full response (simple string): (enforced message contains)",
"Full response (regex): (enforced message contains)",
"Full response length: (of enforced response)",
"Status code equals: (numbers only)"]
self.EDType = JComboBox(EDStrings)
self.EDType.setBounds(80, 10, 430, 30)
self.EDText = JTextArea("", 5, 30)
scrollEDText = JScrollPane(self.EDText)
scrollEDText.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED)
scrollEDText.setBounds(80, 50, 300, 110)
self.EDModel = DefaultListModel()
self.EDList = JList(self.EDModel)
scrollEDList = JScrollPane(self.EDList)
scrollEDList.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED)
scrollEDList.setBounds(80, 175, 300, 110)
scrollEDList.setBorder(LineBorder(Color.BLACK))
self.EDAdd = JButton("Add filter", actionPerformed=self.addEDFilter)
self.EDAdd.setBounds(390, 85, 120, 30)
self.EDDel = JButton("Remove filter", actionPerformed=self.delEDFilter)
self.EDDel.setBounds(390, 210, 120, 30)
self.EDMod = JButton("Modify filter", actionPerformed=self.modEDFilter)
self.EDMod.setBounds(390, 250, 120, 30)
AndOrStrings = ["And", "Or"]
self.AndOrType = JComboBox(AndOrStrings)
self.AndOrType.setBounds(390, 170, 120, 30)
self.EDPnl = JPanel()
self.EDPnl.setLayout(None)
self.EDPnl.setBounds(0, 0, 1000, 1000)
self.EDPnl.add(EDLType)
self.EDPnl.add(self.EDType)
self.EDPnl.add(EDLContent)
self.EDPnl.add(scrollEDText)
self.EDPnl.add(self.EDAdd)
self.EDPnl.add(self.AndOrType)
self.EDPnl.add(self.EDDel)
self.EDPnl.add(self.EDMod)
self.EDPnl.add(EDLabelList)
self.EDPnl.add(scrollEDList)
def initEnforcementDetectorUnauthorized(self):
""" init enforcement detector tab
"""
EDLType = JLabel("Type:")
EDLType.setBounds(10, 10, 140, 30)
EDLContent = JLabel("Content:")
EDLContent.setBounds(10, 50, 140, 30)
EDLabelList = JLabel("Filter List:")
EDLabelList.setBounds(10, 165, 140, 30)
EDStrings = ["Headers (simple string): (enforced message headers contains)",
"Headers (regex): (enforced message headers contains)",
"Body (simple string): (enforced message body contains)",
"Body (regex): (enforced message body contains)",
"Full response (simple string): (enforced message contains)",
"Full response (regex): (enforced message contains)",
"Full response length: (of enforced response)",
"Status code equals: (numbers only)"]
self.EDTypeUnauth = JComboBox(EDStrings)
self.EDTypeUnauth.setBounds(80, 10, 430, 30)
self.EDTextUnauth = JTextArea("", 5, 30)
scrollEDTextUnauth = JScrollPane(self.EDTextUnauth)
scrollEDTextUnauth.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED)
scrollEDTextUnauth.setBounds(80, 50, 300, 110)
self.EDModelUnauth = DefaultListModel()
self.EDListUnauth = JList(self.EDModelUnauth)
scrollEDListUnauth = JScrollPane(self.EDListUnauth)
scrollEDListUnauth.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED)
scrollEDListUnauth.setBounds(80, 175, 300, 110)
scrollEDListUnauth.setBorder(LineBorder(Color.BLACK))
self.EDAddUnauth = JButton("Add filter",
actionPerformed=self.addEDFilterUnauth)
self.EDAddUnauth.setBounds(390, 85, 120, 30)
self.EDDelUnauth = JButton("Remove filter",
actionPerformed=self.delEDFilterUnauth)
self.EDDelUnauth.setBounds(390, 210, 120, 30)
self.EDModUnauth = JButton("Modify filter",
actionPerformed=self.modEDFilterUnauth)
self.EDModUnauth.setBounds(390, 250, 120, 30)
AndOrStrings = ["And", "Or"]
self.AndOrTypeUnauth = JComboBox(AndOrStrings)
self.AndOrTypeUnauth.setBounds(390, 170, 120, 30)
self.EDPnlUnauth = JPanel()
self.EDPnlUnauth.setLayout(None)
self.EDPnlUnauth.setBounds(0, 0, 1000, 1000)
self.EDPnlUnauth.add(EDLType)
self.EDPnlUnauth.add(self.EDTypeUnauth)
self.EDPnlUnauth.add(EDLContent)
self.EDPnlUnauth.add(scrollEDTextUnauth)
self.EDPnlUnauth.add(self.EDAddUnauth)
self.EDPnlUnauth.add(self.AndOrTypeUnauth)
self.EDPnlUnauth.add(self.EDDelUnauth)
self.EDPnlUnauth.add(self.EDModUnauth)
self.EDPnlUnauth.add(EDLabelList)
self.EDPnlUnauth.add(scrollEDListUnauth)
def initInterceptionFilters(self):
""" init interception filters tab
"""
self.savedHeaders = [{"title": "Temporary headers", "headers": "Cookie: Insert=injected; cookie=or;\nHeader: here"}]
# IFStrings has to contains : character
IFStrings = ["Scope items only: (Content is not required)",
"URL Contains (simple string): ",
"URL Contains (regex): ",
"URL Not Contains (simple string): ",
"URL Not Contains (regex): ",
"Only HTTP methods (newline separated): ",
"Ignore HTTP methods (newline separated): ",
"Ignore spider requests: (Content is not required)",
"Ignore proxy requests: (Content is not required)",
"Ignore target requests: (Content is not required)"]
self.IFType = JComboBox(IFStrings)
self.IFType.setBounds(80, 10, 430, 30)
self.IFModel = DefaultListModel()
self.IFList = JList(self.IFModel)
scrollIFList = JScrollPane(self.IFList)
scrollIFList.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED)
scrollIFList.setBounds(80, 175, 300, 110)
scrollIFList.setBorder(LineBorder(Color.BLACK))
# Adding some default interception filters
# self.IFModel.addElement("Scope items only: (Content is not required)") # commented for better first impression.
self.IFModel.addElement("URL Not Contains (regex): \\.js|css|png|jpg|jpeg|gif|woff|map|bmp|ico$")
self.IFModel.addElement("Ignore spider requests: ")
self.IFText = JTextArea("", 5, 30)
scrollIFText = JScrollPane(self.IFText)
scrollIFText.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED)
scrollIFText.setBounds(80, 50, 300, 110)
IFLType = JLabel("Type:")
IFLType.setBounds(10, 10, 140, 30)
IFLContent = JLabel("Content:")
IFLContent.setBounds(10, 50, 140, 30)
IFLabelList = JLabel("Filter List:")
IFLabelList.setBounds(10, 165, 140, 30)
self.IFAdd = JButton("Add filter", actionPerformed=self.addIFFilter)
self.IFAdd.setBounds(390, 85, 120, 30)
self.IFDel = JButton("Remove filter", actionPerformed=self.delIFFilter)
self.IFDel.setBounds(390, 210, 120, 30)
self.IFMod = JButton("Modify filter", actionPerformed=self.modIFFilter)
self.IFMod.setBounds(390, 250, 120, 30)
self.filtersPnl = JPanel()
self.filtersPnl.setLayout(None)
self.filtersPnl.setBounds(0, 0, 1000, 1000)
self.filtersPnl.add(IFLType)
self.filtersPnl.add(self.IFType)
self.filtersPnl.add(IFLContent)
self.filtersPnl.add(scrollIFText)
self.filtersPnl.add(self.IFAdd)
self.filtersPnl.add(self.IFDel)
self.filtersPnl.add(self.IFMod)
self.filtersPnl.add(IFLabelList)
self.filtersPnl.add(scrollIFList)
def initConfigurationTab(self):
""" init configuration tab
"""
self.startButton = JToggleButton("Autorize is off",
actionPerformed=self.startOrStop)
self.startButton.setBounds(10, 20, 230, 30)
self.clearButton = JButton("Clear List", actionPerformed=self.clearList)
self.clearButton.setBounds(10, 80, 100, 30)
self.autoScroll = JCheckBox("Auto Scroll")
self.autoScroll.setBounds(145, 80, 130, 30)
self.ignore304 = JCheckBox("Ignore 304/204 status code responses")
self.ignore304.setBounds(280, 5, 300, 30)
self.ignore304.setSelected(True)
self.prevent304 = JCheckBox("Prevent 304 Not Modified status code")
self.prevent304.setBounds(280, 25, 300, 30)
self.interceptRequestsfromRepeater = JCheckBox("Intercept requests from Repeater")
self.interceptRequestsfromRepeater.setBounds(280, 45, 300, 30)
self.doUnauthorizedRequest = JCheckBox("Check unauthenticated")
self.doUnauthorizedRequest.setBounds(280, 65, 300, 30)
self.doUnauthorizedRequest.setSelected(True)
self.saveHeadersButton = JButton("Save headers",
actionPerformed=self.saveHeaders)
self.saveHeadersButton.setBounds(360, 115, 120, 30)
savedHeadersTitles = self.getSavedHeadersTitles()
self.savedHeadersTitlesCombo = JComboBox(savedHeadersTitles)
self.savedHeadersTitlesCombo.addActionListener(savedHeaderChange(self))
self.savedHeadersTitlesCombo.setBounds(10, 115, 300, 30)
self.replaceString = JTextArea("Cookie: Insert=injected; cookie=or;\nHeader: here", 5, 30)
self.replaceString.setWrapStyleWord(True)
self.replaceString.setLineWrap(True)
scrollReplaceString = JScrollPane(self.replaceString)
scrollReplaceString.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED)
scrollReplaceString.setBounds(10, 150, 470, 150)
self.fetchButton = JButton("Fetch cookies from last request",
actionPerformed=self.fetchCookies)
self.fetchButton.setEnabled(False)
self.fetchButton.setBounds(10, 305, 250, 30)
self.filtersTabs = JTabbedPane()
self.filtersTabs.addTab("Enforcement Detector", self.EDPnl)
self.filtersTabs.addTab("Detector Unauthenticated", self.EDPnlUnauth)
self.filtersTabs.addTab("Interception Filters", self.filtersPnl)
self.filtersTabs.addTab("Table Filter", self.filterPnl)
self.filtersTabs.addTab("Save/Restore", self.exportPnl)
self.filtersTabs.setSelectedIndex(2)
self.filtersTabs.setBounds(0, 350, 2000, 700)
self.pnl = JPanel()
self.pnl.setBounds(0, 0, 1000, 1000)
self.pnl.setLayout(None)
self.pnl.add(self.startButton)
self.pnl.add(self.clearButton)
self.pnl.add(scrollReplaceString)
self.pnl.add(self.saveHeadersButton)
self.pnl.add(self.savedHeadersTitlesCombo)
self.pnl.add(self.fetchButton)
self.pnl.add(self.autoScroll)
self.pnl.add(self.interceptRequestsfromRepeater)
self.pnl.add(self.ignore304)
self.pnl.add(self.prevent304)
self.pnl.add(self.doUnauthorizedRequest)
self.pnl.add(self.filtersTabs)
def initTabs(self):
""" init autorize tabs
"""
self.logTable = Table(self)
#self.logTable.setAutoCreateRowSorter(True)
tableWidth = self.logTable.getPreferredSize().width
self.logTable.getColumn("ID").setPreferredWidth(Math.round(tableWidth / 50 * 2))
self.logTable.getColumn("Method").setPreferredWidth(Math.round(tableWidth / 50 * 3))
self.logTable.getColumn("URL").setPreferredWidth(Math.round(tableWidth / 50 * 25))
self.logTable.getColumn("Orig. Length").setPreferredWidth(Math.round(tableWidth / 50 * 4))
self.logTable.getColumn("Modif. Length").setPreferredWidth(Math.round(tableWidth / 50 * 4))
self.logTable.getColumn("Unauth. Length").setPreferredWidth(Math.round(tableWidth / 50 * 4))
self.logTable.getColumn("Authorization Enforcement Status").setPreferredWidth(Math.round(tableWidth / 50 * 4))
self.logTable.getColumn("Authorization Unauth. Status").setPreferredWidth(Math.round(tableWidth / 50 * 4))
self.tableSorter = TableRowSorter(self)
filter = tableFilter(self)
self.tableSorter.setRowFilter(filter)
self.logTable.setRowSorter(self.tableSorter)
self._splitpane = JSplitPane(JSplitPane.HORIZONTAL_SPLIT)
self._splitpane.setResizeWeight(1)
self.scrollPane = JScrollPane(self.logTable)
self._splitpane.setLeftComponent(self.scrollPane)
self.scrollPane.getVerticalScrollBar().addAdjustmentListener(autoScrollListener(self))
copyURLitem = JMenuItem("Copy URL")
copyURLitem.addActionListener(copySelectedURL(self))
sendRequestMenu = JMenuItem("Send Original Request to Repeater")
sendRequestMenu.addActionListener(sendRequestRepeater(self, self._callbacks, True))
sendRequestMenu2 = JMenuItem("Send Modified Request to Repeater")
sendRequestMenu2.addActionListener(sendRequestRepeater(self, self._callbacks, False))
sendResponseMenu = JMenuItem("Send Responses to Comparer")
sendResponseMenu.addActionListener(sendResponseComparer(self, self._callbacks))
retestSelecteditem = JMenuItem("Retest selected request")
retestSelecteditem.addActionListener(retestSelectedRequest(self))
deleteSelectedItem = JMenuItem("Delete")
deleteSelectedItem.addActionListener(deleteSelectedRequest(self))
self.menu = JPopupMenu("Popup")
self.menu.add(sendRequestMenu)
self.menu.add(sendRequestMenu2)
self.menu.add(sendResponseMenu)
self.menu.add(copyURLitem)
self.menu.add(retestSelecteditem)
# self.menu.add(deleteSelectedItem) disabling this feature until bug will be fixed.
self.tabs = JTabbedPane()
self._requestViewer = self._callbacks.createMessageEditor(self, False)
self._responseViewer = self._callbacks.createMessageEditor(self, False)
self._originalrequestViewer = self._callbacks.createMessageEditor(self, False)
self._originalresponseViewer = self._callbacks.createMessageEditor(self, False)
self._unauthorizedrequestViewer = self._callbacks.createMessageEditor(self, False)
self._unauthorizedresponseViewer = self._callbacks.createMessageEditor(self, False)
self.tabs.addTab("Modified Request", self._requestViewer.getComponent())
self.tabs.addTab("Modified Response", self._responseViewer.getComponent())
self.tabs.addTab("Original Request", self._originalrequestViewer.getComponent())
self.tabs.addTab("Original Response", self._originalresponseViewer.getComponent())
self.tabs.addTab("Unauthenticated Request", self._unauthorizedrequestViewer.getComponent())
self.tabs.addTab("Unauthenticated Response", self._unauthorizedresponseViewer.getComponent())
self.tabs.addTab("Configuration", self.pnl)
self.tabs.setSelectedIndex(6)
self._splitpane.setRightComponent(self.tabs)
def initCallbacks(self):
""" init callbacks
"""
# register HTTP listener
self._callbacks.registerHttpListener(self)
# customize our UI components
self._callbacks.customizeUiComponent(self._splitpane)
self._callbacks.customizeUiComponent(self.logTable)
self._callbacks.customizeUiComponent(self.scrollPane)
self._callbacks.customizeUiComponent(self.tabs)
self._callbacks.customizeUiComponent(self.filtersTabs)
self._callbacks.registerContextMenuFactory(self)
# add the custom tab to Burp's UI
self._callbacks.addSuiteTab(self)
#
## Events functions
#
def startOrStop(self, event):
if self.startButton.getText() == "Autorize is off":
self.startButton.setText("Autorize is on")
self.startButton.setSelected(True)
self.intercept = 1
else:
self.startButton.setText("Autorize is off")
self.startButton.setSelected(False)
self.intercept = 0
#
## FilterHelpers
#
def addFilterHelper(self, typeObj, model, textObj):
typeName = typeObj.getSelectedItem().split(":")[0]
model.addElement(typeName + ": " + textObj.getText().strip())
textObj.setText("")
def delFilterHelper(self, listObj):
index = listObj.getSelectedIndex()
if not index == -1:
listObj.getModel().remove(index)
def modFilterHelper(self, listObj, typeObj, textObj):
index = listObj.getSelectedIndex()
if not index == -1:
valt = listObj.getSelectedValue()
val = valt.split(":", 1)[1].strip()
modifiedFilter = valt.split(":", 1)[0].strip() + ":"
typeObj.getModel().setSelectedItem(modifiedFilter)
if ("Scope items" not in valt) and ("Content-Len" not in valt):
textObj.setText(val)
listObj.getModel().remove(index)
def addEDFilter(self, event):
self.addFilterHelper(self.EDType, self.EDModel, self.EDText)
def delEDFilter(self, event):
self.delFilterHelper(self.EDList)
def modEDFilter(self, event):
self.modFilterHelper(self.EDList, self.EDType, self.EDText)
def addEDFilterUnauth(self, event):
self.addFilterHelper(self.EDTypeUnauth, self.EDModelUnauth, self.EDTextUnauth)
def delEDFilterUnauth(self, event):
self.delFilterHelper(self.EDListUnauth)
def modEDFilterUnauth(self, event):
self.modFilterHelper(self.EDListUnauth, self.EDTypeUnauth, self.EDTextUnauth)
def addIFFilter(self, event):
self.addFilterHelper(self.IFType, self.IFModel, self.IFText)
def delIFFilter(self, event):
self.delFilterHelper(self.IFList)
def modIFFilter(self, event):
self.modFilterHelper(self.IFList, self.IFType, self.IFText)
def getSavedHeadersTitles(self):
titles = []
for savedHeaderObj in self.savedHeaders:
titles.append(savedHeaderObj['title'])
return titles
def saveHeaders(self, event):
savedHeadersTitle = JOptionPane.showInputDialog("Please provide saved headers title:")
self.savedHeaders.append({'title': savedHeadersTitle, 'headers': self.replaceString.getText()})
self.savedHeadersTitlesCombo.setModel(DefaultComboBoxModel(self.getSavedHeadersTitles()))
self.savedHeadersTitlesCombo.getModel().setSelectedItem(savedHeadersTitle)
def clearList(self, event):
self._lock.acquire()
oldSize = self._log.size()
self._log.clear()
SwingUtilities.invokeLater(UpdateTableEDT(self,"delete",0, oldSize - 1))
#self.fireTableRowsDeleted(0, oldSize - 1)
self._lock.release()
def fetchCookies(self, event):
if self.lastCookies:
self.replaceString.setText(self.lastCookies)
def export(self, event):
if self.exportType.getSelectedItem() == "HTML":
self.exportToHTML()
else:
self.exportToCSV()
def saveStateAction(self, event):
self.saveState()
def restoreStateAction(self, event):
self.restoreState()
def exportToCSV(self):
parentFrame = JFrame()
fileChooser = JFileChooser()
fileChooser.setSelectedFile(File("AutorizeReport.csv"))
fileChooser.setDialogTitle("Save Autorize Report")
userSelection = fileChooser.showSaveDialog(parentFrame)
if userSelection == JFileChooser.APPROVE_OPTION:
fileToSave = fileChooser.getSelectedFile()
enforcementStatusFilter = self.exportES.getSelectedItem()
csvContent = "id\tMethod\tURL\tOriginal length\tModified length\tUnauthorized length\tAuthorization Enforcement Status\tAuthorization Unauthenticated Status\n"
for i in range(0,self._log.size()):
if enforcementStatusFilter == "All Statuses":
csvContent += "%d\t%s\t%s\t%d\t%d\t%d\t%s\t%s\n" % (self._log.get(i)._id, self._log.get(i)._method, self._log.get(i)._url, len(self._log.get(i)._originalrequestResponse.getResponse()) if self._log.get(i)._originalrequestResponse is not None else 0, len(self._log.get(i)._requestResponse.getResponse()) if self._log.get(i)._requestResponse is not None else 0, len(self._log.get(i)._unauthorizedRequestResponse.getResponse()) if self._log.get(i)._unauthorizedRequestResponse is not None else 0, self._log.get(i)._enfocementStatus, self._log.get(i)._enfocementStatusUnauthorized)
elif enforcementStatusFilter == "As table filter":
if ((self.showAuthBypassModified.isSelected() and self.BYPASSSED_STR == self._log.get(i)._enfocementStatus) or
(self.showAuthPotentiallyEnforcedModified.isSelected() and "Is enforced???" == self._log.get(i)._enfocementStatus) or
(self.showAuthEnforcedModified.isSelected() and self.ENFORCED_STR == self._log.get(i)._enfocementStatus) or
(self.showAuthBypassUnauthenticated.isSelected() and self.BYPASSSED_STR == self._log.get(i)._enfocementStatusUnauthorized) or
(self.showAuthPotentiallyEnforcedUnauthenticated.isSelected() and "Is enforced???" == self._log.get(i)._enfocementStatusUnauthorized) or
(self.showAuthEnforcedUnauthenticated.isSelected() and self.ENFORCED_STR == self._log.get(i)._enfocementStatusUnauthorized) or
(self.showDisabledUnauthenticated.isSelected() and "Disabled" == self._log.get(i)._enfocementStatusUnauthorized)):
csvContent += "%d\t%s\t%s\t%d\t%d\t%d\t%s\t%s\n" % (self._log.get(i)._id, self._log.get(i)._method, self._log.get(i)._url, len(self._log.get(i)._originalrequestResponse.getResponse()) if self._log.get(i)._originalrequestResponse is not None else 0, len(self._log.get(i)._requestResponse.getResponse()) if self._log.get(i)._requestResponse is not None else 0, len(self._log.get(i)._unauthorizedRequestResponse.getResponse()) if self._log.get(i)._unauthorizedRequestResponse is not None else 0, self._log.get(i)._enfocementStatus, self._log.get(i)._enfocementStatusUnauthorized)
else:
if (enforcementStatusFilter == self._log.get(i)._enfocementStatus) or (enforcementStatusFilter == self._log.get(i)._enfocementStatusUnauthorized):
csvContent += "%d\t%s\t%s\t%d\t%d\t%d\t%s\t%s\n" % (self._log.get(i)._id, self._log.get(i)._method, self._log.get(i)._url, len(self._log.get(i)._originalrequestResponse.getResponse()) if self._log.get(i)._originalrequestResponse is not None else 0, len(self._log.get(i)._requestResponse.getResponse()) if self._log.get(i)._requestResponse is not None else 0, len(self._log.get(i)._unauthorizedRequestResponse.getResponse()) if self._log.get(i)._unauthorizedRequestResponse is not None else 0, self._log.get(i)._enfocementStatus, self._log.get(i)._enfocementStatusUnauthorized)
f = open(fileToSave.getAbsolutePath(), 'w')
f.writelines(csvContent)
f.close()
def exportToHTML(self):
parentFrame = JFrame()
fileChooser = JFileChooser()
fileChooser.setSelectedFile(File("AutorizeReport.html"))
fileChooser.setDialogTitle("Save Autorize Report")
userSelection = fileChooser.showSaveDialog(parentFrame)
if userSelection == JFileChooser.APPROVE_OPTION:
fileToSave = fileChooser.getSelectedFile()
enforcementStatusFilter = self.exportES.getSelectedItem()
htmlContent = """<html><title>Autorize Report by Barak Tawily</title>
<style>
.datagrid table { border-collapse: collapse; text-align: left; width: 100%; }
.datagrid {font: normal 12px/150% Arial, Helvetica, sans-serif; background: #fff; overflow: hidden; border: 1px solid #006699; -webkit-border-radius: 3px; -moz-border-radius: 3px; border-radius: 3px; }
.datagrid table td, .datagrid table th { padding: 3px 10px; }
.datagrid table thead th {background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #006699), color-stop(1, #00557F) );background:-moz-linear-gradient( center top, #006699 5%, #00557F 100% );filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#006699', endColorstr='#00557F');background-color:#006699; color:#FFFFFF; font-size: 15px; font-weight: bold; border-left: 1px solid #0070A8; } .datagrid table thead th:first-child { border: none; }.datagrid table tbody td { color: #00496B; border-left: 1px solid #E1EEF4;font-size: 12px;font-weight: normal; }.datagrid table tbody .alt td { background: #E1EEF4; color: #00496B; }.datagrid table tbody td:first-child { border-left: none; }.datagrid table tbody tr:last-child td { border-bottom: none; }.datagrid table tfoot td div { border-top: 1px solid #006699;background: #E1EEF4;} .datagrid table tfoot td { padding: 0; font-size: 12px } .datagrid table tfoot td div{ padding: 2px; }.datagrid table tfoot td ul { margin: 0; padding:0; list-style: none; text-align: right; }.datagrid table tfoot li { display: inline; }.datagrid table tfoot li a { text-decoration: none; display: inline-block; padding: 2px 8px; margin: 1px;color: #FFFFFF;border: 1px solid #006699;-webkit-border-radius: 3px; -moz-border-radius: 3px; border-radius: 3px; background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #006699), color-stop(1, #00557F) );background:-moz-linear-gradient( center top, #006699 5%, #00557F 100% );filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#006699', endColorstr='#00557F');background-color:#006699; }.datagrid table tfoot ul.active, .datagrid table tfoot ul a:hover { text-decoration: none;border-color: #006699; color: #FFFFFF; background: none; background-color:#00557F;}div.dhtmlx_window_active, div.dhx_modal_cover_dv { position: fixed !important; }
table {
width: 100%;
table-layout: fixed;
}
td {
border: 1px solid #35f;
overflow: hidden;
text-overflow: ellipsis;
}
td.a {
width: 13%;
white-space: nowrap;
}
td.b {
width: 9%;
word-wrap: break-word;
}
</style>
<body>
<h1>Autorize Report<h1>
<div class="datagrid"><table>
<thead><tr><th width=\"3%\">ID</th><th width=\"5%\">Method</th><th width=\"43%\">URL</th><th width=\"9%\">Original length</th><th width=\"9%\">Modified length</th><th width=\"9%\">Unauthorized length</th><th width=\"11%\">Authorization Enforcement Status</th><th width=\"11%\">Authorization Unauthenticated Status</th></tr></thead>
<tbody>"""
for i in range(0,self._log.size()):
color_modified = ""
if self._log.get(i)._enfocementStatus == self.BYPASSSED_STR:
color_modified = "red"
elif self._log.get(i)._enfocementStatus == self.IS_ENFORCED_STR:
color_modified = "yellow"
elif self._log.get(i)._enfocementStatus == self.ENFORCED_STR:
color_modified = "LawnGreen"
color_unauthorized = ""
if self._log.get(i)._enfocementStatusUnauthorized == self.BYPASSSED_STR:
color_unauthorized = "red"
elif self._log.get(i)._enfocementStatusUnauthorized == self.IS_ENFORCED_STR:
color_unauthorized = "yellow"
elif self._log.get(i)._enfocementStatusUnauthorized == self.ENFORCED_STR:
color_unauthorized = "LawnGreen"
if enforcementStatusFilter == "All Statuses":
htmlContent += "<tr><td>%d</td><td>%s</td><td><a href=\"%s\">%s</a></td><td>%d</td><td>%d</td><td>%d</td><td bgcolor=\"%s\">%s</td><td bgcolor=\"%s\">%s</td></tr>" % (self._log.get(i)._id, self._log.get(i)._method, self._log.get(i)._url, self._log.get(i)._url, len(self._log.get(i)._originalrequestResponse.getResponse()) if self._log.get(i)._originalrequestResponse is not None else 0, len(self._log.get(i)._requestResponse.getResponse()) if self._log.get(i)._requestResponse is not None else 0, len(self._log.get(i)._unauthorizedRequestResponse.getResponse()) if self._log.get(i)._unauthorizedRequestResponse is not None else 0, color_modified, self._log.get(i)._enfocementStatus, color_unauthorized, self._log.get(i)._enfocementStatusUnauthorized)
elif enforcementStatusFilter == "As table filter":
if ((self.showAuthBypassModified.isSelected() and self.BYPASSSED_STR == self._log.get(i)._enfocementStatus) or
(self.showAuthPotentiallyEnforcedModified.isSelected() and "Is enforced???" == self._log.get(i)._enfocementStatus) or
(self.showAuthEnforcedModified.isSelected() and self.ENFORCED_STR == self._log.get(i)._enfocementStatus) or
(self.showAuthBypassUnauthenticated.isSelected() and self.BYPASSSED_STR == self._log.get(i)._enfocementStatusUnauthorized) or
(self.showAuthPotentiallyEnforcedUnauthenticated.isSelected() and "Is enforced???" == self._log.get(i)._enfocementStatusUnauthorized) or
(self.showAuthEnforcedUnauthenticated.isSelected() and self.ENFORCED_STR == self._log.get(i)._enfocementStatusUnauthorized) or
(self.showDisabledUnauthenticated.isSelected() and "Disabled" == self._log.get(i)._enfocementStatusUnauthorized)):
htmlContent += "<tr><td>%d</td><td>%s</td><td><a href=\"%s\">%s</a></td><td>%d</td><td>%d</td><td>%d</td><td bgcolor=\"%s\">%s</td><td bgcolor=\"%s\">%s</td></tr>" % (self._log.get(i)._id, self._log.get(i)._method, self._log.get(i)._url, self._log.get(i)._url, len(self._log.get(i)._originalrequestResponse.getResponse()) if self._log.get(i)._originalrequestResponse is not None else 0, len(self._log.get(i)._requestResponse.getResponse()) if self._log.get(i)._requestResponse is not None else 0, len(self._log.get(i)._unauthorizedRequestResponse.getResponse()) if self._log.get(i)._unauthorizedRequestResponse is not None else 0, color_modified, self._log.get(i)._enfocementStatus, color_unauthorized, self._log.get(i)._enfocementStatusUnauthorized)
else:
if (enforcementStatusFilter == self._log.get(i)._enfocementStatus) or (enforcementStatusFilter == self._log.get(i)._enfocementStatusUnauthorized):
htmlContent += "<tr><td>%d</td><td>%s</td><td><a href=\"%s\">%s</a></td><td>%d</td><td>%d</td><td>%d</td><td bgcolor=\"%s\">%s</td><td bgcolor=\"%s\">%s</td></tr>" % (self._log.get(i)._id, self._log.get(i)._method, self._log.get(i)._url, self._log.get(i)._url, len(self._log.get(i)._originalrequestResponse.getResponse()) if self._log.get(i)._originalrequestResponse is not None else 0, len(self._log.get(i)._requestResponse.getResponse()) if self._log.get(i)._requestResponse is not None else 0, len(self._log.get(i)._unauthorizedRequestResponse.getResponse()) if self._log.get(i)._unauthorizedRequestResponse is not None else 0, color_modified, self._log.get(i)._enfocementStatus, color_unauthorized, self._log.get(i)._enfocementStatusUnauthorized)
htmlContent += "</tbody></table></div></body></html>"
f = open(fileToSave.getAbsolutePath(), 'w')
f.writelines(htmlContent)
f.close()
def isStatusCodesReturned(self, messageInfo, statusCodes):
firstHeader = self._helpers.analyzeResponse(messageInfo.getResponse()).getHeaders()[0]
if type(statusCodes) == list:
for statusCode in statusCodes:
if statusCode in firstHeader:
return True
elif type(statusCodes) == str or type(statusCodes) == unicode:
# single status code
if statusCodes in firstHeader:
return True
return False
# Save state
def saveState(self):
parentFrame = JFrame()
fileChooser = JFileChooser()
fileChooser.setDialogTitle("State output file")
userSelection = fileChooser.showSaveDialog(parentFrame)
if userSelection == JFileChooser.APPROVE_OPTION:
exportFile = fileChooser.getSelectedFile()
with open(exportFile.getAbsolutePath(), 'wb') as csvfile:
csvwriter = csv.writer(csvfile, delimiter='\t', quotechar='|', quoting=csv.QUOTE_MINIMAL)
for i in range(0,self._log.size()):
tempRequestResponseHost = self._log.get(i)._requestResponse.getHttpService().getHost()
tempRequestResponsePort = self._log.get(i)._requestResponse.getHttpService().getPort()
tempRequestResponseProtocol = self._log.get(i)._requestResponse.getHttpService().getProtocol()
tempRequestResponseRequest = base64.b64encode(self._log.get(i)._requestResponse.getRequest())
tempRequestResponseResponse = base64.b64encode(self._log.get(i)._requestResponse.getResponse())
tempOriginalRequestResponseHost = self._log.get(i)._originalrequestResponse.getHttpService().getHost()
tempOriginalRequestResponsePort = self._log.get(i)._originalrequestResponse.getHttpService().getPort()
tempOriginalRequestResponseProtocol = self._log.get(i)._originalrequestResponse.getHttpService().getProtocol()
tempOriginalRequestResponseRequest = base64.b64encode(self._log.get(i)._originalrequestResponse.getRequest())
tempOriginalRequestResponseResponse = base64.b64encode(self._log.get(i)._originalrequestResponse.getResponse())
if self._log.get(i)._unauthorizedRequestResponse is not None:
tempUnauthorizedRequestResponseHost = self._log.get(i)._unauthorizedRequestResponse.getHttpService().getHost()
tempUnauthorizedRequestResponsePort = self._log.get(i)._unauthorizedRequestResponse.getHttpService().getPort()
tempUnauthorizedRequestResponseProtocol = self._log.get(i)._unauthorizedRequestResponse.getHttpService().getProtocol()
tempUnauthorizedRequestResponseRequest = base64.b64encode(self._log.get(i)._unauthorizedRequestResponse.getRequest())
tempUnauthorizedRequestResponseResponse = base64.b64encode(self._log.get(i)._unauthorizedRequestResponse.getResponse())
else:
tempUnauthorizedRequestResponseHost = None
tempUnauthorizedRequestResponsePort = None
tempUnauthorizedRequestResponseProtocol = None
tempUnauthorizedRequestResponseRequest = None
tempUnauthorizedRequestResponseResponse = None
tempEnforcementStatus = self._log.get(i)._enfocementStatus
tempEnforcementStatusUnauthorized = self._log.get(i)._enfocementStatusUnauthorized
tempRow = [tempRequestResponseHost,tempRequestResponsePort,tempRequestResponseProtocol,tempRequestResponseRequest,tempRequestResponseResponse]
tempRow.extend([tempOriginalRequestResponseHost,tempOriginalRequestResponsePort,tempOriginalRequestResponseProtocol,tempOriginalRequestResponseRequest,tempOriginalRequestResponseResponse])
tempRow.extend([tempUnauthorizedRequestResponseHost,tempUnauthorizedRequestResponsePort,tempUnauthorizedRequestResponseProtocol,tempUnauthorizedRequestResponseRequest,tempUnauthorizedRequestResponseResponse])
tempRow.extend([tempEnforcementStatus,tempEnforcementStatusUnauthorized])
csvwriter.writerow(tempRow)
# Restore state
def restoreState(self):
parentFrame = JFrame()
fileChooser = JFileChooser()
fileChooser.setDialogTitle("State import file")
userSelection = fileChooser.showDialog(parentFrame,"Restore")
if userSelection == JFileChooser.APPROVE_OPTION:
importFile = fileChooser.getSelectedFile()
with open(importFile.getAbsolutePath(), 'r') as csvfile:
csvreader = csv.reader(csvfile, delimiter='\t', quotechar='|')
for row in csvreader:
tempRequestResponseHost = row[0]
tempRequestResponsePort = row[1]
tempRequestResponseProtocol = row[2]
tempRequestResponseRequest = base64.b64decode(row[3])
tempRequestResponseResponse = base64.b64decode(row[4])
tempRequestResponseHttpService = self._helpers.buildHttpService(tempRequestResponseHost,int(tempRequestResponsePort),tempRequestResponseProtocol)
tempRequestResponse = IHttpRequestResponseImplementation(tempRequestResponseHttpService,tempRequestResponseRequest,tempRequestResponseResponse)
tempOriginalRequestResponseHost = row[5]
tempOriginalRequestResponsePort = row[6]
tempOriginalRequestResponseProtocol = row[7]
tempOriginalRequestResponseRequest = base64.b64decode(row[8])
tempOriginalRequestResponseResponse = base64.b64decode(row[9])
tempOriginalRequestResponseHttpService = self._helpers.buildHttpService(tempOriginalRequestResponseHost,int(tempOriginalRequestResponsePort),tempOriginalRequestResponseProtocol)
tempOriginalRequestResponse = IHttpRequestResponseImplementation(tempOriginalRequestResponseHttpService,tempOriginalRequestResponseRequest,tempOriginalRequestResponseResponse)
checkAuthentication = True
if row[10] != '':
tempUnauthorizedRequestResponseHost = row[10]
tempUnauthorizedRequestResponsePort = row[11]
tempUnauthorizedRequestResponseProtocol = row[12]
tempUnauthorizedRequestResponseRequest = base64.b64decode(row[13])
tempUnauthorizedRequestResponseResponse = base64.b64decode(row[14])
tempUnauthorizedRequestResponseHttpService = self._helpers.buildHttpService(tempUnauthorizedRequestResponseHost,int(tempUnauthorizedRequestResponsePort),tempUnauthorizedRequestResponseProtocol)
tempUnauthorizedRequestResponse = IHttpRequestResponseImplementation(tempUnauthorizedRequestResponseHttpService,tempUnauthorizedRequestResponseRequest,tempUnauthorizedRequestResponseResponse)
else:
checkAuthentication = False
tempUnauthorizedRequestResponse = None
tempEnforcementStatus = row[15]
tempEnforcementStatusUnauthorized = row[16]
self._lock.acquire()
row = self._log.size()
if checkAuthentication:
self._log.add(LogEntry(self.currentRequestNumber,self._callbacks.saveBuffersToTempFiles(tempRequestResponse), self._helpers.analyzeRequest(tempRequestResponse).getMethod(), self._helpers.analyzeRequest(tempRequestResponse).getUrl(), self._callbacks.saveBuffersToTempFiles(tempOriginalRequestResponse),tempEnforcementStatus,self._callbacks.saveBuffersToTempFiles(tempUnauthorizedRequestResponse),tempEnforcementStatusUnauthorized))
else:
self._log.add(LogEntry(self.currentRequestNumber,self._callbacks.saveBuffersToTempFiles(tempRequestResponse), self._helpers.analyzeRequest(tempRequestResponse).getMethod(), self._helpers.analyzeRequest(tempRequestResponse).getUrl(), self._callbacks.saveBuffersToTempFiles(tempOriginalRequestResponse),tempEnforcementStatus,None,tempEnforcementStatusUnauthorized))
SwingUtilities.invokeLater(UpdateTableEDT(self,"insert",row,row))
self.currentRequestNumber = self.currentRequestNumber + 1
self._lock.release()
lastRow = self._log.size()
if lastRow > 0:
cookies = self.getCookieFromMessage(self._log.get(lastRow - 1)._requestResponse)
if cookies:
self.lastCookies = cookies
self.fetchButton.setEnabled(True)
#
# implement IContextMenuFactory
#
def createMenuItems(self, invocation):
responses = invocation.getSelectedMessages()
if responses > 0:
ret = LinkedList()
requestMenuItem = JMenuItem("Send request to Autorize")
cookieMenuItem = JMenuItem("Send cookie to Autorize")
for response in responses:
requestMenuItem.addActionListener(handleMenuItems(self,response, "request"))
cookieMenuItem.addActionListener(handleMenuItems(self, response, "cookie"))
ret.add(requestMenuItem)
ret.add(cookieMenuItem)
return ret
return None
#
# implement ITab
#
def getTabCaption(self):
return "Autorize"
def getUiComponent(self):
return self._splitpane
#
# extend AbstractTableModel
#
def getRowCount(self):
try:
return self._log.size()
except:
return 0
def getColumnCount(self):
return 8
def getColumnName(self, columnIndex):
data = ['ID','Method', 'URL', 'Orig. Length', 'Modif. Length', "Unauth. Length",
"Authorization Enforcement Status", "Authorization Unauth. Status"]
try:
return data[columnIndex]
except IndexError:
return ""
def getColumnClass(self, columnIndex):