Skip to content

Commit d7cd6fb

Browse files
committed
感谢whami-root提交的pr,1、增加自定义请求头、post参数。2、优化post型shiro的探测和利用。
1 parent a426683 commit d7cd6fb

File tree

5 files changed

+253
-211
lines changed

5 files changed

+253
-211
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>org.example</groupId>
88
<artifactId>shiro_attack</artifactId>
9-
<version>4.5.3-SNAPSHOT</version>
9+
<version>4.5.4-SNAPSHOT</version>
1010
<build>
1111
<plugins>
1212
<plugin>

src/main/java/com/summersec/attack/UI/MainController.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ public class MainController {
4747
@FXML
4848
private ComboBox<String> methodOpt;
4949
@FXML
50+
private TextField globalHeader;
51+
@FXML
52+
private TextField post_data;
53+
@FXML
5054
private TextField shiroKeyWord;
5155
@FXML
5256
private TextField targetAddress;
@@ -209,8 +213,17 @@ public void initAttack() {
209213
String shiroKeyWordText = this.shiroKeyWord.getText();
210214
String targetAddressText = this.targetAddress.getText();
211215
String httpTimeoutText = this.httpTimeout.getText();
216+
//自定义请求头
217+
Map<String, String> myheader= new HashMap<>() ;
218+
if(!this.globalHeader.getText().equals("")) {
219+
String header[] = this.globalHeader.getText().split(":",2);
220+
// myheader(this.globalHeader.getText() -> this.globalHeader.getText().split(":"))
221+
myheader.put(header[0], header[1]);
222+
}
223+
// this.globalHeader = myheader
224+
String postData = (String)this.post_data.getText();
212225
String reqMethod = (String)this.methodOpt.getValue();
213-
this.attackService = new AttackService(reqMethod, targetAddressText, shiroKeyWordText, httpTimeoutText);
226+
this.attackService = new AttackService(reqMethod, targetAddressText, shiroKeyWordText, httpTimeoutText,myheader,postData);
214227
if (this.aesGcmOpt.isSelected()) {
215228
AttackService.aesGcmCipherType = 1;
216229
} else {
@@ -225,6 +238,7 @@ public void initContext() {
225238
}
226239

227240
public void initComBoBox() {
241+
// ObservableList<String> methods = FXCollections.observableArrayList(new String[]{"GET", "POST","复杂请求"});
228242
ObservableList<String> methods = FXCollections.observableArrayList(new String[]{"GET", "POST"});
229243
this.methodOpt.setPromptText("GET");
230244
this.methodOpt.setValue("GET");
@@ -294,8 +308,10 @@ private void initToolbar() {
294308
typeCombo.getSelectionModel().select(0);
295309
Label IPLabel = new Label("IP地址:");
296310
TextField IPText = new TextField();
311+
IPText.setText("127.0.0.1");
297312
Label PortLabel = new Label("端口:");
298313
TextField PortText = new TextField();
314+
PortText.setText("8080");
299315
Label userNameLabel = new Label("用户名:");
300316
TextField userNameText = new TextField();
301317
Label passwordLabel = new Label("密码:");

src/main/java/com/summersec/attack/core/AttackService.java

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
//
2-
// Source code recreated from a .class file by IntelliJ IDEA
3-
// (powered by Fernflower decompiler)
4-
//
51

62
package com.summersec.attack.core;
73

@@ -50,15 +46,19 @@ public class AttackService {
5046
public static String gadget = null;
5147
public static String realShiroKey = null;
5248
public static Map<String, String> globalHeader = null;
49+
public static String postData = null;
5350
private final MainController mainController;
5451
public int flagCount = 0;
5552

56-
public AttackService(String method, String url, String shiroKeyWord, String timeout) {
53+
public AttackService(String method, String url, String shiroKeyWord, String timeout, Map<String, String> globalHeader, String postData) {
5754
this.mainController = (MainController)ControllersFactory.controllers.get(MainController.class.getSimpleName());
5855
this.url = url;
5956
this.method = method;
6057
this.timeout = Integer.parseInt(timeout) * 1000;
6158
this.shiroKeyWord = shiroKeyWord;
59+
this.globalHeader = globalHeader;
60+
this.postData = postData;
61+
6262
}
6363

6464
public HashMap<String, String> getCombineHeaders(HashMap<String, String> header) {
@@ -78,15 +78,20 @@ public String headerHttpRequest(HashMap<String, String> header) {
7878
HashMap combineHeaders = this.getCombineHeaders(header);
7979
Proxy proxy = (Proxy)MainController.currentProxy.get("proxy");
8080
try {
81-
result = cn.hutool.http.HttpUtil.createRequest(Method.valueOf(this.method),this.url).setProxy(proxy).headerMap(combineHeaders,true).setFollowRedirects(false).execute().toString();
82-
if (result.contains("Host")){
81+
/* result = cn.hutool.http.HttpUtil.createRequest(Method.valueOf(this.method),this.url).setProxy(proxy).headerMap(combineHeaders,true).setFollowRedirects(false).execute().toString();
82+
return result;*/
83+
/* if (result.contains("Host")){
8384
return result;
84-
}
85+
}*/
8586
if (this.method.equals("GET")) {
86-
result = HttpUtil.getHeaderByHttpRequest(this.url, "UTF-8", combineHeaders, this.timeout);
87+
result = cn.hutool.http.HttpUtil.createRequest(Method.valueOf(this.method),this.url).setProxy(proxy).headerMap(combineHeaders,true).setFollowRedirects(false).execute().toString();
8788

8889
} else {
89-
result = HttpUtil.postHeaderByHttpRequest(this.url, "UTF-8", "", combineHeaders, this.timeout);
90+
// result = HttpUtil.postHeaderByHttpRequest(this.url, "UTF-8", this.postData, combineHeaders, this.timeout);
91+
// result = bodyHttpRequest(combineHeaders, this.postData);
92+
result = HttpUtil.postHttpReuest(this.url, this.postData, "UTF-8", combineHeaders, "application/x-www-form-urlencoded", this.timeout);
93+
System.out.println(result);
94+
9095
}
9196
} catch (Exception var5) {
9297
this.mainController.logTextArea.appendText(Utils.log(var5.getMessage()));

src/main/java/com/summersec/attack/utils/HttpUtil.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,9 @@ public static String httpRequestAddHeader(String requestUrl, int timeOut, String
246246
}
247247

248248
inputStream = ((URLConnection)httpUrlConn).getInputStream();
249-
result = readString(inputStream, encoding);
249+
// result = readString(inputStream, encoding);
250+
Map<String, List<String>> inputStreamHeaders = ((URLConnection)httpUrlConn).getHeaderFields();
251+
result = inputStreamHeaders.toString()+readString(inputStream, encoding);
250252
String var30 = result;
251253
return var30;
252254
} catch (IOException var23) {

0 commit comments

Comments
 (0)