Skip to content

Commit

Permalink
SmartCodec修正
Browse files Browse the repository at this point in the history
  • Loading branch information
isayan committed Feb 13, 2024
1 parent 37cced1 commit 6002b27
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 26 deletions.
Binary file not shown.
Binary file modified release/YaguraExtension-v3.0.jar
Binary file not shown.
7 changes: 5 additions & 2 deletions src/main/java/extend/util/external/TransUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public static Pattern getEncodeTypePattern(EncodeType type) {
}

public enum EncodePattern {
NONE, BASE64, BASE64_URLSAFE, BASE64_MIME, BASE32, BASE16, UUENCODE, QUOTEDPRINTABLE, PUNYCODE, URL_STANDARD, HTML, BYTE_HTML, URL_UNICODE, UNICODE, UNICODE2, BYTE_HEX, BYTE_HEX1, BYTE_HEX2, BYTE_OCT, GZIP, ZLIB, ZLIB_NOWRAP, UTF7, UTF8_ILL, C_LANG, JSON, SQL_LANG, REGEX,
NONE, BASE64, BASE64_URLSAFE, BASE64_MIME, BASE32, BASE16, UUENCODE, QUOTEDPRINTABLE, PUNYCODE, URL_STANDARD, HTML, HTML_UNICODE, HTML_BYTE, URL_UNICODE, UNICODE, UNICODE2, BYTE_HEX, BYTE_HEX1, BYTE_HEX2, BYTE_OCT, GZIP, ZLIB, ZLIB_NOWRAP, UTF7, UTF8_ILL, C_LANG, JSON, SQL_LANG, REGEX,
};

// private final static Pattern PTN_URLENCODE = Pattern.compile("(%[0-9a-fA-F][0-9a-fA-F]|[0-9a-zA-Z\\*_\\+\\.-])+");
Expand Down Expand Up @@ -389,7 +389,10 @@ public static String toSmartDecode(String value, TransUtil.EncodePattern encodeP
case HTML:
decode = SmartCodec.toHtmlDecode(value, SmartCodec.ENCODE_PATTERN_ALL);
break;
case BYTE_HTML: {
case HTML_UNICODE:
decode = SmartCodec.toHtmlUnicodeDecode(value, SmartCodec.ENCODE_PATTERN_ALL);
break;
case HTML_BYTE: {
String guessCode = (charset == null) ? HttpUtil.getUniversalGuessCode(StringUtil.getBytesRaw(SmartCodec.toHtmlDecode(value, StandardCharsets.ISO_8859_1.name()))) : charset;
if (guessCode != null) {
applyCharset = guessCode;
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/yagura/model/SendToServer.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package yagura.model;

import burp.BurpExtender;
import burp.BurpExtension;
import burp.api.montoya.core.ByteArray;
import burp.api.montoya.core.HighlightColor;
Expand Down Expand Up @@ -614,10 +613,10 @@ public String getSendToParameter(SendToParameterType type, HttpRequestResponse m
String body = wrapResponse.getBodyString(true, StandardCharsets.ISO_8859_1.name());
value = HttpUtil.extractHTMLTitle(body);
if (value != null) {
value = SmartCodec.toHtmlDecode(value, wrapResponse.getGuessCharset(StandardCharsets.ISO_8859_1.name()));
value = SmartCodec.toHtmlUnicodeDecode(value);
}
} catch (UnsupportedEncodingException ex) {
logger.log(Level.SEVERE, null, ex);
logger.log(Level.SEVERE, ex.getMessage(), ex);
}
}
break;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/yagura/view/JTransCoderTab.form
Original file line number Diff line number Diff line change
Expand Up @@ -299,15 +299,15 @@
<Property name="rows" type="int" value="1"/>
</Layout>
<SubComponents>
<Component class="javax.swing.JRadioButton" name="rdoHtmlHex">
<Component class="javax.swing.JRadioButton" name="rdoHtmlUnicode">
<Properties>
<Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
<ComponentRef name="rdoEncodeDecodeGrp"/>
</Property>
<Property name="text" type="java.lang.String" value="&amp;#xhh;(unicode)"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="rdoHtmlHexActionPerformed"/>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="rdoHtmlUnicodeActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JRadioButton" name="rdoHtmlByteHex">
Expand Down
28 changes: 14 additions & 14 deletions src/main/java/yagura/view/JTransCoderTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ private void initComponents() {
rdoHtml = new javax.swing.JRadioButton();
rdoHtmlDec = new javax.swing.JRadioButton();
pnlHtmlHex = new javax.swing.JPanel();
rdoHtmlHex = new javax.swing.JRadioButton();
rdoHtmlUnicode = new javax.swing.JRadioButton();
rdoHtmlByteHex = new javax.swing.JRadioButton();
pnlJSUnicodeEnc = new javax.swing.JPanel();
rdoUnicodeHex = new javax.swing.JRadioButton();
Expand Down Expand Up @@ -794,14 +794,14 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {

pnlHtmlHex.setLayout(new java.awt.GridLayout(1, 2));

rdoEncodeDecodeGrp.add(rdoHtmlHex);
rdoHtmlHex.setText("&#xhh;(unicode)");
rdoHtmlHex.addActionListener(new java.awt.event.ActionListener() {
rdoEncodeDecodeGrp.add(rdoHtmlUnicode);
rdoHtmlUnicode.setText("&#xhh;(unicode)");
rdoHtmlUnicode.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
rdoHtmlHexActionPerformed(evt);
rdoHtmlUnicodeActionPerformed(evt);
}
});
pnlHtmlHex.add(rdoHtmlHex);
pnlHtmlHex.add(rdoHtmlUnicode);

rdoEncodeDecodeGrp.add(rdoHtmlByteHex);
rdoHtmlByteHex.setText("&#xhh;(byte)");
Expand Down Expand Up @@ -2601,8 +2601,8 @@ private void btnEncodeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIR
encode = TransUtil.toByteOctEncode(value, this.getSelectEncode(), TransUtil.getEncodeTypePattern(this.getEncodeType()));
} else if (this.rdoHtmlDec.isSelected()) {
encode = SmartCodec.toHtmlDecEncode(value, TransUtil.getEncodeTypePattern(this.getEncodeType()));
} else if (this.rdoHtmlHex.isSelected()) {
encode = SmartCodec.toHtmlHexEncode(value, TransUtil.getEncodeTypePattern(this.getEncodeType()), this.rdoUpperCase.isSelected());
} else if (this.rdoHtmlUnicode.isSelected()) {
encode = SmartCodec.toHtmlUnicodeEncode(value, TransUtil.getEncodeTypePattern(this.getEncodeType()), this.rdoUpperCase.isSelected());
} else if (this.rdoHtmlByteHex.isSelected()) {
encode = SmartCodec.toHtmlByteHexEncode(value, this.getSelectEncode(), TransUtil.getEncodeTypePattern(this.getEncodeType()), this.rdoUpperCase.isSelected());
} else if (this.rdoGzip.isSelected()) {
Expand Down Expand Up @@ -2678,9 +2678,9 @@ private void btnDecodeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIR
} else if (this.rdoHtmlDec.isSelected()) {
encodePattern = TransUtil.EncodePattern.HTML;
} else if (this.rdoHtmlByteHex.isSelected()) {
encodePattern = TransUtil.EncodePattern.BYTE_HTML;
} else if (this.rdoHtmlHex.isSelected()) {
encodePattern = TransUtil.EncodePattern.HTML;
encodePattern = TransUtil.EncodePattern.HTML_BYTE;
} else if (this.rdoHtmlUnicode.isSelected()) {
encodePattern = TransUtil.EncodePattern.HTML_UNICODE;
} else if (this.rdoGzip.isSelected()) {
encodePattern = TransUtil.EncodePattern.GZIP;
} else if (this.rdoZLIB.isSelected()) {
Expand Down Expand Up @@ -3115,9 +3115,9 @@ private void btnOutputCopyActionPerformed(java.awt.event.ActionEvent evt) {//GEN
SwingUtil.systemClipboardCopy(this.txtOutputRaw.getText());
}//GEN-LAST:event_btnOutputCopyActionPerformed

private void rdoHtmlHexActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdoHtmlHexActionPerformed
private void rdoHtmlUnicodeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdoHtmlUnicodeActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_rdoHtmlHexActionPerformed
}//GEN-LAST:event_rdoHtmlUnicodeActionPerformed

private void rdoHtmlByteHexActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdoHtmlByteHexActionPerformed
// TODO add your handling code here:
Expand Down Expand Up @@ -3788,7 +3788,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
private javax.swing.JRadioButton rdoHtml;
private javax.swing.JRadioButton rdoHtmlByteHex;
private javax.swing.JRadioButton rdoHtmlDec;
private javax.swing.JRadioButton rdoHtmlHex;
private javax.swing.JRadioButton rdoHtmlUnicode;
private javax.swing.JRadioButton rdoILLUTF8;
private javax.swing.JRadioButton rdoJSON;
private javax.swing.JRadioButton rdoLF;
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/yagura/view/ResultFilterDlg.java
Original file line number Diff line number Diff line change
Expand Up @@ -683,13 +683,13 @@ public static void main(String args[]) {
}
}
} catch (ClassNotFoundException ex) {
logger.log(java.util.logging.Level.SEVERE, null, ex);
logger.log(java.util.logging.Level.SEVERE, ex.getMessage(), ex);
} catch (InstantiationException ex) {
logger.log(java.util.logging.Level.SEVERE, null, ex);
logger.log(java.util.logging.Level.SEVERE, ex.getMessage(), ex);
} catch (IllegalAccessException ex) {
logger.log(java.util.logging.Level.SEVERE, null, ex);
logger.log(java.util.logging.Level.SEVERE, ex.getMessage(), ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
logger.log(java.util.logging.Level.SEVERE, null, ex);
logger.log(java.util.logging.Level.SEVERE, ex.getMessage(), ex);
}
//</editor-fold>
//</editor-fold>
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/yagura/model/okHttpClientTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ public void testSendtoProxy() {
}
}
} catch (NoSuchAlgorithmException | KeyManagementException ex) {
logger.log(Level.SEVERE, null, ex);
logger.log(Level.SEVERE, ex.getMessage(), ex);
}

}
Expand Down

0 comments on commit 6002b27

Please sign in to comment.