-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlimier.py
More file actions
executable file
·138 lines (108 loc) · 4.57 KB
/
limier.py
File metadata and controls
executable file
·138 lines (108 loc) · 4.57 KB
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#!/usr/bin/env python3
# un fix super chelou Oo
# https://stackoverflow.com/questions/46457179/python3-cannot-import-name-cached-property
import werkzeug
werkzeug.cached_property = werkzeug.utils.cached_property
from robobrowser import RoboBrowser
from urllib.error import HTTPError
# imports custom rich
from rich.console import Console as richConsole
from rich.progress import track as richTrack
from rich.panel import Panel as richPanel
from rich.table import Table as richTable
import re, time, argparse
#import locaux
import research, utils
#on vérifie qu'on est bien lancé en "main" :
if __name__ == "__main__":
#on lance rich
console = richConsole()
console.print("Limier par darcosion (https://github.com/darcosion/limier)")
# paramètres de CLI
parser = argparse.ArgumentParser()
parser.add_argument("-d", "--domain", type=str,
help="domain to investigate")
parser.add_argument('-a', "--user-agent", type=str,
help="User-agent to use")
parser.add_argument('-b', "--bruteforce",
help="Enable bruteforce for website",
action="store_true")
parser.add_argument('-f', "--frameworks",
help="Enable framework identification",
action="store_true")
parser.add_argument('-o', "--output",
help="output file format OPLM")
parser.add_argument('-v', "--verbose",
help="Indicate each actions",
action="store_true", default=False)
args = parser.parse_args()
if(args.user_agent):
user_agent = args.user_agent
else:
user_agent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:82.0) Gecko/20100101 Firefox/82.0'
#créaction d'un décorateur rich pour s'assurer que la verbosité est respecté
def limierLog(*param):
if(args.verbose):
return console.log(*param)
else:
return
# Création d'un browser pour les recherches
browser = RoboBrowser(user_agent=user_agent
, history=True
, parser='html.parser'
, allow_redirects=False)
# TODO : faire une vérification du domaine pour être sur...)
args.domain = utils.protocol_remove(args.domain)
assert utils.tld_check(args.domain), "le paramètre nom de domaine est incorrecte"
domain = None
try:
browser.open("https://" + args.domain)
domain = "https://" + args.domain
except Exception as e:
#on essaie en http au cas où
browser.open("http://" + args.domain)
domain = "http://" + args.domain
# vérifie s'il y a une direction.
if(browser.response.is_redirect):
if(browser.response.url != browser.url):
limierLog("Redirection vers " + browser.response.url)
browser.open(browser.response.url)
else:
limierLog("Pas de redirection")
#moulinette, pour le moment locale
listurl = []
listResearch = [research.getFluxLink
,research.getPossibleFluxLink
,research.getSiteMapFlux]
if(args.bruteforce):
listResearch.append(research.getFluxBruteForce)
if(args.frameworks):
listResearch.append(research.frameworkIdentifier)
for i in richTrack(listResearch, description = 'Researching RSS') if not args.verbose else listResearch:
listurl = list(set(listurl) | set(i(browser, domain, limierLog)))
#gestion des résultats
console.print(richPanel("\n--- Traitement des résultats collectés ---\n\n"))
#retire tout un bordel...
for n, i in enumerate(listurl):
listurl[n] = re.sub("http(s?):(\/?)\/", '', listurl[n])
#print(args.domain)
#print(utils.tld_check(listurl[n]))
#print(listurl[n])
if(not utils.tld_check(listurl[n])):
listurl[n] = args.domain + '/' + listurl[n]
listurl[n] = listurl[n].replace('//', '/')
listurl = list(set(listurl))
if(len(listurl) > 0):
#on crée une table pour affichage rich
table = richTable(show_lines=True)
table.add_column("Liste des fluxs RSS", justify="right", no_wrap=True)
for i in listurl:
table.add_row(i)
console.print(table)
if(args.output != None):
console.print(richPanel("\n--- export dans un fichier OPLM ---\n\n"))
f = open(args.output, 'w')
f.write(utils.opml_file(listurl))
f.close()
else:
console.print("aucun flux trouvé :disappointed:")