Skip to content
Advertisement

Appending a wordlist to URLS to make a webrequest

-I have a wordlist where each entry is printed on a separate line in a .txt file. -I am adding the wordslists entries onto the end of a url (nsip is listed below as a placeholder)

I am trying to take each URL and and make web requests BUT when I print i.e. full_url[0] it just gives me the whole the whole wordlist appended to the url. When I use type it tells me that full_url is a list so I am unsure as to why each element is not accessible.

any ideas how to make it so as I can easily make requests

lines = [
    '.bash_history',
    '.bashrc',
    '.cache',
    '.config',
    '.cvs',
    '.cvsignore',
    '.forward',
    '.git/HEAD',
    '.history',
    '.hta',
]

for line in lines:
    full_url = []
    full_url.append('https://google.com/' + line)
    print(full_url[0])
    print(type(full_url))

Advertisement

Answer

Move full_url = [] before the loop:

filename = '/Users/Desktop/common.txt'
nsip = 'google.com'
with open(filename, 'r') as file:
    full_url = []
    for line in file:
        linefinal = line.rstrip()
        full_url.append("https://" + nsip + '/' + linefinal)

print(full_url)

which gives:

['https://google.com/.bash_history', 'https://google.com/.bashrc', 'https://google.com/.cache', 'https://google.com/.config', 'https://google.com/.cvs', 'https://google.com/.cvsignore', 'https://google.com/.forward', 'https://google.com/.git/HEAD', 'https://google.com/.history', 'https://google.com/.hta']

Is that what you were after?

Advertisement