Skip to content

Commit 81b2fbe

Browse files
committed
chore(release): bump version to 1.8.51
- 同步后端和 Burp 插件 7 处版本号 - 更新 README 中英文变更日志 - 增加 SQLMap -r 参数 bug 的 Issue 报告文档
1 parent 0f478a0 commit 81b2fbe

11 files changed

Lines changed: 219 additions & 11 deletions

File tree

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<img src="https://img.shields.io/badge/Vue-3.x-green.svg" alt="Vue">
1010
<img src="https://img.shields.io/badge/FastAPI-0.100+-red.svg" alt="FastAPI">
1111
<img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="License">
12-
<img src="https://img.shields.io/badge/Version-1.8.50-orange.svg" alt="Version">
12+
<img src="https://img.shields.io/badge/Version-1.8.51-orange.svg" alt="Version">
1313
</p>
1414

1515
<p align="center">
@@ -292,6 +292,12 @@ sqlmapWebUI/
292292

293293
## 📝 更新日志
294294

295+
### v1.8.51 (2026-04-16)
296+
297+
**修复 (Burp 插件)**
298+
- 修复 Burp 插件生成的 HTTP 请求文件尾部多余空行导致 SQLMap `-r` 模式误将 GET 识别为 POST 的问题
299+
- 在 Montoya API 和 Legacy API 插件中增加尾部空行防御性清理逻辑
300+
295301
### v1.8.50 (2026-03-27)
296302

297303
**新功能 (VulnShop 靶场)**

README_EN.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<img src="https://img.shields.io/badge/Vue-3.x-green.svg" alt="Vue">
1010
<img src="https://img.shields.io/badge/FastAPI-0.100+-red.svg" alt="FastAPI">
1111
<img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="License">
12-
<img src="https://img.shields.io/badge/Version-1.8.49-orange.svg" alt="Version">
12+
<img src="https://img.shields.io/badge/Version-1.8.51-orange.svg" alt="Version">
1313
</p>
1414

1515
<p align="center">
@@ -292,6 +292,12 @@ Please read the [Disclaimer](DISCLAIMER.md) before use.
292292

293293
## 📝 Changelog
294294

295+
### v1.8.51 (2026-04-16)
296+
297+
**Fixes (Burp Plugin)**
298+
- Fixed SQLMap `-r` mode incorrectly treating GET as POST due to trailing newlines in HTTP request files generated by Burp plugins
299+
- Added defensive trailing newline cleanup logic in both Montoya API and Legacy API plugins
300+
295301
### v1.8.49 (2026-03-27)
296302

297303
**Documentation**
Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
# SQLMap `-r` 参数误识别 GET 请求为 POST 请求 —— GitHub Issue 报告
2+
3+
---
4+
5+
## Issue 标题
6+
7+
`-r` option incorrectly treats GET request as POST when request file contains trailing newlines
8+
9+
---
10+
11+
## 问题描述 / Description
12+
13+
When using SQLMap with the `-r` option to load an HTTP request from a file, if the request file contains **trailing newlines after the standard HTTP empty line** (i.e., more than one `\r\n` or `\n` at the end), SQLMap incorrectly interprets the request as a **POST request**, regardless of the actual HTTP method specified in the request line.
14+
15+
This behavior affects any HTTP method (GET, PUT, DELETE, etc.) when the request file is not strictly terminated after the single empty line that separates headers from the body.
16+
17+
A typical scenario where this bug is triggered: the original request is a POST (see "Original Request" below), but after editing it in Burp Repeater to change the method to GET and removing the body, the generated request file may still contain trailing newlines. SQLMap then incorrectly treats the edited GET request as POST.
18+
19+
---
20+
21+
## 复现步骤 / Steps to Reproduce
22+
23+
### Original Request (for context)
24+
25+
The original HTTP request before editing was a POST with a JSON body:
26+
27+
```http
28+
POST /api/user/login HTTP/1.1
29+
Host: 127.0.0.1:9527
30+
Content-Length: 37
31+
sec-ch-ua-platform: "Windows"
32+
Accept-Language: zh-CN,zh;q=0.9
33+
sec-ch-ua: "Chromium";v="145", "Not:A-Brand";v="99"
34+
Content-Type: application/json
35+
sec-ch-ua-mobile: ?0
36+
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36
37+
Accept: */*
38+
Origin: http://127.0.0.1:9527
39+
Sec-Fetch-Site: same-origin
40+
Sec-Fetch-Mode: cors
41+
Sec-Fetch-Dest: empty
42+
Referer: http://127.0.0.1:9527/
43+
Accept-Encoding: gzip, deflate, br
44+
Connection: keep-alive
45+
46+
{"username":"test","password":"test"}
47+
```
48+
49+
### Reproducible Request File
50+
51+
After editing the request in Burp Repeater (changing method to GET and removing the body), create a file `requests.txt` with the following content. Note that it ends with **two empty lines** instead of one:
52+
53+
```http
54+
GET /api/user/login HTTP/1.1
55+
Host: 127.0.0.1:9527
56+
Content-Length: 0
57+
sec-ch-ua-platform: "Windows"
58+
Accept-Language: zh-CN,zh;q=0.9
59+
sec-ch-ua: "Chromium";v="145", "Not:A-Brand";v="99"
60+
Content-Type: application/json
61+
sec-ch-ua-mobile: ?0
62+
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36
63+
Accept: */*
64+
Origin: http://127.0.0.1:9527
65+
Sec-Fetch-Site: same-origin
66+
Sec-Fetch-Mode: cors
67+
Sec-Fetch-Dest: empty
68+
Referer: http://127.0.0.1:9527/
69+
Accept-Encoding: gzip, deflate, br
70+
Connection: keep-alive
71+
72+
73+
```
74+
75+
> **Note:** The file ends with **two empty lines** instead of one. In other words, there are extra newline characters after the standard HTTP empty line.
76+
77+
Run SQLMap with the `-r` option:
78+
79+
```bash
80+
python sqlmap.py -r requests.txt --batch --level=1 --risk=1
81+
```
82+
83+
To verify the actual HTTP method sent by SQLMap, you can proxy the traffic through Burp Suite or any other intercepting proxy using the `--proxy` option:
84+
85+
```bash
86+
python sqlmap.py -r requests.txt --batch --level=1 --risk=1 --proxy=http://127.0.0.1:8080
87+
```
88+
89+
Observe that SQLMap treats this as a **POST request** and attempts to inject into the "body" parameters, even though the request method is explicitly `GET`.
90+
91+
---
92+
93+
## 预期行为 / Expected Behavior
94+
95+
SQLMap should respect the HTTP method specified in the request line (`GET` in this case) and should not incorrectly infer `POST` solely based on trailing newlines in the request file.
96+
97+
According to RFC 7230, the empty line (`CRLF CRLF`) marks the end of the header section. Any content **after** that empty line constitutes the message body. However, **trailing empty lines alone** (without actual body content) should not cause SQLMap to change the request method or assume the presence of a body.
98+
99+
---
100+
101+
## 实际行为 / Actual Behavior
102+
103+
SQLMap detects "content" after the first empty line (even if it's just additional newline characters) and proceeds to:
104+
- Treat the request as a **POST request**
105+
- Attempt to parse and inject into what it believes is the request body
106+
- Ignore or mishandle URL/query parameters that should be the actual injection targets
107+
108+
---
109+
110+
## 环境信息 / Environment
111+
112+
- **SQLMap version:** 1.10 (also affects 1.9.11.3 and likely earlier versions)
113+
- **Python version:** 3.10+
114+
- **OS:** Windows 10 (also reproducible on Windows 11 and Linux)
115+
116+
---
117+
118+
## 根因分析 / Root Cause Analysis
119+
120+
The issue appears to be in how SQLMap parses the request file when the `-r` option is used. Specifically, the parser likely checks for the presence of **any bytes after the first `\r\n\r\n`** (or `\n\n`) sequence. If trailing newlines exist, the parser assumes there is a message body and consequently switches the request method to `POST`.
121+
122+
A more robust approach would be:
123+
1. Strip trailing whitespace/newlines from the end of the request file **before** determining if a body exists.
124+
2. Only treat the request as having a body if there is **non-whitespace content** after the header-empty-line.
125+
3. Always preserve the HTTP method explicitly stated in the request line.
126+
127+
---
128+
129+
## 影响范围 / Impact
130+
131+
This bug affects automated workflows and third-party tools (e.g., Burp Suite extensions, custom scripts) that generate HTTP request files for SQLMap. It is common for text editors, logging tools, or programmatic file writers to append trailing newlines, making this issue easy to trigger unintentionally.
132+
133+
---
134+
135+
## 建议修复 / Suggested Fix
136+
137+
In the request file parsing logic (likely within `lib/request/connect.py` or similar), consider stripping trailing newlines before deciding whether a body is present:
138+
139+
```python
140+
# Pseudo-code suggestion
141+
raw_request = read_file(request_file)
142+
# Split headers and body at the first empty line
143+
header_part, _, body_part = raw_request.partition('\r\n\r\n')
144+
# Strip trailing whitespace from the body before evaluation
145+
body_part = body_part.rstrip('\r\n')
146+
if not body_part:
147+
# No actual body content; preserve the original method
148+
has_body = False
149+
else:
150+
has_body = True
151+
```
152+
153+
Alternatively, ensure that the HTTP method from the request line is never overridden unless explicitly requested by the user (e.g., via `--method`).
154+
155+
---
156+
157+
## 附件 / Attachments
158+
159+
- `requests.txt` — Minimal reproducible request file (see "Steps to Reproduce" above)
160+
161+
---
162+
163+
## 备注 / Additional Notes
164+
165+
This issue was discovered while integrating SQLMap with the [SQLMap WebUI](https://github.com/c0ny1/sqlmap-webui) project, where HTTP request files are generated programmatically. Trailing newlines occasionally occur during file generation, leading to unexpected POST behavior on what should be GET-based scans.
166+
167+
Thank you for maintaining SQLMap!
168+
169+
---

src/backEnd/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
MAX_TASKS_COUNT_LOCK = threading.Lock()
55

66

7-
VERSION = "1.8.50"
7+
VERSION = "1.8.51"

src/burpEx/legacy-api/pom.xml

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

77
<groupId>com.sqlmapwebui</groupId>
88
<artifactId>sqlmap-webui-burp-legacy</artifactId>
9-
<version>1.8.50</version>
9+
<version>1.8.51</version>
1010
<packaging>jar</packaging>
1111

1212
<name>SQLMap WebUI Burp Extension (Legacy API)</name>

src/burpEx/legacy-api/src/main/java/com/sqlmapwebui/burp/BurpExtender.java

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public class BurpExtender implements IBurpExtender, IContextMenuFactory, ITab {
5050
private SqlmapUITab uiTab;
5151

5252
private static final String EXTENSION_NAME = "SQLMap WebUI";
53-
private static final String EXTENSION_VERSION = "1.8.50";
53+
private static final String EXTENSION_VERSION = "1.8.51";
5454

5555
/**
5656
* 过滤结果类 - 存储过滤后的纯文本请求和过滤统计
@@ -585,6 +585,12 @@ private void handleExecuteSqlMap(IHttpRequestResponse message) {
585585
/**
586586
* 从IHttpRequestResponse构建HTTP请求字符串
587587
*/
588+
/**
589+
* 构建HTTP请求内容字符串
590+
*
591+
* 防御性修复:去除尾部多余空行,避免SQLMap -r模式误将GET识别为POST
592+
* (SQLMap在请求文件末尾存在多余空行时会错误推断存在body并切换为POST方法)
593+
*/
588594
private String buildHttpRequest(IHttpRequestResponse message) {
589595
StringBuilder request = new StringBuilder();
590596

@@ -619,7 +625,16 @@ private String buildHttpRequest(IHttpRequestResponse message) {
619625
request.append(bodyStr);
620626
}
621627

622-
return request.toString();
628+
// 去除尾部多余换行符,确保SQLMap -r模式正确识别请求方法
629+
String result = request.toString();
630+
while (result.endsWith("\r\n\r\n")) {
631+
result = result.substring(0, result.length() - 2);
632+
}
633+
while (result.endsWith("\n\n")) {
634+
result = result.substring(0, result.length() - 1);
635+
}
636+
637+
return result;
623638
}
624639

625640
/**

src/burpEx/legacy-api/src/main/java/com/sqlmapwebui/burp/dialogs/AboutDialog.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*/
1212
public class AboutDialog extends JDialog {
1313

14-
private static final String VERSION = "1.8.50";
14+
private static final String VERSION = "1.8.51";
1515

1616
// 帮助内容HTML模板 - 使用模块化组织
1717
private static final String HELP_CONTENT_HTML = "<html><head><style>" +

src/burpEx/montoya-api/pom.xml

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

77
<groupId>com.sqlmapwebui</groupId>
88
<artifactId>sqlmap-webui-burp-montoya</artifactId>
9-
<version>1.8.50</version>
9+
<version>1.8.51</version>
1010
<packaging>jar</packaging>
1111

1212
<name>SQLMap WebUI Burp Extension (Montoya API)</name>

src/burpEx/montoya-api/src/main/java/com/sqlmapwebui/burp/SqlmapContextMenuProvider.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,9 @@ private void handleExecuteSqlmap(List<HttpRequestResponse> messages) {
568568

569569
/**
570570
* 构建HTTP请求内容字符串
571+
*
572+
* 防御性修复:去除尾部多余空行,避免SQLMap -r模式误将GET识别为POST
573+
* (SQLMap在请求文件末尾存在多余空行时会错误推断存在body并切换为POST方法)
571574
*/
572575
private String buildHttpRequestContent(HttpRequest request) {
573576
StringBuilder sb = new StringBuilder();
@@ -591,6 +594,15 @@ private String buildHttpRequestContent(HttpRequest request) {
591594
sb.append(body);
592595
}
593596

594-
return sb.toString();
597+
// 去除尾部多余换行符,确保SQLMap -r模式正确识别请求方法
598+
String result = sb.toString();
599+
while (result.endsWith("\r\n\r\n")) {
600+
result = result.substring(0, result.length() - 2);
601+
}
602+
while (result.endsWith("\n\n")) {
603+
result = result.substring(0, result.length() - 1);
604+
}
605+
606+
return result;
595607
}
596608
}

src/burpEx/montoya-api/src/main/java/com/sqlmapwebui/burp/SqlmapWebUIExtension.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
public class SqlmapWebUIExtension implements BurpExtension {
2020

2121
private static final String EXTENSION_NAME = "SQLMap WebUI";
22-
private static final String EXTENSION_VERSION = "1.8.50";
22+
private static final String EXTENSION_VERSION = "1.8.51";
2323

2424
private MontoyaApi api;
2525
private ConfigManager configManager;

0 commit comments

Comments
 (0)