diff --git a/libs/BurpExtensionCommons-v0.4.2.0.jar b/libs/BurpExtensionCommons-v0.4.2.0.jar index 8d64cf9f..77a2c8b3 100644 Binary files a/libs/BurpExtensionCommons-v0.4.2.0.jar and b/libs/BurpExtensionCommons-v0.4.2.0.jar differ diff --git a/nbproject/project.properties b/nbproject/project.properties new file mode 100644 index 00000000..e69de29b diff --git a/release/YaguraExtender-v2.2.jar b/release/YaguraExtender-v2.2.jar index a224bbd2..a1e7d5bd 100644 Binary files a/release/YaguraExtender-v2.2.jar and b/release/YaguraExtender-v2.2.jar differ diff --git a/src/main/java/aspx/viewstate/ViewState.java b/src/main/java/aspx/viewstate/ViewState.java index 31040335..7d5d24e5 100644 --- a/src/main/java/aspx/viewstate/ViewState.java +++ b/src/main/java/aspx/viewstate/ViewState.java @@ -99,13 +99,13 @@ public boolean isMacEnabled() { public Algorithm getMacAlgorithm() { Algorithm algorithm = Algorithm.HMAC_UNKNOWN; switch (digest.length) { - case 0x20: + case 20: algorithm = Algorithm.HMAC_SHA256; break; - case 0x30: + case 30: algorithm = Algorithm.HMAC_SHA384; break; - case 0x40: + case 40: algorithm = Algorithm.HMAC_SHA512; break; } diff --git a/src/main/java/extend/util/external/TransUtil.java b/src/main/java/extend/util/external/TransUtil.java index 67203f95..22e972e0 100644 --- a/src/main/java/extend/util/external/TransUtil.java +++ b/src/main/java/extend/util/external/TransUtil.java @@ -196,7 +196,7 @@ public enum EncodePattern { }; // private final static Pattern PTN_URLENCODE = Pattern.compile("(%[0-9a-fA-F][0-9a-fA-F]|[0-9a-zA-Z\\*_\\+\\.-])+"); - + private final static Pattern PTN_B64 = Pattern.compile("([0-9a-zA-Z+/\r\n])+={0,2}"); private final static Pattern PTN_B64_URLSAFE = Pattern.compile("([0-9a-zA-Z_\\-])"); private final static Pattern PTN_UUENCODE = Pattern.compile("begin\\s[0-6]{3}\\s\\w+"); @@ -213,7 +213,7 @@ public enum EncodePattern { private final static Pattern PTN_GZIP = Pattern.compile("\\x1f\\x8b"); public static EncodePattern getSmartDecode(String value) { - // 判定の順番は検討の余地あり + // 判定の順番は検討の余地あり // % Encode Matcher mURL = PTN_URL.matcher(value); // base64 @@ -314,7 +314,7 @@ else if (!('0' <= c && c <= '9' || 'a' <= c && c <= 'z' || 'A' <= c && c <= 'Z public static boolean isBase64Encoded(String value) { return Base64.isBase64(value); } - + public static String toSmartDecode(String value) { return toSmartDecode(value, getSmartDecode(value), (String) null); } @@ -340,14 +340,14 @@ public static String toSmartDecode(String value, TransUtil.EncodePattern encodeP applyCharset = charset; } decode = StringUtil.getBytesCharsetString(value, applyCharset); - } + } else { // URL encode match switch (encodePattern) { - case NONE: + case NONE: decode = value; break; - case URL_STANDARD: + case URL_STANDARD: { String guessCode = (charset == null) ? getUniversalGuessCode(StringUtil.getBytesRaw(TransUtil.decodeUrl(value, StandardCharsets.ISO_8859_1))) : charset; if (guessCode != null) { @@ -367,7 +367,7 @@ public static String toSmartDecode(String value, TransUtil.EncodePattern encodeP decode = toUnocodeDecode(value); break; // Byte Hex - case BYTE_HEX: + case BYTE_HEX: { String guessCode = (charset == null) ? getUniversalGuessCode(StringUtil.getBytesRaw(toByteDecode(value, StandardCharsets.ISO_8859_1.name()))) : charset; if (guessCode != null) { @@ -379,7 +379,7 @@ public static String toSmartDecode(String value, TransUtil.EncodePattern encodeP } break; // Byte Hex2 - case BYTE_HEX2: + case BYTE_HEX2: { String guessCode = (charset == null) ? getUniversalGuessCode(StringUtil.getBytesRaw(toByteDecode(value, StandardCharsets.ISO_8859_1.name()))) : charset; if (guessCode != null) { @@ -391,7 +391,7 @@ public static String toSmartDecode(String value, TransUtil.EncodePattern encodeP } break; // // Byte Dec -// case BYTE_DEC: +// case BYTE_DEC: // { // String guessCode = (charset == null) ? getUniversalGuessCode(StringUtil.getBytesRaw(toByteDecode(value, StandardCharsets.ISO_8859_1.name()))) : charset; // if (guessCode != null) { @@ -402,7 +402,7 @@ public static String toSmartDecode(String value, TransUtil.EncodePattern encodeP // } // } // break; - case BYTE_OCT: + case BYTE_OCT: { String guessCode = (charset == null) ? getUniversalGuessCode(StringUtil.getBytesRaw(toByteDecode(value, StandardCharsets.ISO_8859_1.name()))) : charset; if (guessCode != null) { @@ -426,7 +426,7 @@ public static String toSmartDecode(String value, TransUtil.EncodePattern encodeP // } // break; // QuotedPrintable - case QUOTEDPRINTABLE: + case QUOTEDPRINTABLE: { String guessCode = (charset == null) ? getUniversalGuessCode(StringUtil.getBytesRaw(toUnQuotedPrintable(value, StandardCharsets.ISO_8859_1))) : charset; if (guessCode != null) { @@ -442,7 +442,7 @@ public static String toSmartDecode(String value, TransUtil.EncodePattern encodeP decode = toPunycodeDecode(value); break; // Base64 encode match - case BASE64: + case BASE64: { value = value.replaceAll("[\r\n]", ""); // 改行削除 byte[] bytes = TransUtil.toBase64Decode(value); @@ -456,7 +456,7 @@ public static String toSmartDecode(String value, TransUtil.EncodePattern encodeP } break; // Base64 URLSafe - case BASE64_URLSAFE: + case BASE64_URLSAFE: { value = value.replaceAll("[\r\n]", ""); // 改行削除 byte[] bytes = TransUtil.toBase64URLSafeDecode(value); @@ -821,7 +821,7 @@ public static String toUTF7Decode(String str) { } private final static String SPECIAL_CHAR = "!\"#$%&'()*+,-./:;<=>?@[\\]{|}~"; - public static String toUSASCII(String str, String enc) + public static String toUSASCII(String str, String charset) throws UnsupportedEncodingException { char[] chars = toChars(str); for (int i = 0; i < chars.length; i++) { @@ -830,8 +830,8 @@ public static String toUSASCII(String str, String enc) chars[i] = (char) ((int) chars[i] | 0x80); } } - String ustr = new String(chars); - return new String(ustr.getBytes(StandardCharsets.ISO_8859_1), enc); + return StringUtil.getStringCharset(StringUtil.getBytesRaw(String.valueOf(chars)), charset); + } public static int getCharCode(String str, String enc) @@ -1045,7 +1045,7 @@ public static String toByteHexEncode(String input, String charset, boolean upper public static String toByteHexEncode(String input, Charset charset, boolean upperCase) throws UnsupportedEncodingException { return toByteHexEncode(input, charset, PTN_ENCODE_ALPHANUM, upperCase); } - + public static String toByteHexEncode(String input, String charset, Pattern pattern, boolean upperCase) throws UnsupportedEncodingException { return toByteHexEncode(input.getBytes(charset), pattern, upperCase); } @@ -1053,7 +1053,7 @@ public static String toByteHexEncode(String input, String charset, Pattern patte public static String toByteHexEncode(String input, Charset charset, Pattern pattern, boolean upperCase) throws UnsupportedEncodingException { return toByteHexEncode(input.getBytes(charset), pattern, upperCase); } - + public static String toByteHex2Encode(String input, String charset, boolean upperCase) throws UnsupportedEncodingException { return toByteHex2Encode(input, charset, PTN_ENCODE_ALPHANUM, upperCase); } @@ -1061,7 +1061,7 @@ public static String toByteHex2Encode(String input, String charset, boolean uppe public static String toByteHex2Encode(String input, Charset charset, boolean upperCase) throws UnsupportedEncodingException { return toByteHex2Encode(input, charset, PTN_ENCODE_ALPHANUM, upperCase); } - + public static String toByteHex2Encode(String input, String charset, Pattern pattern, boolean upperCase) throws UnsupportedEncodingException { return toByteHex2Encode(input.getBytes(charset), pattern, upperCase); } @@ -1069,15 +1069,15 @@ public static String toByteHex2Encode(String input, String charset, Pattern patt public static String toByteHex2Encode(String input, Charset charset, Pattern pattern, boolean upperCase) throws UnsupportedEncodingException { return toByteHex2Encode(input.getBytes(charset), pattern, upperCase); } - + public static String toByteDecEncode(String input, String charset) throws UnsupportedEncodingException { return toByteDecEncode(input, charset, PTN_ENCODE_ALPHANUM); } - + public static String toByteDecEncode(String input, Charset charset) throws UnsupportedEncodingException { return toByteDecEncode(input, charset, PTN_ENCODE_ALPHANUM); } - + public static String toByteDecEncode(String input, String charset, Pattern pattern) throws UnsupportedEncodingException { return toByteDecEncode(input.getBytes(charset), pattern); } @@ -1085,7 +1085,7 @@ public static String toByteDecEncode(String input, String charset, Pattern patte public static String toByteDecEncode(String input, Charset charset, Pattern pattern) throws UnsupportedEncodingException { return toByteDecEncode(input.getBytes(charset), pattern); } - + public static String toByteOctEncode(String input, String charset) throws UnsupportedEncodingException { return toByteOctEncode(input, charset, PTN_ENCODE_ALPHANUM); } @@ -1093,7 +1093,7 @@ public static String toByteOctEncode(String input, String charset) throws Unsupp public static String toByteOctEncode(String input, Charset charset) throws UnsupportedEncodingException { return toByteOctEncode(input, charset, PTN_ENCODE_ALPHANUM); } - + public static String toByteOctEncode(String input, String charset, Pattern pattern) throws UnsupportedEncodingException { return toByteOctEncode(input.getBytes(charset), pattern); } @@ -1101,7 +1101,7 @@ public static String toByteOctEncode(String input, String charset, Pattern patte public static String toByteOctEncode(String input, Charset charset, Pattern pattern) throws UnsupportedEncodingException { return toByteOctEncode(input.getBytes(charset), pattern); } - + public static String toByteHexEncode(byte[] bytes, Pattern pattern, boolean upperCase) { StringBuilder buff = new StringBuilder(); for (int i = 0; i < bytes.length; i++) { @@ -1137,7 +1137,7 @@ public static String toByteHex2Encode(byte[] bytes, Pattern pattern, boolean upp } return buff.toString(); } - + private static String toByteDecEncode(byte[] bytes, Pattern pattern) { StringBuilder buff = new StringBuilder(); for (int i = 0; i < bytes.length; i++) { @@ -1151,7 +1151,7 @@ private static String toByteDecEncode(byte[] bytes, Pattern pattern) { } return buff.toString(); } - + public static String toByteOctEncode(byte[] bytes, Pattern pattern) { StringBuilder buff = new StringBuilder(); for (int i = 0; i < bytes.length; i++) { @@ -1210,7 +1210,7 @@ public static String toByteDecode(String input, String charset) { buf.flip(); byte[] value = new byte[buf.limit()]; buf.get(value); - m.appendReplacement(buff, Matcher.quoteReplacement(new String(value, charset))); + m.appendReplacement(buff, Matcher.quoteReplacement(StringUtil.getStringCharset(value, charset))); } else if (oct != null) { Matcher m3 = PTN_BYTE_OCT.matcher(oct); ByteBuffer buf = ByteBuffer.allocate(oct.length()); @@ -1232,7 +1232,7 @@ public static String toByteDecode(String input, String charset) { } private final static Pattern PTN_BYTE_HEX_GROUP = Pattern.compile("((\\\\[xX][0-9a-fA-F]{2})+)|((\\\\[0-9a-fA-F]{2})+)"); - + public static String toByteHexDecode(String input, String charset) { StringBuffer buff = new StringBuffer(); Matcher m = PTN_BYTE_HEX_GROUP.matcher(input); @@ -1274,8 +1274,8 @@ public static String toByteHexDecode(String input, String charset) { } return buff.toString(); } - - + + public static String toUnocodeUrlEncode(String input, boolean upperCase) { return toUnocodeUrlEncode(input, PTN_ENCODE_ALPHANUM, upperCase); } @@ -1499,7 +1499,7 @@ public static String toHtmlDecode(String input, String charset) throws Unsupport if (charset == null) { return decode; } else { - return new String(decode.getBytes(StandardCharsets.ISO_8859_1), charset); + return StringUtil.getStringCharset(StringUtil.getBytesRaw(decode), charset); } } @@ -1782,7 +1782,7 @@ public static String toSmartMatch(String value, String charset) throws Unsupport buff.append(HttpUtil.toHtmlEncode(ch)); break; case '\\': // escape - if (i == length - 1) + if (i == length - 1) buff.append(toRegexEscape(ch)); else escape = true; @@ -1816,7 +1816,7 @@ public static String toSmartMatch(String value, String charset) throws Unsupport escape = false; break; case '?': // wild card - if (escape) + if (escape) buff.append(toRegexEscape(ch)); else buff.append('.'); @@ -1861,11 +1861,11 @@ public static Pattern compileRegex(String text, boolean smartMatch, boolean rege } return p; } - + public static Pattern compileRegex(String text, boolean smartMatch, boolean regexp, boolean ignoreCase) { return compileRegex(text, smartMatch, regexp, ignoreCase, 0); } - + /** * リストを作成する * @@ -1977,7 +1977,7 @@ public static void hexDump(byte[] output, PrintStream out) { hexmod[j++] = hexs[i]; if (i > 0 && (j - 1) % 16 == 0) { System.arraycopy(output, row * 16, partout, 0, partout.length); - String hexText = new String(partout, StandardCharsets.ISO_8859_1); + String hexText = StringUtil.getStringRaw(partout); hexmod[0] = FMT_HEX_POSITION.format(row); hexmod[17] = hexText; for (int x = 0; x < hexmod.length; x++) { @@ -1996,7 +1996,7 @@ public static void hexDump(byte[] output, PrintStream out) { */ if ((j - 1) > 0) { System.arraycopy(output, row * 16, partout, 0, j - 1); - String hexText = new String(partout, StandardCharsets.ISO_8859_1); + String hexText = StringUtil.getStringRaw(partout); hexmod[0] = FMT_HEX_POSITION.format(row); hexmod[17] = hexText; for (int x = 0; x < j; x++) { @@ -2093,7 +2093,7 @@ private static List extractHTMLComments(Node node) { /** * HashUtil **/ - + /** * MD2値の取得 * @@ -2363,7 +2363,7 @@ public static int toMurmurHash32(byte[] body) { * @return ハッシュ値 */ public static int toMurmurHash32(String str) { - return MurmurHash2.hash32(str); + return MurmurHash2.hash32(str); } /** @@ -2377,8 +2377,8 @@ public static int toMurmurHash32(String str) { public static int toMurmurHash32(String str, String enc) throws UnsupportedEncodingException { byte [] body = str.getBytes(enc); - return MurmurHash2.hash32(body, body.length); - } + return MurmurHash2.hash32(body, body.length); + } /** * MurmurHash値の取得 @@ -2397,7 +2397,7 @@ public static long toMurmurHash64(byte[] body) { * @return ハッシュ値 */ public static long toMurmurHash64(String str) { - return MurmurHash2.hash64(str); + return MurmurHash2.hash64(str); } /** @@ -2412,8 +2412,8 @@ public static long toMurmurHash64(String str, String enc) throws UnsupportedEncodingException { byte [] body = str.getBytes(enc); return MurmurHash2.hash64(body, body.length); - } - + } + public static long toEpochSecond(BigDecimal excel_serial) { // Unixtime = (Excelserial - 25569) * (60 * 60 * 24) - (60 * 60 * 0) final TimeZone tz = TimeZone.getDefault(); @@ -2421,7 +2421,7 @@ public static long toEpochSecond(BigDecimal excel_serial) { excel_serial = excel_serial.subtract(BigDecimal.valueOf(25569L)).multiply(BigDecimal.valueOf(60 * 60 * 24)).subtract(BigDecimal.valueOf(tz_offset)); return excel_serial.longValue(); } - + public static long toEpochMilli(BigDecimal excel_serial) { return toEpochSecond(excel_serial) * 1000L; } diff --git a/src/main/java/yagura/model/HttpMessageItem.java b/src/main/java/yagura/model/HttpMessageItem.java index 3a72e297..b984aa92 100644 --- a/src/main/java/yagura/model/HttpMessageItem.java +++ b/src/main/java/yagura/model/HttpMessageItem.java @@ -9,6 +9,7 @@ import extension.burp.HttpService; import extension.helpers.HttpMessage; import extension.helpers.HttpResponse; +import extension.helpers.HttpUtil; import java.net.URL; import java.nio.charset.StandardCharsets; import java.util.logging.Level; @@ -230,7 +231,7 @@ public String getGuessCharset() { } public boolean isSSL() { - return "https".equals(this.getProtocol()); + return HttpUtil.isSSL(this.getProtocol()); } public void dump() { diff --git a/src/main/java/yagura/model/MatchReplaceGroup.java b/src/main/java/yagura/model/MatchReplaceGroup.java index c1195c47..798f4afd 100644 --- a/src/main/java/yagura/model/MatchReplaceGroup.java +++ b/src/main/java/yagura/model/MatchReplaceGroup.java @@ -21,9 +21,6 @@ public List getReplaceList() { return Collections.unmodifiableList(this.replaceList); } - /** - * @return the replaceMap - */ public void setReplaceList(List replaceList) { this.replaceList.clear(); this.replaceList.addAll(replaceList); diff --git a/src/main/java/yagura/model/Parameter.java b/src/main/java/yagura/model/Parameter.java index 71701062..5536fdc1 100644 --- a/src/main/java/yagura/model/Parameter.java +++ b/src/main/java/yagura/model/Parameter.java @@ -3,9 +3,6 @@ import burp.IParameter; import extension.helpers.StringUtil; import java.io.UnsupportedEncodingException; -import java.nio.charset.StandardCharsets; -import java.util.logging.Level; -import java.util.logging.Logger; /** * @@ -90,7 +87,7 @@ public String getUniversalName() { return null; } } else { - return StringUtil.getStringCharset(StringUtil.getBytesRaw(parameter.getName()), StandardCharsets.ISO_8859_1); + return StringUtil.getStringRaw(StringUtil.getBytesRaw(parameter.getName())); } } @@ -102,7 +99,7 @@ public String getUniversalValue() { return null; } } else { - return StringUtil.getStringCharset(StringUtil.getBytesRaw(parameter.getName()), StandardCharsets.ISO_8859_1); + return StringUtil.getStringRaw(StringUtil.getBytesRaw(parameter.getName())); } } diff --git a/src/main/java/yagura/model/QuickSearchEvent.java b/src/main/java/yagura/model/QuickSearchEvent.java index d822b28e..5530e38b 100644 --- a/src/main/java/yagura/model/QuickSearchEvent.java +++ b/src/main/java/yagura/model/QuickSearchEvent.java @@ -7,13 +7,12 @@ * @author isayan */ public class QuickSearchEvent extends EventObject { - private String keyword = ""; private boolean smartMatch = false; private boolean regexp = false; private boolean ignoreCase = false; public boolean clearView = false; - + public QuickSearchEvent(Object source, String keyword, boolean smartMatch, boolean regexp, boolean ignoreCase, boolean clearView) { super(source); this.keyword = keyword; @@ -29,7 +28,7 @@ public QuickSearchEvent(Object source, String keyword, boolean smartMatch, boole public String getKeyword() { return this.keyword; } - + /** * @return the smartMatch */ @@ -50,7 +49,7 @@ public boolean isRegexp() { public boolean isIgnoreCase() { return ignoreCase; } - + /** * @return the clearView */ diff --git a/src/main/java/yagura/model/ResultView.java b/src/main/java/yagura/model/ResultView.java index 8edbeba8..8a853d81 100644 --- a/src/main/java/yagura/model/ResultView.java +++ b/src/main/java/yagura/model/ResultView.java @@ -36,10 +36,12 @@ public ResultView(IHttpRequestResponse item, int ordinal) { public ObjectTableColumn getColumn() { return new ObjectTableColumn() { + @Override public String getColumnName(int column) { return columns[column]; } + @Override public int getColumnCount() { return columns.length; } @@ -67,7 +69,7 @@ public Object getObject(int column) { try { HttpMessageItem msg = this; switch (column) { - case 0: // + case 0: // value = msg; break; case 1: // # diff --git a/src/main/java/yagura/model/SendToItem.java b/src/main/java/yagura/model/SendToItem.java index afa2034c..77758185 100644 --- a/src/main/java/yagura/model/SendToItem.java +++ b/src/main/java/yagura/model/SendToItem.java @@ -5,7 +5,6 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; -import java.nio.charset.StandardCharsets; import java.util.Properties; import java.util.logging.Level; import java.util.logging.Logger; @@ -260,7 +259,6 @@ public void setExtendPropertyString(String propString) { } } - /** * @return the extend */ diff --git a/src/main/java/yagura/model/SendToMenu.java b/src/main/java/yagura/model/SendToMenu.java index cca6c5b0..55f3a7ff 100644 --- a/src/main/java/yagura/model/SendToMenu.java +++ b/src/main/java/yagura/model/SendToMenu.java @@ -8,9 +8,7 @@ import burp.IHttpService; import burp.IMessageEditorController; import burp.IScanIssue; -import extension.helpers.ConvertUtil; import extension.helpers.HttpUtil; -import java.awt.Component; import java.awt.TrayIcon; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -21,11 +19,7 @@ import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; -import javax.swing.FocusManager; import javax.swing.JMenuItem; -import javax.swing.JTable; -import javax.swing.KeyStroke; -import javax.swing.table.TableModel; /** * burp new IF @@ -76,7 +70,7 @@ public void renewMenu(SendToProperty property) { for (String encoding : encodingList) { javax.swing.JMenuItem mnuItemEncoding = new javax.swing.JMenuItem(); mnuItemEncoding.setText(encoding); - mnuItemEncoding.addActionListener(sendToItem); + mnuItemEncoding.addActionListener(sendToItem); mnuItem.add(mnuItemEncoding); } if (property.isSubMenu()) { @@ -102,7 +96,7 @@ public void renewMenu(SendToProperty property) { if (sendToItem.isEnabled()) { this.menuList.add(mnuItem); } - } + } } } else { @@ -125,9 +119,9 @@ public void warning(SendToEvent evt) { public void error(SendToEvent evt) { BurpExtender.issueAlert("SendToServer", evt.getMessage(), TrayIcon.MessageType.ERROR); logger.log(Level.SEVERE, evt.getMessage()); } - + }); - + sendToList.add(sendToItem); mnuItem.addActionListener(sendToItem); if (property.isSubMenu()) { @@ -317,7 +311,7 @@ public boolean isExtendVisible() { }; } - + private IContextMenuInvocation getContextMenuInvocation(KeyEvent evt, IHttpRequestResponse[] messageInfo) { return new IContextMenuInvocation() { @Override diff --git a/src/main/java/yagura/model/SendToMenuItem.java b/src/main/java/yagura/model/SendToMenuItem.java index 963c2495..8c562139 100644 --- a/src/main/java/yagura/model/SendToMenuItem.java +++ b/src/main/java/yagura/model/SendToMenuItem.java @@ -21,7 +21,7 @@ */ public abstract class SendToMenuItem extends SendToItem implements java.awt.event.ActionListener { - private final static Logger logger = Logger.getLogger(SendToMenu.class.getName()); + private final static Logger logger = Logger.getLogger(SendToMenuItem.class.getName()); protected IContextMenuInvocation contextMenu = null; @@ -93,5 +93,5 @@ protected File tempMessageFile(IHttpRequestResponse messageInfo, int index) { public abstract void menuItemClicked(String menuItemCaption, IHttpRequestResponse[] messageInfo); public abstract boolean isEnabled(); - + } diff --git a/src/main/java/yagura/model/UniversalViewProperty.java b/src/main/java/yagura/model/UniversalViewProperty.java index ad29bc9c..c0107716 100644 --- a/src/main/java/yagura/model/UniversalViewProperty.java +++ b/src/main/java/yagura/model/UniversalViewProperty.java @@ -2,6 +2,7 @@ import com.google.gson.annotations.Expose; import extension.helpers.ConvertUtil; +import extension.helpers.StringUtil; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.util.ArrayList; @@ -61,24 +62,24 @@ public static List getDefaultEncodingList(Locale lang) { List list = new ArrayList<>(); if (lang == null) { for (String enc : ENCODING_DEFAULT_OTHER_LIST) { - if (charSets.get(enc) != null) list.add(enc); + if (charSets.get(enc) != null) list.add(enc); } } else if (lang.equals(Locale.JAPANESE)) { for (String enc : ENCODING_DEFAULT_JAPANESE_LIST) { - if (charSets.get(enc) != null) list.add(enc); + if (charSets.get(enc) != null) list.add(enc); } } else if (lang.equals(Locale.CHINESE)) { for (String enc : ENCODING_DEFAULT_CHINESE_LIST) { - if (charSets.get(enc) != null) list.add(enc); + if (charSets.get(enc) != null) list.add(enc); } } else if (lang.equals(Locale.KOREAN)) { for (String enc : ENCODING_DEFAULT_KOREAN_LIST) { - if (charSets.get(enc) != null) list.add(enc); + if (charSets.get(enc) != null) list.add(enc); } } else { for (String enc : ENCODING_DEFAULT_OTHER_LIST) { - if (charSets.get(enc) != null) list.add(enc); + if (charSets.get(enc) != null) list.add(enc); } } return Collections.unmodifiableList(list); @@ -100,10 +101,10 @@ public boolean isLineWrap() { public void setLineWrap(boolean lineWrap) { this.lineWrap = lineWrap; } - + @Expose private int dispayMaxLength = 10000000; - + public int getDispayMaxLength() { return this.dispayMaxLength; } @@ -111,7 +112,7 @@ public int getDispayMaxLength() { public void setDispayMaxLength(int dispayMaxLength) { this.dispayMaxLength = dispayMaxLength; } - + // non Expose private boolean clipbordAutoDecode = true; @@ -138,24 +139,25 @@ public List getEncodingList() { public enum UniversalView { GENERATE_POC, HTML_COMMENT, JSON, JSONP, JWT, VIEW_STATE, JRAW, JPARAM; - public static UniversalView parseValue(String value) { - UniversalView eval = (UniversalView) ConvertUtil.parseEnumValue(UniversalView.class, value); - if (eval == null) { - return null; - } else { - return eval; - } + public static UniversalView parseEnum(String s) { + String value = s.toUpperCase(); + return Enum.valueOf(UniversalView.class, value); } - private static final Pattern ENUM_SPLIT = Pattern.compile("\\w+"); - - public static EnumSet enumSetValueOf(String s) { - EnumSet values = EnumSet.noneOf(UniversalView.class); - Matcher m = ENUM_SPLIT.matcher(s.toUpperCase()); - while (m.find()) { - values.add((UniversalView) ConvertUtil.parseEnumValue(UniversalView.class, m.group())); + public static EnumSet parseEnumSet(String s) { + EnumSet universal = EnumSet.noneOf(UniversalView.class); + if (!s.startsWith("[") && s.endsWith("]")) { + throw new IllegalArgumentException("No enum constant " + UniversalView.class.getCanonicalName() + "." + s); + } + String content = s.substring(1, s.length() - 1).trim(); + if (content.isEmpty()) { + return universal; + } + for (String t : content.split(",")) { + String v = t.trim(); + universal.add(parseEnum(v.replaceAll("\"", ""))); } - return values; + return universal; } @Override @@ -167,7 +169,7 @@ public String toString() { }; @Expose - private EnumSet mesageView = EnumSet.of(UniversalView.GENERATE_POC, UniversalView.HTML_COMMENT, UniversalView.JSON); + private EnumSet mesageView = EnumSet.of(UniversalView.GENERATE_POC, UniversalView.HTML_COMMENT, UniversalView.JSON, UniversalView.JSONP); public EnumSet getMessageView() { return mesageView; diff --git a/src/main/java/yagura/view/JSearchTab.java b/src/main/java/yagura/view/JSearchTab.java index b32e217d..4bbe4555 100644 --- a/src/main/java/yagura/view/JSearchTab.java +++ b/src/main/java/yagura/view/JSearchTab.java @@ -479,7 +479,7 @@ public void keyPressed(KeyEvent ke) { } }); - // # + // # this.cmbColor.setMaximumRowCount(10); this.cmbColor.setRenderer(this.colorComboBoxRenderer); this.cmbColor.addItem(""); // nonselect @@ -496,12 +496,12 @@ public void keyPressed(KeyEvent ke) { TableColumn colorColumn = this.tableResult.getColumnModel().getColumn(1); colorColumn.setCellEditor(new DefaultCellEditor(this.cmbColor)); - // Data + // Data this.tableResult.getColumnModel().getColumn(0).setMinWidth(0); this.tableResult.getColumnModel().getColumn(0).setPreferredWidth(0); this.tableResult.getColumnModel().getColumn(0).setMaxWidth(0); - // # + // # this.tableResult.getColumnModel().getColumn(1).setMinWidth(20); this.tableResult.getColumnModel().getColumn(1).setPreferredWidth(60); this.tableResult.getColumnModel().getColumn(1).setMaxWidth(80); @@ -697,7 +697,7 @@ private boolean isValidRegex(String text) { Pattern p = TransUtil.compileRegex(text, searchProp.isSmartMatch(), searchProp.isRegexp(), searchProp.isIgnoreCase()); IHttpRequestResponse messageInfo[] = BurpExtender.getCallbacks().getProxyHistory(); - try { + try { this.lblProgress.setText(String.format(SEARCH_PROGRESS, 0.0)); for (int i = 0; i < messageInfo.length; i++) { HttpMessageItem item = new HttpMessageItem(messageInfo[i], i); @@ -869,6 +869,6 @@ public void setLineWrap(boolean lineWrap) { this.tabMessageView.setRequestLineWrap(lineWrap); this.tabMessageView.setResponseLineWrap(lineWrap); } - - + + } diff --git a/src/test/java/aspx/viewstate/ViewStateTest.java b/src/test/java/aspx/viewstate/ViewStateTest.java deleted file mode 100644 index be7da62e..00000000 --- a/src/test/java/aspx/viewstate/ViewStateTest.java +++ /dev/null @@ -1,126 +0,0 @@ -package aspx.viewstate; - -import extension.helpers.StringUtil; -import extension.helpers.json.JsonUtil; -import java.nio.charset.StandardCharsets; -import java.util.Base64; -import org.junit.After; -import org.junit.AfterClass; -import static org.junit.Assert.fail; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; - -/** - * - * @author isayan - */ -public class ViewStateTest { - - public ViewStateTest() { - } - - @BeforeClass - public static void setUpClass() { - } - - @AfterClass - public static void tearDownClass() { - } - - @Before - public void setUp() { - } - - @After - public void tearDown() { - } - - /** - * Test of parse method, of class ViewStatePaser. - */ - @Test - public void testParser() { - System.out.println("Parser"); - System.out.println("Testcase1"); - { - String viewState = "/wFn"; - ViewStateParser instance = new ViewStateParser(); - ViewState result = instance.parse(viewState); - System.out.println(JsonUtil.prettyJson(result.toJson(), true)); - - } - System.out.println("Testcase2"); - { - String viewState = "/wECiAE="; - ViewStateParser instance = new ViewStateParser(); - ViewState result = instance.parse(viewState); - System.out.println(JsonUtil.prettyJson(result.toJson(), true)); - } - System.out.println("Testcase3"); - { - byte[] bvs = new byte[]{(byte) 0xff, 0x01, 0x05, 0x0a, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a}; - String viewState = StringUtil.getStringUTF8(Base64.getEncoder().encode(bvs)); - ViewStateParser instance = new ViewStateParser(); - ViewState result = instance.parse(viewState); - System.out.println(JsonUtil.prettyJson(result.toJson(), true)); - } - System.out.println("Testcase4"); - { - byte[] bvs = new byte[]{(byte) 0xff, 0x01, 0x18, 0x02, 0x05, 0x1a, 0x05, 0x1b, 0x05, 0x1c, 0x05, 0x1d}; - String viewState = StringUtil.getStringUTF8(Base64.getEncoder().encode(bvs)); - System.out.println("VewState:" + viewState); - ViewStateParser instance = new ViewStateParser(); - ViewState result = instance.parse(viewState); - System.out.println(JsonUtil.prettyJson(result.toJson(), true)); - } - - } - - /** - * Test of ViewState method, of class ViewStatePaser. - */ - @Test - public void testViewState() { - System.out.println("ViewState"); - System.out.println("Parser01"); - { - String viewState = "/wEPDwUKLTM0MjUyMzM2OWRkmW75zyss5UROsLtrTEuOq7AGUDk="; - ViewStateParser instance = new ViewStateParser(); - ViewState result = instance.parse(viewState); - System.out.println(JsonUtil.prettyJson(result.toJson(), true)); - // assertEquals(expResult, result); - } - System.out.println("Parser02"); - { - String viewState = "/wEPDwUENTM4MWRkhsjF+62gWnhYUcEyuRwTHxGDVzA="; - ViewStateParser instance = new ViewStateParser(); - instance.setDetailMode(true); - ViewState result = instance.parse(viewState); - System.out.println(JsonUtil.prettyJson(result.toJson(), true)); - // assertEquals(expResult, result); - } - System.out.println("Parser03"); - { - String viewState = "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"; - ViewStateParser instance = new ViewStateParser(); - ViewState result = instance.parse(viewState); - System.out.println(JsonUtil.prettyJson(result.toJson(), true)); - } - - System.out.println("Parser04"); - { - try { - String viewState = "/wEPDwUENTM4MWRkhsjF+62gWnhYUcEyuRwTHxGDVzA=&__EVENT=xxxxx"; - ViewStateParser instance = new ViewStateParser(); - ViewState result = instance.parse(viewState); - System.out.println(JsonUtil.prettyJson(result.toJson(), true)); - fail(); - } catch (IllegalArgumentException ex) { - System.out.println(StringUtil.getStackTrace(ex)); - } - } - - } - -} diff --git a/src/test/java/extend/util/external/JsonUtilTest.java b/src/test/java/extend/util/external/JsonUtilTest.java deleted file mode 100644 index 71c54f03..00000000 --- a/src/test/java/extend/util/external/JsonUtilTest.java +++ /dev/null @@ -1,184 +0,0 @@ -package extend.util.external; - -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonSyntaxException; -import extension.helpers.json.JsonUtil; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import static org.junit.Assert.*; - -/** - * - * @author isayan - */ -public class JsonUtilTest { - - public JsonUtilTest() { - } - - @BeforeClass - public static void setUpClass() { - } - - @AfterClass - public static void tearDownClass() { - } - - @Before - public void setUp() { - } - - @After - public void tearDown() { - } - - /** - * Test of stringify method, of class JsonUtil. - */ - @Test - public void testStringify() { - System.out.println("stringify"); - JsonObject jsonObject = new JsonObject(); - jsonObject.addProperty("abc", 123); - jsonObject.addProperty("def", "test"); - String expResult = "{\"abc\":123,\"def\":\"test\"}"; - String result = JsonUtil.stringify(jsonObject); - assertEquals(expResult, result); - } - - /** - * Test of parse method, of class JsonUtil. - */ - @Test - public void testParse() { - System.out.println("parse"); - String jsonElementString = "{ \n \"abc\": 123, \n \"def\": \"test\" }"; - JsonElement result = JsonUtil.parse(jsonElementString); - assertEquals(true, result.isJsonObject()); - assertEquals(true, result.getAsJsonObject().has("abc")); - assertEquals(false, result.getAsJsonObject().has("xyz")); - } - - /** - * Test of prettyJson method, of class JsonUtil. - */ - @Test - public void testPrettyJSON_String_boolean() { - System.out.println("prettyJSON"); - { - String jsonElementString = "{ \n \"abc\": 123, \n \"def\": \"test\" }"; - boolean pretty = false; - String expResult = "{\"abc\":123,\"def\":\"test\"}"; - String result = JsonUtil.prettyJson(jsonElementString, pretty); - assertEquals(expResult, result); - } - { - try { - String jsonElementString = "test"; - boolean pretty = false; - String expResult = "{\"abc\":123,\"def\":\"test\"}"; - String result = JsonUtil.prettyJson(jsonElementString, pretty); - fail(); - } catch (JsonSyntaxException ex) { - assertTrue(true); - } - } - } - - /** - * Test of prettyJson method, of class JsonUtil. - */ - @Test - public void testPrettyJSON_JsonElement_boolean() { - System.out.println("prettyJSON"); - JsonObject jsonObject = new JsonObject(); - jsonObject.addProperty("abc", 123); - jsonObject.addProperty("def", "test"); - boolean pretty = false; - String expResult = "{\"abc\":123,\"def\":\"test\"}"; - String result = JsonUtil.prettyJson(jsonObject, pretty); - assertEquals(expResult, result); - } - - @Test - public void testisJson() { - System.out.println("isJson"); - { - String json = "{\"abc\":123,\"def\":\"test\"}"; - boolean result = JsonUtil.isJson(json); - assertEquals(true, result); - } - { - String json = "{ \n \"abc\": 123, \n \"def\": \"test\" }"; - boolean result = JsonUtil.isJson(json); - assertEquals(true, result); - } - { - String json = "[\"abc\",\"def\",\"ghi\"]"; - boolean result = JsonUtil.isJson(json); - assertEquals(true, result); - } - { - String json = "[\n \"abc\",\"def\",\"ghi\" \n]"; - boolean result = JsonUtil.isJson(json); - assertEquals(true, result); - } - } - - @Test - public void testisJsonp() { - System.out.println("isJsonp"); - { - String json = "{\"abc\":123,\"def\":\"test\"}"; - boolean result = JsonUtil.isJsonp(json); - assertEquals(false, result); - } - - { - String json = "[\"abc\",\"def\",\"ghi\"]"; - boolean result = JsonUtil.isJsonp(json); - assertEquals(false, result); - } - - { - String json = "callback({ \"abc\": 123, \"def\": \"test\" });"; - boolean result = JsonUtil.isJsonp(json); - assertEquals(true, result); - } - - { - String json = "_callback({ \"abc\": 123, \"def\": \"test\" });"; - boolean result = JsonUtil.isJsonp(json); - assertEquals(true, result); - } - - { - String json = " callback ({ \"abc\": 123, \"def\": \"test\" });"; - boolean result = JsonUtil.isJsonp(json); - assertEquals(true, result); - } - - { - String json = "window.open({ \"abc\": 123, \"def\": \"test\" });"; - boolean result = JsonUtil.isJsonp(json); - assertEquals(true, result); - } - - { - String json = "$_({ \"abc\": 123, \"def\": \"test\" });"; - boolean result = JsonUtil.isJsonp(json); - assertEquals(true, result); - } - { - String json = "callback([\"abc\",\"def\",\"ghi\"])"; - boolean result = JsonUtil.isJsonp(json); - assertEquals(true, result); - } - - } - -} diff --git a/src/test/java/extend/util/external/JsonpElementTest.java b/src/test/java/extend/util/external/JsonpElementTest.java deleted file mode 100644 index 5400b3ab..00000000 --- a/src/test/java/extend/util/external/JsonpElementTest.java +++ /dev/null @@ -1,159 +0,0 @@ -package extend.util.external; - -import com.google.gson.JsonSyntaxException; -import extension.helpers.json.JsonpElement; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import static org.junit.Assert.*; - -/** - * - * @author isayan - */ -public class JsonpElementTest { - - public JsonpElementTest() { - } - - @BeforeClass - public static void setUpClass() { - } - - @AfterClass - public static void tearDownClass() { - } - - @Before - public void setUp() { - } - - @After - public void tearDown() { - } - - /** - * Test of parseJsonp method, of class JsonpElement. - */ - @Test - public void testParseJsonp() { - System.out.println("parseJsonp"); - { - String json = "{\"abc\":123,\"def\":\"test\"}"; - try { - JsonpElement jsonp = JsonpElement.parseJsonp(json); - assertTrue(false); - } - catch (JsonSyntaxException ex) { - assertTrue(true); - } - } - - { - String json = "[\"abc\",\"def\",\"ghi\"]"; - try { - JsonpElement jsonp = JsonpElement.parseJsonp(json); - assertTrue(false); - } - catch (JsonSyntaxException ex) { - assertTrue(true); - } - } - - { - String json = "callback({ \"abc\": 123, \"def\": \"test\" });"; - try { - JsonpElement jsonp = JsonpElement.parseJsonp(json); - assertEquals("callback", jsonp.getCallbackName()); - assertEquals(json, jsonp.getRaw()); - } - catch (JsonSyntaxException ex) { - fail(); - } - } - - { - String json = "_callback({ \"abc\": 123, \"def\": \"test\" });"; - try { - JsonpElement jsonp = JsonpElement.parseJsonp(json); - assertEquals("_callback", jsonp.getCallbackName()); - assertEquals(json, jsonp.getRaw()); - } - catch (JsonSyntaxException ex) { - fail(); - } - } - - { - String json = " callback ({ \"abc\": 123, \"def\": \"test\" });"; - try { - JsonpElement jsonp = JsonpElement.parseJsonp(json); - assertEquals("callback", jsonp.getCallbackName()); - assertEquals(json, jsonp.getRaw()); - } - catch (JsonSyntaxException ex) { - fail(); - } - } - - { - String json = "window.open({ \"abc\": 123, \"def\": \"test\" });"; - try { - JsonpElement jsonp = JsonpElement.parseJsonp(json); - assertEquals("window.open", jsonp.getCallbackName()); - assertEquals(json, jsonp.getRaw()); - } - catch (JsonSyntaxException ex) { - fail(); - } - } - - { - String json = "$_({ \"abc\": 123, \"def\": \"test\" });"; - try { - JsonpElement jsonp = JsonpElement.parseJsonp(json); - assertEquals("$_", jsonp.getCallbackName()); - assertEquals(json, jsonp.getRaw()); - } - catch (JsonSyntaxException ex) { - fail(); - } - } - { - String json = "callback([\"abc\",\"def\",\"ghi\"])"; - try { - JsonpElement jsonp = JsonpElement.parseJsonp(json); - assertEquals("callback", jsonp.getCallbackName()); - assertEquals(json, jsonp.getRaw()); - } - catch (JsonSyntaxException ex) { - fail(); - } - } - { - String json = "callback({\"inarray\":[\"abc\",\"def\",\"ghi\"]})"; - try { - JsonpElement jsonp = JsonpElement.parseJsonp(json); - assertEquals("callback", jsonp.getCallbackName()); - assertEquals(json, jsonp.getRaw()); - } - catch (JsonSyntaxException ex) { - fail(); - } - } - { - String json = "callback([{\"abc\":\"def\"},\"ghi\"])"; - try { - JsonpElement jsonp = JsonpElement.parseJsonp(json); - assertEquals("callback", jsonp.getCallbackName()); - assertEquals(json, jsonp.getRaw()); - } - catch (JsonSyntaxException ex) { - fail(); - } - } - } - -} diff --git a/src/test/java/yagura/model/StartEndPosionTest.java b/src/test/java/yagura/model/StartEndPosionTest.java new file mode 100644 index 00000000..2cd0571a --- /dev/null +++ b/src/test/java/yagura/model/StartEndPosionTest.java @@ -0,0 +1,73 @@ +package yagura.model; + +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import static org.junit.Assert.*; + +/** + * + * @author isayan + */ +public class StartEndPosionTest { + + public StartEndPosionTest() { + } + + @BeforeClass + public static void setUpClass() { + } + + @AfterClass + public static void tearDownClass() { + } + + @Before + public void setUp() { + } + + @After + public void tearDown() { + } + + /** + * Test of setPosision method, of class StartEndPosion. + */ + @Test + public void testStartEndPosision() { + System.out.println("testStartEndPosision"); + int s = 0; + int e = 1; + { + StartEndPosion instance = new StartEndPosion(s, e); + assertEquals(s, instance.getStartPos()); + assertEquals(e, instance.getEndPos()); + } + { + try { + StartEndPosion instance = new StartEndPosion(e, s); + fail(); + } catch (IllegalArgumentException ex) { + + } + } + } + + /** + * Test of getLength method, of class StartEndPosion. + */ + @Test + public void testGetLength() { + System.out.println("getLength"); + int s = 1; + int e = 2; + { + StartEndPosion instance = new StartEndPosion(s, e); + int result = instance.getLength(); + assertEquals(1, result); + } + } + +} diff --git a/src/test/java/yagura/model/UniversalViewPropertyTest.java b/src/test/java/yagura/model/UniversalViewPropertyTest.java new file mode 100644 index 00000000..f0406e9c --- /dev/null +++ b/src/test/java/yagura/model/UniversalViewPropertyTest.java @@ -0,0 +1,95 @@ +package yagura.model; + +import extension.burp.NotifyType; +import java.util.EnumSet; +import java.util.List; +import java.util.Locale; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import static org.junit.Assert.*; + +/** + * + * @author isayan + */ +public class UniversalViewPropertyTest { + + public UniversalViewPropertyTest() { + } + + @BeforeClass + public static void setUpClass() { + } + + @AfterClass + public static void tearDownClass() { + } + + @Before + public void setUp() { + } + + @After + public void tearDown() { + } + + /** + * Test of getDefaultEncodingList method, of class UniversalViewProperty. + */ + @Test + public void testGetDefaultEncodingList_0args() { + System.out.println("getDefaultEncodingList"); + List result = UniversalViewProperty.getDefaultEncodingList(); + assertTrue(result.size() > 0); + } + + /** + * Test of getDefaultEncodingList method, of class UniversalViewProperty. + */ + @Test + public void testGetDefaultEncodingList_Locale() { + System.out.println("getDefaultEncodingList"); + List result = UniversalViewProperty.getDefaultEncodingList(Locale.JAPANESE); + assertTrue(result.size() > 0); + } + + /** + * Test of getEncodingList method, of class UniversalViewProperty. + */ + @Test + public void testGetEncodingList() { + System.out.println("getEncodingList"); + UniversalViewProperty instance = new UniversalViewProperty(); + List result = instance.getEncodingList(); + assertTrue(result.size() > 0); + } + + + /** + * Test of parseEnum method, of class NotifyType. + */ + @Test + public void testParseEnum() { + System.out.println("parseEnum"); + String s = "GENERATE_POC"; + UniversalViewProperty.UniversalView expResult = UniversalViewProperty.UniversalView.GENERATE_POC; + UniversalViewProperty.UniversalView result = UniversalViewProperty.UniversalView.parseEnum(s); + assertEquals(expResult, result); + } + + /** + * Test of parseEnumSet method, of class NotifyType. + */ + @Test + public void testParseEnumSet() { + System.out.println("parseEnumSet"); + String s = "[\"GENERATE_POC\",\"HTML_COMMENT\",\"JSON\"]"; + EnumSet expResult = EnumSet.of(UniversalViewProperty.UniversalView.GENERATE_POC, UniversalViewProperty.UniversalView.HTML_COMMENT, UniversalViewProperty.UniversalView.JSON); + EnumSet result = UniversalViewProperty.UniversalView.parseEnumSet(s); + assertEquals(expResult, result); + } + +}