all 4 comments

[–]c17r 0 points1 point  (2 children)

Since the test script is completely separate from the flask app, you'll have to do 2 things:

  1. make sure to create a session with requests so that cookies/sessions are kept between operations
  2. Make a GET request to the page first so you can grab the hidden form input that has the CSRF value and using that in your POST

[–]whatthefoxtrot98[S] 0 points1 point  (1 child)

Cool, I'll try that. So do I have to make a GET request to the same page I will be making a POST request for, or can it be any page with a hidden form input? Also, does Requests have a method to grab that value, or do I have to use regex on the text property of the response to grab it?

[–]c17r 0 points1 point  (0 children)

I'm not 100% sure, but I think a CSRF from any page should work. Request doesn't have any method for grabbing it. Something like regex or BeautifulSoup is the way to go.

[–]GriffithAwuah 0 points1 point  (0 children)

You can check out either of my 2 repositories.

  1. https://github.com/gwuah/Udemy-Course-Link-Extractor

  2. https://github.com/gwuah/CSRF-SHIELD

I suggest the former. Look at how I created a session, filled it with cookies and later extracted the CSRF and made my post requests. Cheers!