The Burp Suite User Forum was discontinued on the 1st November 2024.

Burp Suite User Forum

For support requests, go to the Support Center. To discuss with other Burp users, head to our Discord page.

SUPPORT CENTER DISCORD

Empty Cookies Jar

Chim | Last updated: Oct 17, 2023 10:15PM UTC

I am trying to empty the cookies jar with each new session started. I created the Rule to invoke an Extension to Empty Cookies Jar. I used the following script below and added it into the Extension. However, it seem like hit and miss. Sometimes it would Empty the Cookies Jar. Most of the time the cookies are still there. I checked the logs in the Extension and the output showed that the cookies are deleted but the cookies jar is not empty. Can you please let me know what I did wrong? Please see the Python Script below. from burp import IBurpExtender, ICookie, ISessionHandlingAction from java.io import PrintWriter class BurpExtender(IBurpExtender, ISessionHandlingAction): def registerExtenderCallbacks(self, callbacks): extName = "Delete Cookies" self._callbacks = callbacks self._helpers = callbacks.getHelpers() callbacks.setExtensionName(extName) callbacks.registerSessionHandlingAction(self) def getActionName(self): return "Delete Cookies" def performAction(self, currentRequest, macroItems): self._stdout = PrintWriter(self._callbacks.getStdout(), True) self._stderr = PrintWriter(self._callbacks.getStderr(), True) cookies = self._callbacks.getCookieJarContents() for cookie in cookies: new_cookie = CustomCookie(cookie.getDomain(), cookie.getName(), None, cookie.getPath(), cookie.getExpiration()) self._callbacks.updateCookieJar(new_cookie) self._stdout.println("Cookie deleted!") return class CustomCookie(ICookie): def getDomain(self): return self.cookie_domain def getPath(self): return self.cookie_path def getExpiration(self): return self.cookie_expiration def getName(self): return self.cookie_name def getValue(self): return self.cookie_value def __init__(self, cookie_domain, cookie_name, cookie_value, cookie_path, cookie_expiration): self.cookie_domain = cookie_domain self.cookie_name = cookie_name self.cookie_value = cookie_value self.cookie_path = cookie_path self.cookie_expiration = cookie_expiration

Hannah, PortSwigger Agent | Last updated: Oct 18, 2023 08:46AM UTC