Skip to content

Instantly share code, notes, and snippets.

@gopinath6
Forked from imran-parray/paramReplacer.py
Created May 23, 2020 14:41
Show Gist options
  • Save gopinath6/37b9fca895e8f62b07b1783a2c337c3b to your computer and use it in GitHub Desktop.
Save gopinath6/37b9fca895e8f62b07b1783a2c337c3b to your computer and use it in GitHub Desktop.
import re
import sys
urls=[]
try:
file_name=sys.argv[1]
replacement=sys.argv[2]
except:
print("[!] Enter urls file name")
else:
try:
with open(file_name,'r') as fh:
for line in fh:
urls.append(line)
except:
print("File not Found")
else:
regex2=r'=(.*)$'
final=[]
for line in urls:
params=[]
if '?' in line:
params.append(line.split('?')[0])
x=line.split('?')[1]
z=x.split('&')
for a in z:
params.append(re.sub(regex2, '='+replacement+'&', a))
final.append('?'.join(params).replace('&?','&').rstrip('\n&'))
for a in final:
if 'http' in a:
print(a)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment