如何使用ZAP扫描HTTP安全header?
how to use ZAP to scan HTTP security header?
我们想将python/ZAPv2集成到我们的SDLC中,有时我们只想使用ZAP来验证安全性header,例如Set-Cookie中的HttpOnly标志,CSP [=24] =], 等...
我 google 很多,发现也许 ZAP 策略可以帮助我们...但是关于如何 self-define 一个 zap 策略,以及如何调用 API 调用 ZAPv2 库中的 self-defined 策略
有什么 document/advices/ 想法可以帮助我......?谢谢!
安全 header 检查通常作为被动扫描规则实施(因此,如果您使用蜘蛛或代理流量,您可以获得它们的结果)。以下是有关以编程方式设置被动扫描 "policy" 的一些信息。
Re-using 我在这里的回答:Export/Import OWASP ZAP Passive Scan Rules
有一个现有的工单可以统一 Active/Passive 单一策略类型接口中的扫描处理:https://github.com/zaproxy/zaproxy/issues/3870。
如果您真的对此感兴趣,您可以在 BountySource (https://www.bountysource.com/issues/49047644-improved-active-passive-rules-management) 上支持它,看看它是否吸引了一些 attention/action。
您可以选择的另一个选项是创建一个快速脚本,该脚本使用 ZAP 的网络 API 来应用被动扫描规则 "policy"。相关端点包括:pscan/view/scanners/、pscan/action/disableAllScanners/、pscan/action/enableScanners/。这是一个 python 示例:
from zapv2 import ZAPv2 as zap
import time
apikey = "apikey12345" #Your apikey
z = zap(apikey=apikey, proxies={"http": "http://127.0.0.1:8080", "https": "http://127.0.0.1:8080"})
time.sleep(2) #Might need to be longer depending on your machine and if ZAP is already running or not
print "Disabling all passive scan rules.."
z.pscan.disable_all_scanners()
scanners = z.pscan.scanners
for scanner in scanners:
print scanner.get("id") + " : " + scanner.get("enabled") + " : " + scanner.get("name")
to_enable = "10020,10021,10062" #Customize as you see fit
print "\nEnabling specific passive scan rules..[" + to_enable +"]"
z.pscan.enable_scanners(to_enable)
print "\nListing enabled passive scan rules.."
scanners2 = z.pscan.scanners
for scanner in scanners2:
if (scanner.get("enabled") == "true"):
print scanner.get("id") + " : " + scanner.get("enabled") + " : " + scanner.get("name")
最后,您可以在一个系统上配置 ZAP,然后根据需要将 config.xml
复制到其他系统。
我们想将python/ZAPv2集成到我们的SDLC中,有时我们只想使用ZAP来验证安全性header,例如Set-Cookie中的HttpOnly标志,CSP [=24] =], 等...
我 google 很多,发现也许 ZAP 策略可以帮助我们...但是关于如何 self-define 一个 zap 策略,以及如何调用 API 调用 ZAPv2 库中的 self-defined 策略
有什么 document/advices/ 想法可以帮助我......?谢谢!
安全 header 检查通常作为被动扫描规则实施(因此,如果您使用蜘蛛或代理流量,您可以获得它们的结果)。以下是有关以编程方式设置被动扫描 "policy" 的一些信息。
Re-using 我在这里的回答:Export/Import OWASP ZAP Passive Scan Rules
有一个现有的工单可以统一 Active/Passive 单一策略类型接口中的扫描处理:https://github.com/zaproxy/zaproxy/issues/3870。 如果您真的对此感兴趣,您可以在 BountySource (https://www.bountysource.com/issues/49047644-improved-active-passive-rules-management) 上支持它,看看它是否吸引了一些 attention/action。
您可以选择的另一个选项是创建一个快速脚本,该脚本使用 ZAP 的网络 API 来应用被动扫描规则 "policy"。相关端点包括:pscan/view/scanners/、pscan/action/disableAllScanners/、pscan/action/enableScanners/。这是一个 python 示例:
from zapv2 import ZAPv2 as zap
import time
apikey = "apikey12345" #Your apikey
z = zap(apikey=apikey, proxies={"http": "http://127.0.0.1:8080", "https": "http://127.0.0.1:8080"})
time.sleep(2) #Might need to be longer depending on your machine and if ZAP is already running or not
print "Disabling all passive scan rules.."
z.pscan.disable_all_scanners()
scanners = z.pscan.scanners
for scanner in scanners:
print scanner.get("id") + " : " + scanner.get("enabled") + " : " + scanner.get("name")
to_enable = "10020,10021,10062" #Customize as you see fit
print "\nEnabling specific passive scan rules..[" + to_enable +"]"
z.pscan.enable_scanners(to_enable)
print "\nListing enabled passive scan rules.."
scanners2 = z.pscan.scanners
for scanner in scanners2:
if (scanner.get("enabled") == "true"):
print scanner.get("id") + " : " + scanner.get("enabled") + " : " + scanner.get("name")
最后,您可以在一个系统上配置 ZAP,然后根据需要将 config.xml
复制到其他系统。