custom_spider.py

Does not support different levels, just “base URL” + “some string”.

#!/usr/bin/python3
#---------------------------------------------------------------------
# Name        : custom_spider.py
# Description : Custom spider script, looks for a specific message in HTTP response.
# Author      : Lisandre.com
# Date        : 2022-05-24
#---------------------------------------------------------------------
import requests

# Remove warnings: InsecureRequestWarning: Unverified HTTPS request
requests.packages.urllib3.disable_warnings(requests.packages.urllib3.exceptions.InsecureRequestWarning)

### CHANGE CONFIG ###
WL = '/usr/share/dirb/wordlists/common.txt'
#WL = '/usr/share/seclists/Discovery/Web-Content/directory-list-2.3-medium.txt'
base_url = 'http://x.x.x.x:80/'

# Intercept requests using Burp :)
#proxies = None
proxies = {
    'http': 'http://127.0.0.1:8080',
    'https': 'http://127.0.0.1:8080'
}

headers = {
    'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Firefox/91.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',
    'Connection': 'close',
    'Upgrade-Insecure-Requests': '1'
}

try:
    file1 = open(WL, 'r')

    for line in file1:
        #print(line.rstrip('\r\n'))
        url = base_url + line.rstrip('\r\n')
        #print(url)
        response = requests.request("GET", url, headers=headers, verify=False, proxies=proxies)
        #print(response.headers)

        if "Invalid URL" in response.text:
            print("Not Found: " + url)
        else:
            print("Found: " + url)

    file1.close
except IOError:
    print("Could not read file.")