Skip to content

Commit

Permalink
更换依赖包
Browse files Browse the repository at this point in the history
  • Loading branch information
bit4woo committed Apr 25, 2024
1 parent 8955a8b commit 9ff79d8
Show file tree
Hide file tree
Showing 26 changed files with 113 additions and 489 deletions.
7 changes: 4 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
<target>1.8</target>
<excludes>
<!-- 编译时排除Deprecated包及下面的资源 -->
<exclude>**/Deprecated/**</exclude>
<exclude>**/Requester/**</exclude>
<exclude>**/test/**</exclude>
</excludes>
Expand Down Expand Up @@ -81,11 +82,11 @@
<version>1.7.22</version>
</dependency>

<!-- https://github.com/bit4woo/burp-api-common -->
<!-- https://github.com/bit4woo/java_utilbox -->
<dependency>
<groupId>com.github.bit4woo</groupId>
<artifactId>burp-api-common</artifactId>
<version>master-SNAPSHOT</version>
<artifactId>java_utilbox</artifactId>
<version>main-SNAPSHOT</version>
</dependency>

<!-- https://mvnrepository.com/artifact/commons-codec/commons-codec <dependency>
Expand Down
2 changes: 1 addition & 1 deletion src/base/RequestTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
import java.net.MalformedURLException;
import java.net.URL;

import com.bit4woo.utilbox.burp.HelperPlus;
import com.github.kevinsawicki.http.HttpRequest;

import burp.BurpExtender;
import burp.HelperPlus;
import burp.IBurpExtenderCallbacks;
import burp.IHttpRequestResponse;
import burp.IHttpService;
Expand Down
18 changes: 15 additions & 3 deletions src/burp/BurpExtender.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import javax.swing.JMenu;
import javax.swing.JMenuItem;

import com.bit4woo.utilbox.burp.HelperPlus;
import com.google.gson.Gson;

import config.ConfigManager;
Expand Down Expand Up @@ -48,11 +49,15 @@ public class BurpExtender extends GUI implements IBurpExtender, IContextMenuFact
private static final long serialVersionUID = 1L;

public static IBurpExtenderCallbacks callbacks;
public IExtensionHelpers helpers;
public static IExtensionHelpers helpers;
private static HelperPlus helperPlus;


public static PrintWriter stdout;
public static PrintWriter stderr;
public IContextMenuInvocation invocation;


public static String ExtensionName = "Knife";
public static String Version = bsh.This.class.getPackage().getImplementationVersion();
public static String Author = "by bit4woo";
Expand All @@ -63,7 +68,9 @@ public class BurpExtender extends GUI implements IBurpExtender, IContextMenuFact
@Override
public void registerExtenderCallbacks(IBurpExtenderCallbacks callbacks) {
BurpExtender.callbacks = callbacks;
this.helpers = callbacks.getHelpers();
BurpExtender.helpers = callbacks.getHelpers();
BurpExtender.helperPlus = new HelperPlus(helpers);

flushStd();
BurpExtender.stdout.println(getFullExtensionName());
BurpExtender.stdout.println(github);
Expand Down Expand Up @@ -265,7 +272,12 @@ public static IBurpExtenderCallbacks getCallbacks() {
}


public static boolean isInCheckBoxScope(int toolFlag, IHttpRequestResponse messageInfo) {
public static HelperPlus getHelperPlus() {
return helperPlus;
}


public static boolean isInCheckBoxScope(int toolFlag, IHttpRequestResponse messageInfo) {
if (toolFlag == (toolFlag & configManager.getEnableStatus())) {

IExtensionHelpers helpers = getCallbacks().getHelpers();
Expand Down
2 changes: 2 additions & 0 deletions src/burp/RobotInput.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import java.awt.datatransfer.Transferable;
import java.awt.event.KeyEvent;

import com.bit4woo.utilbox.utils.SystemUtils;

//https://bbs.51cto.com/thread-1097189-1.html
public class RobotInput extends Robot {

Expand Down
23 changes: 15 additions & 8 deletions src/config/ConfigEntry.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package config;

import burp.*;
import com.google.gson.Gson;
import org.apache.commons.lang3.StringUtils;
import runcmd.MessagePart;
import static burp.BurpExtender.isInCheckBoxScope;
import static runcmd.MessagePart.getValueByPartType;

import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
Expand All @@ -12,8 +10,17 @@
import java.util.List;
import java.util.regex.Pattern;

import static burp.BurpExtender.isInCheckBoxScope;
import static runcmd.MessagePart.getValueByPartType;
import org.apache.commons.lang3.StringUtils;

import com.bit4woo.utilbox.burp.HelperPlus;
import com.bit4woo.utilbox.utils.TextUtils;
import com.google.gson.Gson;

import burp.BurpExtender;
import burp.IBurpExtenderCallbacks;
import burp.IHttpRequestResponse;
import burp.IInterceptedProxyMessage;
import runcmd.MessagePart;

public class ConfigEntry {

Expand Down Expand Up @@ -250,8 +257,8 @@ public String[] listAllConfigType() {
}

public boolean isInRuleScope(int toolFlag, IHttpRequestResponse messageInfo) {
HelperPlus getter = new HelperPlus(BurpExtender.getCallbacks().getHelpers());
String baseUrl = HelperPlus.getShortURL(messageInfo).toString();
HelperPlus getter = BurpExtender.getHelperPlus();
String baseUrl = HelperPlus.getBaseURL(messageInfo).toString();
String url = getter.getFullURL(messageInfo).toString();
String host = HelperPlus.getHost(messageInfo);
String configkey = getKey();
Expand Down
18 changes: 10 additions & 8 deletions src/config/ProcessManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import burp.*;
import org.apache.commons.lang3.StringUtils;

import com.bit4woo.utilbox.burp.HelperPlus;

public class ProcessManager {

//////////////////////////////////////////common methods for cookie handle///////////////////////////////
Expand Down Expand Up @@ -44,21 +46,21 @@ public static IHttpRequestResponse[] Reverse(IHttpRequestResponse[] input) {
}

public static String getLatestHeaderFromHistory(IHttpRequestResponse messageInfo, String headerName) {
String sourceshorturl = HelperPlus.getShortURL(messageInfo).toString();
String sourceshorturl = HelperPlus.getBaseURL(messageInfo).toString();
return getLatestHeaderFromHistory(sourceshorturl, headerName);
}

public static String getLatestHeaderFromHistory(String shortUrl, String headerName) {
//还是草粉师傅说得对,直接从history里面拿最好

shortUrl = HelperPlus.removeDefaultPort(shortUrl);//url格式标准化,以保证后面比较的准确性。
shortUrl = HelperPlus.removeUrlDefaultPort(shortUrl);//url格式标准化,以保证后面比较的准确性。
IHttpRequestResponse[] historyMessages = BurpExtender.callbacks.getProxyHistory();
HelperPlus getter = new HelperPlus(BurpExtender.callbacks.getHelpers());

for (int i = historyMessages.length - 1; i >= 0; i--) {
IHttpRequestResponse historyMessage = historyMessages[i];
String hisShortUrl = HelperPlus.getShortURL(historyMessage).toString();
hisShortUrl = HelperPlus.removeDefaultPort(hisShortUrl);
String hisShortUrl = HelperPlus.getBaseURL(historyMessage).toString();
hisShortUrl = HelperPlus.removeUrlDefaultPort(hisShortUrl);
if (hisShortUrl.equalsIgnoreCase(shortUrl)) {
String headerLine = getter.getHeaderLine(true, historyMessage, headerName);
return headerLine;
Expand All @@ -77,14 +79,14 @@ public static String getLatestHeaderFromHistory(String shortUrl, String headerNa
public static String getLatestHeaderFromSiteMap(String shortUrl, String headerName) {
//还是草粉师傅说得对,直接从history里面拿最好

shortUrl = HelperPlus.removeDefaultPort(shortUrl);//url格式标准化,以保证后面比较的准确性。
shortUrl = HelperPlus.removeUrlDefaultPort(shortUrl);//url格式标准化,以保证后面比较的准确性。
IHttpRequestResponse[] historyMessages = BurpExtender.callbacks.getSiteMap(shortUrl);
HelperPlus getter = new HelperPlus(BurpExtender.callbacks.getHelpers());

for (int i = historyMessages.length - 1; i >= 0; i--) {
IHttpRequestResponse historyMessage = historyMessages[i];
String hisShortUrl = HelperPlus.getShortURL(historyMessage).toString();
hisShortUrl = HelperPlus.removeDefaultPort(hisShortUrl);
String hisShortUrl = HelperPlus.getBaseURL(historyMessage).toString();
hisShortUrl = HelperPlus.removeUrlDefaultPort(hisShortUrl);
if (hisShortUrl.equalsIgnoreCase(shortUrl)) {
String headerLine = getter.getHeaderLine(true, historyMessage, headerName);
return headerLine;
Expand Down Expand Up @@ -182,7 +184,7 @@ public static IHttpRequestResponse updateHeader(boolean messageIsRequest, IHttpR

public static void addHandleRule(IHttpRequestResponse[] messages, String headerLine) {
for (IHttpRequestResponse message : messages) {
String targetShortUrl = HelperPlus.getShortURL(message).toString();
String targetShortUrl = HelperPlus.getBaseURL(message).toString();
ConfigEntry rule = new ConfigEntry(targetShortUrl, headerLine, ConfigEntry.Action_If_Base_URL_Matches_Add_Or_Replace_Header, true);
delSameConditionRule(rule);
GUI.tableModel.addNewConfigEntry(rule);
Expand Down
5 changes: 3 additions & 2 deletions src/knife/AddHostToScopeMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@

import javax.swing.JMenuItem;

import com.bit4woo.utilbox.burp.HelperPlus;

import burp.BurpExtender;
import burp.HelperPlus;
import burp.IBurpExtenderCallbacks;
import burp.IContextMenuInvocation;
import burp.IExtensionHelpers;
Expand Down Expand Up @@ -47,7 +48,7 @@ public void actionPerformed(ActionEvent e)
try{
IHttpRequestResponse[] messages = invocation.getSelectedMessages();
for(IHttpRequestResponse message:messages) {
String url = HelperPlus.getShortURL(message.getHttpService());
String url = HelperPlus.getBaseURL(message.getHttpService());
URL shortUrl = new URL(url);
callbacks.includeInScope(shortUrl);
}
Expand Down
3 changes: 2 additions & 1 deletion src/knife/ChangeToUploadRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@

import javax.swing.JMenuItem;

import com.bit4woo.utilbox.burp.HelperPlus;

import burp.BurpExtender;
import burp.HelperPlus;
import burp.IHttpRequestResponse;

/**
Expand Down
11 changes: 5 additions & 6 deletions src/knife/ChunkedEncodingMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@

import javax.swing.JMenuItem;

import com.bit4woo.utilbox.burp.HelperPlus;

import burp.BurpExtender;
import burp.Getter;
import burp.IBurpExtenderCallbacks;
import burp.IContextMenuInvocation;
import burp.IExtensionHelpers;
Expand All @@ -23,13 +24,13 @@ public class ChunkedEncodingMenu extends JMenuItem {
//JMenuItem vs. JMenu
public BurpExtender burp;
public IContextMenuInvocation invocation;
public Getter getter;
public HelperPlus getter;
public ChunkedEncodingMenu(BurpExtender burp){

try {
this.invocation = burp.invocation;
this.burp = burp;
this.getter = new Getter(burp.helpers);
this.getter = new HelperPlus(burp.helpers);
IHttpRequestResponse[] messages = this.invocation.getSelectedMessages();
if (messages == null || messages.length == 0) {
return;
Expand Down Expand Up @@ -70,7 +71,7 @@ public void actionPerformed(ActionEvent event) {
IHttpRequestResponse[] selectedItems = invocation.getSelectedMessages();
IHttpRequestResponse messageInfo = selectedItems[0];

Getter getter = new Getter(helpers);
HelperPlus getter = new HelperPlus(helpers);

List<String> headers = getter.getHeaderList(true, messageInfo);
byte[] body = getter.getBody(true, messageInfo);
Expand Down Expand Up @@ -120,6 +121,4 @@ public void actionPerformed(ActionEvent event) {
selectedItems[0].setRequest(newRequestBytes);
}



}
5 changes: 3 additions & 2 deletions src/knife/CopyJsOfThisSite.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,16 @@
import javax.swing.JMenuItem;

import burp.BurpExtender;
import burp.HelperPlus;
import burp.IBurpExtenderCallbacks;
import burp.IContextMenuInvocation;
import burp.IExtensionHelpers;
import burp.IHttpRequestResponse;
import burp.SystemUtils;
import burp.Utils;
import org.apache.commons.lang3.StringUtils;

import com.bit4woo.utilbox.burp.HelperPlus;
import com.bit4woo.utilbox.utils.SystemUtils;


public class CopyJsOfThisSite extends JMenuItem {
/**
Expand Down
7 changes: 4 additions & 3 deletions src/knife/CustomPayloadForAllInsertpointMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
import org.json.JSONException;
import org.json.JSONObject;

import com.bit4woo.utilbox.burp.HelperPlus;

import burp.BurpExtender;
import burp.Getter;
import burp.IBurpExtenderCallbacks;
import burp.IContextMenuInvocation;
import burp.IExtensionHelpers;
Expand Down Expand Up @@ -88,8 +89,8 @@ public void actionPerformed(ActionEvent event) {
IHttpRequestResponse messageInfo = selectedItems[0];
byte[] newRequest = messageInfo.getRequest();//为了不影响原始request,通过final进行一次转换

Getter getter = new Getter(helpers);
List<IParameter> paras = getter.getParas(messageInfo);
HelperPlus getter = new HelperPlus(helpers);
List<IParameter> paras = getter.getParameters(messageInfo);

String charset = CharSetHelper.detectCharset(newRequest);
String xsspayload;
Expand Down
3 changes: 2 additions & 1 deletion src/knife/DoPortScanMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@

import javax.swing.JMenuItem;

import com.bit4woo.utilbox.utils.SystemUtils;

import burp.BurpExtender;
import burp.IBurpExtenderCallbacks;
import burp.IContextMenuInvocation;
import burp.IExtensionHelpers;
import burp.IHttpRequestResponse;
import burp.RobotInput;
import burp.SystemUtils;
import config.GUI;


Expand Down
9 changes: 5 additions & 4 deletions src/knife/DownloadResponseMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@

import org.apache.commons.io.FileUtils;

import com.bit4woo.utilbox.burp.HelperPlus;

import burp.BurpExtender;
import burp.Getter;
import burp.IBurpExtenderCallbacks;
import burp.IContextMenuInvocation;
import burp.IExtensionHelpers;
Expand Down Expand Up @@ -60,7 +61,7 @@ public void actionPerformed(ActionEvent event) {
public void run() {
try{
IHttpRequestResponse[] messages = invocation.getSelectedMessages();
Getter getter = new Getter(helpers);
HelperPlus getter = new HelperPlus(helpers);
if (messages == null) {
return;
}
Expand Down Expand Up @@ -154,11 +155,11 @@ public File selectPath() {
public File getFileName(IHttpRequestResponse message,File rootPath) throws IOException{
String canonicalFile = "KnifeSaved";
try {
Getter getter = new Getter(helpers);
HelperPlus getter = new HelperPlus(helpers);

String pathStr = null;
//1、从参数名中获取文件名称,任意文件读取多是这种情况
List<IParameter> paras = getter.getParas(message);
List<IParameter> paras = getter.getParameters(message);
for (IParameter para:paras) {
if (para.getType() == IParameter.PARAM_COOKIE) continue;
String value = para.getValue();
Expand Down
3 changes: 2 additions & 1 deletion src/knife/FindUrlAndRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
import base.RequestTask;
import base.RequestType;
import burp.*;
import org.apache.commons.lang3.StringUtils;

import com.bit4woo.utilbox.burp.HelperPlus;


public class FindUrlAndRequest extends JMenuItem {
Expand Down
Loading

0 comments on commit 9ff79d8

Please sign in to comment.