-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathBurpExtender.java
1659 lines (1505 loc) · 81.2 KB
/
BurpExtender.java
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
package burp;
import burp.error.SigCredentialProviderException;
import org.apache.commons.lang3.StringUtils;
import com.google.gson.*;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import software.amazon.awssdk.auth.credentials.AwsBasicCredentials;
import software.amazon.awssdk.auth.credentials.AwsCredentials;
import software.amazon.awssdk.auth.credentials.AwsSessionCredentials;
import software.amazon.awssdk.auth.signer.Aws4Signer;
import software.amazon.awssdk.auth.signer.AwsS3V4Signer;
import software.amazon.awssdk.auth.signer.params.Aws4PresignerParams;
import software.amazon.awssdk.auth.signer.params.Aws4SignerParams;
import software.amazon.awssdk.auth.signer.params.AwsS3V4SignerParams;
import software.amazon.awssdk.http.SdkHttpFullRequest;
import software.amazon.awssdk.http.SdkHttpMethod;
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.sts.StsClient;
import software.amazon.awssdk.services.sts.model.GetCallerIdentityResponse;
import software.amazon.awssdk.services.sts.model.StsException;
import javax.swing.*;
import javax.swing.table.DefaultTableModel;
import java.awt.*;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.time.Instant;
import java.util.List;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import java.util.stream.Stream;
public class BurpExtender implements IBurpExtender, IHttpListener, ITab, IExtensionStateListener, IMessageEditorTabFactory, IContextMenuFactory
{
// make sure to update version in build.gradle as well
private static final String EXTENSION_VERSION = "0.2.9";
private static final String BURP_SETTINGS_KEY = "JsonSettings";
private static final String SETTING_VERSION = "ExtensionVersion";
private static final String SETTING_LOG_LEVEL = "LogLevel";
private static final String SETTING_CONFIG_VERSION = "SettingsVersion";
public static final String EXTENSION_NAME = "SigV4"; // Name in extender menu
public static final String DISPLAY_NAME = "SigV4"; // name for tabs, menu, and other UI components
private static final String NO_DEFAULT_PROFILE = " "; // ensure combobox is visible. SigProfile.profileNamePattern doesn't allow this name
// Regex for extracting usable signature fields and for just identifying a request as SigV4 (loose)
private static final Pattern authorizationHeaderRegex = Pattern.compile("^Authorization:[ ]{1,20}AWS4-HMAC-SHA256[ ]{1,20}Credential=(?<accessKeyId>[\\w]{16,128})/(?<date>[0-9]{8})/(?<region>[a-z0-9-]{5,64})/(?<service>[a-z0-9-]{1,64})/aws4_request,[ ]{1,20}SignedHeaders=(?<headers>[\\w;-]+),[ ]{1,20}Signature=(?<signature>[a-z0-9]{64})$", Pattern.CASE_INSENSITIVE);
private static final Pattern authorizationHeaderLooseRegex = Pattern.compile("^Authorization:[ ]{1,20}AWS4-HMAC-SHA256[ ]{1,20}Credential=(?<accessKeyId>[\\w-]{0,128})/(?<date>[\\w-]{0,8})/(?<region>[\\w-]{0,64})/(?<service>[\\w-]{0,64})/aws4_request,[ ]{1,20}SignedHeaders=(?<headers>[\\w;-]+),[ ]{1,20}Signature=(?<signature>[\\w-]{0,64})$", Pattern.CASE_INSENSITIVE);
private static final Pattern authorizationHeaderLooseNoCaptureRegex = Pattern.compile("^Authorization:[ ]{1,20}AWS4-HMAC-SHA256[ ]{1,20}Credential=[\\w-]{0,128}/[\\w-]{0,8}/[\\w-]{0,64}/[\\w-]{0,64}/aws4_request,[ ]{1,20}SignedHeaders=[\\w;-]+,[ ]{1,20}Signature=[\\w-]{0,64}$", Pattern.CASE_INSENSITIVE);
private static final Pattern xAmzCredentialRegex = Pattern.compile("^(?<accessKeyId>[\\w]{16,128})/(?<date>[0-9]{8})/(?<region>[a-z0-9-]{5,64})/(?<service>[a-z0-9-]{1,64})/aws4_request$", Pattern.CASE_INSENSITIVE);
// define headers for internal use
public static final String HEADER_PREFIX = "X-BurpSigV4-";
public static final String PROFILE_HEADER_NAME = HEADER_PREFIX + "Profile"; // used to specify a named profile to sign the request with
public static final String SKIP_SIGNING_HEADER = HEADER_PREFIX + "Skip: DO NOT SIGN"; // do not sign any requests that contain this header
protected IExtensionHelpers helpers;
protected IBurpExtenderCallbacks callbacks;
private HashMap<String, SigProfile> profileKeyIdMap; // map accessKeyId to profile
private HashMap<String, SigProfile> profileNameMap; // map name to profile
protected LogWriter logger = LogWriter.getLogger();
private JLabel statusLabel;
private JCheckBox signingEnabledCheckBox;
private JComboBox<String> defaultProfileComboBox;
private JComboBox<Object> logLevelComboBox;
private JCheckBox persistProfilesCheckBox;
private JCheckBox inScopeOnlyCheckBox;
private JTextField additionalSignedHeadersField;
private AdvancedSettingsDialog advancedSettingsDialog;
private JTable profileTable;
private JTable customHeadersTable;
private JCheckBox customHeadersOverwriteCheckbox;
private JScrollPane outerScrollPane;
// mimic burp colors
protected static final Color textOrange = new Color(255, 102, 51);
protected static final Color darkOrange = new Color(226, 73, 33);
private static BurpExtender burpInstance;
public static BurpExtender getBurp()
{
return burpInstance;
}
public BurpExtender() {}
private void buildUiTab()
{
final Font sectionFont = new JLabel().getFont().deriveFont(Font.BOLD, 15);
//
// global settings, checkboxes
//
JPanel globalSettingsPanel = new JPanel();
globalSettingsPanel.setLayout(new GridBagLayout());
JLabel settingsLabel = new JLabel("Settings");
settingsLabel.setForeground(BurpExtender.textOrange);
settingsLabel.setFont(sectionFont);
JPanel checkBoxPanel = new JPanel();
signingEnabledCheckBox = new JCheckBox("Signing Enabled");
signingEnabledCheckBox.setToolTipText("Enable SigV4 signing");
inScopeOnlyCheckBox = new JCheckBox("In-scope Only");
inScopeOnlyCheckBox.setToolTipText("Sign in-scope requests only");
persistProfilesCheckBox = new JCheckBox("Persist Profiles");
persistProfilesCheckBox.setToolTipText("Save profiles, including keys, in Burp settings store");
checkBoxPanel.add(signingEnabledCheckBox);
checkBoxPanel.add(inScopeOnlyCheckBox);
checkBoxPanel.add(persistProfilesCheckBox);
JPanel otherSettingsPanel = new JPanel();
defaultProfileComboBox = new JComboBox<>();
logLevelComboBox = new JComboBox<>();
otherSettingsPanel.add(new JLabel("Log Level"));
otherSettingsPanel.add(logLevelComboBox);
otherSettingsPanel.add(new JLabel("Default Profile"));
otherSettingsPanel.add(defaultProfileComboBox);
JButton advancedSettingsButton = new JButton("Advanced");
advancedSettingsButton.addActionListener(actionEvent -> {
advancedSettingsDialog.setVisible(true);
});
checkBoxPanel.add(new JSeparator(SwingConstants.VERTICAL));
checkBoxPanel.add(advancedSettingsButton);
advancedSettingsDialog = AdvancedSettingsDialog.get();
advancedSettingsDialog.applyExtensionSettings(new ExtensionSettings()); // load with defaults for now
GridBagConstraints c00 = new GridBagConstraints(); c00.anchor = GridBagConstraints.FIRST_LINE_START; c00.gridy = 0; c00.gridwidth = 2;
GridBagConstraints c01 = new GridBagConstraints(); c01.anchor = GridBagConstraints.FIRST_LINE_START; c01.gridy = 1; c01.gridwidth = 2; c01.insets = new Insets(10, 0, 10, 0);
GridBagConstraints c02 = new GridBagConstraints(); c02.anchor = GridBagConstraints.FIRST_LINE_START; c02.gridy = 2;
GridBagConstraints c03 = new GridBagConstraints(); c03.anchor = GridBagConstraints.FIRST_LINE_START; c03.gridy = 3;
globalSettingsPanel.add(settingsLabel, c00);
globalSettingsPanel.add(new JLabel("Change plugin behavior. Set \"Default Profile\" to force signing of all requests with the specified profile credentials."), c01);
globalSettingsPanel.add(checkBoxPanel, c02);
globalSettingsPanel.add(otherSettingsPanel, c03);
//
// status label
//
JPanel statusPanel = new JPanel();
statusLabel = new JLabel();
statusPanel.add(statusLabel);
//
// profiles table
//
JPanel profilePanel = new JPanel(new GridBagLayout());
JLabel profileLabel = new JLabel("AWS Credentials");
profileLabel.setForeground(BurpExtender.textOrange);
profileLabel.setFont(sectionFont);
JButton addProfileButton = new JButton("Add");
JButton editProfileButton = new JButton("Edit");
JButton removeProfileButton = new JButton("Remove");
JButton testProfileButton = new JButton("Test");
JButton importProfileButton = new JButton("Import");
JButton exportProfileButton = new JButton("Export");
JPanel profileButtonPanel = new JPanel(new GridLayout(7, 1, 0, 5));
profileButtonPanel.add(addProfileButton);
profileButtonPanel.add(editProfileButton);
profileButtonPanel.add(removeProfileButton);
profileButtonPanel.add(testProfileButton);
profileButtonPanel.add(importProfileButton);
profileButtonPanel.add(exportProfileButton);
final String[] profileColumnNames = {"Name", "KeyId", "Credential Provider", "Region", "Service"};
profileTable = new JTable(new DefaultTableModel(profileColumnNames, 0)
{
@Override
public boolean isCellEditable(int row, int column)
{
// prevent table cells from being edited. must use dialog to edit.
return false;
}
});
profileTable.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() == 2) {
editProfileButton.doClick();
}
}
});
JScrollPane profileScrollPane = new JScrollPane(profileTable);
profileScrollPane.setPreferredSize(new Dimension(1000, 200));
GridBagConstraints c000 = new GridBagConstraints(); c000.gridy = 0; c000.gridwidth = 2; c000.anchor = GridBagConstraints.FIRST_LINE_START;
GridBagConstraints c001 = new GridBagConstraints(); c001.gridy = 1; c001.gridwidth = 2; c001.anchor = GridBagConstraints.FIRST_LINE_START; c001.insets = new Insets(10, 0, 10, 0);
GridBagConstraints c002 = new GridBagConstraints(); c002.gridy = 2; c002.gridx = 0; c002.anchor = GridBagConstraints.FIRST_LINE_START; c002.insets = new Insets(0, 0, 0, 5);
GridBagConstraints c003 = new GridBagConstraints(); c003.gridy = 2; c003.gridx = 1; c003.anchor = GridBagConstraints.FIRST_LINE_START;
profilePanel.add(profileLabel, c000);
profilePanel.add(new JLabel("Add AWS credentials using your \"aws_access_key_id\" and \"aws_secret_access_key\"."), c001);
profilePanel.add(profileButtonPanel, c002);
profilePanel.add(profileScrollPane, c003);
//
// custom signed headers table
//
JPanel customHeadersPanel = new JPanel(new GridBagLayout());
JLabel customHeadersLabel = new JLabel("Custom Signed Headers");
customHeadersLabel.setForeground(textOrange);
customHeadersLabel.setFont(sectionFont);
customHeadersOverwriteCheckbox = new JCheckBox("Overwrite existing headers");
customHeadersOverwriteCheckbox.setToolTipText("Default behavior is to append these headers even if they exist in original request");
JPanel customHeadersButtonPanel = new JPanel();
customHeadersButtonPanel.setLayout(new GridLayout(3, 1, 0, 5));
JButton addCustomHeaderButton = new JButton("Add");
JButton removeCustomHeaderButton = new JButton("Remove");
customHeadersButtonPanel.add(addCustomHeaderButton);
customHeadersButtonPanel.add(removeCustomHeaderButton);
final String[] headersColumnNames = {"Name", "Value"};
customHeadersTable = new JTable(new DefaultTableModel(headersColumnNames, 0));
JScrollPane headersScrollPane = new JScrollPane(customHeadersTable);
headersScrollPane.setPreferredSize(new Dimension(1000, 150));
GridBagConstraints c100 = new GridBagConstraints(); c100.gridy = 0; c100.gridwidth = 2; c100.anchor = GridBagConstraints.FIRST_LINE_START;
GridBagConstraints c101 = new GridBagConstraints(); c101.gridy = 1; c101.gridwidth = 2; c101.anchor = GridBagConstraints.FIRST_LINE_START; c101.insets = new Insets(10, 0, 10, 0);
GridBagConstraints c102 = new GridBagConstraints(); c102.gridy = 2; c102.gridx = 1; c102.anchor = GridBagConstraints.FIRST_LINE_START;
GridBagConstraints c103 = new GridBagConstraints(); c103.gridy = 3; c103.gridx = 0; c103.anchor = GridBagConstraints.FIRST_LINE_START; c103.insets = new Insets(0, 0, 0, 5);
GridBagConstraints c104 = new GridBagConstraints(); c104.gridy = 3; c104.gridx = 1; c104.anchor = GridBagConstraints.FIRST_LINE_START;
customHeadersPanel.add(customHeadersLabel, c100);
customHeadersPanel.add(new JLabel("Add request headers to be included in the signature. These can be edited in place."), c101);
customHeadersPanel.add(customHeadersOverwriteCheckbox, c102);
customHeadersPanel.add(customHeadersButtonPanel, c103);
customHeadersPanel.add(headersScrollPane, c104);
//
// additional headers to sign
//
JPanel additionalSignedHeadersPanel = new JPanel(new GridBagLayout());
JLabel additionalHeadersLabel = new JLabel("Signed Headers");
additionalHeadersLabel.setForeground(this.textOrange);
additionalHeadersLabel.setFont(sectionFont);
additionalSignedHeadersField = new JTextField("", 65);
GridBagConstraints c200 = new GridBagConstraints(); c200.gridy = 0; c200.gridwidth = 2; c200.anchor = GridBagConstraints.FIRST_LINE_START;
GridBagConstraints c201 = new GridBagConstraints(); c201.gridy = 1; c201.gridwidth = 2; c201.anchor = GridBagConstraints.FIRST_LINE_START; c201.insets = new Insets(10, 0, 10, 0);
GridBagConstraints c202 = new GridBagConstraints(); c202.gridy = 2; c202.anchor = GridBagConstraints.FIRST_LINE_START;
additionalSignedHeadersPanel.add(additionalHeadersLabel, c200);
additionalSignedHeadersPanel.add(new JLabel("Specify comma-separated header names from the request to include in the signature. Defaults are Host and X-Amz-*"), c201);
additionalSignedHeadersPanel.add(additionalSignedHeadersField, c202);
//
// put it all together
//
List<GridBagConstraints> sectionConstraints = new ArrayList<>();
for (int i = 0; i < 7; i++) {
GridBagConstraints c = new GridBagConstraints();
c.gridy = i;
c.gridx = 0;
// add padding in all directions
c.insets = new Insets(10, 10, 10, 10);
c.anchor = GridBagConstraints.FIRST_LINE_START;
c.weightx = 1.0;
sectionConstraints.add(c);
}
JPanel outerPanel = new JPanel(new GridBagLayout());
outerPanel.add(globalSettingsPanel, sectionConstraints.remove(0));
GridBagConstraints c = sectionConstraints.remove(0);
c.fill = GridBagConstraints.HORIZONTAL; // have separator span entire width of display
outerPanel.add(new JSeparator(SwingConstants.HORIZONTAL), c);
//outerPanel.add(statusPanel, sectionConstraints.remove(0));
outerPanel.add(profilePanel, sectionConstraints.remove(0));
c = sectionConstraints.remove(0);
c.fill = GridBagConstraints.HORIZONTAL;
outerPanel.add(new JSeparator(SwingConstants.HORIZONTAL), c);
outerPanel.add(customHeadersPanel, sectionConstraints.remove(0));
c = sectionConstraints.remove(0);
c.fill = GridBagConstraints.HORIZONTAL;
outerPanel.add(new JSeparator(SwingConstants.HORIZONTAL), c);
outerPanel.add(additionalSignedHeadersPanel, sectionConstraints.remove(0));
// use outerOuterPanel to force components north
JPanel outerOuterPanel = new JPanel(new BorderLayout());
outerOuterPanel.add(outerPanel, BorderLayout.PAGE_START);
outerScrollPane = new JScrollPane(outerOuterPanel);
outerScrollPane.getVerticalScrollBar().setUnitIncrement(18);
this.callbacks.customizeUiComponent(outerPanel);
// profile button handlers
addProfileButton.addActionListener(new ActionListener()
{
@Override
public void actionPerformed(ActionEvent actionEvent)
{
SigProfileEditorDialog dialog = new SigProfileEditorDialog(null, "Add Profile", true, null);
callbacks.customizeUiComponent(dialog);
dialog.setVisible(true);
// set first profile added as the default
if (profileNameMap.size() == 1 && dialog.getNewProfileName() != null) {
setDefaultProfileName(dialog.getNewProfileName());
}
}
});
editProfileButton.addActionListener(new ActionListener()
{
@Override
public void actionPerformed(ActionEvent actionEvent)
{
int[] rowIndeces = profileTable.getSelectedRows();
if (rowIndeces.length == 1) {
DefaultTableModel model = (DefaultTableModel) profileTable.getModel();
final String name = (String) model.getValueAt(rowIndeces[0], 0);
JDialog dialog = new SigProfileEditorDialog(null, "Edit Profile", true, profileNameMap.get(name));
callbacks.customizeUiComponent(dialog);
dialog.setVisible(true);
}
else {
updateStatus("Select a single profile to edit");
}
}
});
removeProfileButton.addActionListener(new ActionListener()
{
@Override
public void actionPerformed(ActionEvent actionEvent)
{
DefaultTableModel model = (DefaultTableModel) profileTable.getModel();
ArrayList<String> profileNames = new ArrayList<>();
for (int rowIndex : profileTable.getSelectedRows()) {
profileNames.add((String) model.getValueAt(rowIndex, 0));
}
for (final String name : profileNames) {
deleteProfile(profileNameMap.get(name));
}
}
});
testProfileButton.addActionListener(new ActionListener()
{
@Override
public void actionPerformed(ActionEvent actionEvent)
{
// Test credentials by making a request to sts:GetCallerIdentity
int[] rowIndeces = profileTable.getSelectedRows();
DefaultTableModel model = (DefaultTableModel) profileTable.getModel();
if (rowIndeces.length == 1) {
final String name = (String) model.getValueAt(rowIndeces[0], 0);
SigProfile profile = profileNameMap.get(name);
// don't block the UI thread
(new Thread(() -> {
try (StsClient stsClient = StsClient.builder()
.httpClient(new SdkHttpClientForBurp())
.region(Region.US_EAST_1)
.credentialsProvider(() -> {
final SigCredential cred = profile.getCredential();
if (cred.isTemporary()) {
return AwsSessionCredentials.create(cred.getAccessKeyId(), cred.getSecretKey(), ((SigTemporaryCredential)cred).getSessionToken());
}
return AwsBasicCredentials.create(cred.getAccessKeyId(), cred.getSecretKey());
})
.build()) {
SigProfileTestDialog dialog = new SigProfileTestDialog(null, profile, false);
dialog.setVisible(true);
GetCallerIdentityResponse response = stsClient.getCallerIdentity();
dialog.updateWithResult(response);
} catch (Exception exc) {
JOptionPane.showMessageDialog(getUiComponent(),
exc.getMessage(),
"Credential Test Failed: "+profile.getName(),
JOptionPane.ERROR_MESSAGE);
}
})).start();
}
else {
updateStatus("Select a single profile to test");
}
}
});
importProfileButton.addActionListener(new ActionListener()
{
@Override
public void actionPerformed(ActionEvent actionEvent)
{
try {
SigProfileImportDialog importDialog = new SigProfileImportDialog(null, "Import Profiles", true);
callbacks.customizeUiComponent(importDialog);
importDialog.setVisible(true);
}
catch (Exception exc) {
logger.error("Failed to display import dialog: "+exc);
}
}
});
exportProfileButton.addActionListener(new ActionListener()
{
@Override
public void actionPerformed(ActionEvent actionEvent)
{
JFileChooser chooser = new JFileChooser(System.getProperty("user.home"));
chooser.setFileHidingEnabled(false);
if (chooser.showOpenDialog(getUiComponent()) == JFileChooser.APPROVE_OPTION) {
final Path exportPath = Paths.get(chooser.getSelectedFile().getPath());
ArrayList<SigProfile> sigProfiles = new ArrayList<>();
for (final String name : profileNameMap.keySet()) {
sigProfiles.add(profileNameMap.get(name));
}
int exportCount = SigProfile.exportToFilePath(sigProfiles, exportPath);
final String msg = String.format("Exported %d profiles to %s", exportCount, exportPath);
// TODO: line wrap
JOptionPane.showMessageDialog(getUiComponent(), msg);
logger.info(msg);
}
}
});
// custom header button handlers
addCustomHeaderButton.addActionListener(new ActionListener()
{
@Override
public void actionPerformed(ActionEvent actionEvent)
{
DefaultTableModel model = (DefaultTableModel) customHeadersTable.getModel();
int i;
for (i = 0; i < model.getRowCount(); i++) {
final String name = ((String) model.getValueAt(i, 0)).trim();
if (name.length() == 0) {
// do not add more rows if an empty row exists
break;
}
}
if (i == model.getRowCount()) {
model.addRow(new Object[]{"", ""});
}
customHeadersTable.clearSelection();
customHeadersTable.addRowSelectionInterval(i, i);
customHeadersTable.addColumnSelectionInterval(0, 0);
customHeadersTable.editCellAt(i, 0);
}
});
removeCustomHeaderButton.addActionListener(new ActionListener()
{
@Override
public void actionPerformed(ActionEvent actionEvent)
{
DefaultTableModel model = (DefaultTableModel) customHeadersTable.getModel();
// remove editor or the table locks up if a cell is being edited
customHeadersTable.removeEditor();
// remove rows in reverse order or larger indices will become invalid before removing
Arrays.stream(customHeadersTable.getSelectedRows())
.boxed()
.sorted(Comparator.reverseOrder())
.forEach(model::removeRow);
}
});
// log level combo box
class LogLevelComboBoxItem
{
final private int logLevel;
final private String levelName;
public LogLevelComboBoxItem(final int logLevel)
{
this.logLevel = logLevel;
this.levelName = LogWriter.levelNameFromInt(logLevel);
}
@Override
public String toString()
{
return this.levelName;
}
}
this.logLevelComboBox.addItem(new LogLevelComboBoxItem(LogWriter.DEBUG_LEVEL));
this.logLevelComboBox.addItem(new LogLevelComboBoxItem(LogWriter.INFO_LEVEL));
this.logLevelComboBox.addItem(new LogLevelComboBoxItem(LogWriter.ERROR_LEVEL));
this.logLevelComboBox.addItem(new LogLevelComboBoxItem(LogWriter.FATAL_LEVEL));
this.logLevelComboBox.setSelectedIndex(logger.getLevel());
this.logLevelComboBox.addActionListener(new ActionListener()
{
@Override
public void actionPerformed(ActionEvent actionEvent)
{
logger.setLevel(((LogLevelComboBoxItem) logLevelComboBox.getSelectedItem()).logLevel);
}
});
}
public boolean isSigningEnabled()
{
return this.signingEnabledCheckBox.isSelected();
}
public boolean isInScopeOnlyEnabled() { return this.inScopeOnlyCheckBox.isSelected(); }
private void setLogLevel(final int level)
{
this.logger.setLevel(level);
// logger is created before UI components are initialized.
if (this.logLevelComboBox != null) {
this.logLevelComboBox.setSelectedIndex(logger.getLevel());
}
}
@Override
public void registerExtenderCallbacks(IBurpExtenderCallbacks callbacks)
{
burpInstance = this;
this.helpers = callbacks.getHelpers();
this.callbacks = callbacks;
callbacks.setExtensionName(EXTENSION_NAME);
callbacks.registerExtensionStateListener(this);
this.logger.configure(callbacks.getStdout(), callbacks.getStderr(), LogWriter.DEFAULT_LEVEL);
final String setting = this.callbacks.loadExtensionSetting(SETTING_LOG_LEVEL);
if (setting != null) {
try {
setLogLevel(Integer.parseInt(setting));
} catch (NumberFormatException ignored) {
// use default level
}
}
this.profileKeyIdMap = new HashMap<>();
this.profileNameMap = new HashMap<>();
SwingUtilities.invokeLater(new Runnable()
{
@Override
public void run()
{
buildUiTab();
loadExtensionSettings();
callbacks.addSuiteTab(BurpExtender.this);
callbacks.registerHttpListener(BurpExtender.this);
callbacks.registerContextMenuFactory(BurpExtender.this);
callbacks.registerMessageEditorTabFactory(BurpExtender.this);
logger.info(String.format("Loaded %s %s", EXTENSION_NAME, EXTENSION_VERSION));
}
});
}
/*
build Gson object for de/serialization of settings. SigCredential, SigCredentialProvider, and Path need
to be handled as a special case since they're interfaces.
*/
private Gson getGsonSerializer(final double settingsVersion)
{
return new GsonBuilder()
.registerTypeAdapter(SigCredential.class, new SigCredentialSerializer())
.registerTypeAdapter(SigCredentialProvider.class, new SigCredentialProviderSerializer())
.registerTypeHierarchyAdapter(Path.class, new TypeAdapter<Path>() {
@Override
public void write(JsonWriter out, Path value) throws IOException {
if (value == null)
out.nullValue();
else
out.value(value.toString());
}
@Override
public Path read(JsonReader in) throws IOException {
return Paths.get(in.nextString());
}
})
.setPrettyPrinting() // not necessary...
.setVersion(settingsVersion)
//.setFieldNamingPolicy(FieldNamingPolicy.UPPER_CAMEL_CASE)
.create();
}
protected String exportExtensionSettingsToJson()
{
ExtensionSettings.ExtensionSettingsBuilder builder = ExtensionSettings.builder()
.logLevel(this.logger.getLevel())
.extensionVersion(EXTENSION_VERSION)
.persistProfiles(this.persistProfilesCheckBox.isSelected())
.extensionEnabled(this.signingEnabledCheckBox.isSelected())
.defaultProfileName(this.getDefaultProfileName())
.customSignedHeaders(getCustomHeadersFromUI())
.customSignedHeadersOverwrite(this.customHeadersOverwriteCheckbox.isSelected())
.additionalSignedHeaderNames(getAdditionalSignedHeadersFromUI())
.inScopeOnly(this.inScopeOnlyCheckBox.isSelected())
.preserveHeaderOrder(this.advancedSettingsDialog.preserveHeaderOrderCheckBox.isSelected())
.updateContentSha256(this.advancedSettingsDialog.updateContentSha256CheckBox.isSelected())
.presignedUrlLifetimeInSeconds(this.advancedSettingsDialog.getPresignedUrlLifetimeSeconds())
.contentMD5HeaderBehavior(this.advancedSettingsDialog.getContentMD5HeaderBehavior())
.signingEnabledForProxy(advancedSettingsDialog.signingEnabledForProxyCheckbox.isSelected())
.signingEnabledForSpider(advancedSettingsDialog.signingEnabledForSpiderCheckBox.isSelected())
.signingEnabledForScanner(advancedSettingsDialog.signingEnabledForScannerCheckBox.isSelected())
.signingEnabledForIntruder(advancedSettingsDialog.signingEnabledForIntruderCheckBox.isSelected())
.signingEnabledForRepeater(advancedSettingsDialog.signingEnabledForRepeaterCheckBox.isSelected())
.signingEnabledForSequencer(advancedSettingsDialog.signingEnabledForSequencerCheckBox.isSelected())
.signingEnabledForExtender(advancedSettingsDialog.signingEnabledForExtenderCheckBox.isSelected())
.addProfileComment(advancedSettingsDialog.addProfileCommentCheckBox.isSelected());
if (this.persistProfilesCheckBox.isSelected()) {
builder.profiles(this.profileNameMap);
logger.info(String.format("Saved %d profile(s)", this.profileNameMap.size()));
}
ExtensionSettings settings = builder.build();
return getGsonSerializer(settings.settingsVersion()).toJson(settings);
}
protected void importExtensionSettingsFromJson(final String jsonString)
{
if (StringUtils.isEmpty(jsonString)) {
logger.error("Invalid Json settings. Skipping import.");
return;
}
double settingsVersion = 0.0;
final String setting = callbacks.loadExtensionSetting(SETTING_CONFIG_VERSION);
if (StringUtils.isNotEmpty(setting)) {
try {
settingsVersion = Double.parseDouble(setting);
} catch (NumberFormatException ignored) {
}
}
ExtensionSettings settings;
try {
settings = getGsonSerializer(settingsVersion).fromJson(jsonString, ExtensionSettings.class);
} catch (JsonParseException exc) {
logger.error("Failed to parse Json settings. Using defaults. Error: "+exc.getMessage());
settings = ExtensionSettings.builder().build();
}
setLogLevel(settings.logLevel());
// load profiles
Map<String, SigProfile> profileMap = settings.profiles();
for (final String name : profileMap.keySet()) {
final SigProfile profile = profileMap.get(name);
if (profile.getCredentialProviderCount() <= 0) {
logger.error("Profile has no credential provider: "+name);
}
try {
addProfile(profile);
} catch (IllegalArgumentException | NullPointerException exc) {
logger.error("Failed to add profile: "+name);
}
}
setDefaultProfileName(settings.defaultProfileName());
this.persistProfilesCheckBox.setSelected(settings.persistProfiles());
this.signingEnabledCheckBox.setSelected(settings.extensionEnabled());
setCustomHeadersInUI(settings.customSignedHeaders());
this.customHeadersOverwriteCheckbox.setSelected(settings.customSignedHeadersOverwrite());
this.additionalSignedHeadersField.setText(String.join(", ", settings.additionalSignedHeaderNames()));
this.inScopeOnlyCheckBox.setSelected(settings.inScopeOnly());
final long lifetime = settings.presignedUrlLifetimeInSeconds();
if (lifetime < ExtensionSettings.PRESIGNED_URL_LIFETIME_MIN_SECONDS || lifetime > ExtensionSettings.PRESIGNED_URL_LIFETIME_MAX_SECONDS) {
settings = settings.withPresignedUrlLifetimeInSeconds(ExtensionSettings.PRESIGNED_URL_LIFETIME_DEFAULT_SECONDS);
}
final String behavior = settings.contentMD5HeaderBehavior();
if (!Arrays.asList(ExtensionSettings.CONTENT_MD5_REMOVE, ExtensionSettings.CONTENT_MD5_IGNORE, ExtensionSettings.CONTENT_MD5_UPDATE).contains(behavior)) {
settings = settings.withContentMD5HeaderBehavior(ExtensionSettings.CONTENT_MD5_DEFAULT);
}
advancedSettingsDialog.applyExtensionSettings(settings);
}
private void saveExtensionSettings()
{
// save these with their own key since they may be required before the other settings are loaded
this.callbacks.saveExtensionSetting(SETTING_LOG_LEVEL, Integer.toString(this.logger.getLevel()));
this.callbacks.saveExtensionSetting(SETTING_VERSION, EXTENSION_VERSION);
this.callbacks.saveExtensionSetting(SETTING_CONFIG_VERSION, Double.toString(ExtensionSettings.SETTINGS_VERSION));
this.callbacks.saveExtensionSetting(BURP_SETTINGS_KEY, exportExtensionSettingsToJson());
}
private void loadExtensionSettings()
{
// plugin version that added the settings. in the future use this to migrate settings.
final String pluginVersion = this.callbacks.loadExtensionSetting(SETTING_VERSION);
if (pluginVersion != null)
logger.info("Found settings for version "+pluginVersion);
else
logger.info("Found settings for version < 0.2.0");
final String jsonSettingsString = this.callbacks.loadExtensionSetting(BURP_SETTINGS_KEY);
if (StringUtils.isEmpty(jsonSettingsString)) {
logger.info("No plugin settings found");
}
else {
importExtensionSettingsFromJson(jsonSettingsString);
}
}
@Override
public IMessageEditorTab createNewInstance(IMessageEditorController controller, boolean editable)
{
return new SigMessageEditorTab(controller, editable);
}
@Override
public void extensionUnloaded()
{
saveExtensionSettings();
logger.info("Unloading "+EXTENSION_NAME);
}
@Override
public String getTabCaption()
{
return DISPLAY_NAME;
}
@Override
public Component getUiComponent()
{
return outerScrollPane;
}
@Override
public List<JMenuItem> createMenuItems(IContextMenuInvocation invocation)
{
JMenu menu = new JMenu("Default Profile");
// add disable item
JRadioButtonMenuItem item = new JRadioButtonMenuItem("Disabled", !isSigningEnabled());
Font defaultFont = item.getFont();
item.setFont(new Font(defaultFont.getFamily(), Font.ITALIC, defaultFont.getSize()));
item.addActionListener(new ActionListener()
{
@Override
public void actionPerformed(ActionEvent actionEvent)
{
signingEnabledCheckBox.setSelected(false);
}
});
menu.add(item);
// insert "auto" profile option
List<String> profileList = getSortedProfileNames();
profileList.add(0, NO_DEFAULT_PROFILE); // no default option
// add all profile names to menu, along with a listener to set the default profile when selected
for (final String name : profileList) {
item = new JRadioButtonMenuItem(name, isSigningEnabled() && name.equals(getDefaultProfileName()));
item.addActionListener(new ActionListener()
{
@Override
public void actionPerformed(ActionEvent actionEvent)
{
JRadioButtonMenuItem item = (JRadioButtonMenuItem) actionEvent.getSource();
setDefaultProfileName(item.getText());
signingEnabledCheckBox.setSelected(true);
}
});
menu.add(item);
}
List<JMenuItem> list = new ArrayList<>();
list.add(menu);
// add context menu items
switch (invocation.getInvocationContext()) {
case IContextMenuInvocation.CONTEXT_MESSAGE_EDITOR_REQUEST:
case IContextMenuInvocation.CONTEXT_MESSAGE_VIEWER_REQUEST:
case IContextMenuInvocation.CONTEXT_PROXY_HISTORY:
IHttpRequestResponse[] messages = invocation.getSelectedMessages();
IRequestInfo requestInfo = helpers.analyzeRequest(messages[0]);
final List<String> authorizationHeaders = requestInfo.getHeaders().stream()
.filter(h -> StringUtils.startsWithIgnoreCase(h, "Authorization:"))
.collect(Collectors.toList());
Map<String, String> signature = authorizationHeaders.stream()
.map(h -> parseSigV4AuthorizationHeader(h, false))
.filter(Objects::nonNull)
.findFirst()
.orElse(null);
// Add menu item for presigned s3 URLs for GET and PUT
// XXX: add subitems to get signed url with any profile?
if ((signature != null) && StringUtils.equalsIgnoreCase(signature.get("service"), "s3") &&
Arrays.asList("GET", "PUT").contains(requestInfo.getMethod().toUpperCase())) {
JMenuItem signedUrlItem = new JMenuItem("Copy Signed URL");
signedUrlItem.addActionListener(new ActionListener()
{
@Override
public void actionPerformed(ActionEvent actionEvent)
{
final SigProfile profile = getSigningProfile(requestInfo.getHeaders());
String signedUrl = ""; // clear clipboard on error
if (profile == null) {
final String msg = "Failed to determine signing profile for presigned URL";
logger.error(msg);
JOptionPane.showMessageDialog(getUiComponent(), msg);
}
else {
signedUrl = presignRequest(messages[0].getHttpService(), messages[0].getRequest(), profile, advancedSettingsDialog.getPresignedUrlLifetimeSeconds()).toString();
}
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
clipboard.setContents(new StringSelection(signedUrl), null);
}
});
list.add(signedUrlItem);
}
if ((signature == null) && (invocation.getInvocationContext() == IContextMenuInvocation.CONTEXT_MESSAGE_EDITOR_REQUEST)) {
JMenu addSignatureMenu = new JMenu("Add Signature");
for (final String name : profileList) {
if (name.length() == 0 || name.equals(NO_DEFAULT_PROFILE)) continue;
JMenuItem sigItem = new JMenuItem(name);
sigItem.setActionCommand(name);
sigItem.addActionListener(new ActionListener()
{
@Override
public void actionPerformed(ActionEvent actionEvent)
{
final String profileName = actionEvent.getActionCommand();
SigProfile profile = profileNameMap.get(profileName);
if (profile == null) {
// this should never happen since the menu is populated with existing profile names
JOptionPane.showMessageDialog(getUiComponent(), "Profile name does not exist: "+profileName);
return;
}
// if region or service is missing from profile, prompt user
if (StringUtils.isEmpty(profile.getService()) || StringUtils.isEmpty(profile.getRegion())) {
SigProfileEditorReadOnlyDialog dialog = new SigProfileEditorReadOnlyDialog(null, "Add Signature", true, profile);
callbacks.customizeUiComponent(dialog);
dialog.disableForEdit();
dialog.setVisible(true);
if (dialog.getProfile() == null) {
// user hit "Cancel", abort.
return;
}
profile = dialog.getProfile();
}
final SigProfile profileCopy = profile; // reference copy is fine here
(new Thread(() -> {
try {
// XXX we do some work to prevent custom signed headers specified in the SigV4 UI from
// showing up in the Raw message editor tab to prevent them from being duplicated when
// it's signed again. consider modifying signRequest() to optionally skip adding these.
final byte[] signedRequest = signRequest(messages[0].getHttpService(), messages[0].getRequest(), profileCopy);
if (signedRequest == null || signedRequest.length == 0) {
throw new NullPointerException("Request signing failed for profile: "+profileCopy.getName());
}
IRequestInfo signedRequestInfo = helpers.analyzeRequest(signedRequest);
// make sure new signature contains a keyId that can be used to automatically select the correct profile
Map<String, String> signature = parseSigV4AuthorizationHeader(signedRequestInfo.getHeaders().stream()
.filter(h -> StringUtils.startsWithIgnoreCase(h, "Authorization:"))
.findFirst().orElse(null), true);
final String accessKeyId = profileCopy.getAccessKeyIdForProfileSelection();
if (accessKeyId != null) {
signature.put("accessKeyId", accessKeyId);
}
// get original headers minus AWS headers
List<String> allHeaders = requestInfo.getHeaders().stream()
.filter(h -> !StringUtils.startsWithIgnoreCase(h, "Authorization:"))
.filter(h -> !StringUtils.startsWithIgnoreCase(h, "X-Amz-"))
.collect(Collectors.toList());
// add the headers created by signing followed by the modified Authorization header
allHeaders.addAll(signedRequestInfo.getHeaders().stream()
.filter(h -> StringUtils.startsWithIgnoreCase(h, "X-Amz-"))
.collect(Collectors.toList()));
allHeaders.add(buildSigV4AuthorizationHeader(signature));
final byte[] body = Arrays.copyOfRange(messages[0].getRequest(), requestInfo.getBodyOffset(), messages[0].getRequest().length);
messages[0].setRequest(helpers.buildHttpMessage(allHeaders, body));
} catch (IllegalArgumentException | NullPointerException exc) {
// TODO: line wrap
JOptionPane.showMessageDialog(getUiComponent(), "Failed to add signature: " + exc.getMessage());
}
})).start();
}
});
addSignatureMenu.add(sigItem);
}
list.add(addSignatureMenu);
}
else if ((signature != null) && (invocation.getInvocationContext() == IContextMenuInvocation.CONTEXT_MESSAGE_EDITOR_REQUEST)) {
JMenuItem editSignatureItem = new JMenuItem("Edit Signature");
editSignatureItem.addActionListener(new ActionListener()
{
@Override
public void actionPerformed(ActionEvent actionEvent)
{
SigProfile signingProfile = authorizationHeaders.stream()
.map(BurpExtender.this::profileFromAuthorizationHeader)
.filter(Objects::nonNull)
.findFirst()
.orElse(null);
SigProfileEditorReadOnlyDialog dialog = new SigProfileEditorReadOnlyDialog(
null, "Edit Signature", true,
(signingProfile != null) ? signingProfile : new SigProfile.Builder("TEMP").build());
if (signingProfile == null) {
// populate Add Profile dialog with some defaults taken from the Authorization header
dialog.nameTextField.setText(" ");
dialog.profileKeyIdTextField.setText(signature.get("accessKeyId"));
}
if (StringUtils.isNotEmpty(signature.get("service")))
dialog.serviceTextField.setText(signature.get("service"));
if (StringUtils.isNotEmpty(signature.get("region")))
dialog.regionTextField.setText(signature.get("region"));
callbacks.customizeUiComponent(dialog);
dialog.disableForEdit();
dialog.focusEmptyField();
dialog.setVisible(true);
signingProfile = dialog.getProfile();
if (signingProfile != null) {
// preserve header order by getting index of first Authorization header
final List<String> allHeaders = requestInfo.getHeaders();
final int insertIndex = IntStream.range(0, allHeaders.size())
.filter(i -> StringUtils.startsWithIgnoreCase(allHeaders.get(i), "Authorization:"))
.findFirst()
.orElse(1);
List<String> nonAuthHeaders = requestInfo.getHeaders().stream()
.filter(h -> !StringUtils.startsWithIgnoreCase(h, "Authorization:"))
.collect(Collectors.toList());
final byte[] body = Arrays.copyOfRange(messages[0].getRequest(), requestInfo.getBodyOffset(), messages[0].getRequest().length);
signature.put("accessKeyId", signature.getOrDefault("accessKeyId", signingProfile.getAccessKeyId()));
signature.put("region", signingProfile.getRegion());
signature.put("service", signingProfile.getService());
nonAuthHeaders.add(insertIndex, buildSigV4AuthorizationHeader(signature));
messages[0].setRequest(helpers.buildHttpMessage(nonAuthHeaders, body));
}
}
});
list.add(editSignatureItem);
}
break;
case IContextMenuInvocation.CONTEXT_MESSAGE_VIEWER_RESPONSE:
final IHttpRequestResponse[] selectedMessages = invocation.getSelectedMessages();
if (selectedMessages == null || selectedMessages.length < 1) {
break;
}
final int[] bounds = invocation.getSelectionBounds();
if (bounds == null || (bounds[1] - bounds[0] < 90)) {
// expect at least 90 chars for API credentials with a key id and secret.
break;
}
JMenuItem importItem = new JMenuItem("Import Selected Credential");
importItem.addActionListener(actionEvent -> {
final byte[] selection = Arrays.copyOfRange(selectedMessages[0].getResponse(), bounds[0], bounds[1]);
try {
Optional<SigProfile> profile = JSONCredentialParser.profileFromJSON(new String(selection));
if (profile.isPresent()) {
SigProfileEditorDialog dialog = new SigProfileEditorDialog(null, "Import Credential", true, null);
dialog.applyProfile(profile.get());
dialog.setVisible(true);
} else {
logger.error("Invalid JSON credentials object");
}
} catch (JsonSyntaxException e) {
logger.error("Invalid JSON credentials object");
}
});
list.add(importItem);
break;
}
return list;
}
// check Authorization header for AccessKeyId and return matching profile or null.
private SigProfile profileFromAuthorizationHeader(final String header) {
return Stream.of(header)
.map(h -> parseSigV4AuthorizationHeader(h, false))
.filter(Objects::nonNull)
.filter(a -> this.profileKeyIdMap.containsKey(a.get("accessKeyId")))
.map(a -> this.profileKeyIdMap.get(a.get("accessKeyId")))
.findFirst()
.orElse(null);
}
private static Map<String, String> parseSigV4AuthorizationHeader(final String header, final boolean strict)
{
Map<String, String> signature = null;
Pattern pattern = authorizationHeaderLooseRegex;
if (strict) {