1
Beginner's Corner / Re: SQL Injection Vulnerability in Python
« on: February 19, 2016, 09:51:09 pm »Function readlines() puts lines of file to list, so when you do:Code: [Select]r = requests.get(content+"'")
You are trying to add string " ' " to a list and request whole list. I wonder how you didn't get error there?
Basically you should do something like this:Code: [Select]import requests
with open("URL_list.txt", 'r') as f:
content = f.readlines()
for url in content:
#strip() strips newline characters.
if "SQL" in requests.get(url.strip()+"'").content:
print '\033[1;31mVulnerable!'
else:
print '\033[1;32mFailed.'
Using with statement when opening file is good practise to do because it handles files closing etc.
That..Code: [Select]str(tosearch)
..doesn't do anything. Or atleast it doesn't save what it does to anywhere, also it's pointless because 'tosearch' -variable is string already.
Thanks mate, that worked! However, after a few executions of the File, I'm facing this output when I run the .py file from Terminal:
Code: [Select]
Traceback (most recent call last):
File "rgsr.py", line 7, in <module>
if "SQL" in requests.get(url.strip()+"'").content:
File "/usr/lib/python2.7/dist-packages/requests/api.py", line 67, in get
return request('get', url, params=params, **kwargs)
File "/usr/lib/python2.7/dist-packages/requests/api.py", line 53, in request
return session.request(method=method, url=url, **kwargs)
File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 468, in request
resp = self.send(prep, **send_kwargs)
File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 576, in send
r = adapter.send(request, **kwargs)
File "/usr/lib/python2.7/dist-packages/requests/adapters.py", line 437, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='www.angelvestgroup.com', port=80): Max retries exceeded with url: /info.php?id=1' (Caused by NewConnectionError('<requests.packages.urllib3.connection.HTTPConnection object at 0x7fa2d5a5ca50>: Failed to establish a new connection: [Errno -2] Name or service not known',))
EDIT: Never mind, after paying close attention to the output, I saw that the link just doesn't exists. Is there a way I can add an elif statement to my Code, to say if the Site doesn't exist at all?