3
3
import javax .swing .*;
4
4
import javax .swing .event .ChangeEvent ;
5
5
import java .awt .*;
6
+ import java .awt .event .ItemEvent ;
7
+ import java .awt .event .ItemListener ;
6
8
import java .awt .event .MouseAdapter ;
7
9
import java .awt .event .MouseEvent ;
8
10
import java .io .IOException ;
13
15
import static burp .Signing .log ;
14
16
15
17
public class ConfigSettings {
18
+ public static String SIGNATURE_ALGORITHM = "rsa-sha256" ;
16
19
public LinkedHashMap <String , String > settings ; // key is e.g. "Header", value is "Authorization"
17
20
// profiles: key is the name of the Tab, value is a settings LinkedHashMap
18
21
private LinkedHashMap <String , LinkedHashMap <String , String >> profiles ;
@@ -23,6 +26,8 @@ public class ConfigSettings {
23
26
JCheckBox checkBoxToolScanner = new JCheckBox ("Scanner" );
24
27
JCheckBox checkBoxToolIntruder = new JCheckBox ("Intruder" );
25
28
JCheckBox checkBoxToolRepeater = new JCheckBox ("Repeater" );
29
+ JCheckBox useHS2019Signature = new JCheckBox ("HS2019" );
30
+ JCheckBox useRSASHA256Signature = new JCheckBox ("RSA-SHA256" );
26
31
private boolean tabChangeListenerLock = false ;
27
32
28
33
ConfigSettings () {
@@ -83,7 +88,8 @@ public class ConfigSettings {
83
88
84
89
/**
85
90
* Return the Burp frame used for the option dialog and the menu button
86
- * @return The Burp Suite frame
91
+ *
92
+ * @return The Burp Suite frame
87
93
*/
88
94
static JFrame getBurpFrame () {
89
95
for (Frame f : Frame .getFrames ()) {
@@ -96,8 +102,9 @@ static JFrame getBurpFrame() {
96
102
97
103
/**
98
104
* Get the value from a key/profile setting (e.g. "keyId") from the active profile
99
- * @param key The key to retrieve
100
- * @return The value for the key belonging to the active profile
105
+ *
106
+ * @param key The key to retrieve
107
+ * @return The value for the key belonging to the active profile
101
108
*/
102
109
public String getString (String key ) {
103
110
return profiles .get ("ActiveKey" ).get (key );
@@ -117,6 +124,41 @@ protected void showSettings() {
117
124
titleGlobalConfig .setForeground (Color .ORANGE );
118
125
titleGlobalConfig .setFont (titleGlobalConfig .getFont ().deriveFont (Font .BOLD , titleGlobalConfig .getFont ().getSize () + 4 ));
119
126
globalPanel .add (titleGlobalConfig );
127
+ //Signature algo
128
+ JLabel labelSignatureAlgo = new JLabel ("Signature algorithm:" );
129
+ Font labelSigFont = labelSignatureAlgo .getFont ();
130
+ labelSignatureAlgo .setFont (labelSigFont .deriveFont (labelSigFont .getStyle () | Font .BOLD )); // make text bold
131
+ globalPanel .add (labelSignatureAlgo );
132
+ if ((Signing .callbacks .loadExtensionSetting ("useHS2019Signature" ) != null ) &&
133
+ Signing .callbacks .loadExtensionSetting ("useHS2019Signature" ).equals ("true" )) {
134
+ useHS2019Signature .setSelected (true );
135
+ useRSASHA256Signature .setSelected (false );
136
+ ConfigSettings .SIGNATURE_ALGORITHM = "hs2019" ;
137
+ } else {
138
+ useHS2019Signature .setSelected (false );
139
+ useRSASHA256Signature .setSelected (true );
140
+ ConfigSettings .SIGNATURE_ALGORITHM = "rsa-sha256" ;
141
+ }
142
+ useHS2019Signature .addItemListener (new ItemListener () {
143
+ @ Override
144
+ public void itemStateChanged (ItemEvent e ) {
145
+ if (e .getStateChange () == ItemEvent .SELECTED ){
146
+ ConfigSettings .this .useRSASHA256Signature .setSelected (false );
147
+ ConfigSettings .SIGNATURE_ALGORITHM = "hs2019" ;
148
+ }
149
+ }
150
+ });
151
+ useRSASHA256Signature .addItemListener (new ItemListener () {
152
+ @ Override
153
+ public void itemStateChanged (ItemEvent e ) {
154
+ if (e .getStateChange () == ItemEvent .SELECTED ){
155
+ ConfigSettings .this .useHS2019Signature .setSelected (false );
156
+ ConfigSettings .SIGNATURE_ALGORITHM = "rsa-sha256" ;
157
+ }
158
+ }
159
+ });
160
+ globalPanel .add (useHS2019Signature );
161
+ globalPanel .add (useRSASHA256Signature );
120
162
// Checkboxes to enable/disable the extension for each Burp Suite tool
121
163
JLabel labelTools = new JLabel ("Enable the extension for the following Burp Suite tools:" );
122
164
Font labelToolsFont = labelTools .getFont ();
@@ -173,7 +215,8 @@ public void mouseClicked(MouseEvent e) {
173
215
// the user clicks on the label
174
216
try {
175
217
Desktop .getDesktop ().browse (new URI ("https://github.com/nccgroup/HTTPSignatures" ));
176
- } catch (IOException | URISyntaxException e1 ) {}
218
+ } catch (IOException | URISyntaxException e1 ) {
219
+ }
177
220
}
178
221
179
222
@ Override
@@ -248,11 +291,12 @@ public void mouseExited(MouseEvent e) {
248
291
249
292
/**
250
293
* Make a ProfileTab active
251
- * @param profileTab The ProfileTab to set active
294
+ *
295
+ * @param profileTab The ProfileTab to set active
252
296
*/
253
297
private void setActiveProfile (ProfileTab profileTab ) {
254
298
String tabName = profileTab .profileTabHandle .tabNameField .getText ();
255
- tabName .replaceAll (";" ,"" ); // remove semicolons
299
+ tabName .replaceAll (";" , "" ); // remove semicolons
256
300
log ("Setting active profile to '" + tabName + "' active" );
257
301
258
302
LinkedHashMap <String , Object > newProfile = profileTab .getNewProfile ();
@@ -265,7 +309,7 @@ private void setActiveProfile(ProfileTab profileTab) {
265
309
}
266
310
Object val = newProfile .get (key );
267
311
String valStr = ((JTextField ) val ).getText ();
268
- profileValues += valStr .replaceAll (";" ,"" ); // remove semicolons
312
+ profileValues += valStr .replaceAll (";" , "" ); // remove semicolons
269
313
newProfile2 .put (key , valStr );
270
314
log ("Setting active profile " + tabName + ": key: " + key + " value: " + valStr );
271
315
}
@@ -299,7 +343,7 @@ private void saveProfiles() {
299
343
}
300
344
LinkedHashMap <String , Object > newProfile = profileTab .getNewProfile ();
301
345
String tabName = profileTab .profileTabHandle .tabNameField .getText ();
302
- tabName = tabName .replaceAll (";" ,"" ); // remove semicolons
346
+ tabName = tabName .replaceAll (";" , "" ); // remove semicolons
303
347
304
348
if (!tabNames .isEmpty ()) {
305
349
// add semicolon, but not on first key
@@ -316,7 +360,7 @@ private void saveProfiles() {
316
360
}
317
361
Object val = newProfile .get (key );
318
362
String valStr = ((JTextField ) val ).getText ();
319
- valStr = valStr .replaceAll (";" ,"" ); // remove any semicolon
363
+ valStr = valStr .replaceAll (";" , "" ); // remove any semicolon
320
364
profileValues += valStr ;
321
365
log ("Saving profile " + tabName + ": key: " + key + " value: " + valStr );
322
366
}
@@ -359,6 +403,11 @@ private void saveProfiles() {
359
403
Signing .DEBUG = false ;
360
404
Signing .callbacks .saveExtensionSetting ("debug" , "false" );
361
405
}
406
+ if (useHS2019Signature .isSelected () || !useRSASHA256Signature .isSelected () || (!useRSASHA256Signature .isSelected () && !useHS2019Signature .isSelected ())) {
407
+ Signing .callbacks .saveExtensionSetting ("useHS2019Signature" , "true" );
408
+ } else {
409
+ Signing .callbacks .saveExtensionSetting ("useHS2019Signature" , "false" );
410
+ }
362
411
}
363
412
364
413
/**
@@ -374,7 +423,8 @@ private void addTab() {
374
423
375
424
/**
376
425
* Add a new (empty) tab
377
- * @param tabName the name of the new tab
426
+ *
427
+ * @param tabName the name of the new tab
378
428
*/
379
429
private void addTab (String tabName ) {
380
430
tabChangeListenerLock = true ;
@@ -387,9 +437,10 @@ private void addTab(String tabName) {
387
437
388
438
/**
389
439
* Add a new tab with content
390
- * @param tabName The name of the new tab
391
- * @param tabConfig The configuration of the new tab (values separated by semicolons)
392
- * @param active Boolean: true means the profile is active; false means the profile is not active
440
+ *
441
+ * @param tabName The name of the new tab
442
+ * @param tabConfig The configuration of the new tab (values separated by semicolons)
443
+ * @param active Boolean: true means the profile is active; false means the profile is not active
393
444
*/
394
445
private void addTab (String tabName , String tabConfig , Boolean active ) {
395
446
tabChangeListenerLock = true ;
@@ -416,8 +467,9 @@ private void addTab(String tabName, String tabConfig, Boolean active) {
416
467
417
468
/**
418
469
* Checks if a color is bright or dark.
419
- * @param color The RGB color
420
- * @return True if bright, false if dark
470
+ *
471
+ * @param color The RGB color
472
+ * @return True if bright, false if dark
421
473
*/
422
474
private boolean isColorBright (int color ) {
423
475
if (brightness (color ) > 0.5 ) {
@@ -431,8 +483,9 @@ private boolean isColorBright(int color) {
431
483
* Returns the brightness of a color.
432
484
* Based on
433
485
* https://chromium.googlesource.com/android_tools/+/18728e9dd5dd66d4f5edf1b792e77e2b544a1cb0/sdk/sources/android-19/android/graphics/Color.java#187
434
- * @param color The RGB color
435
- * @return A value between 0.0f and 1.0f
486
+ *
487
+ * @param color The RGB color
488
+ * @return A value between 0.0f and 1.0f
436
489
*/
437
490
private float brightness (int color ) {
438
491
int r = (color >> 16 ) & 0xFF ;
@@ -445,7 +498,8 @@ private float brightness(int color) {
445
498
446
499
/**
447
500
* Close a tab
448
- * @param configTabContent The tab to close
501
+ *
502
+ * @param configTabContent The tab to close
449
503
*/
450
504
public void closeTab (JPanel configTabContent ) {
451
505
tabChangeListenerLock = true ;
@@ -505,7 +559,7 @@ private void initTabs() {
505
559
continue ;
506
560
}
507
561
String tabName = profileTab .profileTabHandle .tabNameField .getText ();
508
- if (tabName .equals (activeTabName ) ) {
562
+ if (tabName .equals (activeTabName )) {
509
563
tabbedPane .setSelectedIndex (tabNum );
510
564
}
511
565
}
0 commit comments