1
- // Flow Burp Extension, (c) 2015-2017 Marcin Woloszyn (@hvqzao), Released under MIT license
1
+ // Flow Burp Extension, (c) 2015-2019 Marcin Woloszyn (@hvqzao), Released under MIT license
2
2
package hvqzao .flow ;
3
3
4
4
import hvqzao .flow .ui .DialogWrapper ;
61
61
import burp .IScopeChangeListener ;
62
62
import burp .ITab ;
63
63
import hvqzao .flow .ui .BooleanTableCellRenderer ;
64
- import static hvqzao .flow .ui .Helper . cellBackground ;
64
+ import hvqzao .flow .ui .ThemeHelper ;
65
65
import java .awt .Dialog ;
66
66
import java .io .PrintWriter ;
67
67
import java .util .List ;
77
77
78
78
public class FlowExtension implements IBurpExtender , ITab , IHttpListener , IScopeChangeListener , IExtensionStateListener {
79
79
80
- private final String version = "Flow v1.23 (2018-04-16) (unreleased)" ;
80
+ private final String version = "Flow v1.24 (2019-05-20)" ;
81
+ // Changes in v1.24:
82
+ // - rows coloring is now disabled on dark theme
83
+ // - reflections count display limit introduced
84
+ //
81
85
// Changes in v1.23:
82
86
// - Center "Add new sitemap issue" dialog, resize according to preferred size
83
87
// - Filter by search term does not break window anymore when search is too long
@@ -176,9 +180,15 @@ public class FlowExtension implements IBurpExtender, ITab, IHttpListener, IScope
176
180
private boolean autoDelete = false ;
177
181
private int autoDeleteKeep = 1000 ;
178
182
private boolean autoPopulate = false ;
183
+ private boolean showReflections = true ;
184
+ private int showReflectionsCount ;
185
+ private final int showReflectionsCountMax = 50 ;
186
+ private final int showReflectionsCountDefault = 10 ;
179
187
private boolean modalAutoPopulate ;
180
188
private boolean modalAutoDelete ;
181
189
private int modalAutoDeleteKeep ;
190
+ private boolean modalShowReflections ;
191
+ private int modalShowReflectionsCount ;
182
192
private static PrintWriter stderr ;
183
193
private FilterWorker flowFilterWorker ;
184
194
private static int sortOrder ;
@@ -206,7 +216,7 @@ public void run() {
206
216
ImageIcon iconNewWindow = new ImageIcon (new ImageIcon (getClass ().getResource ("/hvqzao/flow/resources/newwindow.png" )).getImage ().getScaledInstance (13 , 13 , java .awt .Image .SCALE_SMOOTH ));
207
217
ImageIcon iconCheckbox = new ImageIcon (new ImageIcon (getClass ().getResource ("/hvqzao/flow/resources/checkbox.png" )).getImage ().getScaledInstance (13 , 13 , java .awt .Image .SCALE_SMOOTH ));
208
218
Dimension iconDimension = new Dimension (24 , 24 );
209
-
219
+
210
220
// flow tab prolog: vertical split
211
221
flowTab = new JSplitPane (JSplitPane .VERTICAL_SPLIT );
212
222
callbacks .customizeUiComponent (flowTab );
@@ -723,6 +733,14 @@ public void actionPerformed(ActionEvent e) {
723
733
flowTableSorter .sort ();
724
734
}
725
735
}
736
+ if (showReflections != modalShowReflections ) {
737
+ showReflections = modalShowReflections ;
738
+ callbacks .saveExtensionSetting ("showReflections" , showReflections ? "1" : "0" );
739
+ }
740
+ if (showReflectionsCount != modalShowReflectionsCount ) {
741
+ showReflectionsCount = modalShowReflectionsCount ;
742
+ callbacks .saveExtensionSetting ("showReflectionsCount" , String .valueOf (showReflectionsCount ));
743
+ }
726
744
}
727
745
}
728
746
});
@@ -742,6 +760,8 @@ public void actionPerformed(ActionEvent e) {
742
760
autoPopulate = "1" .equals (callbacks .loadExtensionSetting ("autoPopulateProxy" ));
743
761
autoDeleteKeep = validateAutoDeleteKeep (callbacks .loadExtensionSetting ("autoDeleteKeep" ));
744
762
autoDelete = "1" .equals (callbacks .loadExtensionSetting ("autoDelete" ));
763
+ showReflections = "0" .equals (callbacks .loadExtensionSetting ("showReflections" )) == false ;
764
+ showReflectionsCount = parseReflectionsCount (callbacks .loadExtensionSetting ("showReflectionsCount" ));
745
765
//
746
766
747
767
//
@@ -751,6 +771,14 @@ public void actionPerformed(ActionEvent e) {
751
771
//callbacks.printOutput("Initializing extension with contents of Burp Proxy...");
752
772
(new PopulateWorker (callbacks .getProxyHistory ())).execute ();
753
773
}
774
+
775
+ //Set<Map.Entry<Object, Object>> entries = UIManager.getLookAndFeelDefaults().entrySet();
776
+ //for (Map.Entry<Object, Object> entry : entries) {
777
+ // if (entry.getValue() instanceof Color) {
778
+ // stderr.println(String.valueOf(entry.getKey()) + "\t" + String.valueOf(UIManager.getColor(entry.getKey())) + "\t" + String.valueOf(entry.getValue()));
779
+ // }
780
+ //}
781
+
754
782
//callbacks.printOutput("Loaded.");
755
783
// TODO end main
756
784
}
@@ -1033,7 +1061,7 @@ private boolean showOptionsDialog() {
1033
1061
//
1034
1062
// wrap optionsPane
1035
1063
wrapper .getScrollPane ().getViewport ().add (optionsPane );
1036
- dialog .setBounds (100 , 100 , 526 , 420 );
1064
+ dialog .setBounds (100 , 100 , 526 , 500 );
1037
1065
dialog .setContentPane (wrapper );
1038
1066
//
1039
1067
modalResult = false ;
@@ -1043,6 +1071,8 @@ private boolean showOptionsDialog() {
1043
1071
optionsPane .getAutoPopulate ().setSelected (autoPopulate );
1044
1072
optionsPane .getAutoDelete ().setSelected (autoDelete );
1045
1073
optionsPane .getAutoDeleteKeep ().setText (String .valueOf (autoDeleteKeep ));
1074
+ optionsPane .getShowReflections ().setSelected (showReflections );
1075
+ optionsPane .getShowReflectionsCount ().setText (String .valueOf (showReflectionsCount ));
1046
1076
//
1047
1077
JButton ok = wrapper .getOkButton ();
1048
1078
callbacks .customizeUiComponent (ok );
@@ -1054,6 +1084,8 @@ public void actionPerformed(ActionEvent e) {
1054
1084
modalAutoPopulate = optionsPane .getAutoPopulate ().isSelected ();
1055
1085
modalAutoDelete = optionsPane .getAutoDelete ().isSelected ();
1056
1086
modalAutoDeleteKeep = validateAutoDeleteKeep (optionsPane .getAutoDeleteKeep ().getText ());
1087
+ modalShowReflections = optionsPane .getShowReflections ().isSelected ();
1088
+ modalShowReflectionsCount = parseReflectionsCount (optionsPane .getShowReflectionsCount ().getText ());
1057
1089
dialog .dispose ();
1058
1090
}
1059
1091
});
@@ -2399,44 +2431,62 @@ protected void setValue(Object value) {
2399
2431
@ Override
2400
2432
public Component getTableCellRendererComponent (JTable table , Object value , boolean isSelected , boolean hasFocus , int row , int column ) {
2401
2433
final Component c = super .getTableCellRendererComponent (table , value , isSelected , hasFocus , row , column );
2402
- // c.setBackground(row % 2 == 0 ? Color.LIGHT_GRAY : Color.WHITE);
2403
- //if (!isSelected && tempy != null && flowTable.convertRowIndexToModel(row) == flow.indexOf(tempy)) {
2404
- // c.setForeground(Color.blue);
2405
- //} else {
2406
- // c.setForeground(Color.black);
2407
- //}
2408
2434
int modelRow = table .convertRowIndexToModel (row );
2409
2435
FlowEntry entry = flow .get (modelRow );
2410
- int r = 0 , g = 0 , b = 0 ;
2411
- if (entry .status == 404 || entry .status == 403 ) {
2412
- r += 196 ;
2413
- g += 128 ;
2414
- b += 128 ;
2415
- }
2416
- if (entry .status == 500 ) {
2417
- g += 196 ;
2418
- }
2419
- if (entry .toolFlag != IBurpExtenderCallbacks .TOOL_PROXY ) {
2420
- b += 196 ;
2421
- }
2422
- if (r > 255 ) {
2423
- r = 255 ;
2424
- }
2425
- if (g > 255 ) {
2426
- g = 255 ;
2427
- }
2428
- if (b > 255 ) {
2429
- b = 255 ;
2430
- }
2431
- c .setForeground (new Color (r , g , b ));
2436
+ if (ThemeHelper .isDarkTheme () == false ) {
2437
+ // c.setBackground(row % 2 == 0 ? Color.LIGHT_GRAY : Color.WHITE);
2438
+ //if (!isSelected && tempy != null && flowTable.convertRowIndexToModel(row) == flow.indexOf(tempy)) {
2439
+ // c.setForeground(Color.blue);
2440
+ //} else {
2441
+ // c.setForeground(Color.black);
2442
+ //}
2443
+ int r = 0 , g = 0 , b = 0 ;
2444
+ if (entry .status == 404 || entry .status == 403 ) {
2445
+ r += 196 ;
2446
+ g += 128 ;
2447
+ b += 128 ;
2448
+ }
2449
+ if (entry .status == 500 ) {
2450
+ g += 196 ;
2451
+ }
2452
+ if (entry .toolFlag != IBurpExtenderCallbacks .TOOL_PROXY ) {
2453
+ b += 196 ;
2454
+ }
2455
+ if (r > 255 ) {
2456
+ r = 255 ;
2457
+ }
2458
+ if (g > 255 ) {
2459
+ g = 255 ;
2460
+ }
2461
+ if (b > 255 ) {
2462
+ b = 255 ;
2463
+ }
2464
+ c .setForeground (new Color (r , g , b ));
2432
2465
2433
- c .setBackground (cellBackground (table .getRowCount (), row , isSelected ));
2466
+ c .setBackground (ThemeHelper .cellBackground (table .getRowCount (), row , isSelected ));
2467
+ }
2434
2468
2435
2469
final ArrayList <String > reflections = new ArrayList <>();
2436
- for (IParameter reflection : entry .getReflections ()) {
2437
- reflections .add (new StringBuilder (" (" ).append (paramType (reflection .getType ())).append (") " ).append (reflection .getName ()).append ("=" ).append (reflection .getValue ()).toString ());
2438
- }
2439
- if (reflections .size () > 0 ) {
2470
+ final ArrayList <IParameter > allReflections = entry .getReflections ();
2471
+ int reflectionsAmount = allReflections .size ();
2472
+ if (reflectionsAmount > showReflectionsCount ) {
2473
+ reflectionsAmount = showReflectionsCount ;
2474
+ }
2475
+ if (allReflections .size () > 0 ) {
2476
+ for (IParameter reflection : allReflections .subList (0 , reflectionsAmount )) {
2477
+ String param = reflection .getName ();
2478
+ if (param .length () > 50 ) {
2479
+ param = param .substring (0 , 50 - 3 ) + "..." ;
2480
+ }
2481
+ String val = reflection .getValue ();
2482
+ if (val .length () > 50 ) {
2483
+ val = val .substring (0 , 50 - 3 ) + "..." ;
2484
+ }
2485
+ reflections .add (new StringBuilder (" (" ).append (paramType (reflection .getType ())).append (") " ).append (param ).append ("=" ).append (val ).toString ());
2486
+ }
2487
+ if (allReflections .size () > showReflectionsCount ) {
2488
+ reflections .add ("..." );
2489
+ }
2440
2490
((JLabel ) c ).setToolTipText (new StringBuilder ("<html>Reflections:<br/>" ).append (String .join ("<br/>" , reflections )).append ("</html>" ).toString ());
2441
2491
} else {
2442
2492
((JLabel ) c ).setToolTipText (null );
@@ -2501,4 +2551,22 @@ public static FlowExtension getInstance() {
2501
2551
public static PrintWriter getStderr () {
2502
2552
return stderr ;
2503
2553
}
2554
+
2555
+ private int parseReflectionsCount (String text ) {
2556
+ int result = showReflectionsCountDefault ;
2557
+ if (text != null ) {
2558
+ try {
2559
+ showReflectionsCount = Integer .parseInt (text );
2560
+ if (showReflectionsCount > showReflectionsCountMax ) {
2561
+ showReflectionsCount = showReflectionsCountMax ;
2562
+ }
2563
+ if (showReflectionsCount < 0 ) {
2564
+ showReflectionsCount = 0 ;
2565
+ }
2566
+ } catch (NumberFormatException ex ) {
2567
+ // do nothing
2568
+ }
2569
+ }
2570
+ return result ;
2571
+ }
2504
2572
}
0 commit comments