File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import httpx
2+ import os
3+ from dotenv import load_dotenv
4+
5+ load_dotenv ()
6+ SQLMAP_API = os .getenv ("SQLMAP_API" )
7+ AUTH = (os .getenv ("SQLMAP_USERNAME" ), os .getenv ("SQLMAP_PASSWORD" )) # Basic Auth
8+
9+
10+ # 异步 HTTP 封装
11+ async def async_get (path : str , timeout = 10 ):
12+ async with httpx .AsyncClient (auth = AUTH , timeout = timeout ) as client :
13+ resp = await client .get (f"{ SQLMAP_API } { path } " )
14+ resp .raise_for_status ()
15+ return resp .json ()
16+
17+
18+ async def async_post (path : str , json = None , timeout = 30 ):
19+ async with httpx .AsyncClient (auth = AUTH , timeout = timeout ) as client :
20+ resp = await client .post (f"{ SQLMAP_API } { path } " , json = json )
21+ resp .raise_for_status ()
22+ return resp .json ()
23+
24+
25+ # 异步获取日志
26+ async def async_fetch_sqlmap_logs (task_id : str ):
27+ return await async_get (f"/scan/{ task_id } /log" )
28+
29+
30+ # 异步获取扫描状态
31+ async def async_fetch_sqlmap_status (task_id : str ):
32+ return await async_get (f"/scan/{ task_id } /status" )
33+
34+
35+ # 异步获取扫描结果
36+ async def async_fetch_sqlmap_result (task_id : str ):
37+ return await async_get (f"/scan/{ task_id } /data" )
You can’t perform that action at this time.
0 commit comments