OWASP-ZAP:如何使用脚本暂停传统蜘蛛

发布于 2025-02-02 22:04:21 字数 941 浏览 3 评论 0原文

我需要在以下条件上暂停蜘蛛

  1. 当响应代码为302时,
  2. ,当响应标头的位置设置为登录页面时:“ login.jsp”

以下是我当前正在做的事情 脚本:HTTP发件人 引擎:Jython 脚本:

import httplib
HOST = "127.0.0.1"
PORT = 2031
APIKEY="2031"

def sendingRequest(msg, initiator, helper):pass
    
def responseReceived(msg, initiator, helper):
    if initiator == 3:
        try:
            h=httplib.HTTPConnection("{0}:{1}".format(HOST,PORT))
            if h:
                if msg.getResponseHeader() and msg.getResponseHeader().getStatusCode()==302:
                    if msg.getResponseHeader().getHeader("Location") is not None:
                        if "Login.jsp" in msg.getResponseHeader().getHeader("Location"):
                            h.request("GET", "/JSON/spider/action/pauseAllScans/?apikey={0}".format(APIKEY))
                            
                            
        except: pass

我想知道他们是否还有其他或更好的方法来实现这一目标?

先感谢您。

I have an requirement where I need to pause spider on the following condition

  1. when response code is 302
  2. when response header has location with value set to login page eg: "login.jsp"

Following is what I am currently doing
Script: HTTP sender
Engine: Jython
Script:

import httplib
HOST = "127.0.0.1"
PORT = 2031
APIKEY="2031"

def sendingRequest(msg, initiator, helper):pass
    
def responseReceived(msg, initiator, helper):
    if initiator == 3:
        try:
            h=httplib.HTTPConnection("{0}:{1}".format(HOST,PORT))
            if h:
                if msg.getResponseHeader() and msg.getResponseHeader().getStatusCode()==302:
                    if msg.getResponseHeader().getHeader("Location") is not None:
                        if "Login.jsp" in msg.getResponseHeader().getHeader("Location"):
                            h.request("GET", "/JSON/spider/action/pauseAllScans/?apikey={0}".format(APIKEY))
                            
                            
        except: pass

I was wondering if their is any other or better way to achieve this?

Thank you in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

飞烟轻若梦 2025-02-09 22:04:21

您有Sai 为什么要暂停扫描。我的猜测是,您可以重新认证。如果是这样,我认为更好的选择是配置ZAP来处理身份验证,那么如果用户被登录,它将自动重新实现。如果您真的想以自己的方式执行此操作,那么您就不必进行API调用 - 您的脚本已经在ZAP中运行,因此可以通过代码暂停蜘蛛。

You havnt sai why you want to pause the scans. My guess is that so you can re-authenticate. If so then I think the better option is to configure ZAP to handle authentication, then it will automatically re-authenticate if the user ever gets logged out. If you really want to do it your way then you dont have to make an API call - your script is already running in ZAP and so will be able to pause the spider via code.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文