Trying to build a program that uses a request file from a user.
When I try to parse that file named POST.txt
I get an error:
<versionspec>, RequirementsTokenType.COMMENT, RequirementsTokenType.EOL, RequirementsTokenType.LSBRACE, RequirementsTokenType.SEMICOLON or RequirementsTokenType.WHITE_SPACE expected, got '/'
Looks like it interperts the request file as requirements file, but I have no idea why, I simply pasted a request from burpsuite and saved to a .txt file. Until now, when I worked with requests files it worked well.
Here is the request:
POST /forum/ HTTP/1.1
Host: localhost
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Content-Type: application/x-www-form-urlencoded
Content-Length: 31
Origin: http://localhost
DNT: 1
Connection: close
Referer: http://localhost/forum/
Cookie: PHPSESSID=f42ec9c38b762bb6f9856f5e99963610
Upgrade-Insecure-Requests: 1
l_username=l33t&l_password=1337
That's what my program looks like until now (Can't really move further if my request file is not parsed):
import argparse
import requests
import Burpee.burpee as burp
import re
MARKER = input("What are the markers for the variables (Default: '$'): ") or '$'
parser = argparse.ArgumentParser(description = 'sniper.py, Allows 1 set of payloads, runs by order '
'in all the marked positions, one at a time.')
parser.add_argument('request_file', help = 'Request file with marked variables (POST or GET)')
args = parser.parse_args()
request_file = args.request_file
headers, POST_data = burp.parse_request(request_file)
METHOD = burp.get_method_and_resource(request_file)[0] # Sets METHOD (POST \ GET)
marked_vars = []
with open(request_file, 'r') as request_f:
lines = request_f.readlines()
for line in lines:
marked = re.findall('\$(.*?)\$', line)
for var in marked:
marked_vars.append(var)
print(marked_vars)
destination = burp.get_method_and_resource(request_file)[1] # Where the referer sends the request
And + the inspection error I get in PyCharm:
<versionspec>, RequirementsTokenType.COMMENT, RequirementsTokenType.EOL, RequirementsTokenType.LSBRACE, RequirementsTokenType.SEMICOLON or RequirementsTokenType.WHITE_SPACE expected, got '/'
Haven't seen this inspection in my life. How can I solve this issue?
I'm having the same issue with a text file but apparently PyCharm doesn't recognize '.txt' extension.
Try creating a new file with no extension and then try to parse it.
It worked for me, so let me know if this works for you.