Skip to content

Commit

Permalink
Update Util.java
Browse files Browse the repository at this point in the history
  • Loading branch information
f0ng authored Dec 14, 2022
1 parent e2b2d5f commit c5dbff9
Showing 1 changed file with 23 additions and 12 deletions.
35 changes: 23 additions & 12 deletions src/main/java/utils/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,13 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.Base64;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import static burp.BurpExtender.stdout;

// import sun.misc.BASE64Decoder;
// import sun.misc.BASE64Encoder;
//import java.util.Base64.Decoder;
Expand All @@ -41,8 +44,10 @@ public static String getBanner(String extName,String version){
+ "[*] ###################################################\n"
+ "[*] modifier: f0ng\n"
+ "[*] github: http://github.com/f0ng/captcha-killer-modified\n"
+ "[!] Install " + extName + " successful!\n"
+ "[*] Please enjoy it ^_^\n"
+ "[!] Install " + extName + " successful!\n"
+ "[*] Please enjoy it ^_^\n"
+ "[*] use `@captcha@` replace captcha\n"
+ "[*] use `@captcha-killer-modified@` replace captcha's token\n"
+ "[*] ";
return bannerInfo;
}
Expand Down Expand Up @@ -73,24 +78,25 @@ public static boolean isImage(String str_img,String words) throws IOException {
}

public static boolean isImage(String str_img) throws IOException {
System.out.println(str_img);
// System.out.println(str_img);
String pattern = "(data:image.*?)[\"|&]|(data%2Aimage.*?)[\"|&]";
str_img = str_img.replace("\\r\\n","").replace("\\","");
System.out.println(str_img);
// System.out.println(str_img);
str_img = URLDecoder.decode(str_img,"utf-8");
Pattern r = Pattern.compile(pattern);
Matcher m = r.matcher(str_img);
if (m.find( )) {
str_img = m.group(0).replace("\"","").replace("&","").replace("Base64:","").replace("base64:","") ;
str_img = m.group(0).replace("\"","").replace("&","").replace("Base64:","").replace("base64:","").replace(".","") ;
}
if (!str_img.contains("data:image")){
str_img = "data:image/jpeg;base64," + str_img;
}

stdout.println(str_img);
byte[] img = DatatypeConverter.parseBase64Binary(str_img.substring(str_img.indexOf(",") + 1));
boolean isImg = false;
InputStream buffin = new ByteArrayInputStream(img);
BufferedImage image = ImageIO.read(buffin);
System.out.println(image);
// System.out.println(image);
if(image == null){
isImg = false;
}else {
Expand All @@ -105,10 +111,11 @@ public static byte[] dataimgToimg(String str_img) throws IOException {
String pattern = "(data:image.*?)[\"|&]|(data%2Aimage.*?)[\"|&]";
str_img = str_img.replace("\\r\\n","").replace("\\","");
str_img = str_img.replace("\\n","");
str_img = URLDecoder.decode(str_img,"utf-8");
Pattern r = Pattern.compile(pattern);
Matcher m = r.matcher(str_img);
if (m.find( )) {
str_img = m.group(0).replace("\"","").replace("&","").replace("Base64:","").replace("base64:","") ;
str_img = m.group(0).replace("\"","").replace("&","").replace("Base64:","").replace("base64:","").replace(".","") ;
}
if (!str_img.contains("data:image")){
str_img = "data:image/jpeg;base64," + str_img;
Expand Down Expand Up @@ -145,15 +152,19 @@ public static byte[] dataimgToimg(String str_img,String words) throws IOExceptio

Pattern r = Pattern.compile(pattern);
Matcher m = r.matcher(str_img);
str_img = URLDecoder.decode(str_img,"utf-8");
if (m.find( )) {
stdout.println(m.group(0));
str_img = m.group(0).replace("\"","").replace(words,"").replace(":","").replace("&","").replace(",","") ;
}
if (!str_img.contains("data:image")){
str_img = "data:image/jpeg;base64," + str_img;
}

stdout.println(str_img);
//str_img = str_img;
System.out.println(str_img);
System.out.println(str_img.indexOf(","));
// System.out.println(str_img);
// System.out.println(str_img.indexOf(","));
byte[] img = DatatypeConverter.parseBase64Binary(str_img.substring(str_img.indexOf(",") + 1));
//InputStream buffin = new ByteArrayInputStream(img);
return img;
Expand Down Expand Up @@ -228,7 +239,7 @@ public static String URLEncode(String str) {
try {
result = java.net.URLEncoder.encode(str, "UTF-8");
} catch (UnsupportedEncodingException e) {
BurpExtender.stdout.println(e.getMessage());
stdout.println(e.getMessage());
}
return result;
}
Expand All @@ -241,7 +252,7 @@ public static String URLDecode(String str) {
try {
result = java.net.URLDecoder.decode(str, "UTF-8");
} catch (UnsupportedEncodingException e) {
BurpExtender.stdout.println(e.getMessage());
stdout.println(e.getMessage());
}
return result;
}
Expand Down

0 comments on commit c5dbff9

Please sign in to comment.