-
Notifications
You must be signed in to change notification settings - Fork 1
/
404recon.py
65 lines (59 loc) · 1.8 KB
/
404recon.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import requests
import os,time
from bs4 import BeautifulSoup
href = []
unique = []
headers = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36'}
class bcolors:
HEADER = '\033[95m'
OKBLUE = '\033[94m'
OKGREEN = '\033[92m'
WARNING = '\033[93m'
def linkExtractor():
link = input("Enter Link:")
try:
r = requests.get("http://"+link,headers=headers)
r.raise_for_status()
except requests.exceptions.HTTPError:
print('Error Http')
pass
except requests.exceptions.ConnectionError:
print('Check Your Connection, Or Site Not Responding')
pass
else:
html = r.text
soup = BeautifulSoup(html,'html.parser')
for l in soup.find_all('a'):
if len(l.get("href").strip()) > 1 and l.get("href")[0] != '#' and 'javascript:' not in l.get("href").strip() and 'mailto:' not in l.get("href").strip() and 'tel:' not in l.get("href").strip():
if 'http' in l.get("href").strip() or 'https' in l.get("href").strip():
href.append(l.get("href").strip())
def uniquelink(href):
for x in href:
if x not in unique:
unique.append(x)
def Check404():
print("Total "+ str(len(unique)) + " link Found")
for line in unique:
try:
f = requests.get(line,headers=headers)
except requests.exceptions.SSLError:
continue
else:
if f.status_code == 200:
print(bcolors.OKGREEN + "[ "+ str(f.status_code)+ " ]"+line)
else:
print(bcolors.WARNING + "[ "+ str(f.status_code)+ " ]" + line)
def banner():
if (os.name in ('ce', 'nt', 'dos')):
os.system('cls')
elif ('posix' in os.name):
os.system('clear')
print(bcolors.HEADER+"Started Recon404 \n \n")
def mainf():
banner()
linkExtractor()
uniquelink(href)
Check404()
mainf()