Search code examples
javazap

How can I log anything when ZAP receives a communication?


I want to create a ZAP add-on which simply logs something on the console whenever a communication is received. I followed following tutorial to create a simple add-on, but now I don't know what should I do to achieve my goal.


Solution

  • First you need to be more clear about what you're trying to achieve. Does your plan apply only to Proxied traffic?

    Assuming it does:

    You'd need to implemented a ProxyListener and hook it:

    @Override
    public void hook(ExtensionHook extensionHook) {
        extensionHook.addProxyListener(getMyProxyListener());
    }
    

    However, if you aren't set on an add-on, you can simply use a proxy script: https://github.com/zaproxy/community-scripts/tree/main/proxy