diff --git a/doc/sqlmap-泛读报告.docx b/doc/sqlmap-泛读报告.docx index bb9c431..c87ed17 100644 Binary files a/doc/sqlmap-泛读报告.docx and b/doc/sqlmap-泛读报告.docx differ diff --git a/src/sqlmap-master/data/xml/errors.xml b/src/sqlmap-master/data/xml/errors.xml index 4993a8a..44fb48d 100644 --- a/src/sqlmap-master/data/xml/errors.xml +++ b/src/sqlmap-master/data/xml/errors.xml @@ -1,240 +1,357 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - + + + + + - - - - - - - - - - - - + + + + + + + + + + + + - - - - - - - + + + + + + + - - - - - - - + + + + + + + - - - - - + + + + + - - - - - + + + + + - - - - + + + + - - - + + + - - - - + + + + + + - - - - + + + + + + + + + + + + + + + + + + + + + + + - - - - - - + + + + + + + + + + - - - - + + + + + + + + + + + + + + + + + - - - - - - + + + + + + + + + + + + - - + + + + + + + - - - + + + + + + + - - - + + + + + - - + + + + + - - - + + + + - - - + + + - - - - - - + + + + diff --git a/src/sqlmap-master/data/xml/queries.xml b/src/sqlmap-master/data/xml/queries.xml index 28b5582..4652872 100644 --- a/src/sqlmap-master/data/xml/queries.xml +++ b/src/sqlmap-master/data/xml/queries.xml @@ -1,1177 +1,668 @@ + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + - - - - - - + + + + + + + + + + + + + + + + + + + + - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + - - + + + + + + + - - + + + + + + + - - + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - - + + + + + + + - - + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + - - - - - - - + + + + + + + + + + + + + + + + + + + + - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + - - + + + + + + + - - + + + + + + + - - - + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + - - - - - - /> - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1586,6 +1077,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/sqlmap-master/sqlmap.conf b/src/sqlmap-master/sqlmap.conf index 5b1a102..a0ca217 100644 --- a/src/sqlmap-master/sqlmap.conf +++ b/src/sqlmap-master/sqlmap.conf @@ -1,900 +1,929 @@ -# At least one of these options has to be specified to set the source to -# get target URLs from. +# 至少要指定以下选项中的一个,以设置源并获取目标 URL。 [Target] -# Target URL. -# Example: http://192.168.1.121/sqlmap/mysql/get_int.php?id=1&cat=2 -url = +# 目标 URL。 +# 示例: http://192.168.1.121/sqlmap/mysql/get_int.php?id=1&cat=2 +url = # 这里填写待扫描的目标网址 -# Direct connection to the database. -# Examples: +# 直接连接到数据库。 +# 示例: # mysql://USER:PASSWORD@DBMS_IP:DBMS_PORT/DATABASE_NAME # oracle://USER:PASSWORD@DBMS_IP:DBMS_PORT/DATABASE_SID -direct = +direct = # 这里填写直接连接数据库所需的连接字符串 -# Parse targets from Burp or WebScarab logs -# Valid: Burp proxy (http://portswigger.net/suite/) requests log file path -# or WebScarab proxy (http://www.owasp.org/index.php/Category:OWASP_WebScarab_Project) -# 'conversations/' folder path -logFile = +# 从 Burp 或 WebScarab 日志中解析目标 +# 有效值:Burp 代理的请求日志文件路径(http://portswigger.net/suite/) +# 或 WebScarab 代理的 conversations/ 文件夹路径(http://www.owasp.org/index.php/Category:OWASP_WebScarab_Project) +logFile = # 这里填写 Burp 或 WebScarab 日志文件的路径 -# Scan multiple targets enlisted in a given textual file -bulkFile = +# 从给定的文本文件中扫描多个目标 +bulkFile = # 这里填写包含多个目标网址的文本文件路径 -# Load HTTP request from a file -# Example (file content): POST /login.jsp HTTP/1.1\nHost: example.com\nUser-Agent: Mozilla/4.0\n\nuserid=joe&password=guessme -requestFile = +# 从文件加载 HTTP 请求 +# 示例(文件内容):POST /login.jsp HTTP/1.1\nHost: example.com\nUser-Agent: Mozilla/4.0\n\nuserid=joe&password=guessme +requestFile = # 这里填写包含 HTTP 请求的文件路径 -# Rather than providing a target URL, let Google return target -# hosts as result of your Google dork expression. For a list of Google -# dorks see Johnny Long Google Hacking Database at -# http://johnny.ihackstuff.com/ghdb.php. -# Example: +ext:php +inurl:"&id=" +intext:"powered by " -googleDork = +# 不提供目标 URL,而是让 Google 根据 Google dork 表达式返回目标主机。 +# 有关 Google dork 的列表,请参见 Johnny Long 的 Google Hacking Database +# (http://johnny.ihackstuff.com/ghdb.php)。 +# 示例: +ext:php +inurl:"&id=" +intext:"powered by " +googleDork = # 这里填写 Google dork 查询字符串 - -# These options can be used to specify how to connect to the target URL. +# 这些选项可用于指定如何连接到目标 URL。 [Request] -# Force usage of given HTTP method (e.g. PUT). -method = +# 强制使用指定的 HTTP 方法(例如 PUT)。 +method = # 这里填写 HTTP 方法(如 GET 或 POST) -# Data string to be sent through POST (e.g. "id=1"). -data = +# 要通过 POST 发送的数据字符串(例如 "id=1")。 +data = # 这里填写要发送的 POST 数据 -# Character used for splitting parameter values (e.g. &). -paramDel = +# 用于分隔参数值的字符(例如 &)。 +paramDel = # 这里填写参数分隔符 -# HTTP Cookie header value (e.g. "PHPSESSID=a8d127e.."). -cookie = +# HTTP Cookie 头的值(例如 "PHPSESSID=a8d127e..")。 +cookie = # 这里填写 HTTP Cookie 的值 -# Character used for splitting cookie values (e.g. ;). -cookieDel = +# 用于分隔 Cookie 值的字符(例如 ;)。 +cookieDel = # 这里填写 Cookie 分隔符 -# Live cookies file used for loading up-to-date values. -liveCookies = +# 用于加载最新值的实时 Cookie 文件。 +liveCookies = # 这里填写实时 Cookie 文件的路径 -# File containing cookies in Netscape/wget format. -loadCookies = +# 包含 Netscape/wget 格式的 Cookie 的文件。 +loadCookies = # 这里填写包含 Cookie 的文件路径 -# Ignore Set-Cookie header from response. -# Valid: True or False -dropSetCookie = False +# 忽略响应中的 Set-Cookie 头。 +# 有效值: True 或 False +dropSetCookie = False # 设置为 True 则忽略响应中的 Set-Cookie 头 -# HTTP User-Agent header value. Useful to fake the HTTP User-Agent header value -# at each HTTP request. -# sqlmap will also test for SQL injection on the HTTP User-Agent value. -agent = +# HTTP User-Agent 头的值。用于在每个 HTTP 请求中伪装 HTTP User-Agent 头的值。 +# sqlmap 还将测试 HTTP User-Agent 值是否存在 SQL 注入。 +agent = # 这里填写自定义 User-Agent 值 -# Imitate smartphone through HTTP User-Agent header. -# Valid: True or False -mobile = False +# 通过 HTTP User-Agent 头模拟智能手机。 +# 有效值: True 或 False +mobile = False # 设置为 True 将通过 User-Agent 模拟智能手机 -# Use randomly selected HTTP User-Agent header value. -# Valid: True or False -randomAgent = False +# 使用随机选择的 HTTP User-Agent 头值。 +# 有效值: True 或 False +randomAgent = False # 设置是否随机使用 User-Agent 头,默认值为 False -# HTTP Host header value. -host = +# HTTP Host 头的值。 +host = # 这里填写 HTTP 请求中的主机名 -# HTTP Referer header. Useful to fake the HTTP Referer header value at -# each HTTP request. -referer = +# HTTP Referer 头。用于在每个 HTTP 请求中伪装 HTTP Referer 头的值。 +referer = # 这里填写 HTTP Referer 的值 -# Extra HTTP headers +# 额外的 HTTP 头 headers = Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5 Accept-Language: en-us,en;q=0.5 Accept-Charset: ISO-8859-15,utf-8;q=0.7,*;q=0.7 +# 这里填写其他自定义的 HTTP 头,可以指定多个头信息 -# HTTP Authentication type. Useful only if the target URL requires -# HTTP Basic, Digest, Bearer or NTLM authentication and you have such data. -# Valid: Basic, Digest, Bearer, NTLM or PKI -authType = +# HTTP 身份验证类型。仅当目标 URL 需要以下身份验证时有用: +# HTTP 基本认证、摘要认证、Bearer 或 NTLM 认证,且您有相关数据。 +# 有效值: Basic、Digest、Bearer、NTLM 或 PKI +authType = # 这里填写认证类型 -# HTTP authentication credentials. Useful only if the target URL requires -# HTTP Basic, Digest, Token or NTLM authentication and you have such data. -# Syntax: username:password -authCred = +# HTTP 身份验证凭据。仅当目标 URL 需要以下身份验证时有用: +# HTTP 基本认证、摘要认证、Token 或 NTLM 认证,且您有相关数据。 +# 语法: username:password +authCred = # 这里填写身份验证凭据 -# HTTP Authentication PEM private/cert key file. Useful only if the target URL requires -# PKI authentication and you have such data. -# Syntax: key_file -authFile = +# HTTP 认证 PEM 私钥/证书文件。仅当目标 URL 需要 PKI 认证时有用,且您有相关数据。 +# 语法: key_file +authFile = # 这里填写 PEM 文件的路径 -# Abort on (problematic) HTTP error code (e.g. 401). -# Valid: string -abortCode = +# 在(存在问题的)HTTP 错误代码上中止(例如 401)。 +# 有效值:字符串 +abortCode = # 这里填写需要中止的 HTTP 错误代码 -# Ignore (problematic) HTTP error code (e.g. 401). -# Valid: string -ignoreCode = +# 忽略(存在问题的)HTTP 错误代码(例如 401)。 +# 有效值:字符串 +ignoreCode = # 这里填写要忽略的 HTTP 错误代码 -# Ignore system default proxy settings. -# Valid: True or False -ignoreProxy = False +# 忽略系统默认代理设置。 +# 有效值: True 或 False +ignoreProxy = False # 设置为 True 将忽略系统的代理设置 -# Ignore redirection attempts. -# Valid: True or False -ignoreRedirects = False +# 忽略重定向尝试。 +# 有效值: True 或 False +ignoreRedirects = False # 设置为 True 将忽略 HTTP 重定向 -# Ignore connection timeouts. -# Valid: True or False -ignoreTimeouts = False +# 忽略连接超时。 +# 有效值: True 或 False +ignoreTimeouts = False # 设置为 True 将忽略连接超时的错误 -# Use a proxy to connect to the target URL. -# Syntax: (http|https|socks4|socks5)://address:port -proxy = +# 使用代理连接到目标 URL。 +# 语法: (http|https|socks4|socks5)://address:port +proxy = # 这里填写代理服务器的地址和端口 -# Proxy authentication credentials. Useful only if the proxy requires -# Basic or Digest authentication and you have such data. -# Syntax: username:password -proxyCred = +# 代理身份验证凭据。仅当代理需要以下认证时有用: +# 基本认证或摘要认证,且您有相关数据。 +# 语法: username:password +proxyCred = # 这里填写代理的身份验证凭据 -# Load proxy list from a file -proxyFile = +# 从文件加载代理列表。 +proxyFile = # 这里填写包含代理地址的文件路径 -# Use Tor anonymity network. -# Valid: True or False -tor = False +# 使用 Tor 匿名网络。 +# 有效值: True 或 False +tor = False # 设置为 True 将通过 Tor 网络发送请求 -# Set Tor proxy port other than default. -# Valid: integer -# torPort = +# 设置 Tor 代理端口,非默认值。 +# 有效值: 整数 +# torPort = # 这里可以填写 Tor 代理的端口,默认是 9050 -# Set Tor proxy type. -# Valid: HTTP, SOCKS4, SOCKS5 -torType = SOCKS5 +# 设置 Tor 代理类型。 +# 有效值: HTTP、SOCKS4、SOCKS5 +torType = SOCKS5 # 这里设置使用的 Tor 代理类型,默认是 SOCKS5 -# Check to see if Tor is used properly. -# Valid: True or False -checkTor = False +# 检查 Tor 是否正确使用。 +# 有效值: True 或 False +checkTor = False # 设置为 True 将检查 Tor 连接是否正常 -# Delay in seconds between each HTTP request. -# Valid: float -# Default: 0 -delay = 0 +# 每个 HTTP 请求之间的延迟(秒)。 +# 有效值:浮点数 +# 默认值: 0 +delay = 0 # 这里可以设置发送请求之间的延迟时间 -# Seconds to wait before timeout connection. -# Valid: float -# Default: 30 -timeout = 30 +# 等待超时连接之前的秒数。 +# 有效值:浮点数 +# 默认值: 30 +timeout = 30 # 这里可以设置连接超时的等待时间 -# Maximum number of retries when the HTTP connection timeouts. -# Valid: integer -# Default: 3 -retries = 3 +# 当 HTTP 连接超时时的最大重试次数。 +# 有效值:整数 +# 默认值: 3 +retries = 3 # 这里可以设置在超时情况下重试的最大次数 -# Retry request on regexp matching content. -retryOn = +# 在正则表达式匹配内容上重试请求。 +retryOn = # 这里填写正则表达式,用于重试请求 -# Randomly change value for the given parameter. -rParam = +# 随机改变给定参数的值。 +rParam = # 这里填写要随机改变的参数 -# URL address to visit frequently during testing. -# Example: http://192.168.1.121/index.html -safeUrl = +# 在测试期间访问的 URL 地址。 +# 示例: http://192.168.1.121/index.html +safeUrl = # 这里填写安全 URL 的地址,供频繁访问 -# POST data to send to a safe URL. -# Example: username=admin&password=passw0rd! -safePost = +# 要发送到安全 URL 的 POST 数据。 +# 示例: username=admin&password=passw0rd! +safePost = # 这里填写 POST 数据,用于安全 URL 请求 -# Load safe HTTP request from a file. -safeReqFile = +# 从文件加载安全 HTTP 请求。 +safeReqFile = # 这里填写包含安全 HTTP 请求的文件路径 -# Regular requests between visits to a safe URL (default 0). -# Valid: integer -# Default: 0 -safeFreq = 0 +# 访问安全 URL 之间的常规请求(默认值 0)。 +# 有效值:整数 +# 默认值: 0 +safeFreq = 0 # 这里可以设置访问安全 URL 之间的常规请求频率 -# Skip URL encoding of payload data. -# Valid: True or False -skipUrlEncode = False +# 跳过有效负载数据的 URL 编码。 +# 有效值: True 或 False +skipUrlEncode = False # 设置为 True 则不对有效负载数据进行 URL 编码 -# Parameter used to hold anti-CSRF token. -csrfToken = +# 用于持有 anti-CSRF 令牌的参数。 +csrfToken = # 这里填写用来存储 anti-CSRF 令牌的参数 -# URL address to visit to extract anti-CSRF token -csrfUrl = +# 提取 anti-CSRF 令牌的 URL 地址。 +csrfUrl = # 这里填写用于提取 anti-CSRF 令牌的 URL -# HTTP method to use during anti-CSRF token page visit. -csrfMethod = +# 在获取 anti-CSRF 令牌页面访问时使用的 HTTP 方法。 +csrfMethod = # 这里填写获取 anti-CSRF 令牌时使用的 HTTP 方法 -# POST data to send during anti-CSRF token page visit. -csrfData = +# 在获取 anti-CSRF 令牌页面访问时发送的 POST 数据。 +csrfData = # 这里填写获取 anti-CSRF 令牌时发送的 POST 数据 -# Retries for anti-CSRF token retrieval. -csrfRetries = +# 获取 anti-CSRF 令牌时的重试次数。 +csrfRetries = # 这里填写获取 anti-CSRF 令牌的重试次数 -# Force usage of SSL/HTTPS -# Valid: True or False -forceSSL = False +# 强制使用 SSL/HTTPS。 +# 有效值: True 或 False +forceSSL = False # 设置为 True 将强制使用 SSL 进行连接 -# Use HTTP chunked transfer encoded requests. -# Valid: True or False -chunked = False +# 使用 HTTP 切块传输编码请求。 +# 有效值: True 或 False +chunked = False # 设置为 True 将使用切块传输编码 -# Use HTTP parameter pollution. -# Valid: True or False -hpp = False +# 使用 HTTP 参数污染。 +# 有效值: True 或 False +hpp = False # 设置为 True 将启用 HTTP 参数污染功能 -# Evaluate provided Python code before the request. -# Example: import hashlib;id2=hashlib.md5(id).hexdigest() -evalCode = +# 在请求之前评估提供的 Python 代码。 +# 示例: import hashlib;id2=hashlib.md5(id).hexdigest() +evalCode = # 这里可以填写要执行的 Python 代码,作为请求前的预处理 -# These options can be used to optimize the performance of sqlmap. +# 这些选项可用于优化 sqlmap 的性能。 [Optimization] -# Use all optimization options. -# Valid: True or False -optimize = False - -# Predict common queries output. -# Valid: True or False -predictOutput = False +# 使用所有优化选项。 +# 有效值: True 或 False +optimize = False # 设置为 True 则启用所有优化选项,默认为 False -# Use persistent HTTP(s) connections. -keepAlive = False +# 预测常见查询的输出。 +# 有效值: True 或 False +predictOutput = False # 设置为 True 将启用对常见查询输出的预测优化,默认为 False -# Retrieve page length without actual HTTP response body. -# Valid: True or False -nullConnection = False +# 使用持久的 HTTP(s) 连接。 +keepAlive = False # 设置为 True 使用持久连接,默认为 False,每次请求都新建连接 -# Maximum number of concurrent HTTP(s) requests (handled with Python threads) -# to be used in the inference SQL injection attack. -# Valid: integer -# Default: 1 -threads = 1 +# 在不实际响应 HTTP 响应体的情况下检索页面长度。 +# 有效值: True 或 False +nullConnection = False # 设置为 True 将使用 Null 连接,只获取响应头信息,默认为 False +# 最大并发 HTTP(s) 请求数(使用 Python 线程处理) +# 在推断 SQL 注入攻击中使用。 +# 有效值:整数 +# 默认值: 1 +threads = 1 # 设置并发请求的最大数量,默认为 1,表示一次一个请求 -# These options can be used to specify which parameters to test for, -# provide custom injection payloads and optional tampering scripts. +# 这些选项可以用来指定要测试的参数,提供自定义注入有效负载和可选的篡改脚本。 [Injection] -# Testable parameter(s) comma separated. By default all GET/POST/Cookie -# parameters and HTTP User-Agent are tested by sqlmap. -testParameter = - -# Skip testing for given parameter(s). -skip = +# 可测试的参数,以逗号分隔。默认情况下,sqlmap 会测试所有 GET/POST/Cookie +# 参数和 HTTP User-Agent。 +testParameter = # 这里填写需要测试的参数名称,默认测试所有参数 -# Skip testing parameters that not appear to be dynamic. -# Valid: True or False -skipStatic = False +# 跳过给定的参数。 +skip = # 这里填写需要跳过测试的参数,以逗号分隔 -# Regexp to exclude parameters from testing (e.g. "ses"). -paramExclude = +# 跳过不看起来动态的参数测试。 +# 有效值: True 或 False +skipStatic = False # 设置为 True 跳过静态参数的测试,默认为 False -# Select testable parameter(s) by place (e.g. "POST"). -paramFilter = +# 用于排除参数的正则表达式(例如 "ses")。 +paramExclude = # 这里填写正则表达式,将排除匹配的参数 -# Force back-end DBMS to provided value. If this option is set, the back-end -# DBMS identification process will be minimized as needed. -# If not set, sqlmap will detect back-end DBMS automatically by default. -# Valid: mssql, mysql, mysql 4, mysql 5, oracle, pgsql, sqlite, sqlite3, -# access, firebird, maxdb, sybase -dbms = +# 通过位置选择可测试的参数(例如 "POST")。 +paramFilter = # 这里填写过滤参数的位置(如 GET、POST) -# DBMS authentication credentials (user:password). Useful if you want to -# run SQL statements as another user, the back-end database management -# system is PostgreSQL or Microsoft SQL Server and the parameter is -# vulnerable by stacked queries SQL injection or you are connecting directly -# to the DBMS (-d switch). -# Syntax: username:password -dbmsCred = +# 强制后端数据库管理系统使用提供的值。如果设置此选项,则后端 +# 数据库管理系统识别过程将尽量减少需要。 +# 如果未设置,sqlmap 将默认为自动检测后端数据库管理系统。 +# 有效值:mssql、mysql、mysql 4、mysql 5、oracle、pgsql、sqlite、sqlite3、 +# access、firebird、maxdb、sybase +dbms = # 这里填写强制使用的数据库类型 -# Force back-end DBMS operating system to provided value. If this option is -# set, the back-end DBMS identification process will be minimized as -# needed. -# If not set, sqlmap will detect back-end DBMS operating system -# automatically by default. -# Valid: linux, windows -os = +# 数据库管理系统的身份验证凭据(用户:密码)。如果您想 +# 以其他用户身份运行 SQL 语句,该后端数据库管理系统为 +# PostgreSQL 或 Microsoft SQL Server,并且参数 +# 是通过堆叠查询的 SQL 注入攻击脆弱或您直接连接到 DBMS(-d 选项)。 +# 语法: username:password +dbmsCred = # 这里填写数据库登录的凭据 -# Use big numbers for invalidating values. -# Valid: True or False -invalidBignum = False +# 强制后端数据库管理系统操作系统使用提供的值。如果设置此选项, +# 则后端数据库管理系统识别过程将尽量减少需要。 +# 如果未设置,sqlmap 将默认为自动检测后端数据库管理系统操作系统。 +# 有效值:linux、windows +os = # 这里填写强制使用的操作系统类型 -# Use logical operations for invalidating values. -# Valid: True or False -invalidLogical = False +# 使用大数字来无效化值。 +# 有效值: True 或 False +invalidBignum = False # 设置为 True 使用大数字来无效化测试,默认为 False -# Use random strings for invalidating values. -# Valid: True or False -invalidString = False +# 使用逻辑运算来无效化值。 +# 有效值: True 或 False +invalidLogical = False # 设置为 True 使用逻辑运算符来无效化测试,默认为 False -# Turn off payload casting mechanism -# Valid: True or False -noCast = False +# 使用随机字符串来无效化值。 +# 有效值: True 或 False +invalidString = False # 设置为 True 使用随机字符串来无效化测试,默认为 False -# Turn off string escaping mechanism -# Valid: True or False -noEscape = False +# 关闭有效负载类型转换机制。 +# 有效值: True 或 False +noCast = False # 设置为 True 关闭有效负载的类型转换,默认为 False -# Injection payload prefix string. -prefix = +# 关闭字符串转义机制。 +# 有效值: True 或 False +noEscape = False # 设置为 True 关闭 SQL 注入时的字符串转义,默认为 False -# Injection payload suffix string. -suffix = +# 注入有效负载前缀字符串。 +prefix = # 这里填写注入有效负载的前缀字符串 -# Use given script(s) for tampering injection data. -tamper = +# 注入有效负载后缀字符串。 +suffix = # 这里填写注入有效负载的后缀字符串 +# 使用给定的脚本来篡改注入数据。 +tamper = # 这里填写要使用的篡改脚本 -# These options can be used to specify how to parse and compare page -# content from HTTP responses when using blind SQL injection technique. +# 这些选项可以用来指定如何解析和比较 HTTP 响应内容, +# 特别是在使用盲 SQL 注入技术时。 [Detection] -# Level of tests to perform. -# The higher the value is, the higher the number of HTTP(s) requests are -# as well as the better chances to detect a tricky SQL injection. -# Valid: Integer between 1 and 5 -# Default: 1 -level = 1 - -# Risk of tests to perform. -# Note: boolean-based blind SQL injection tests with AND are considered -# risk 1, with OR are considered risk 3. -# Valid: Integer between 1 and 3 -# Default: 1 -risk = 1 - -# String to match within the raw response when the query is evaluated to -# True, only needed if the page content dynamically changes at each refresh. -# Refer to the user's manual for further details. -string = - -# String to match within the raw response when the query is evaluated to -# False, only needed if the page content dynamically changes at each refresh. -# Refer to the user's manual for further details. -notString = - -# Regular expression to match within the raw response when the query is -# evaluated to True, only needed if the needed if the page content -# dynamically changes at each refresh. -# Refer to the user's manual for further details. -# Valid: regular expression with Python syntax +# 测试执行的级别。 +# 级别越高,发送的 HTTP(s) 请求越多, +# 也就越能提高检测复杂 SQL 注入的概率。 +# 有效值: 1 到 5 之间的整数 +# 默认值: 1 +level = 1 # 设置检测级别,默认是最低级别 1 + +# 执行测试的风险级别。 +# 注意:基于布尔盲 SQL 注入的 AND 被视为风险等级 1, +# 使用 OR 的情况被视为风险等级 3。 +# 有效值: 1 到 3 之间的整数 +# 默认值: 1 +risk = 1 # 设置测试的风险级别,默认为 1 + +# 当查询评估为真时,匹配原始响应中的字符串。 +# 仅在页面内容在每次刷新时动态改变时需要指定此项。 +# 请参考用户手册以获取更多详细信息。 +string = # 这里填写匹配字符串,用来判断查询结果为真时的响应内容 + +# 当查询评估为假时,匹配原始响应中的字符串。 +# 仅在页面内容在每次刷新时动态改变时需要指定此项。 +# 请参考用户手册以获取更多详细信息。 +notString = # 这里填写匹配字符串,用来判断查询结果为假的响应内容 + +# 匹配原始响应中当查询评估为真时的正则表达式。 +# 仅在页面内容在每次刷新时动态改变时需要指定此项。 +# 有效值:具有 Python 语法的正则表达式 # (http://www.python.org/doc/2.5.2/lib/re-syntax.html) -regexp = +regexp = # 这里填写正则表达式,用于匹配响应内容 -# HTTP response code to match when the query is True. -# Valid: Integer -# Example: 200 (assuming any False statement returns a different response -# code) -# code = +# 当查询为真时匹配的 HTTP 响应代码。 +# 有效值: 整数 +# 示例: 200 (假设任何假的语句返回不同的响应代码) +# code = # 这里填写需要匹配的响应代码 -# Conduct thorough tests only if positive heuristic(s). -# Valid: True or False -smart = False +# 仅在出现积极启发式结果时进行全面测试。 +# 有效值: True 或 False +smart = False # 设置为 True 则在有积极启发式结果时执行全面测试,默认为 False -# Compare pages based only on the textual content. -# Valid: True or False -textOnly = False +# 仅基于文本内容比较页面。 +# 有效值: True 或 False +textOnly = False # 设置为 True 则仅通过文本内容进行比较,默认为 False -# Compare pages based only on their titles. -# Valid: True or False -titles = False +# 仅基于页面标题比较页面。 +# 有效值: True 或 False +titles = False # 设置为 True 则仅通过页面标题进行比较,默认为 False - -# These options can be used to tweak testing of specific SQL injection -# techniques. +# 这些选项可以用来调整特定 SQL 注入技术的测试。 [Techniques] -# SQL injection techniques to use. -# Valid: a string composed by B, E, U, S, T and Q where: -# B: Boolean-based blind SQL injection -# E: Error-based SQL injection -# U: UNION query SQL injection -# S: Stacked queries SQL injection -# T: Time-based blind SQL injection -# Q: Inline SQL injection -# Example: ES (means test for error-based and stacked queries SQL -# injection types only) -# Default: BEUSTQ (means test for all SQL injection types - recommended) -technique = BEUSTQ - -# Seconds to delay the response from the DBMS. -# Valid: integer -# Default: 5 -timeSec = 5 - -# Range of columns to test for. -# Valid: range of integers -# Example: 1-10 -uCols = - -# Character to use for bruteforcing number of columns. -# Valid: string -# Example: NULL -uChar = - -# Table to use in FROM part of UNION query SQL injection. -# Valid: string -# Example: INFORMATION_SCHEMA.COLLATIONS -uFrom = - -# Column values to use for UNION query SQL injection. -# Valid: string -# Example: NULL,1,*,NULL -uValues = - -# Domain name used for DNS exfiltration attack. -# Valid: string -dnsDomain = - -# Resulting page URL searched for second-order response. -# Valid: string -secondUrl = - -# Load second-order HTTP request from file. -# Valid: string -secondReq = - +# 要使用的 SQL 注入技术。 +# 有效值:一种字符串,由 B、E、U、S、T 和 Q 组成,其中: +# B: 基于布尔的盲 SQL 注入 +# E: 基于错误的 SQL 注入 +# U: UNION 查询 SQL 注入 +# S: 堆叠查询 SQL 注入 +# T: 基于时间的盲 SQL 注入 +# Q: 内联 SQL 注入 +# 示例: ES (表示仅测试基于错误和堆叠查询的 SQL 注入类型) +# 默认值: BEUSTQ(表示测试所有 SQL 注入类型 - 推荐) +technique = BEUSTQ # 这里填写要使用的 SQL 注入技术 + +# 延迟从数据库管理系统返回响应的秒数。 +# 有效值: 整数 +# 默认值: 5 +timeSec = 5 # 这里填写延迟的秒数,默认为 5 秒 + +# 测试的列范围。 +# 有效值:整型范围 +# 示例: 1-10 +uCols = # 这里填写测试的列范围,例如“1-10” + +# 用于强制破解列数的字符。 +# 有效值: 字符串 +# 示例: NULL +uChar = # 这里填写用于破解列数的字符 + +# 在 UNION 查询 SQL 注入的 FROM 部分中使用的表。 +# 有效值: 字符串 +# 示例: INFORMATION_SCHEMA.COLLATIONS +uFrom = # 这里填写将用于 UNION 查询的表名 + +# 用于 UNION 查询 SQL 注入的列值。 +# 有效值: 字符串 +# 示例: NULL,1,*,NULL +uValues = # 这里填写用于 UNION 查询的列值 + +# 用于 DNS 外泄攻击的域名。 +# 有效值:字符串 +dnsDomain = # 这里填写用于 DNS 外泄攻击的域名 + +# 搜索到的第二次响应的页面 URL。 +# 有效值:字符串 +secondUrl = # 这里填写用于寻找第二次响应的页面 URL + +# 从文件加载第二次 HTTP 请求。 +# 有效值:字符串 +secondReq = # 这里填写包含第二次 HTTP 请求的文件路径 [Fingerprint] -# Perform an extensive back-end database management system fingerprint -# based on various techniques. -# Valid: True or False -extensiveFp = False +# 执行基于各种技术的广泛后端数据库管理系统指纹识别。 +# 有效值: True 或 False +extensiveFp = False # 设置为 True 将启用详细指纹识别,默认为 False - -# These options can be used to enumerate the back-end database -# management system information, structure and data contained in the -# tables. Moreover you can run your own SQL statements. +# 这些选项可以用于枚举后端数据库管理系统的信息、结构和表中包含的数据。 +# 此外,您还可以运行自己的 SQL 语句。 [Enumeration] -# Retrieve everything -# Valid: True or False -getAll = False +# 检索所有内容。 +# 有效值: True 或 False +getAll = False # 设置为 True 将检索所有可用信息,默认为 False -# Retrieve back-end database management system banner. -# Valid: True or False -getBanner = False +# 检索后端数据库管理系统的横幅信息(数据库版本等)。 +# 有效值: True 或 False +getBanner = False # 设置为 True 将检索数据库管理系统的版本信息,默认为 False -# Retrieve back-end database management system current user. -# Valid: True or False -getCurrentUser = False +# 检索后端数据库管理系统的当前用户。 +# 有效值: True 或 False +getCurrentUser = False # 设置为 True 将检索当前连接的用户,默认为 False -# Retrieve back-end database management system current database. -# Valid: True or False -getCurrentDb = False +# 检索后端数据库管理系统的当前数据库。 +# 有效值: True 或 False +getCurrentDb = False # 设置为 True 将检索当前使用的数据库,默认为 False -# Retrieve back-end database management system server hostname. -# Valid: True or False -getHostname = False +# 检索后端数据库管理系统的服务器主机名。 +# 有效值: True 或 False +getHostname = False # 设置为 True 将检索数据库服务器的主机名,默认为 False -# Detect if the DBMS current user is DBA. -# Valid: True or False -isDba = False +# 检测 DBMS 当前用户是否为 DBA(数据库管理员)。 +# 有效值: True 或 False +isDba = False # 设置为 True 将检查当前用户是否具有 DBA 权限,默认为 False -# Enumerate back-end database management system users. -# Valid: True or False -getUsers = False +# 枚举后端数据库管理系统的用户。 +# 有效值: True 或 False +getUsers = False # 设置为 True 将检索数据库中的所有用户信息,默认为 False -# Enumerate back-end database management system users password hashes. -# Valid: True or False -getPasswordHashes = False - -# Enumerate back-end database management system users privileges. -# Valid: True or False -getPrivileges = False - -# Enumerate back-end database management system users roles. -# Valid: True or False -getRoles = False - -# Enumerate back-end database management system databases. -# Valid: True or False -getDbs = False - -# Enumerate back-end database management system database tables. -# Optional: db -# Valid: True or False -getTables = False +# 枚举后端数据库管理系统用户的密码哈希。 +# 有效值: True 或 False +getPasswordHashes = False # 设置为 True 将获取用户密码的哈希值,默认为 False -# Enumerate back-end database management system database table columns. -# Optional: db, tbl, col -# Valid: True or False -getColumns = False +# 枚举后端数据库管理系统用户的权限。 +# 有效值: True 或 False +getPrivileges = False # 设置为 True 将检索用户权限,默认为 False -# Enumerate back-end database management system schema. -# Valid: True or False -getSchema = False +# 枚举后端数据库管理系统用户的角色。 +# 有效值: True 或 False +getRoles = False # 设置为 True 将检索用户角色信息,默认为 False -# Retrieve number of entries for table(s). -# Valid: True or False -getCount = False +# 枚举后端数据库管理系统的数据库列表。 +# 有效值: True 或 False +getDbs = False # 设置为 True 将检索所有数据库名,默认为 False -# Dump back-end database management system database table entries. -# Requires: tbl and/or col -# Optional: db -# Valid: True or False -dumpTable = False +# 枚举后端数据库管理系统数据库的表。 +# 可选: db +# 有效值: True 或 False +getTables = False # 设置为 True 将检索特定数据库中的所有表,默认为 False -# Dump all back-end database management system databases tables entries. -# Valid: True or False -dumpAll = False +# 枚举后端数据库管理系统数据库表的列。 +# 可选: db, tbl, col +# 有效值: True 或 False +getColumns = False # 设置为 True 将检索特定表中的所有列,默认为 False -# Search column(s), table(s) and/or database name(s). -# Requires: db, tbl or col -# Valid: True or False -search = False +# 枚举后端数据库管理系统的架构。 +# 有效值: True 或 False +getSchema = False # 设置为 True 将检索数据库的架构信息,默认为 False -# Check for database management system database comments during enumeration. -# Valid: True or False -getComments = False +# 检索表(们)中的条目数量。 +# 有效值: True 或 False +getCount = False # 设置为 True 将获取表中的记录数,默认为 False -# Retrieve SQL statements being run on database management system. -# Valid: True or False -getStatements = False +# 转储后端数据库管理系统数据库表的条目。 +# 需要: tbl 和/或 col +# 可选: db +# 有效值: True 或 False +dumpTable = False # 设置为 True 将导出特定表的所有数据,默认为 False -# Back-end database management system database to enumerate. -db = +# 转储所有后端数据库管理系统数据库表的条目。 +# 有效值: True 或 False +dumpAll = False # 设置为 True 将导出所有数据库表的数据,默认为 False -# Back-end database management system database table(s) to enumerate. -tbl = +# 搜索列、表和/或数据库名称。 +# 需要: db、tbl 或 col +# 有效值: True 或 False +search = False # 设置为 True 将进行特定名称的搜索,默认为 False -# Back-end database management system database table column(s) to enumerate. -col = +# 在枚举过程中检查数据库管理系统数据库的注释。 +# 有效值: True 或 False +getComments = False # 设置为 True 将检索数据库对象的注释,默认为 False -# Back-end database management system identifiers (database(s), table(s) and column(s)) to not enumerate. -exclude = +# 检索在数据库管理系统上运行的 SQL 语句。 +# 有效值: True 或 False +getStatements = False # 设置为 True 将获取最新的 SQL 查询,默认为 False -# Pivot column name. -pivotColumn = +# 待枚举的后端数据库管理系统数据库。 +db = # 这里填写要枚举的数据库名称 -# Use WHERE condition while table dumping (e.g. "id=1"). -dumpWhere = +# 待枚举的后端数据库管理系统数据库表。 +tbl = # 这里填写要枚举的表名称 -# Back-end database management system database user to enumerate. -user = +# 待枚举的后端数据库管理系统数据库表列。 +col = # 这里填写要枚举的列名称 -# Exclude DBMS system databases when enumerating tables. -# Valid: True or False -excludeSysDbs = False +# 需要排除的不枚举的后端数据库管理系统标识符(数据库、表和列)。 +exclude = # 这里填写要排除的数据库、表或列名称,以逗号分隔 -# First query output entry to retrieve -# Valid: integer -# Default: 0 (sqlmap will start to retrieve the table dump entries from -# first one) -limitStart = 0 +# 透视列名。 +pivotColumn = # 这里填写用于透视的列的名称 -# Last query output entry to retrieve -# Valid: integer -# Default: 0 (sqlmap will detect the number of table dump entries and -# retrieve them until the last) -limitStop = 0 +# 在转储表时使用的 WHERE 条件(例如 "id=1")。 +dumpWhere = # 这里填写用于转储数据的 WHERE 条件 -# First query output word character to retrieve -# Valid: integer -# Default: 0 (sqlmap will enumerate the query output from the first -# character) -firstChar = 0 +# 待枚举的后端数据库管理系统数据库用户。 +user = # 这里填写待枚举的数据库用户名称 -# Last query output word character to retrieve -# Valid: integer -# Default: 0 (sqlmap will enumerate the query output until the last -# character) -lastChar = 0 +# 在枚举表时排除 DBMS 系统数据库。 +# 有效值: True 或 False +excludeSysDbs = False # 设置为 True 将排除系统数据库,默认为 False -# SQL statement to be executed. -# Example: SELECT 'foo', 'bar' -sqlQuery = +# 检索的查询输出第一条条目。 +# 有效值:整数 +# 默认值: 0(sqlmap 将从第一条检索表转储条目) +limitStart = 0 # 这里可以设置查询结果的起始条目,默认为 0(第一条) -# Prompt for an interactive SQL shell. -# Valid: True or False -sqlShell = False +# 检索的查询输出最后一条条目。 +# 有效值:整数 +# 默认值: 0(sqlmap 将检测表转储条目的数量并检索到最后) +limitStop = 0 # 这里可以设置查询结果的结束条目,默认为 0(最后一条) -# Execute SQL statements from given file(s). -sqlFile = +# 检索的查询输出第一个字符。 +# 有效值:整数 +# 默认值: 0(sqlmap 将从第一个字符开始枚举查询输出) +firstChar = 0 # 这里可以设置在输出中检索起始字符的位置,默认为 0 +# 最后查询输出的最后一个字符位置。 +# 有效值:整数 +# 默认值: 0(sqlmap将枚举查询输出,直到最后一个字符) +lastChar = 0 # 这里可以设置检索输出的最后一个字符位置,默认为 0(表示获取所有字符) -# These options can be used to run brute force checks. -[Brute force] +# 要执行的 SQL 语句。 +# 示例: SELECT 'foo', 'bar' +sqlQuery = # 这里填写要执行的 SQL 查询,例如查询特定数据 -# Check existence of common tables. -# Valid: True or False -commonTables = False +# 提升为交互式 SQL shell 提示。 +# 有效值: True 或 False +sqlShell = False # 设置为 True 将打开一个交互式 SQL shell,允许手动执行 SQL 语句,默认为 False -# Check existence of common columns. -# Valid: True or False -commonColumns = False +# 从给定文件中执行 SQL 语句。 +sqlFile = # 这里填写包含 SQL 查询的文件路径,sqlmap将从中读取要执行的 SQL 语句 -# Check existence of common files. -# Valid: True or False -commonFiles = False +# 这些选项可用于执行暴力破解检查。 +[Brute force] +# 检查常见表的存在性。 +# 有效值: True 或 False +commonTables = False # 设置为 True 将检查数据库中是否存在常见表,默认为 False -# These options can be used to create custom user-defined functions. -[User-defined function] +# 检查常见列的存在性。 +# 有效值: True 或 False +commonColumns = False # 设置为 True 将检查数据库中是否存在常见列,默认为 False -# Inject custom user-defined functions -# Valid: True or False -udfInject = False +# 检查常见文件的存在性。 +# 有效值: True 或 False +commonFiles = False # 设置为 True 将检查数据库中是否存在常见文件,默认为 False -# Local path of the shared library -shLib = +# 这些选项可用于创建自定义用户定义函数。 +[User-defined function] +# 注入自定义用户定义函数。 +# 有效值: True 或 False +udfInject = False # 设置为 True 将尝试注入用户定义的函数,默认为 False -# These options can be used to access the back-end database management -# system underlying file system. -[File system] +# 共享库的本地路径。 +shLib = # 这里填写要注入的共享库的文件路径,通常是动态链接库 -# Read a specific file from the back-end DBMS underlying file system. -# Examples: /etc/passwd or C:\boot.ini -fileRead = +# 这些选项可以用来访问后端数据库管理系统底层文件系统。 +[File system] -# Write a local file to a specific path on the back-end DBMS underlying -# file system. -# Example: /tmp/sqlmap.txt or C:\WINNT\Temp\sqlmap.txt -fileWrite = +# 从后端 DBMS 底层文件系统读取特定文件。 +# 示例: /etc/passwd 或 C:\boot.ini +fileRead = # 这里填写要读取的文件路径,sqlmap将尝试读取该文件内容 -# Back-end DBMS absolute filepath to write the file to. -fileDest = +# 将本地文件写入后端 DBMS 底层文件系统的特定路径。 +# 示例: /tmp/sqlmap.txt 或 C:\WINNT\Temp\sqlmap.txt +fileWrite = # 这里填写要写入的文件路径,sqlmap将尝试将本地文件写入该路径 +# 后端数据库管理系统的绝对文件路径以写入文件。 +fileDest = # 这里填写目标文件的路径,sqlmap将尝试将文件写入该路径 -# These options can be used to access the back-end database management -# system underlying operating system. +# 这些选项可用于访问后端数据库管理系统底层操作系统。 [Takeover] -# Execute an operating system command. -# Valid: operating system command -osCmd = +# 执行操作系统命令。 +# 有效值:操作系统命令 +osCmd = # 这里填写要执行的操作系统命令,sqlmap将尝试在目标系统上执行该命令 -# Prompt for an interactive operating system shell. -# Valid: True or False -osShell = False +# 提升为交互式操作系统 shell 提示。 +# 有效值: True 或 False +osShell = False # 设置为 True 将打开一个交互式系统 shell,默认为 False -# Prompt for an out-of-band shell, Meterpreter or VNC. -# Valid: True or False -osPwn = False +# 提升为出带外 shell,Meterpreter 或 VNC。 +# 有效值: True 或 False +osPwn = False # 设置为 True 尝试创建一个出带外的 shell 连接,默认为 False -# One click prompt for an out-of-band shell, Meterpreter or VNC. -# Valid: True or False -osSmb = False +# 一键提示出带外 shell,Meterpreter 或 VNC。 +# 有效值: True 或 False +osSmb = False # 设置为 True 尝试利用 SMB 协议一键获取回调 shell,默认为 False -# Microsoft SQL Server 2000 and 2005 'sp_replwritetovarbin' stored -# procedure heap-based buffer overflow (MS09-004) exploitation. -# Valid: True or False -osBof = False +# 微软 SQL Server 2000 和 2005 的 'sp_replwritetovarbin' 存储过程堆基缓冲区溢出(MS09-004)利用。 +# 有效值: True 或 False +osBof = False # 设置为 True 尝试利用缓冲区溢出漏洞,默认为 False -# Database process' user privilege escalation. -# Note: Use in conjunction with osPwn, osSmb or osBof. It will force the -# payload to be Meterpreter. -privEsc = False +# 数据库进程的用户权限提升。 +# 注意:与 osPwn、osSmb 或 osBof 一起使用。它将强制 payload 为 Meterpreter。 +privEsc = False # 设置为 True 将尝试提升用户权限,默认为 False -# Local path where Metasploit Framework is installed. -# Valid: file system path -msfPath = +# 本地的 Metasploit Framework 安装路径。 +# 有效值:文件系统路径 +msfPath = # 这里填写 Metasploit Framework 安装目录的路径,用于进行攻击的时候,如生成 payload -# Remote absolute path of temporary files directory. -# Valid: absolute file system path -tmpPath = +# 远程临时文件目录的绝对路径。 +# 有效值:绝对文件系统路径 +tmpPath = # 这里填写用于在目标系统上存放临时文件的路径,方便进行临时文件操作 - -# These options can be used to access the back-end database management -# system Windows registry. +# 这些选项可以用来访问后端数据库管理系统的 Windows 注册表。 [Windows] -# Read a Windows registry key value. -# Valid: True or False -regRead = False - -# Write a Windows registry key value data. -# Valid: True or False -regAdd = False +# 读取 Windows 注册表键值。 +# 有效值: True 或 False +regRead = False # 设置为 True 将尝试读取 Windows 注册表项,默认为 False -# Delete a Windows registry key value. -# Valid: True or False -regDel = False +# 写入 Windows 注册表键值数据。 +# 有效值: True 或 False +regAdd = False # 设置为 True 将尝试添加或更新 Windows 注册表项,默认为 False -# Windows registry key. -regKey = +# 删除 Windows 注册表键值。 +# 有效值: True 或 False +regDel = False # 设置为 True 将尝试删除指定的 Windows 注册表项,默认为 False -# Windows registry key value. -regVal = +# Windows 注册表键。 +regKey = # 这里填写要读取、修改或删除的 Windows 注册表键名称 -# Windows registry key value data. -regData = +# Windows 注册表键值。 +regVal = # 这里填写要操作的 Windows 注册表值 -# Windows registry key value type. -regType = +# Windows 注册表键值数据类型。 +regData = # 这里填写要写入的注册表键值的数据,如字符串、DWORD 等 +# Windows 注册表键值类型。 +regType = # 这里填写注册表值的数据类型,如 REG_SZ、REG_DWORD 等 -# These options can be used to set some general working parameters. +# 这些选项可用于设置一些通用工作参数。 [General] -# Load session from a stored (.sqlite) file -# Example: output/www.target.com/session.sqlite -sessionFile = +# 从存储的 (.sqlite) 文件中加载会话。 +# 示例: output/www.target.com/session.sqlite +sessionFile = # 这里填写要加载的会话文件路径,用于恢复之前的会话信息 + +# 将所有 HTTP 流量记录到文本文件中。 +trafficFile = # 这里填写记录 HTTP 请求和响应的文件路径,可以用于调试和分析 + +# 在空结果上中止数据检索。 +# 有效值: True 或 False +abortOnEmpty = False # 设置为 True 如果没有结果则中止检索,默认为 False,即继续执行 + +# 设置预定义的答案(例如 "quit=N,follow=N")。 +answers = # 这里填写用于自动响应的设置,允许无交互操作 + +# 包含 Base64 编码数据的参数。 +base64Parameter = # 这里填写包含 Base64 编码数据的参数名,用于处理编码数据 -# Log all HTTP traffic into a textual file. -trafficFile = +# 使用 URL 和文件名安全的 Base64 字母表(参考:https://en.wikipedia.org/wiki/Base64#URL_applications)。 +# 有效值: True 或 False +base64Safe = False # 设置为 True 使用 URL 安全的 Base64 编码,默认为 False -# Abort data retrieval on empty results. -abortOnEmpty = False +# 从不请求用户输入,使用默认行为。 +# 有效值: True 或 False +batch = False # 设置为 True 将不询问用户输入,直接使用默认值,默认为 False -# Set predefined answers (e.g. "quit=N,follow=N"). -answers = +# 结果字段中包含二进制值(例如 "digest")。 +binaryFields = # 这里填写包含二进制数据(如哈希值)的字段名称 -# Parameter(s) containing Base64 encoded data -base64Parameter = +# 在评估目标之前检查 Internet 连接。 +# 有效值: True 或 False +checkInternet = False # 设置为 True 将在攻击之前检查互联网连接,默认为 False -# Use URL and filename safe Base64 alphabet (Reference: https://en.wikipedia.org/wiki/Base64#URL_applications). -# Valid: True or False -base64Safe = False +# 清理数据库管理系统中的 sqlmap 特定 UDF 和表。 +# 有效值: True 或 False +cleanup = False # 设置为 True 将清除 sqlmap 创建的 UDF 和表,默认为 False -# Never ask for user input, use the default behaviour. -# Valid: True or False -batch = False +# 爬虫从目标 URL 开始。 +# 有效值:整数 +# 默认值: 0 +crawlDepth = 0 # 设置爬虫的深度,默认为 0 表示不进行爬虫,数字越大越深入 -# Result fields having binary values (e.g. "digest"). -binaryFields = +# 用于排除爬虫的页面的正则表达式(例如 "logout")。 +crawlExclude = # 这里填写正则表达式,用于匹配需要排除的页面路径 -# Check Internet connection before assessing the target. -checkInternet = False +# CSV 输出中使用的分隔符字符。 +# 默认值: , +csvDel = , # 这里设置 CSV 输出的字段分隔符,默认为逗号 -# Clean up the DBMS from sqlmap specific UDF and tables. -# Valid: True or False -cleanup = False +# 将转储的数据存储到自定义文件中。 +dumpFile = # 这里填写转储数据的目标文件路径,可以指定保存位置和文件名 -# Crawl the website starting from the target URL. -# Valid: integer -# Default: 0 -crawlDepth = 0 +# 转储数据的格式 +# 有效值: CSV、HTML 或 SQLITE +dumpFormat = CSV # 设置转储数据的格式,默认为 CSV -# Regexp to exclude pages from crawling (e.g. "logout"). -crawlExclude = +# 强制用于数据检索的字符编码。 +encoding = # 这里填写强制使用的字符编码,例如 "utf-8",用于数据处理 -# Delimiting character used in CSV output. -# Default: , -csvDel = , +# 获取每个查询输出长度并实时计算预计到达时间。 +# 有效值: True 或 False +eta = False # 设置为 True 将显示每个请求的预计到达时间,默认为 False -# Store dumped data to a custom file. -dumpFile = +# 清除当前目标的会话文件。 +# 有效值: True 或 False +flushSession = False # 设置为 True 将清除先前会话的数据,默认为 False -# Format of dumped data -# Valid: CSV, HTML or SQLITE -dumpFormat = CSV +# 解析并测试目标 URL 上的表单。 +# 有效值: True 或 False +forms = False # 设置为 True 将解析和测试目标页面的 HTML 表单,默认为 False -# Force character encoding used for data retrieval. -encoding = +# 忽略存储在会话文件中的查询结果。 +# 有效值: True 或 False +freshQueries = False # 设置为 True 将忽略会话中的查询缓存,重新进行测试,默认为 False -# Retrieve each query output length and calculate the estimated time of -# arrival in real time. -# Valid: True or False -eta = False +# 使用指定页码的 Google dork 结果。 +# 有效值:整数 +# 默认值: 1 +googlePage = 1 # 设置使用的 Google dork 结果的页码,从第1页开始,默认为 1 -# Flush session files for current target. -# Valid: True or False -flushSession = False +# 在数据检索过程中使用十六进制转换。 +# 有效值: True 或 False +hexConvert = False # 设置为 True 将在数据处理过程中启用十六进制格式,默认为 False -# Parse and test forms on target URL. -# Valid: True or False -forms = False +# 自定义输出目录路径。 +outputDir = # 这里填写输出文件的自定义目录路径,保存结果文件 -# Ignore query results stored in session file. -# Valid: True or False -freshQueries = False +# 解析并显示响应中的数据库管理系统错误消息。 +# 有效值: True 或 False +parseErrors = False # 设置为 True 将在输出中解析并显示数据库管理系统的错误信息,默认为 False -# Use Google dork results from specified page number. -# Valid: integer -# Default: 1 -googlePage = 1 +# 使用给定脚本进行请求的预处理。 +preprocess = # 这里填写请求预处理的脚本路径,用于自定义请求数据 -# Use hex conversion during data retrieval. -# Valid: True or False -hexConvert = False +# 使用给定脚本进行响应数据的后处理。 +postprocess = # 这里填写响应后处理的脚本路径,用于处理返回的数据 + +# 重新转储具有未知字符标记(?)的条目。 +# 有效值: True 或 False +repair = False # 设置为 True 将尝试重新转储具有不明字符的条目,默认为 False + +# 用于从提供的 Burp 或 WebScarab 代理日志中过滤目标的正则表达式。 +# 示例: (google|yahoo) +scope = # 这里填写正则表达式,用于匹配并过滤目标的日志条目 + +# 跳过对 SQLi/XSS 漏洞的启发式检测。 +# 有效值: True 或 False +skipHeuristics = False # 设置为 True 将跳过对 SQL 注入和 XSS 漏洞的启发式检测,默认为 False + +# 跳过对 WAF/IPS 保护的启发式检测。 +# 有效值: True 或 False +skipWaf = False # 设置为 True 将跳过对 Web 应用防火墙/入侵防御系统的检测,默认为 False + +# 本地的 Metasploit Framework 安装路径。 +# 有效值:文件系统路径 +msfPath = # 这里填写本地 Metasploit Framework 的安装路径,用于与该工具集成 + +# 远程临时文件目录的绝对路径。 +# 有效值:绝对文件系统路径 +tmpPath = # 这里填写用于存放临时文件的路径,允许在目标空间写入操作 + +# 这些选项可以用来访问后端数据库管理系统的 Windows 注册表。 +[Windows] + +# 读取 Windows 注册表键值。 +# 有效值: True 或 False +regRead = False # 设置为 True 将尝试读取指定的 Windows 注册表键,默认为 False + +# 写入 Windows 注册表键值数据。 +# 有效值: True 或 False +regAdd = False # 设置为 True 将尝试添加或修改指定的注册表键值,默认为 False + +# 删除 Windows 注册表键值。 +# 有效值: True 或 False +regDel = False # 设置为 True 将尝试删除指定的 Windows 注册表键,默认为 False + +# Windows 注册表键。 +regKey = # 这里填写要操作的 Windows 注册表键的名称,指定要读取或修改的键 + +# Windows 注册表键值。 +regVal = # 这里填写要操作的 Windows 注册表键的具体值,用于写入或读取 + +# Windows 注册表键值数据类型。 +regData = # 这里填写要写入的注册表键值的数据类型,例如字符串或 DWORD + +# Windows 注册表键值类型。 +regType = # 这里填写注册表值的数据类型,如 REG_SZ(字符串类型)或 REG_DWORD + +# 这些选项可用于设置一些通用工作参数。 +[General] -# Custom output directory path. -outputDir = +# 从存储的 (.sqlite) 文件中加载会话。 +# 示例: output/www.target.com/session.sqlite +sessionFile = # 这里填写要加载会话的文件路径,用于恢复之前的进程 -# Parse and display DBMS error messages from responses. -# Valid: True or False -parseErrors = False +# 将所有 HTTP 流量记录到文本文件中。 +trafficFile = # 这里填写日志文件路径,用于记录 HTTP 请求和响应,便于后期分析 -# Use given script(s) for preprocessing of request. -preprocess = +# 在空结果上中止数据检索。 +# 有效值: True 或 False +abortOnEmpty = False # 设置为 True 时,如果没有结果将中止检索,默认为 False -# Use given script(s) for postprocessing of response data. -postprocess = +# 设置预定义的答案(例如 "quit=N,follow=N")。 +answers = # 这里填写针对提示的预定义回答,用于自动化操作 -# Redump entries having unknown character marker (?). -# Valid: True or False -repair = False +# 包含 Base64 编码数据的参数。 +base64Parameter = # 这里填写要包含 Base64 编码数据的参数名,便于数据处理 -# Regular expression for filtering targets from provided Burp. -# or WebScarab proxy log. -# Example: (google|yahoo) -scope = +# 使用 URL 和文件名安全的 Base64 字母表(参考:https://en.wikipedia.org/wiki/Base64#URL_applications)。 +# 有效值: True 或 False +base64Safe = False # 设置为 True 使用改良的 Base64 编码,适合 URL 的安全性,默认为 False -# Skip heuristic detection of SQLi/XSS vulnerabilities. -# Valid: True or False -skipHeuristics = False +# 从不请求用户输入,使用默认行为。 +# 有效值: True 或 False +batch = False # 设置为 True 将禁用任何用户输入,直接使用默认选项,默认为 False -# Skip heuristic detection of WAF/IPS protection. -# Valid: True or False -skipWaf = False +# 结果字段中包含二进制值(例如 "digest")。 +binaryFields = # 这里填写包含二进制数据的字段名,便于处理数据 -# Prefix used for temporary tables. -# Default: sqlmap -tablePrefix = sqlmap +# 在评估目标之前检查 Internet 连接。 +# 有效值: True 或 False +checkInternet = False # 设置为 True 时将在执行前检查网络连接,默认为 False -# Select tests by payloads and/or titles (e.g. ROW). -testFilter = +# 清理数据库管理系统中的 sqlmap 特定 UDF 和表。 +# 有效值: True 或 False +cleanup = False # 设置为 True 将移除 sqlmap 创建的用户定义函数 (UDF) 和表,默认为 False -# Skip tests by payloads and/or titles (e.g. BENCHMARK). -testSkip = +# 爬虫从目标 URL 开始。 +# 有效值:整数 +# 默认值: 0 +crawlDepth = 0 # 设置爬虫的深度,默认为 0 表示不进行深度爬取,数字越大爬取越深 -# Run with a time limit in seconds (e.g. 3600). -timeLimit = +# 用于排除爬虫的页面的正则表达式(例如 "logout")。 +crawlExclude = # 这里填写正则表达式,以匹配需要排除的 URL 页面 -# Disable escaping of DBMS identifiers (e.g. "user"). -unsafeNaming = False +# CSV 输出中使用的分隔符字符。 +# 默认值: , +csvDel = , # 设置 CSV 格式输出的字段分隔符,默认为逗号 -# Web server document root directory (e.g. "/var/www"). -webRoot = +# 将转储的数据存储到自定义文件中。 +dumpFile = # 这里填写输出转储数据的文件路径和文件名 +# 转储数据的格式 +# 有效值: CSV、HTML 或 SQLITE +dumpFormat = CSV # 设置转储数据的格式,默认为 CSV 文件格式 -[Miscellaneous] +# 强制用于数据检索的字符编码。 +encoding = # 这里填写强制使用的字符编码,例如 "utf-8",便于处理字符数据 -# Run host OS command(s) when SQL injection is found. -alert = +# 获取每个查询输出长度并实时计算预计到达时间。 +# 有效值: True 或 False +eta = False # 设置为 True 时将计算并显示每个请求的预计到达时间,默认为 False -# Beep on question and/or when SQL injection is found. -# Valid: True or False -beep = False +# 清除当前目标的会话文件。 +# 有效值: True 或 False +flushSession = False # 设置为 True 将清除当前会话的数据,默认为 False -# Offline WAF/IPS payload detection testing. -# Valid: True or False -checkPayload = False +# 解析并测试目标 URL 上的表单。 +# 有效值: True 或 False +forms = False # 设置为 True 将解析 HTML 表单并进行测试,默认为 False -# Check for missing (optional) sqlmap dependencies. -# Valid: True or False -dependencies = False +# 忽略存储在会话文件中的查询结果。 +# 有效值: True 或 False +freshQueries = False # 设置为 True 将忽略会话中已存储的查询记录,默认为 False -# Disable console output coloring. -# Valid: True or False -disableColoring = False +# 使用指定页码的 Google dork 结果。 +# 有效值:整数 +# 默认值: 1 +googlePage = 1 # 设置使用的 Google dork 结果的页码,默认为第 1 页 -# Display list of available tamper scripts. -# Valid: True or False -listTampers = False +# 在数据检索过程中使用十六进制转换。 +# 有效值: True 或 False +hexConvert = False # 设置为 True 将在数据处理中启用十六进制格式,默认为 False -# Disable logging to a file. -# Valid: True or False -noLogging = False +# 自定义输出目录路径。 +outputDir = # 这里填写输出文件的自定义目录路径,便于存储数据结果 -# Work in offline mode (only use session data) -# Valid: True or False -offline = False +# 解析并显示响应中的数据库管理系统错误消息。 +# 有效值: True 或 False +parseErrors = False # 设置为 True 将在响应中解析并显示数据库错误信息,默认为 False -# Location of CSV results file in multiple targets mode. -resultsFile = +# 使用给定脚本进行请求的预处理。 +preprocess = # 这里填写请求预处理脚本的路径,用于修改请求数据 -# Local directory for storing temporary files. -tmpDir = +# 使用给定脚本进行响应数据的后处理。 +postprocess = # 这里填写响应后处理脚本的路径,用于处理返回的数据 -# Adjust options for unstable connections. -# Valid: True or False -unstable = False +# 重新转储具有未知字符标记(?)的条目。 +# 有效值: True 或 False +repair = False # 设置为 True 将尝试重新转储带有未知字符的条目,默认为 False -# Update sqlmap. -# Valid: True or False -updateAll = False +# 用于从提供的 Burp 或 WebScarab 代理日志中过滤目标的正则表达式。 +# 示例: (google|yahoo) +scope = # 这里填写正则表达式,用于筛选指定的目标 -# Simple wizard interface for beginner users. -# Valid: True or False -wizard = False +# 跳过对 SQLi/XSS 漏洞的启发式检测。 +# 有效值: True 或 False +skipHeuristics = False # 设置为 True 跳过 SQL 注入和 XSS 漏洞的启发式检测,默认为 False -# Verbosity level. -# Valid: integer between 0 and 6 -# 0: Show only error and critical messages -# 1: Show also warning and info messages -# 2: Show also debug messages -# 3: Show also payloads injected -# 4: Show also HTTP requests -# 5: Show also HTTP responses' headers -# 6: Show also HTTP responses' page content -# Default: 1 -verbose = 1 +# 跳过对 WAF/IPS 保护的启发式检测。 +# 有效值: True 或 False +skipWaf = False # 设置为 True 跳过对 Web 应用防火墙和入侵防御系统的检测,默认为 False diff --git a/src/sqlmap-master/sqlmap.py b/src/sqlmap-master/sqlmap.py index cd8385d..856e547 100644 --- a/src/sqlmap-master/sqlmap.py +++ b/src/sqlmap-master/sqlmap.py @@ -5,111 +5,111 @@ Copyright (c) 2006-2024 sqlmap developers (https://sqlmap.org/) See the file 'LICENSE' for copying permission """ -from __future__ import print_function +from __future__ import print_function # 导入print_function特性,确保在Python 2和3中print函数的行为一致 try: - import sys + import sys # 导入sys模块,用于处理与Python解释器相关的操作 # 防止Python自动生成.pyc文件 - sys.dont_write_bytecode = True + sys.dont_write_bytecode = True # 设置不生成.pyc字节码文件,以减少磁盘空间占用和加载时间 try: # 检查sqlmap的安装是否正确 - __import__("lib.utils.versioncheck") # this has to be the first non-standard import - except ImportError: - sys.exit("[!] wrong installation detected (missing modules). Visit 'https://github.com/sqlmapproject/sqlmap/#installation' for further details") + __import__("lib.utils.versioncheck") # 动态导入lib.utils.versioncheck模块,通常用于检查版本兼容性 + except ImportError: # 如果导入失败(例如模块不存在),则执行以下代码 + sys.exit("[!] wrong installation detected (missing modules). Visit 'https://github.com/sqlmapproject/sqlmap/#installation' for further details") # 退出程序并提示安装错误,建议用户访问指定链接查看安装说明 # 导入标准库模块 - import bdb - import glob - import inspect - import json - import logging - import os - import re - import shutil - import sys - import tempfile - import threading - import time - import traceback - import warnings + import bdb # 导入bdb模块,用于调试器支持 + import glob # 导入glob模块,用于文件路径匹配 + import inspect # 导入inspect模块,用于获取对象信息 + import json # 导入json模块,用于处理JSON数据 + import logging # 导入logging模块,用于记录日志信息 + import os # 导入os模块,用于与操作系统进行交互 + import re # 导入re模块,用于正则表达式操作 + import shutil # 导入shutil模块,用于文件操作(如复制、删除等) + import sys # 再次导入sys模块,确保其可用性 + import tempfile # 导入tempfile模块,用于创建临时文件和目录 + import threading # 导入threading模块,用于多线程支持 + import time # 导入time模块,用于时间相关操作 + import traceback # 导入traceback模块,用于获取异常信息 + import warnings # 导入warnings模块,用于处理警告信息 # 忽略DeprecationWarning,除非命令行参数中包含"--deprecations" - if "--deprecations" not in sys.argv: - warnings.filterwarnings(action="ignore", category=DeprecationWarning) - else: - warnings.resetwarnings() - warnings.filterwarnings(action="ignore", message="'crypt'", category=DeprecationWarning) - warnings.simplefilter("ignore", category=ImportWarning) - if sys.version_info >= (3, 0): - warnings.simplefilter("ignore", category=ResourceWarning) + if "--deprecations" not in sys.argv: # 如果命令行参数中不包含"--deprecations" + warnings.filterwarnings(action="ignore", category=DeprecationWarning) # 忽略所有DeprecationWarning类别的警告 + else: # 如果命令行参数中包含"--deprecations" + warnings.resetwarnings() # 重置警告过滤器 + warnings.filterwarnings(action="ignore", message="'crypt'", category=DeprecationWarning) # 忽略特定消息的DeprecationWarning + warnings.simplefilter("ignore", category=ImportWarning) # 忽略所有ImportWarning类别的警告 + if sys.version_info >= (3, 0): # 如果Python版本大于等于3.0 + warnings.simplefilter("ignore", category=ResourceWarning) # 忽略所有ResourceWarning类别的警告 # 忽略特定警告 - warnings.filterwarnings(action="ignore", message="Python 2 is no longer supported") - warnings.filterwarnings(action="ignore", message=".*was already imported", category=UserWarning) - warnings.filterwarnings(action="ignore", message=".*using a very old release", category=UserWarning) - warnings.filterwarnings(action="ignore", message=".*default buffer size will be used", category=RuntimeWarning) - warnings.filterwarnings(action="ignore", category=UserWarning, module="psycopg2") + warnings.filterwarnings(action="ignore", message="Python 2 is no longer supported") # 忽略关于Python 2不再支持的警告 + warnings.filterwarnings(action="ignore", message=".*was already imported", category=UserWarning) # 忽略关于模块已导入的UserWarning + warnings.filterwarnings(action="ignore", message=".*using a very old release", category=UserWarning) # 忽略关于使用旧版本的UserWarning + warnings.filterwarnings(action="ignore", message=".*default buffer size will be used", category=RuntimeWarning) # 忽略关于默认缓冲区大小的RuntimeWarning + warnings.filterwarnings(action="ignore", category=UserWarning, module="psycopg2") # 忽略psycopg2模块的UserWarning # 导入sqlmap的核心日志模块 - from lib.core.data import logger + from lib.core.data import logger # 从lib.core.data模块导入logger对象,用于记录日志信息 # 导入sqlmap的核心功能模块 - from lib.core.common import banner - from lib.core.common import checkPipedInput - from lib.core.common import checkSums - from lib.core.common import createGithubIssue - from lib.core.common import dataToStdout - from lib.core.common import extractRegexResult - from lib.core.common import filterNone - from lib.core.common import getDaysFromLastUpdate - from lib.core.common import getFileItems - from lib.core.common import getSafeExString - from lib.core.common import maskSensitiveData - from lib.core.common import openFile - from lib.core.common import setPaths - from lib.core.common import weAreFrozen - from lib.core.convert import getUnicode - from lib.core.common import setColor - from lib.core.common import unhandledExceptionMessage - from lib.core.compat import LooseVersion - from lib.core.compat import xrange - from lib.core.data import cmdLineOptions - from lib.core.data import conf - from lib.core.data import kb - from lib.core.datatype import OrderedSet - from lib.core.enums import MKSTEMP_PREFIX - from lib.core.exception import SqlmapBaseException - from lib.core.exception import SqlmapShellQuitException - from lib.core.exception import SqlmapSilentQuitException - from lib.core.exception import SqlmapUserQuitException - from lib.core.option import init - from lib.core.option import initOptions - from lib.core.patch import dirtyPatches - from lib.core.patch import resolveCrossReferences - from lib.core.settings import GIT_PAGE - from lib.core.settings import IS_WIN - from lib.core.settings import LAST_UPDATE_NAGGING_DAYS - from lib.core.settings import LEGAL_DISCLAIMER - from lib.core.settings import THREAD_FINALIZATION_TIMEOUT - from lib.core.settings import UNICODE_ENCODING - from lib.core.settings import VERSION - from lib.parse.cmdline import cmdLineParser - from lib.utils.crawler import crawl -except Exception as ex: - print("An error occurred: " + str(ex)) -except KeyboardInterrupt: - errMsg = "user aborted" - - if "logger" in globals(): - logger.critical(errMsg) - raise SystemExit - else: - import time - sys.exit("\r[%s] [CRITICAL] %s" % (time.strftime("%X"), errMsg)) - -def modulePath(): + from lib.core.common import banner # 从lib.core.common模块导入banner函数,用于显示程序横幅 + from lib.core.common import checkPipedInput # 从lib.core.common模块导入checkPipedInput函数,用于检查管道输入 + from lib.core.common import checkSums # 从lib.core.common模块导入checkSums函数,用于校验文件哈希值 + from lib.core.common import createGithubIssue # 从lib.core.common模块导入createGithubIssue函数,用于创建GitHub问题 + from lib.core.common import dataToStdout # 从lib.core.common模块导入dataToStdout函数,用于将数据输出到标准输出 + from lib.core.common import extractRegexResult # 从lib.core.common模块导入extractRegexResult函数,用于提取正则表达式匹配结果 + from lib.core.common import filterNone # 从lib.core.common模块导入filterNone函数,用于过滤None值 + from lib.core.common import getDaysFromLastUpdate # 从lib.core.common模块导入getDaysFromLastUpdate函数,用于计算自上次更新以来的天数 + from lib.core.common import getFileItems # 从lib.core.common模块导入getFileItems函数,用于从文件中读取内容 + from lib.core.common import getSafeExString # 从lib.core.common模块导入getSafeExString函数,用于安全地获取异常信息 + from lib.core.common import maskSensitiveData # 从lib.core.common模块导入maskSensitiveData函数,用于屏蔽敏感数据 + from lib.core.common import openFile # 从lib.core.common模块导入openFile函数,用于打开文件 + from lib.core.common import setPaths # 从lib.core.common模块导入setPaths函数,用于设置文件路径 + from lib.core.common import weAreFrozen # 从lib.core.common模块导入weAreFrozen函数,用于检查程序是否被冻结(打包) + from lib.core.convert import getUnicode # 从lib.core.convert模块导入getUnicode函数,用于将字符串转换为Unicode格式 + from lib.core.common import setColor # 从lib.core.common模块导入setColor函数,用于设置输出颜色 + from lib.core.common import unhandledExceptionMessage # 从lib.core.common模块导入unhandledExceptionMessage函数,用于处理未捕获的异常信息 + from lib.core.compat import LooseVersion # 从lib.core.compat模块导入LooseVersion类,用于版本号比较 + from lib.core.compat import xrange # 从lib.core.compat模块导入xrange函数,用于兼容Python 2和3的range函数 + from lib.core.data import cmdLineOptions # 从lib.core.data模块导入cmdLineOptions对象,用于存储命令行选项 + from lib.core.data import conf # 从lib.core.data模块导入conf对象,用于存储配置信息 + from lib.core.data import kb # 从lib.core.data模块导入kb对象,用于存储知识库信息 + from lib.core.datatype import OrderedSet # 从lib.core.datatype模块导入OrderedSet类,用于存储有序集合 + from lib.core.enums import MKSTEMP_PREFIX # 从lib.core.enums模块导入MKSTEMP_PREFIX常量,表示临时文件前缀 + from lib.core.exception import SqlmapBaseException # 从lib.core.exception模块导入SqlmapBaseException类,表示sqlmap的基础异常 + from lib.core.exception import SqlmapShellQuitException # 从lib.core.exception模块导入SqlmapShellQuitException类,表示shell退出异常 + from lib.core.exception import SqlmapSilentQuitException # 从lib.core.exception模块导入SqlmapSilentQuitException类,表示静默退出异常 + from lib.core.exception import SqlmapUserQuitException # 从lib.core.exception模块导入SqlmapUserQuitException类,表示用户退出异常 + from lib.core.option import init # 从lib.core.option模块导入init函数,用于初始化选项 + from lib.core.option import initOptions # 从lib.core.option模块导入initOptions函数,用于初始化命令行选项 + from lib.core.patch import dirtyPatches # 从lib.core.patch模块导入dirtyPatches函数,用于应用临时补丁 + from lib.core.patch import resolveCrossReferences # 从lib.core.patch模块导入resolveCrossReferences函数,用于解决交叉引用问题 + from lib.core.settings import GIT_PAGE # 从lib.core.settings模块导入GIT_PAGE常量,表示GitHub页面地址 + from lib.core.settings import IS_WIN # 从lib.core.settings模块导入IS_WIN常量,表示当前操作系统是否为Windows + from lib.core.settings import LAST_UPDATE_NAGGING_DAYS # 从lib.core.settings模块导入LAST_UPDATE_NAGGING_DAYS常量,表示提醒更新的天数 + from lib.core.settings import LEGAL_DISCLAIMER # 从lib.core.settings模块导入LEGAL_DISCLAIMER常量,表示法律声明 + from lib.core.settings import THREAD_FINALIZATION_TIMEOUT # 从lib.core.settings模块导入THREAD_FINALIZATION_TIMEOUT常量,表示线程结束的超时时间 + from lib.core.settings import UNICODE_ENCODING # 从lib.core.settings模块导入UNICODE_ENCODING常量,表示默认的Unicode编码 + from lib.core.settings import VERSION # 从lib.core.settings模块导入VERSION常量,表示程序版本号 + from lib.parse.cmdline import cmdLineParser # 从lib.parse.cmdline模块导入cmdLineParser函数,用于解析命令行参数 + from lib.utils.crawler import crawl # 从lib.utils.crawler模块导入crawl函数,用于爬取数据 +except Exception as ex: # 捕获所有异常 + print("An error occurred: " + str(ex)) # 打印异常信息 +except KeyboardInterrupt: # 捕获用户中断(如按下Ctrl+C) + errMsg = "user aborted" # 定义错误信息 + + if "logger" in globals(): # 如果logger对象已定义 + logger.critical(errMsg) # 记录严重错误信息 + raise SystemExit # 退出程序 + else: # 如果logger对象未定义 + import time # 导入time模块 + sys.exit("\r[%s] [CRITICAL] %s" % (time.strftime("%X"), errMsg)) # 退出程序并打印错误信息,包含当前时间 + +def modulePath(): # 定义modulePath函数,用于获取程序的目录路径 """ 获取程序的目录路径,即使使用了 py2exe 进行冻结打包也能正确获取。 @@ -118,15 +118,15 @@ def modulePath(): """ try: # 如果程序被py2exe冻结,则使用sys.executable获取路径;否则使用__file__获取 - _ = sys.executable if weAreFrozen() else __file__ - except NameError: + _ = sys.executable if weAreFrozen() else __file__ # 如果程序被冻结,使用sys.executable获取路径;否则使用__file__获取当前文件路径 + except NameError: # 如果__file__未定义(在某些环境下可能发生),则执行以下代码 # 如果__file__未定义(在某些环境下可能发生),则使用inspect模块获取当前函数的文件路径 - _ = inspect.getsourcefile(modulePath) + _ = inspect.getsourcefile(modulePath) # 使用inspect模块获取当前函数的源文件路径 # 获取_的目录路径,并转换为Unicode编码 - return getUnicode(os.path.dirname(os.path.realpath(_)), encoding=sys.getfilesystemencoding() or UNICODE_ENCODING) + return getUnicode(os.path.dirname(os.path.realpath(_)), encoding=sys.getfilesystemencoding() or UNICODE_ENCODING) # 返回_的目录路径,并将其转换为Unicode编码 -def checkEnvironment(): +def checkEnvironment(): # 定义checkEnvironment函数,用于检查运行环境是否适合运行sqlmap """ 检查运行环境是否适合运行 sqlmap。 @@ -134,32 +134,33 @@ def checkEnvironment(): """ try: # 检查程序目录是否存在 - os.path.isdir(modulePath()) - except UnicodeEncodeError: + os.path.isdir(modulePath()) # 检查modulePath函数返回的路径是否为目录 + except UnicodeEncodeError: # 如果系统无法正确处理非ASCII路径,则执行以下代码 # 如果系统无法正确处理非ASCII路径,则记录错误信息并退出 - errMsg = "your system does not properly handle non-ASCII paths. " - errMsg += "Please move the sqlmap's directory to the other location" - logger.critical(errMsg) - raise SystemExit + errMsg = "your system does not properly handle non-ASCII paths. " # 定义错误信息,提示系统无法处理非ASCII路径 + errMsg += "Please move the sqlmap's directory to the other location" # 建议用户将sqlmap目录移动到其他位置 + logger.critical(errMsg) # 记录严重错误信息 + raise SystemExit # 退出程序 # 检查sqlmap的版本是否低于1.0,如果是,则说明运行环境有问题 - if LooseVersion(VERSION) < LooseVersion("1.0"): - errMsg = "your runtime environment (e.g. PYTHONPATH) is " - errMsg += "broken. Please make sure that you are not running " - errMsg += "newer versions of sqlmap with runtime scripts for older " - errMsg += "versions" - logger.critical(errMsg) - raise SystemExit + if LooseVersion(VERSION) < LooseVersion("1.0"): # 如果当前版本低于1.0 + errMsg = "your runtime environment (e.g. PYTHONPATH) is " # 定义错误信息,提示运行环境有问题 + errMsg += "broken. Please make sure that you are not running " # 建议用户检查是否使用了旧版本的运行脚本 + errMsg += "newer versions of sqlmap with runtime scripts for older " # 提示用户不要使用旧版本的运行脚本运行新版本的sqlmap + errMsg += "versions" # 提示用户检查运行环境 + logger.critical(errMsg) # 记录严重错误信息 + raise SystemExit # 退出程序 # 如果是通过pip安装的sqlmap,则需要对sys.modules进行一些修补操作 - if "sqlmap.sqlmap" in sys.modules: - for _ in ("cmdLineOptions", "conf", "kb"): + if "sqlmap.sqlmap" in sys.modules: # 如果sqlmap.sqlmap模块已加载 + for _ in ("cmdLineOptions", "conf", "kb"): # 遍历需要修补的变量名 # 将lib.core.data模块中的cmdLineOptions、conf、kb变量添加到全局变量中 - globals()[_] = getattr(sys.modules["lib.core.data"], _) + globals()[_] = getattr(sys.modules["lib.core.data"], _) # 将lib.core.data模块中的变量添加到全局变量中 - for _ in ("SqlmapBaseException", "SqlmapShellQuitException", "SqlmapSilentQuitException", "SqlmapUserQuitException"): + for _ in ("SqlmapBaseException", "SqlmapShellQuitException", "SqlmapSilentQuitException", "SqlmapUserQuitException"): # 遍历需要修补的异常类名 # 将lib.core.exception模块中的异常类添加到全局变量中 - globals()[_] = getattr(sys.modules["lib.core.exception"], _) + globals()[_] = getattr(sys.modules["lib.core.exception"], _) # 将lib.core.exception模块中的异常类添加到全局变量中 + def main(): """ 当从命令行运行时,这是 sqlmap 的主函数。 @@ -167,500 +168,485 @@ def main(): try: # 应用脏补丁和解析交叉引用 - dirtyPatches() - resolveCrossReferences() + dirtyPatches() # 应用一些临时的修复或补丁 + resolveCrossReferences() # 解析并处理代码中的交叉引用 # 检查运行环境并设置程序路径 - checkEnvironment() - setPaths(modulePath()) - banner() + checkEnvironment() # 检查当前运行环境是否满足要求 + setPaths(modulePath()) # 设置程序的路径 + banner() # 显示程序的横幅信息 # 解析命令行参数并更新全局配置 - args = cmdLineParser() - cmdLineOptions.update(args.__dict__ if hasattr(args, "__dict__") else args) - initOptions(cmdLineOptions) + args = cmdLineParser() # 解析命令行参数 + cmdLineOptions.update(args.__dict__ if hasattr(args, "__dict__") else args) # 更新全局命令行选项 + initOptions(cmdLineOptions) # 初始化全局配置选项 # 如果有管道输入,则设置批量模式 - if checkPipedInput(): - conf.batch = True + if checkPipedInput(): # 检查是否有管道输入 + conf.batch = True # 如果有管道输入,则设置批量模式为True # 如果配置了API,设置API日志和重定向标准输出和错误 - if conf.get("api"): + if conf.get("api"): # 检查是否配置了API # 延迟导入(重量级导入) - from lib.utils.api import StdDbOut - from lib.utils.api import setRestAPILog + from lib.utils.api import StdDbOut # 导入StdDbOut类,用于重定向标准输出和错误 + from lib.utils.api import setRestAPILog # 导入setRestAPILog函数,用于设置API日志 # 重定向标准输出和错误到IPC数据库 - sys.stdout = StdDbOut(conf.taskid, messagetype="stdout") - sys.stderr = StdDbOut(conf.taskid, messagetype="stderr") + sys.stdout = StdDbOut(conf.taskid, messagetype="stdout") # 重定向标准输出到IPC数据库 + sys.stderr = StdDbOut(conf.taskid, messagetype="stderr") # 重定向标准错误到IPC数据库 - setRestAPILog() + setRestAPILog() # 设置API日志 # 设置显示时间并显示法律声明和启动信息 - conf.showTime = True - dataToStdout("[!] legal disclaimer: %s\n\n" % LEGAL_DISCLAIMER, forceOutput=True) - dataToStdout("[*] starting @ %s\n\n" % time.strftime("%X /%Y-%m-%d/"), forceOutput=True) + conf.showTime = True # 设置显示时间 + dataToStdout("[!] legal disclaimer: %s\n\n" % LEGAL_DISCLAIMER, forceOutput=True) # 显示法律声明 + dataToStdout("[*] starting @ %s\n\n" % time.strftime("%X /%Y-%m-%d/"), forceOutput=True) # 显示启动信息 # 初始化程序 - init() + init() # 调用初始化函数,完成程序的初始化工作 # 如果没有设置更新所有选项,则执行后续操作 - if not conf.updateAll: + if not conf.updateAll: # 检查是否设置了更新所有选项 # 延迟导入(更快的启动) - if conf.smokeTest: + if conf.smokeTest: # 检查是否设置了烟雾测试 # 运行烟雾测试 - from lib.core.testing import smokeTest - os._exitcode = 1 - (smokeTest() or 0) - elif conf.vulnTest: + from lib.core.testing import smokeTest # 导入烟雾测试函数 + os._exitcode = 1 - (smokeTest() or 0) # 运行烟雾测试并设置退出码 + elif conf.vulnTest: # 检查是否设置了漏洞测试 # 运行漏洞测试 - from lib.core.testing import vulnTest - os._exitcode = 1 - (vulnTest() or 0) + from lib.core.testing import vulnTest # 导入漏洞测试函数 + os._exitcode = 1 - (vulnTest() or 0) # 运行漏洞测试并设置退出码 else: # 启动sqlmap控制器 - from lib.controller.controller import start - if conf.profile: + from lib.controller.controller import start # 导入启动控制器函数 + if conf.profile: # 检查是否设置了性能分析 # 如果设置了性能分析,则进行性能分析 - from lib.core.profiling import profile - globals()["start"] = start - profile() + from lib.core.profiling import profile # 导入性能分析函数 + globals()["start"] = start # 将start函数添加到全局命名空间 + profile() # 运行性能分析 else: try: # 如果设置了爬取深度和批量文件,则开始爬取 - if conf.crawlDepth and conf.bulkFile: - targets = getFileItems(conf.bulkFile) + if conf.crawlDepth and conf.bulkFile: # 检查是否设置了爬取深度和批量文件 + targets = getFileItems(conf.bulkFile) # 从批量文件中获取目标列表 - for i in xrange(len(targets)): - target = None + for i in xrange(len(targets)): # 遍历目标列表 + target = None # 初始化目标变量 try: - kb.targets = OrderedSet() - target = targets[i] + kb.targets = OrderedSet() # 初始化目标集合 + target = targets[i] # 获取当前目标 - if not re.search(r"(?i)\Ahttp[s]*://", target): - target = "http://%s" % target + if not re.search(r"(?i)\Ahttp[s]*://", target): # 检查目标是否包含协议 + target = "http://%s" % target # 如果没有协议,则添加默认的HTTP协议 - infoMsg = "starting crawler for target URL '%s' (%d/%d)" % (target, i + 1, len(targets)) - logger.info(infoMsg) + infoMsg = "starting crawler for target URL '%s' (%d/%d)" % (target, i + 1, len(targets)) # 生成日志信息 + logger.info(infoMsg) # 记录日志信息 - crawl(target) - except Exception as ex: - if target and not isinstance(ex, SqlmapUserQuitException): - errMsg = "problem occurred while crawling '%s' ('%s')" % (target, getSafeExString(ex)) - logger.error(errMsg) + crawl(target) # 开始爬取目标 + except Exception as ex: # 捕获异常 + if target and not isinstance(ex, SqlmapUserQuitException): # 检查异常类型 + errMsg = "problem occurred while crawling '%s' ('%s')" % (target, getSafeExString(ex)) # 生成错误信息 + logger.error(errMsg) # 记录错误信息 else: - raise + raise # 重新抛出异常 else: - if kb.targets: - start() + if kb.targets: # 检查目标集合是否非空 + start() # 启动控制器 else: - start() - except Exception as ex: - os._exitcode = 1 + start() # 如果没有设置爬取深度和批量文件,则直接启动控制器 + except Exception as ex: # 捕获异常 + os._exitcode = 1 # 设置退出码为1 # 如果无法启动新线程,则记录错误信息并退出 - if "can't start new thread" in getSafeExString(ex): - errMsg = "unable to start new threads. Please check OS (u)limits" - logger.critical(errMsg) - raise SystemExit + if "can't start new thread" in getSafeExString(ex): # 检查异常信息是否包含无法启动新线程 + errMsg = "unable to start new threads. Please check OS (u)limits" # 生成错误信息 + logger.critical(errMsg) # 记录严重错误信息 + raise SystemExit # 退出程序 else: - raise + raise # 重新抛出异常 # 捕获并处理各种异常,记录错误信息并退出 - except SqlmapUserQuitException: - if not conf.batch: - errMsg = "user quit" - logger.error(errMsg) + except SqlmapUserQuitException: # 捕获用户主动退出的异常 + if not conf.batch: # 检查是否处于批量模式 + errMsg = "user quit" # 生成错误信息 + logger.error(errMsg) # 记录错误信息 - except (SqlmapSilentQuitException, bdb.BdbQuit): - pass + except (SqlmapSilentQuitException, bdb.BdbQuit): # 捕获静默退出或调试器退出的异常 + pass # 不处理,直接跳过 - except SqlmapShellQuitException: - cmdLineOptions.sqlmapShell = False + except SqlmapShellQuitException: # 捕获SQLMap Shell退出的异常 + cmdLineOptions.sqlmapShell = False # 设置SQLMap Shell选项为False - except SqlmapBaseException as ex: - errMsg = getSafeExString(ex) - logger.critical(errMsg) + except SqlmapBaseException as ex: # 捕获SQLMap基础异常 + errMsg = getSafeExString(ex) # 获取安全的异常信息 + logger.critical(errMsg) # 记录严重错误信息 - os._exitcode = 1 + os._exitcode = 1 # 设置退出码为1 - raise SystemExit + raise SystemExit # 退出程序 - except KeyboardInterrupt: + except KeyboardInterrupt: # 捕获键盘中断异常(如Ctrl+C) try: - print() - except IOError: - pass + print() # 打印空行 + except IOError: # 捕获IO错误 + pass # 不处理,直接跳过 - except EOFError: - print() + except EOFError: # 捕获文件结束异常(如Ctrl+D) + print() # 打印空行 - errMsg = "exit" - logger.error(errMsg) + errMsg = "exit" # 生成错误信息 + logger.error(errMsg) # 记录错误信息 - except SystemExit as ex: - os._exitcode = ex.code or 0 + except SystemExit as ex: # 捕获系统退出异常 + os._exitcode = ex.code or 0 # 设置退出码为异常代码或0 - except: - print() - errMsg = unhandledExceptionMessage() - excMsg = traceback.format_exc() - valid = checkSums() + except: # 捕获所有其他异常 + print() # 打印空行 + errMsg = unhandledExceptionMessage() # 获取未处理异常的信息 + excMsg = traceback.format_exc() # 获取异常的详细堆栈信息 + valid = checkSums() # 检查校验和 - os._exitcode = 255 + os._exitcode = 255 # 设置退出码为255 # 如果异常信息中包含内存耗尽相关的消息,则记录内存耗尽错误并退出 - if any(_ in excMsg for _ in ("MemoryError", "Cannot allocate memory")): - errMsg = "memory exhaustion detected" - logger.critical(errMsg) - raise SystemExit + if any(_ in excMsg for _ in ("MemoryError", "Cannot allocate memory")): # 检查异常信息是否包含内存耗尽 + errMsg = "memory exhaustion detected" # 生成错误信息 + logger.critical(errMsg) # 记录严重错误信息 + raise SystemExit # 退出程序 # 如果异常信息中包含磁盘空间不足相关的消息,则记录磁盘空间错误并退出 - elif any(_ in excMsg for _ in ("No space left", "Disk quota exceeded", "Disk full while accessing")): - errMsg = "no space left on output device" - logger.critical(errMsg) - raise SystemExit + elif any(_ in excMsg for _ in ("No space left", "Disk quota exceeded", "Disk full while accessing")): # 检查异常信息是否包含磁盘空间不足 + errMsg = "no space left on output device" # 生成错误信息 + logger.critical(errMsg) # 记录严重错误信息 + raise SystemExit # 退出程序 # 如果异常信息中包含分页文件空间不足的消息,则记录分页文件空间错误并退出 - elif any(_ in excMsg for _ in ("The paging file is too small",)): - errMsg = "no space left for paging file" - logger.critical(errMsg) - raise SystemExit + elif any(_ in excMsg for _ in ("The paging file is too small",)): # 检查异常信息是否包含分页文件空间不足 + errMsg = "no space left for paging file" # 生成错误信息 + logger.critical(errMsg) # 记录严重错误信息 + raise SystemExit # 退出程序 # 如果异常信息中包含权限拒绝和Metasploit相关的消息,则记录Metasploit权限错误并退出 - elif all(_ in excMsg for _ in ("Access is denied", "subprocess", "metasploit")): - errMsg = "permission error occurred while running Metasploit" - logger.critical(errMsg) - raise SystemExit + elif all(_ in excMsg for _ in ("Access is denied", "subprocess", "metasploit")): # 检查异常信息是否包含Metasploit权限错误 + errMsg = "permission error occurred while running Metasploit" # 生成错误信息 + logger.critical(errMsg) # 记录严重错误信息 + raise SystemExit # 退出程序 # 如果异常信息中包含权限拒绝和metasploit相关的消息,则记录Metasploit权限错误并退出 - elif all(_ in excMsg for _ in ("Permission denied", "metasploit")): - errMsg = "permission error occurred while using Metasploit" - logger.critical(errMsg) - raise SystemExit + elif all(_ in excMsg for _ in ("Permission denied", "metasploit")): # 检查异常信息是否包含Metasploit权限错误 + errMsg = "permission error occurred while using Metasploit" # 生成错误信息 + logger.critical(errMsg) # 记录严重错误信息 + raise SystemExit # 退出程序 # 如果异常信息中包含只读文件系统的消息,则记录只读文件系统错误并退出 - elif "Read-only file system" in excMsg: - errMsg = "output device is mounted as read-only" - logger.critical(errMsg) - raise SystemExit + elif "Read-only file system" in excMsg: # 检查异常信息是否包含只读文件系统 + errMsg = "output device is mounted as read-only" # 生成错误信息 + logger.critical(errMsg) # 记录严重错误信息 + raise SystemExit # 退出程序 # 如果异常信息中包含系统资源不足的消息,则记录资源耗尽错误并退出 - elif "Insufficient system resources" in excMsg: - errMsg = "resource exhaustion detected" - logger.critical(errMsg) - raise SystemExit + elif "Insufficient system resources" in excMsg: # 检查异常信息是否包含系统资源不足 + errMsg = "resource exhaustion detected" # 生成错误信息 + logger.critical(errMsg) # 记录严重错误信息 + raise SystemExit # 退出程序 # 如果异常信息中包含磁盘I/O错误的消息,则记录I/O错误并退出 - elif "OperationalError: disk I/O error" in excMsg: - errMsg = "I/O error on output device" - logger.critical(errMsg) - raise SystemExit + elif "OperationalError: disk I/O error" in excMsg: # 检查异常信息是否包含磁盘I/O错误 + errMsg = "I/O error on output device" # 生成错误信息 + logger.critical(errMsg) # 记录严重错误信息 + raise SystemExit # 退出程序 # 如果异常信息中包含URL违反BIDI规则的消息,则记录无效URL错误并退出 - elif "Violation of BIDI" in excMsg: - errMsg = "invalid URL (violation of Bidi IDNA rule - RFC 5893)" - logger.critical(errMsg) - raise SystemExit + elif "Violation of BIDI" in excMsg: # 检查异常信息是否包含URL违反BIDI规则 + errMsg = "invalid URL (violation of Bidi IDNA rule - RFC 5893)" # 生成错误信息 + logger.critical(errMsg) # 记录严重错误信息 + raise SystemExit # 退出程序 # 如果异常信息中包含无效IPv6 URL的消息,则记录无效URL错误并退出 - elif "Invalid IPv6 URL" in excMsg: - errMsg = "invalid URL ('%s')" % excMsg.strip().split('\n')[-1] - logger.critical(errMsg) - raise SystemExit + elif "Invalid IPv6 URL" in excMsg: # 检查异常信息是否包含无效IPv6 URL + errMsg = "invalid URL ('%s')" % excMsg.strip().split('\n')[-1] # 生成错误信息 + logger.critical(errMsg) # 记录严重错误信息 + raise SystemExit # 退出程序 + # 如果异常信息中包含临时文件访问问题的消息,则记录临时文件访问错误并退出 - elif "_mkstemp_inner" in excMsg: - errMsg = "there has been a problem while accessing temporary files" - logger.critical(errMsg) - raise SystemExit + elif "_mkstemp_inner" in excMsg: # 检查异常信息是否包含临时文件访问问题 + errMsg = "there has been a problem while accessing temporary files" # 生成错误信息 + logger.critical(errMsg) # 记录严重错误信息 + raise SystemExit # 退出程序 # 如果异常信息中包含无法写入临时目录的消息,则记录临时目录写入错误并退出 - elif any(_ in excMsg for _ in ("tempfile.mkdtemp", "tempfile.mkstemp", "tempfile.py")): - errMsg = "unable to write to the temporary directory '%s'. " % tempfile.gettempdir() - errMsg += "Please make sure that your disk is not full and " - errMsg += "that you have sufficient write permissions to " - errMsg += "create temporary files and/or directories" - logger.critical(errMsg) - raise SystemExit + elif any(_ in excMsg for _ in ("tempfile.mkdtemp", "tempfile.mkstemp", "tempfile.py")): # 检查异常信息是否包含临时目录写入问题 + errMsg = "unable to write to the temporary directory '%s'. " % tempfile.gettempdir() # 生成错误信息 + errMsg += "Please make sure that your disk is not full and " # 添加提示信息 + errMsg += "that you have sufficient write permissions to " # 添加提示信息 + errMsg += "create temporary files and/or directories" # 添加提示信息 + logger.critical(errMsg) # 记录严重错误信息 + raise SystemExit # 退出程序 # 如果异常信息中包含权限拒绝的消息,则记录文件访问权限错误并退出 - elif "Permission denied: '" in excMsg: - match = re.search(r"Permission denied: '([^']*)", excMsg) - errMsg = "permission error occurred while accessing file '%s'" % match.group(1) - logger.critical(errMsg) - raise SystemExit + elif "Permission denied: '" in excMsg: # 检查异常信息是否包含权限拒绝 + match = re.search(r"Permission denied: '([^']*)", excMsg) # 提取被拒绝访问的文件路径 + errMsg = "permission error occurred while accessing file '%s'" % match.group(1) # 生成错误信息 + logger.critical(errMsg) # 记录严重错误信息 + raise SystemExit # 退出程序 # 如果异常信息中包含sqlalchemy包版本问题的消息,则记录sqlalchemy版本错误并退出 - elif all(_ in excMsg for _ in ("twophase", "sqlalchemy")): - errMsg = "please update the 'sqlalchemy' package (>= 1.1.11) " - # 由于网络原因,无法解析提供的链接,可能是链接问题或网络问题,请检查链接的合法性并适当重试。 - logger.critical(errMsg) - raise SystemExit + elif all(_ in excMsg for _ in ("twophase", "sqlalchemy")): # 检查异常信息是否包含sqlalchemy版本问题 + errMsg = "please update the 'sqlalchemy' package (>= 1.1.11) " # 生成错误信息 + logger.critical(errMsg) # 记录严重错误信息 + raise SystemExit # 退出程序 # 如果异常信息中包含Python版本问题的消息,则记录Python版本错误并退出 - elif "invalid maximum character passed to PyUnicode_New" in excMsg and re.search(r"\A3\.[34]", sys.version) is not None: - errMsg = "please upgrade the Python version (>= 3.5) " - # 由于网络原因,无法解析提供的链接,可能是链接问题或网络问题,请检查链接的合法性并适当重试。 - logger.critical(errMsg) - raise SystemExit + elif "invalid maximum character passed to PyUnicode_New" in excMsg and re.search(r"\A3\.[34]", sys.version) is not None: # 检查异常信息是否包含Python版本问题 + errMsg = "please upgrade the Python version (>= 3.5) " # 生成错误信息 + logger.critical(errMsg) # 记录严重错误信息 + raise SystemExit # 退出程序 # 如果异常信息中包含PyMySQL包版本问题的消息,则记录PyMySQL版本错误并退出 - elif all(_ in excMsg for _ in ("scramble_caching_sha2", "TypeError")): - errMsg = "please downgrade the 'PyMySQL' package (=< 0.8.1) " - # 由于网络原因,无法解析提供的链接,可能是链接问题或网络问题,请检查链接的合法性并适当重试。 - logger.critical(errMsg) - raise SystemExit + elif all(_ in excMsg for _ in ("scramble_caching_sha2", "TypeError")): # 检查异常信息是否包含PyMySQL版本问题 + errMsg = "please downgrade the 'PyMySQL' package (=< 0.8.1) " # 生成错误信息 + logger.critical(errMsg) # 记录严重错误信息 + raise SystemExit # 退出程序 # 如果异常信息中包含Python解 - # 假设excMsg是一个包含异常信息的字符串变量 # 检查excMsg是否包含"pymysql"和"configparser"这两个字符串 - elif all(_ in excMsg for _ in ("pymysql", "configparser")): - # 如果都包含,则设置错误信息为检测到'pymsql'的错误初始化(使用了Python3的依赖) - errMsg = "wrong initialization of 'pymsql' detected (using Python3 dependencies)" - # 使用logger记录这个严重错误 - logger.critical(errMsg) - # 抛出SystemExit异常,导致程序退出 - raise SystemExit + elif all(_ in excMsg for _ in ("pymysql", "configparser")): # 检查异常信息是否包含pymysql和configparser + errMsg = "wrong initialization of 'pymsql' detected (using Python3 dependencies)" # 生成错误信息 + logger.critical(errMsg) # 记录严重错误信息 + raise SystemExit # 退出程序 # 检查excMsg是否包含"ntlm"、"socket.error, err"和"SyntaxError"这三个字符串 - elif all(_ in excMsg for _ in ("ntlm", "socket.error, err", "SyntaxError")): - # 如果都包含,则设置错误信息为检测到'python-ntlm'的错误初始化(使用了Python2的语法) - errMsg = "wrong initialization of 'python-ntlm' detected (using Python2 syntax)" - # 使用logger记录这个严重错误 - logger.critical(errMsg) - # 抛出SystemExit异常,导致程序退出 - raise SystemExit + elif all(_ in excMsg for _ in ("ntlm", "socket.error, err", "SyntaxError")): # 检查异常信息是否包含ntlm、socket.error和SyntaxError + errMsg = "wrong initialization of 'python-ntlm' detected (using Python2 syntax)" # 生成错误信息 + logger.critical(errMsg) # 记录严重错误信息 + raise SystemExit # 退出程序 # 检查excMsg是否包含"drda"和"to_bytes"这两个字符串 - elif all(_ in excMsg for _ in ("drda", "to_bytes")): - # 如果都包含,则设置错误信息为检测到'drda'的错误初始化(使用了Python3的语法) - errMsg = "wrong initialization of 'drda' detected (using Python3 syntax)" - # 使用logger记录这个严重错误 - logger.critical(errMsg) - # 抛出SystemExit异常,导致程序退出 - raise SystemExit + elif all(_ in excMsg for _ in ("drda", "to_bytes")): # 检查异常信息是否包含drda和to_bytes + errMsg = "wrong initialization of 'drda' detected (using Python3 syntax)" # 生成错误信息 + logger.critical(errMsg) # 记录严重错误信息 + raise SystemExit # 退出程序 # 检查excMsg是否包含特定的错误信息,即'WebSocket'对象没有'status'属性 - elif "'WebSocket' object has no attribute 'status'" in excMsg: - # 如果包含,则设置错误信息为检测到错误的websocket库 - errMsg = "wrong websocket library detected" - # 添加参考链接到错误信息中 - errMsg += " (Reference: 'https://github.com/sqlmapproject/sqlmap/issues/4572#issuecomment-775041086')" - # 使用logger记录这个严重错误 - logger.critical(errMsg) - # 抛出SystemExit异常,导致程序退出 - raise SystemExit + elif "'WebSocket' object has no attribute 'status'" in excMsg: # 检查异常信息是否包含WebSocket对象缺少status属性 + errMsg = "wrong websocket library detected" # 生成错误信息 + errMsg += " (Reference: 'https://github.com/sqlmapproject/sqlmap/issues/4572#issuecomment-775041086')" # 添加参考链接 + logger.critical(errMsg) # 记录严重错误信息 + raise SystemExit # 退出程序 # 检查excMsg是否包含特定的错误信息,即初始化GUI界面时出现问题 - elif all(_ in excMsg for _ in ("window = tkinter.Tk()",)): - # 如果包含,则设置错误信息为GUI界面初始化问题 - errMsg = "there has been a problem in initialization of GUI interface " - # 添加具体的错误信息到错误消息中 - errMsg += "('%s')" % excMsg.strip().split('\n')[-1] - # 使用logger记录这个严重错误 - logger.critical(errMsg) - # 抛出SystemExit异常,导致程序退出 - raise SystemExit + elif all(_ in excMsg for _ in ("window = tkinter.Tk()",)): # 检查异常信息是否包含GUI初始化问题 + errMsg = "there has been a problem in initialization of GUI interface " # 生成错误信息 + errMsg += "('%s')" % excMsg.strip().split('\n')[-1] # 添加具体错误信息 + logger.critical(errMsg) # 记录严重错误信息 + raise SystemExit # 退出程序 # 检查excMsg是否包含特定的错误信息,即使用了不同版本的sqlmap文件 - elif any(_ in excMsg for _ in ("unable to access item 'liveTest'",)): - # 如果包含,则设置错误信息为检测到使用了不同版本的sqlmap文件 - errMsg = "detected usage of files from different versions of sqlmap" - # 使用logger记录这个严重错误 - logger.critical(errMsg) - # 抛出SystemExit异常,导致程序退出 - raise SystemExit + elif any(_ in excMsg for _ in ("unable to access item 'liveTest'",)): # 检查异常信息是否包含不同版本sqlmap文件问题 + errMsg = "detected usage of files from different versions of sqlmap" # 生成错误信息 + logger.critical(errMsg) # 记录严重错误信息 + raise SystemExit # 退出程序 # 检查errMsg是否包含特定的错误信息,即版本号相关的错误 - elif any(_ in errMsg for _ in (": 9.9.9#",)): - # 如果包含,则设置错误信息为一个简单的文本 - errMsg = "LOL xD" - # 使用logger记录这个严重错误 - logger.critical(errMsg) - # 抛出SystemExit异常,导致程序退出 - raise SystemExit + elif any(_ in errMsg for _ in (": 9.9.9#",)): # 检查错误信息是否包含特定版本号 + errMsg = "LOL xD" # 生成错误信息 + logger.critical(errMsg) # 记录严重错误信息 + raise SystemExit # 退出程序 # 检查是否设置了键盘中断的标记 - elif kb.get("dumpKeyboardInterrupt"): - # 如果设置了,则抛出SystemExit异常,导致程序退出 - raise SystemExit + elif kb.get("dumpKeyboardInterrupt"): # 检查是否设置了键盘中断标记 + raise SystemExit # 退出程序 # 检查excMsg是否包含特定的错误信息,即"Broken pipe" - elif any(_ in excMsg for _ in ("Broken pipe",)): - # 如果包含,则直接抛出SystemExit异常,导致程序退出 - raise SystemExit + elif any(_ in excMsg for _ in ("Broken pipe",)): # 检查异常信息是否包含Broken pipe + raise SystemExit # 退出程序 # 检查valid变量是否为False - elif valid is False: - # 如果为False,则设置错误信息为代码校验失败 - errMsg = "code checksum failed (turning off automatic issue creation). " - errMsg += "You should retrieve the latest development version from official GitHub " - errMsg += "repository at '%s'" % GIT_PAGE - # 使用logger记录这个严重错误 - logger.critical(errMsg) - # 打印空行 - print() - # 将错误信息输出到标准输出 - dataToStdout(excMsg) - # 抛出SystemExit异常,导致程序退出 - raise SystemExit + elif valid is False: # 检查校验和是否无效 + errMsg = "code checksum failed (turning off automatic issue creation). " # 生成错误信息 + errMsg += "You should retrieve the latest development version from official GitHub " # 添加提示信息 + errMsg += "repository at '%s'" % GIT_PAGE # 添加GitHub仓库链接 + logger.critical(errMsg) # 记录严重错误信息 + print() # 打印空行 + dataToStdout(excMsg) # 输出异常信息到标准输出 + raise SystemExit # 退出程序 # 检查errMsg和excMsg组合后是否包含特定的错误信息,即文件路径或特定参数 - elif any(_ in "%s\n%s" % (errMsg, excMsg) for _ in ("tamper/", "waf/", "--engagement-dojo")): - # 如果包含,则使用logger记录这个严重错误 - logger.critical(errMsg) - # 打印空行 - print() - # 将错误信息输出到标准输出 - dataToStdout(excMsg) - # 抛出SystemExit异常,导致程序退出 - raise SystemExit - - elif any(_ in excMsg for _ in ("ImportError", "ModuleNotFoundError", " returned NULL without setting an exception", "source code string cannot contain null bytes", "No module named", "tp_name field", "module 'sqlite3' has no attribute 'OperationalError'")): - errMsg = "invalid runtime environment ('%s')" % excMsg.split("Error: ")[-1].strip() - logger.critical(errMsg) - raise SystemExit - - elif all(_ in excMsg for _ in ("SyntaxError: Non-ASCII character", ".py on line", "but no encoding declared")): - errMsg = "invalid runtime environment ('%s')" % excMsg.split("Error: ")[-1].strip() - logger.critical(errMsg) - raise SystemExit - - elif all(_ in excMsg for _ in ("FileNotFoundError: [Errno 2] No such file or directory", "cwd = os.getcwd()")): - errMsg = "invalid runtime environment ('%s')" % excMsg.split("Error: ")[-1].strip() - logger.critical(errMsg) - raise SystemExit - - elif all(_ in excMsg for _ in ("PermissionError: [WinError 5]", "multiprocessing")): - errMsg = "there is a permission problem in running multiprocessing on this system. " - errMsg += "Please rerun with '--disable-multi'" - logger.critical(errMsg) - raise SystemExit - - elif all(_ in excMsg for _ in ("No such file", "_'")): - errMsg = "corrupted installation detected ('%s'). " % excMsg.strip().split('\n')[-1] - errMsg += "You should retrieve the latest development version from official GitHub " - errMsg += "repository at '%s'" % GIT_PAGE - logger.critical(errMsg) - raise SystemExit - - elif all(_ in excMsg for _ in ("No such file", "sqlmap.conf", "Test")): - errMsg = "you are trying to run (hidden) development tests inside the production environment" - logger.critical(errMsg) - raise SystemExit - - elif all(_ in excMsg for _ in ("HTTPNtlmAuthHandler", "'str' object has no attribute 'decode'")): - errMsg = "package 'python-ntlm' has a known compatibility issue with the " - errMsg += "Python 3 (Reference: 'https://github.com/mullender/python-ntlm/pull/61')" - logger.critical(errMsg) - raise SystemExit - - elif "'DictObject' object has no attribute '" in excMsg and all(_ in errMsg for _ in ("(fingerprinted)", "(identified)")): - errMsg = "there has been a problem in enumeration. " - errMsg += "Because of a considerable chance of false-positive case " - errMsg += "you are advised to rerun with switch '--flush-session'" - logger.critical(errMsg) - raise SystemExit - - elif "database disk image is malformed" in excMsg: - errMsg = "local session file seems to be malformed. Please rerun with '--flush-session'" - logger.critical(errMsg) - raise SystemExit - - elif "AttributeError: 'module' object has no attribute 'F_GETFD'" in excMsg: - errMsg = "invalid runtime (\"%s\") " % excMsg.split("Error: ")[-1].strip() - errMsg += "(Reference: 'https://stackoverflow.com/a/38841364' & 'https://bugs.python.org/issue24944#msg249231')" - logger.critical(errMsg) - raise SystemExit - - elif "bad marshal data (unknown type code)" in excMsg: - match = re.search(r"\s*(.+)\s+ValueError", excMsg) - errMsg = "one of your .pyc files are corrupted%s" % (" ('%s')" % match.group(1) if match else "") - errMsg += ". Please delete .pyc files on your system to fix the problem" - logger.critical(errMsg) - raise SystemExit - - for match in re.finditer(r'File "(.+?)", line', excMsg): - file_ = match.group(1) + elif any(_ in "%s\n%s" % (errMsg, excMsg) for _ in ("tamper/", "waf/", "--engagement-dojo")): # 检查错误信息是否包含特定路径或参数 + logger.critical(errMsg) # 记录严重错误信息 + print() # 打印空行 + dataToStdout(excMsg) # 输出异常信息到标准输出 + raise SystemExit # 退出程序 + + # 检查错误信息中是否包含特定的错误关键词,如果包含,则认为是运行时环境错误,并提取错误信息的最后部分。 + elif any(_ in excMsg for _ in ("ImportError", "ModuleNotFoundError", " returned NULL without setting an exception", "source code string cannot contain null bytes", "No module named", "tp_name field", "module 'sqlite3' has no attribute 'OperationalError'")): # 检查异常信息是否包含运行时环境错误 + errMsg = "invalid runtime environment ('%s')" % excMsg.split("Error: ")[-1].strip() # 生成错误信息 + logger.critical(errMsg) # 记录严重错误信息 + raise SystemExit # 退出程序 + + # 如果错误信息包含非ASCII字符编码错误,则认为是运行时环境错误,并提取错误信息的最后部分。 + elif all(_ in excMsg for _ in ("SyntaxError: Non-ASCII character", ".py on line", "but no encoding declared")): # 检查异常信息是否包含非ASCII字符编码错误 + errMsg = "invalid runtime environment ('%s')" % excMsg.split("Error: ")[-1].strip() # 生成错误信息 + logger.critical(errMsg) # 记录严重错误信息 + raise SystemExit # 退出程序 + + # 如果错误信息包含文件不存在的错误,则认为是运行时环境错误,并提取错误信息的最后部分。 + elif all(_ in excMsg for _ in ("FileNotFoundError: [Errno 2] No such file or directory", "cwd = os.getcwd()")): # 检查异常信息是否包含文件不存在错误 + errMsg = "invalid runtime environment ('%s')" % excMsg.split("Error: ")[-1].strip() # 生成错误信息 + logger.critical(errMsg) # 记录严重错误信息 + raise SystemExit # 退出程序 + + # 如果错误信息包含权限错误,则提示用户可能存在权限问题,并建议重新运行程序时禁用多进程。 + elif all(_ in excMsg for _ in ("PermissionError: [WinError 5]", "multiprocessing")): # 检查异常信息是否包含权限错误 + errMsg = "there is a permission problem in running multiprocessing on this system. " # 生成错误信息 + errMsg += "Please rerun with '--disable-multi'" # 添加建议信息 + logger.critical(errMsg) # 记录严重错误信息 + raise SystemExit # 退出程序 + + # 如果错误信息包含文件不存在的错误,则提示用户安装可能已损坏,并建议从官方GitHub仓库获取最新开发版本。 + elif all(_ in excMsg for _ in ("No such file", "_'")): # 检查异常信息是否包含文件不存在错误 + errMsg = "corrupted installation detected ('%s'). " % excMsg.strip().split('\n')[-1] # 生成错误信息 + errMsg += "You should retrieve the latest development version from official GitHub " # 添加提示信息 + errMsg += "repository at '%s'" % GIT_PAGE # 添加GitHub仓库链接 + logger.critical(errMsg) # 记录严重错误信息 + raise SystemExit # 退出程序 + + # 如果错误信息包含尝试在生产环境中运行开发测试的错误,则输出相应的错误信息。 + elif all(_ in excMsg for _ in ("No such file", "sqlmap.conf", "Test")): # 检查异常信息是否包含在生产环境中运行开发测试的错误 + errMsg = "you are trying to run (hidden) development tests inside the production environment" # 生成错误信息 + logger.critical(errMsg) # 记录严重错误信息 + raise SystemExit # 退出程序 + + # 如果错误信息包含HTTP NTLM认证相关的兼容性问题,则输出相应的错误信息,并提供参考链接。 + elif all(_ in excMsg for _ in ("HTTPNtlmAuthHandler", "'str' object has no attribute 'decode'")): # 检查异常信息是否包含HTTP NTLM认证兼容性问题 + errMsg = "package 'python-ntlm' has a known compatibility issue with the " # 生成错误信息 + errMsg += "Python 3 (Reference: 'https://github.com/mullender/python-ntlm/pull/61')" " # 添加参考链接 + logger.critical(errMsg) # 记录严重错误信息 + raise SystemExit # 退出程序 + + # 如果错误信息包含字典对象属性错误,并且与枚举相关,则提示用户可能存在枚举问题,并建议重新运行程序时刷新会话。 + elif "'DictObject' object has no attribute '" in excMsg and all(_ in errMsg for _ in ("(fingerprinted)", "(identified)")): # 检查异常信息是否包含字典对象属性错误 + errMsg = "there has been a problem in enumeration. " # 生成错误信息 + errMsg += "Because of a considerable chance of false-positive case " # 添加提示信息 + errMsg += "you are advised to rerun with switch '--flush-session'" # 添加建议信息 + logger.critical(errMsg) # 记录严重错误信息 + raise SystemExit # 退出程序 + + # 如果错误信息包含数据库磁盘映像损坏的错误,则提示用户会话文件可能损坏,并建议刷新会话。 + elif "database disk image is malformed" in excMsg: # 检查异常信息是否包含数据库磁盘映像损坏 + errMsg = "local session file seems to be malformed. Please rerun with '--flush-session'" # 生成错误信息 + logger.critical(errMsg) # 记录严重错误信息 + raise SystemExit # 退出程序 + + # 如果错误信息包含模块属性错误,则认为是运行时环境错误,并提取错误信息的最后部分。 + elif "AttributeError: 'module' object has no attribute 'F_GETFD'" in excMsg: # 检查异常信息是否包含模块属性错误 + errMsg = "invalid runtime (\"%s\") " % excMsg.split("Error: ")[-1].strip() # 生成错误信息 + errMsg += "(Reference: 'https://stackoverflow.com/a/38841364' & 'https://bugs.python.org/issue24944#msg249231')" " # 添加参考链接 + logger.critical(errMsg) # 记录严重错误信息 + raise SystemExit # 退出程序 + + + # 如果错误信息包含marshal数据错误,则提示用户.pyc文件可能损坏,并建议删除.pyc文件来解决问题。 + elif "bad marshal data (unknown type code)" in excMsg: # 检查异常信息是否包含marshal数据错误 + match = re.search(r"\s*(.+)\s+ValueError", excMsg) # 提取损坏的文件路径 + errMsg = "one of your .pyc files are corrupted%s" % (" ('%s')" % match.group(1) if match else "") # 生成错误信息 + errMsg += ". Please delete .pyc files on your system to fix the problem" # 添加建议信息 + logger.critical(errMsg) # 记录严重错误信息 + raise SystemExit # 退出程序 + + # 遍历异常信息中的文件路径,并对其进行规范化处理 + for match in re.finditer(r'File "(.+?)", line', excMsg): # 查找异常信息中的文件路径 + file_ = match.group(1) # 提取文件路径 try: - file_ = os.path.relpath(file_, os.path.dirname(__file__)) - except ValueError: - pass - file_ = file_.replace("\\", '/') - if "../" in file_: - file_ = re.sub(r"(\.\./)+", '/', file_) + file_ = os.path.relpath(file_, os.path.dirname(__file__)) # 将文件路径转换为相对路径 + except ValueError: # 捕获路径转换错误 + pass # 忽略错误 + file_ = file_.replace("\\", '/') # 将路径中的反斜杠替换为正斜杠 + if "../" in file_: # 检查路径中是否包含上级目录 + file_ = re.sub(r"(\.\./)+", '/', file_) # 替换上级目录为单斜杠 else: - file_ = file_.lstrip('/') - file_ = re.sub(r"/{2,}", '/', file_) - excMsg = excMsg.replace(match.group(1), file_) + file_ = file_.lstrip('/') # 去除路径开头的斜杠 + file_ = re.sub(r"/{2,}", '/', file_) # 将多个斜杠替换为单斜杠 + excMsg = excMsg.replace(match.group(1), file_) # 更新异常信息中的文件路径 - errMsg = maskSensitiveData(errMsg) - excMsg = maskSensitiveData(excMsg) + # 对错误信息和异常信息进行敏感数据掩码处理 + errMsg = maskSensitiveData(errMsg) # 掩码处理错误信息中的敏感数据 + excMsg = maskSensitiveData(excMsg) # 掩码处理异常信息中的敏感数据 - if conf.get("api") or not valid: - logger.critical("%s\n%s" % (errMsg, excMsg)) + # 如果配置了API或校验和无效,则记录错误信息和异常信息 + if conf.get("api") or not valid: # 检查是否配置了API或校验和无效 + logger.critical("%s\n%s" % (errMsg, excMsg)) # 记录严重错误信息和异常信息 else: - logger.critical(errMsg) - dataToStdout("%s\n" % setColor(excMsg.strip(), level=logging.CRITICAL)) - createGithubIssue(errMsg, excMsg) + logger.critical(errMsg) # 记录严重错误信息 + dataToStdout("%s\n" % setColor(excMsg.strip(), level=logging.CRITICAL)) # 输出带颜色的异常信息到标准输出 + createGithubIssue(errMsg, excMsg) # 创建GitHub问题 - finally: - kb.threadContinue = False + finally: # 无论是否发生异常,最终都会执行的代码块 + kb.threadContinue = False # 设置线程继续标志为False - if (getDaysFromLastUpdate() or 0) > LAST_UPDATE_NAGGING_DAYS: - warnMsg = "your sqlmap version is outdated" - logger.warning(warnMsg) + # 如果距离上次更新的天数超过指定值,则提示用户版本过时 + if (getDaysFromLastUpdate() or 0) > LAST_UPDATE_NAGGING_DAYS: # 检查距离上次更新的天数 + warnMsg = "your sqlmap version is outdated" # 生成警告信息 + logger.warning(warnMsg) # 记录警告信息 - if conf.get("showTime"): - dataToStdout("\n[*] ending @ %s\n\n" % time.strftime("%X /%Y-%m-%d/"), forceOutput=True) + # 如果配置了显示时间,则输出结束时间 + if conf.get("showTime"): # 检查是否配置了显示时间 + dataToStdout("\n[*] ending @ %s\n\n" % time.strftime("%X /%Y-%m-%d/"), forceOutput=True) # 输出结束时间 - kb.threadException = True + kb.threadException = True # 设置线程异常标志为True - if kb.get("tempDir"): - for prefix in (MKSTEMP_PREFIX.IPC, MKSTEMP_PREFIX.TESTING, MKSTEMP_PREFIX.COOKIE_JAR, MKSTEMP_PREFIX.BIG_ARRAY): - for filepath in glob.glob(os.path.join(kb.tempDir, "%s*" % prefix)): + # 如果存在临时目录,则清理临时文件 + if kb.get("tempDir"): # 检查是否存在临时目录 + for prefix in (MKSTEMP_PREFIX.IPC, MKSTEMP_PREFIX.TESTING, MKSTEMP_PREFIX.COOKIE_JAR, MKSTEMP_PREFIX.BIG_ARRAY): # 遍历临时文件前缀 + for filepath in glob.glob(os.path.join(kb.tempDir, "%s*" % prefix)): # 查找匹配的临时文件 try: - os.remove(filepath) - except OSError: - pass + os.remove(filepath) # 删除临时文件 + except OSError: # 捕获文件删除错误 + pass # 忽略错误 - if not filterNone(filepath for filepath in glob.glob(os.path.join(kb.tempDir, '*')) if not any(filepath.endswith(_) for _ in (".lock", ".exe", ".so", '_'))): # ignore junk files + # 如果临时目录中没有其他文件,则删除临时目录 + if not filterNone(filepath for filepath in glob.glob(os.path.join(kb.tempDir, '*')) if not any(filepath.endswith(_) for _ in (".lock", ".exe", ".so", '_'))): # 检查临时目录是否为空 + # 使用glob模块获取临时目录中的所有文件路径,并过滤掉以.lock、.exe、.so或_结尾的文件 try: - shutil.rmtree(kb.tempDir, ignore_errors=True) - except OSError: - pass + shutil.rmtree(kb.tempDir, ignore_errors=True) # 删除临时目录,ignore_errors=True表示忽略删除过程中可能出现的错误 + except OSError: # 捕获目录删除错误 + pass # 忽略错误,继续执行后续代码 + - if conf.get("hashDB"): - conf.hashDB.flush(True) - conf.hashDB.close() # NOTE: because of PyPy + if conf.get("hashDB"): # 检查配置中是否存在hashDB + conf.hashDB.flush(True) # 将hashDB中的数据刷新到磁盘 + conf.hashDB.close() # 关闭hashDB连接,NOTE: 由于PyPy的原因需要显式关闭 - if conf.get("harFile"): + if conf.get("harFile"): # 检查配置中是否存在harFile try: - with openFile(conf.harFile, "w+b") as f: - json.dump(conf.httpCollector.obtain(), fp=f, indent=4, separators=(',', ': ')) - except SqlmapBaseException as ex: - errMsg = getSafeExString(ex) - logger.critical(errMsg) + with openFile(conf.harFile, "w+b") as f: # 以二进制写模式打开harFile + json.dump(conf.httpCollector.obtain(), fp=f, indent=4, separators=(',', ': ')) # 将HTTP收集器中的数据以JSON格式写入文件 + except SqlmapBaseException as ex: # 捕获sqlmap基础异常 + errMsg = getSafeExString(ex) # 获取异常的安全字符串表示 + logger.critical(errMsg) # 记录严重错误日志 - if conf.get("api"): - conf.databaseCursor.disconnect() + if conf.get("api"): # 检查配置中是否存在api + conf.databaseCursor.disconnect() # 断开数据库游标连接 - if conf.get("dumper"): - conf.dumper.flush() + if conf.get("dumper"): # 检查配置中是否存在dumper + conf.dumper.flush() # 刷新dumper中的数据 # short delay for thread finalization - _ = time.time() - while threading.active_count() > 1 and (time.time() - _) > THREAD_FINALIZATION_TIMEOUT: - time.sleep(0.01) - - if cmdLineOptions.get("sqlmapShell"): - cmdLineOptions.clear() - conf.clear() - kb.clear() - conf.disableBanner = True - main() + _ = time.time() # 获取当前时间 + while threading.active_count() > 1 and (time.time() - _) > THREAD_FINALIZATION_TIMEOUT: # 检查当前活跃线程数是否大于1,并且等待时间是否超过线程最终化超时时间 + time.sleep(0.01) # 等待0.01秒,避免CPU占用过高 + + if cmdLineOptions.get("sqlmapShell"): # 检查命令行选项中是否存在sqlmapShell + cmdLineOptions.clear() # 清空命令行选项 + conf.clear() # 清空配置 + kb.clear() # 清空知识库 + conf.disableBanner = True # 禁用启动横幅 + main() # 调用主函数重新启动sqlmap + # 检查是否是作为主模块运行,如果是,则执行以下代码 if __name__ == "__main__": diff --git a/src/sqlmap-master/sqlmapapi.py b/src/sqlmap-master/sqlmapapi.py index 8527f1e..07e64a0 100644 --- a/src/sqlmap-master/sqlmapapi.py +++ b/src/sqlmap-master/sqlmapapi.py @@ -5,114 +5,114 @@ Copyright (c) 2006-2024 sqlmap developers (https://sqlmap.org/) See the file 'LICENSE' for copying permission """ -import sys +import sys # 导入sys模块,用于处理与Python解释器相关的操作 -sys.dont_write_bytecode = True +sys.dont_write_bytecode = True # 设置不生成.pyc字节码文件,以减少磁盘空间占用和加载时间 -__import__("lib.utils.versioncheck") # this has to be the first non-standard import +__import__("lib.utils.versioncheck") # 动态导入lib.utils.versioncheck模块,通常用于检查版本兼容性 -import logging -import os -import warnings +import logging # 导入logging模块,用于记录日志信息 +import os # 导入os模块,用于与操作系统进行交互 +import warnings # 导入warnings模块,用于处理警告信息 -warnings.filterwarnings(action="ignore", category=UserWarning) -warnings.filterwarnings(action="ignore", category=DeprecationWarning) +warnings.filterwarnings(action="ignore", category=UserWarning) # 忽略所有UserWarning类别的警告 +warnings.filterwarnings(action="ignore", category=DeprecationWarning) # 忽略所有DeprecationWarning类别的警告 try: - from optparse import OptionGroup - from optparse import OptionParser as ArgumentParser + from optparse import OptionGroup # 从optparse模块导入OptionGroup类,用于处理命令行选项组 + from optparse import OptionParser as ArgumentParser # 从optparse模块导入OptionParser类,并将其重命名为ArgumentParser - ArgumentParser.add_argument = ArgumentParser.add_option + ArgumentParser.add_argument = ArgumentParser.add_option # 将ArgumentParser的add_option方法重命名为add_argument,以兼容argparse的API - def _add_argument(self, *args, **kwargs): + def _add_argument(self, *args, **kwargs): # 定义一个辅助函数_add_argument,用于将add_argument方法映射到add_option方法 return self.add_option(*args, **kwargs) - OptionGroup.add_argument = _add_argument - -except ImportError: - from argparse import ArgumentParser - -finally: - def get_actions(instance): - for attr in ("option_list", "_group_actions", "_actions"): - if hasattr(instance, attr): - return getattr(instance, attr) - - def get_groups(parser): - return getattr(parser, "option_groups", None) or getattr(parser, "_action_groups") - - def get_all_options(parser): - retVal = set() - - for option in get_actions(parser): - if hasattr(option, "option_strings"): - retVal.update(option.option_strings) - else: - retVal.update(option._long_opts) - retVal.update(option._short_opts) - - for group in get_groups(parser): - for option in get_actions(group): - if hasattr(option, "option_strings"): - retVal.update(option.option_strings) - else: - retVal.update(option._long_opts) - retVal.update(option._short_opts) - - return retVal - -from lib.core.common import getUnicode -from lib.core.common import setPaths -from lib.core.data import logger -from lib.core.patch import dirtyPatches -from lib.core.patch import resolveCrossReferences -from lib.core.settings import RESTAPI_DEFAULT_ADAPTER -from lib.core.settings import RESTAPI_DEFAULT_ADDRESS -from lib.core.settings import RESTAPI_DEFAULT_PORT -from lib.core.settings import UNICODE_ENCODING -from lib.utils.api import client -from lib.utils.api import server + OptionGroup.add_argument = _add_argument # 将OptionGroup的add_argument方法映射到_add_argument函数 + +except ImportError: # 如果导入optparse模块失败(例如在Python 3中),则执行以下代码 + from argparse import ArgumentParser # 从argparse模块导入ArgumentParser类,用于处理命令行参数 + +finally: # 无论try块中的代码是否成功执行,finally块中的代码都会执行 + def get_actions(instance): # 定义一个函数get_actions,用于获取命令行解析器实例中的选项列表 + for attr in ("option_list", "_group_actions", "_actions"): # 遍历可能的属性名称 + if hasattr(instance, attr): # 如果实例具有该属性 + return getattr(instance, attr) # 返回该属性的值 + + def get_groups(parser): # 定义一个函数get_groups,用于获取命令行解析器中的选项组 + return getattr(parser, "option_groups", None) or getattr(parser, "_action_groups") # 返回解析器中的选项组,如果不存在则返回None + + def get_all_options(parser): # 定义一个函数get_all_options,用于获取命令行解析器中的所有选项 + retVal = set() # 创建一个空集合,用于存储所有选项 + + for option in get_actions(parser): # 遍历解析器中的选项 + if hasattr(option, "option_strings"): # 如果选项具有option_strings属性 + retVal.update(option.option_strings) # 将选项字符串添加到集合中 + else: # 否则 + retVal.update(option._long_opts) # 将长选项添加到集合中 + retVal.update(option._short_opts) # 将短选项添加到集合中 + + for group in get_groups(parser): # 遍历解析器中的选项组 + for option in get_actions(group): # 遍历选项组中的选项 + if hasattr(option, "option_strings"): # 如果选项具有option_strings属性 + retVal.update(option.option_strings) # 将选项字符串添加到集合中 + else: # 否则 + retVal.update(option._long_opts) # 将长选项添加到集合中 + retVal.update(option._short_opts) # 将短选项添加到集合中 + + return retVal # 返回包含所有选项的集合 + + +from lib.core.common import getUnicode # 从lib.core.common模块导入getUnicode函数,用于将字符串转换为Unicode格式 +from lib.core.common import setPaths # 从lib.core.common模块导入setPaths函数,用于设置文件路径 +from lib.core.data import logger # 从lib.core.data模块导入logger对象,用于记录日志信息 +from lib.core.patch import dirtyPatches # 从lib.core.patch模块导入dirtyPatches函数,用于应用临时补丁 +from lib.core.patch import resolveCrossReferences # 从lib.core.patch模块导入resolveCrossReferences函数,用于解决交叉引用问题 +from lib.core.settings import RESTAPI_DEFAULT_ADAPTER # 从lib.core.settings模块导入RESTAPI_DEFAULT_ADAPTER常量,表示默认的服务器适配器 +from lib.core.settings import RESTAPI_DEFAULT_ADDRESS # 从lib.core.settings模块导入RESTAPI_DEFAULT_ADDRESS常量,表示默认的服务器地址 +from lib.core.settings import RESTAPI_DEFAULT_PORT # 从lib.core.settings模块导入RESTAPI_DEFAULT_PORT常量,表示默认的服务器端口 +from lib.core.settings import UNICODE_ENCODING # 从lib.core.settings模块导入UNICODE_ENCODING常量,表示默认的Unicode编码 +from lib.utils.api import client # 从lib.utils.api模块导入client函数,用于启动REST-JSON API客户端 +from lib.utils.api import server # 从lib.utils.api模块导入server函数,用于启动REST-JSON API服务器 try: - from sqlmap import modulePath -except ImportError: - def modulePath(): - return getUnicode(os.path.dirname(os.path.realpath(__file__)), encoding=sys.getfilesystemencoding() or UNICODE_ENCODING) + from sqlmap import modulePath # 从sqlmap模块导入modulePath函数,用于获取模块路径 +except ImportError: # 如果导入失败(例如sqlmap模块不存在),则执行以下代码 + def modulePath(): # 定义一个函数modulePath,用于获取当前模块的路径 + return getUnicode(os.path.dirname(os.path.realpath(__file__)), encoding=sys.getfilesystemencoding() or UNICODE_ENCODING) # 返回当前文件的目录路径,并将其转换为Unicode格式 -def main(): +def main(): # 定义main函数,作为REST-JSON API的入口函数 """ REST-JSON API main function """ - dirtyPatches() - resolveCrossReferences() + dirtyPatches() # 应用临时补丁 + resolveCrossReferences() # 解决交叉引用问题 # Set default logging level to debug - logger.setLevel(logging.DEBUG) + logger.setLevel(logging.DEBUG) # 设置日志记录级别为DEBUG,以便记录详细信息 # Initialize paths - setPaths(modulePath()) + setPaths(modulePath()) # 初始化文件路径,使用modulePath函数获取当前模块路径 # Parse command line options - apiparser = ArgumentParser() - apiparser.add_argument("-s", "--server", help="Run as a REST-JSON API server", action="store_true") - apiparser.add_argument("-c", "--client", help="Run as a REST-JSON API client", action="store_true") - apiparser.add_argument("-H", "--host", help="Host of the REST-JSON API server (default \"%s\")" % RESTAPI_DEFAULT_ADDRESS, default=RESTAPI_DEFAULT_ADDRESS) - apiparser.add_argument("-p", "--port", help="Port of the REST-JSON API server (default %d)" % RESTAPI_DEFAULT_PORT, default=RESTAPI_DEFAULT_PORT, type=int) - apiparser.add_argument("--adapter", help="Server (bottle) adapter to use (default \"%s\")" % RESTAPI_DEFAULT_ADAPTER, default=RESTAPI_DEFAULT_ADAPTER) - apiparser.add_argument("--database", help="Set IPC database filepath (optional)") - apiparser.add_argument("--username", help="Basic authentication username (optional)") - apiparser.add_argument("--password", help="Basic authentication password (optional)") - (args, _) = apiparser.parse_known_args() if hasattr(apiparser, "parse_known_args") else apiparser.parse_args() - + apiparser = ArgumentParser() # 创建一个ArgumentParser对象,用于解析命令行参数 + apiparser.add_argument("-s", "--server", help="Run as a REST-JSON API server", action="store_true") # 添加一个命令行选项,用于启动服务器 + apiparser.add_argument("-c", "--client", help="Run as a REST-JSON API client", action="store_true") # 添加一个命令行选项,用于启动客户端 + apiparser.add_argument("-H", "--host", help="Host of the REST-JSON API server (default \"%s\")" % RESTAPI_DEFAULT_ADDRESS, default=RESTAPI_DEFAULT_ADDRESS) # 添加一个命令行选项,用于指定服务器主机地址,默认值为RESTAPI_DEFAULT_ADDRESS + apiparser.add_argument("-p", "--port", help="Port of the REST-JSON API server (default %d)" % RESTAPI_DEFAULT_PORT, default=RESTAPI_DEFAULT_PORT, type=int) # 添加一个命令行选项,用于指定服务器端口,默认值为RESTAPI_DEFAULT_PORT + apiparser.add_argument("--adapter", help="Server (bottle) adapter to use (default \"%s\")" % RESTAPI_DEFAULT_ADAPTER, default=RESTAPI_DEFAULT_ADAPTER) # 添加一个命令行选项,用于指定服务器适配器,默认值为RESTAPI_DEFAULT_ADAPTER + apiparser.add_argument("--database", help="Set IPC database filepath (optional)") # 添加一个命令行选项,用于指定IPC数据库文件路径(可选) + apiparser.add_argument("--username", help="Basic authentication username (optional)") # 添加一个命令行选项,用于指定基本认证的用户名(可选) + apiparser.add_argument("--password", help="Basic authentication password (optional)") # 添加一个命令行选项,用于指定基本认证的密码(可选) + (args, _) = apiparser.parse_known_args() if hasattr(apiparser, "parse_known_args") else apiparser.parse_args() # 解析命令行参数,如果支持parse_known_args方法则使用它,否则使用parse_args方法 # Start the client or the server - if args.server: - server(args.host, args.port, adapter=args.adapter, username=args.username, password=args.password, database=args.database) - elif args.client: - client(args.host, args.port, username=args.username, password=args.password) - else: - apiparser.print_help() - -if __name__ == "__main__": - main() + if args.server: # 如果命令行参数中指定了启动服务器 + server(args.host, args.port, adapter=args.adapter, username=args.username, password=args.password, database=args.database) # 调用server函数启动服务器 + elif args.client: # 如果命令行参数中指定了启动客户端 + client(args.host, args.port, username=args.username, password=args.password) # 调用client函数启动客户端 + else: # 如果未指定启动服务器或客户端 + apiparser.print_help() # 打印命令行帮助信息 + +if __name__ == "__main__": # 如果当前脚本作为主程序运行 + main() # 调用main函数