PortSwigger / python-scripter

Sourced from gist: https://gist.github.com/mwielgoszewski/7026954
50 stars 11 forks source link

add static variable to the context of the script #4

Closed bAuh0lz closed 2 years ago

bAuh0lz commented 2 years ago

This PR enables a user to add key-value pairs for later use. In my case, I had to increment one of the parameters in every request. To achieve this goal, I wrote a PoC script:

if messageIsRequest:
    statics['counter']=statics.get('counter',0)+1
    print(statics['counter'])

Note that the variable statics in the script is newly defined by this PR.

After I loaded the script to Python Scripter and sent two requests, the UI shows:

1
2

As you see, statics['counter'] worked as a counter.

I think this can be done by using another extension, but this PR can make it simpler and Python Scripter more flexible.

stavinski commented 2 years ago

Hi @bAuh0lz This was actually functionality I had in the back of my mind that I wanted to introduce. I have added the feature into the main repo and should be published to the BApp store to be used soon. See https://github.com/PortSwigger/python-scripter#state-dictionary for details :)

bAuh0lz commented 2 years ago

Great :) Thank you.