url = "http://www.example.com?type=a&type1=b&type2=c"
urllist = get_urllist(url)
trigger = ["'or '1'='1'"," 'OR '1'='2'","'OR a=a"]
def get_urllist(url):
url_parsed = urlparse.urlparse(url)
#extract the query parameters of the URL
query = urlparse.parse_qs(url_parsed.query)
#get the list of query
query_list = query_list(query)
#Get Base url
url = urlparse._replace(query=None).geturl()
#modify url to get url_list
for query in query_list :
# change the original query to get the expected result
return url_list
def query_list(query):
for t in trigger:
for key, value in query.items():
query[key] += t
query_list.append(query)
return query_list
How to return a list of URLs by changing the query parameter values?
Original url = "http://www.example.com?type=a&type1=b&type2=c"
Expected Result:
Url_list= ["http://www.example.com?type=a'OR '1'='1'&type1=b'OR '1'='1'&type2=c'OR '1'='1'","http://www.example.com?type=a'OR '1'='2'&type1=b'OR '1'='2'&type2=c'OR '1'='2'","http://www.example.com?type=a'OR a=a&type1=b'OR a=a&type2=c''OR a=a" ]
In Python2.x
You can use
urlparse.urlparse
function andParseResult._replace
method:Note
The
urlparse
module is renamed tourllib.parse
inPython 3
. The2to3
tool will automatically adapt imports when converting your sources to Python 3.In Python3.x
You can use
urlparse.urlparse
function as well.DEMO OUTPUT:
You can use the package furl.
gives the output:
http://www.example.com?type=a%27or+%271%27%3D%271%27
and decoded:
http://www.example.com?type=a'or '1'='1'