Skip to content

Commit 5bcff88

Browse files
author
isayan
committed
bugfix JWT View
1 parent 28bca35 commit 5bcff88

File tree

14 files changed

+457
-278
lines changed

14 files changed

+457
-278
lines changed

release/YaguraExtender.jar

5.08 KB
Binary file not shown.

src/burp/release.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# YaguraExtender build xml properties
22

33
# version
4-
version=1.7.36.3
4+
version=1.7.36.4
55

66
#lib
77
asciidoctor-version=1.5.6

src/yagura/external/TransUtil.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ public static String toSmartDecode(String value, TransUtil.EncodePattern encodeP
393393
decode = TransUtil.decodeSQLangQuote(value);
394394
break;
395395
case REGEX:
396-
// nothing
396+
decode = TransUtil.toRegexDecode(value);
397397
break;
398398
default:
399399
break;
@@ -917,7 +917,7 @@ public static String toHtmlEncode(char c) {
917917
return buff.toString();
918918
}
919919

920-
public static String toRegexEscape(String input) {
920+
public static String toRegexEncode(String input) {
921921
StringBuilder buff = new StringBuilder();
922922
int length = input.length();
923923
for (int i = 0; i < length; i++) {
@@ -960,7 +960,11 @@ public static String toRegexEscape(char ch) {
960960
}
961961
return buff.toString();
962962
}
963-
963+
964+
public static String toRegexDecode(String input) {
965+
return input.replaceAll("\\\\([\\\\\\.\\+\\*\\?\\[\\^\\]\\$\\(\\)\\{\\}\\=\\!\\<\\>\\|\\:\\-])", "$1");
966+
}
967+
964968
public static String toHtmlDecode(String input) {
965969
StringBuffer buff = new StringBuffer();
966970
Pattern p = Pattern.compile("(&(?:(#\\d+)|(#[xX][0-9a-fA-F]+)|(\\w+));)");

src/yagura/model/JWTObject.java

Lines changed: 7 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -1,142 +1,45 @@
11
package yagura.model;
22

33
import java.io.IOException;
4-
import java.nio.charset.StandardCharsets;
5-
import java.util.Base64;
6-
import java.util.regex.Matcher;
7-
import java.util.regex.Pattern;
84
import yagura.external.JsonUtil;
95

106
/**
117
*
128
* @author isayan
139
*/
14-
public class JWTObject {
10+
public class JWTObject extends JWTToken {
1511

16-
private final static Pattern PTN_JWT = Pattern.compile("(e(?:[0-9a-zA-Z_-]){10,})\\.(e(?:[0-9a-zA-Z_-]){2,})\\.((?:[0-9a-zA-Z_-]){20,})");
17-
18-
public static boolean isJWTFormat(String value) {
19-
Matcher m = PTN_JWT.matcher(value);
20-
if (m.matches()) {
21-
return true;
22-
}
23-
return false;
24-
}
25-
26-
public static boolean containsJWTFormat(String value) {
27-
Matcher m = PTN_JWT.matcher(value);
28-
if (m.find()) {
29-
return true;
30-
}
31-
return false;
32-
}
33-
34-
public static String findJWTValue(String value) {
35-
Matcher m = PTN_JWT.matcher(value);
36-
if (m.find()) {
37-
return m.group(0);
38-
}
39-
return null;
40-
}
41-
42-
43-
public static JWTObject parseJWTObject(String value, boolean matches) {
44-
JWTObject jwt = new JWTObject();
45-
Matcher m = PTN_JWT.matcher(value);
46-
boolean find = false;
47-
if (matches)
48-
find = m.matches();
49-
else
50-
find = m.find();
51-
52-
if (find) {
53-
String header = m.group(1);
54-
String payload = m.group(2);
55-
String signature = m.group(3);
56-
JsonUtil.parse(decodeB64(header));
57-
JsonUtil.parse(decodeB64(payload));
58-
decodeB64(signature);
59-
jwt.header = header;
60-
jwt.payload = payload;
61-
jwt.signature = signature;
62-
}
63-
return jwt;
64-
}
65-
66-
private String header;
67-
private String payload;
68-
private String signature;
69-
70-
private static byte [] decodeB64Byte(String value) {
71-
value = value.replace('-', '+');
72-
value = value.replace('_', '/');
73-
return Base64.getDecoder().decode(value);
74-
}
75-
76-
private static String decodeB64(String src) {
77-
return new String(decodeB64Byte(src), StandardCharsets.UTF_8);
78-
}
79-
80-
private static String encodeB64Byte(byte [] src) {
81-
byte[] encoded = Base64.getEncoder().withoutPadding().encode(src);
82-
String value = new String(encoded, StandardCharsets.US_ASCII);
83-
value = value.replace('+', '-');
84-
value = value.replace('/', '_');
85-
return value;
12+
public JWTObject(JWTToken token) {
13+
super(token);
8614
}
8715

88-
private static String encodeB64(String src) {
89-
return encodeB64Byte(src.getBytes(StandardCharsets.UTF_8));
90-
}
91-
92-
/**
93-
* @return the header
94-
*/
95-
public String getHeader() {
96-
return header;
97-
}
98-
99-
/**
16+
/**
10017
* @return the header
10118
*/
10219
public String getHeaderJSON(boolean pretty) {
10320
try {
104-
return JsonUtil.prettyJSON(decodeB64(header), pretty);
21+
return JsonUtil.prettyJSON(decodeB64(this.getHeader()), pretty);
10522
} catch (IOException ex) {
10623
return null;
10724
}
10825
}
109-
110-
/**
111-
* @return the payload
112-
*/
113-
public String getPayload() {
114-
return payload;
115-
}
11626

11727
/**
11828
* @return the payload
11929
*/
12030
public String getPayloadJSON(boolean pretty) {
12131
try {
122-
return JsonUtil.prettyJSON(decodeB64(payload), pretty);
32+
return JsonUtil.prettyJSON(decodeB64(this.getPayload()), pretty);
12333
} catch (IOException ex) {
12434
return null;
12535
}
12636
}
12737

128-
/**
129-
* @return the signature
130-
*/
131-
public String getSignature() {
132-
return signature;
133-
}
134-
13538
/**
13639
* @return the signature
13740
*/
13841
public byte [] getSignatureByte() {
139-
return decodeB64Byte(signature);
42+
return decodeB64Byte(this.getSignature());
14043
}
14144

14245
}

0 commit comments

Comments
 (0)