-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathScannerWebCore.py
More file actions
168 lines (155 loc) · 6.78 KB
/
ScannerWebCore.py
File metadata and controls
168 lines (155 loc) · 6.78 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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
from Connection import connector
from screen import screen
from random import choice
from regex import regex
class Scanner_Web_Core (object):
logos = [(" ___ __ __ _ \n"
"/ __| __ __ _ _ _ _ _ ___ _ _ \ \ / /__| |__ \n"
"\__ \/ _/ _` | ' \| ' \/ -_) '_| \ \/\/ / -_) '_ \ \n"
"|___/\__\__,_|_||_|_||_\___|_| \_/\_/\___|_.__/\n"
),
(" ____ _ __ __ \n"
" / __/______ ____ ___ ___ ____ | | /| / /__ / / \n"
" _\ \/ __/ _ `/ _ \/ _ \/ -_) __/ | |/ |/ / -_) _ \ \n"
"/___/\__/\_,_/_//_/_//_/\__/_/ |__/|__/\__/_.__/\n"),
(
" () (_| | |_/ | | \n"
" /\ __ __, _ _ _ _ _ ,_ | | | _ | | \n"
" / \/ / | / |/ | / |/ | |/ / | | | ||/ |/ \_\n"
"/(__/\___/\_/|_/ | |_/ | |_/|__/ |_/ \_/ \_/ |__/\_/ \n")]
googleDot = ["com", "ac", "com.om", "ad", "ae", "com.af", "com.ag", "com.ai", "am", "it.ao", "com.ar", "cat", "as", "at", "com.au", "az", "ba",
"com.bd", "be", "bf", "bg", "com.bh", "bi", "bj", "com.bn", "com.bo", "com.br", "bs", "co.bw", "com.by", "com.bz", "ca", "com.kh",
"cc", "cd", "cf", "cn", "com.co", "co.nz", "cg", "ch", "co.ck", "cl", "cm", "cz", "de", "nu", "dj",
"dk", "dm", "com.do", "dz", "no", "com.ec", "ee", "com.eg", "es", "com.np", "fi", "com.fj", "fm", "fr", "ga", "nl", "ge",
"gf", "gg", "com.gh", "com.gi", "nr", "gl", "gp", "gr", "com.gt", "com.ni", "gy", "com.hk", "hn", "com.ng",
"co.id", "iq", "ie", "co.il", "com.nf", "im", "co.in", "is", "it", "ne", "je", "com.jm", "jo", "co.jp", "co.ke", "com.na",
"kg", "co.kr", "la", "com.lb", "li", "com.my", "co.ls", "lt", "lu", "lv", "com.ly", "com.mx",
"co.ma", "md", "mg", "mk", "ml", "mn", "ms", "com.mt", "mu", "mv", "com.pa", "com.pe", "com.ph", "com.pk", "pn", "com.pr",
"ps", "pt", "com.py", "com.qa", "ro", "rs", "ru", "rw", "com.sa", "com.sb", "sc", "se", "com.sg", "sh", "si", "com.sl", "sn", "sm",
"so", "st", "com.sv", "td", "tg", "co.th", "tk", "tl", "tm", "to", "com.tn", "com.tr", "tt", "com.tw", "co.tz", "com.ua", "co.ug", "co.uk",
"us", "com.uy", "co.uz", "co.ve", "vg", "co.vi", "vu", "co.za", "co.zm", "co.zw"]
Forbiden = ['facebook.com', 'twitter.', '.google.','github.', 'linkedin.', 'microsoft.', 'youtube.', 'bing.',"stackoverflow.","teamfortress",
'yahoo.', 'sogou.', 'ask.', 'yandex.', 'msn.', 'w3school.','w3.', 'windows.', 'adobe.com', 'outlook.',"laravel.","wordpress.","w3schools"
'window.', 'JQuery.min', 'hotmail.', 'yandex.','sogou.', 'bing.','php.', 'mysql.', 'microsofttranslator.','amazon.', 'www.asp.net',
"devdocs.","steampowered.","origin.","adsense.google.","linuxmint.","ubuntu.","debian.","arch-linux.","w3schools.com"]
cmsTags = {
"wordpress":["<a href=\"https:\/\/wordpress.org\/\">Proudly powered by WordPress", "<meta name=\"|'generator\"|' content=\"|'WordPress\"|'", "\/wp-content\/(.*).js","wordpress/plugins"],
"joomla" : ["<meta name=\"generator\" content=\"Joomla"]
}
def __init__(self, connector) :
self.version = 1.8
self.scanTitles = {"u":"URL SCAN","d":"DORK SEARCH","md5":"MD5 ENCRYPTATION"}
self.sc = screen()
self.connector = connector
self.engins = {"google":"http://www.google.{}/search?q={}&start={}",
"bing":"http://www.bing.com/search?q={}&first={}",
}
self.urlFound = []
self.regex = regex()
"""
Method prepareEngin (self, dork, engin)
return String ==> url of engin for Dork search
"""
def prepareEngin(self, dork, page, engin):
"""
param dork string dork to add it to url engin
"""
engin = engin.lower()
if engin == "bing":
return self.engins.get(engin).format(dork,page)
elif engin == "google" :
domain = choice(self.googleDot)
return self.engins.get(engin).format(domain,self.connector.queryEncode(dork),page)
"""
Method searchDork (self, enginUrl)
return search dork result after passing self.connector.connection(urlEngin) to getDorkResutls method
"""
def searchDork(self,enginUrl, engin):
"""
param enginUrl string
"""
enginResponse = self.connector.connection(enginUrl)
try :
return self.getDorkResults( enginResponse.response.read().decode("utf-8","ignore"), engin )
except Exception :
pass
"""
Method getDorkResults(self, html)
return self.urlFound after filtring html code passed by searchDork and engin used
"""
def getDorkResults (self, html, engin):
"""
param html string html code
"""
if engin == "bing":
result = self.regex.findRegex(r'<h2><a href="(.*?)" h="',html)
elif engin == "google":
result = self.regex.findRegex(r'<div class="r"><a href="(.*?)"', html)
for url in result :
if self.isForbiden(url) == False and url not in self.urlFound :
self.urlFound.append(url)
return self.urlFound
"""
Method isForbiden(self, url)
check if the domain is forbiden
return False if url is not Forbiden True else
"""
def isForbiden(self,url):
"""
param url String
"""
for forbiden in self.Forbiden :
if forbiden in connector.parser(url).netloc :
return True
return False
"""
Method cmsDetector(self, hmtl)
look for self.cmsTags in the html code
return detected cms if true or not detected if is not detected
"""
def cmsDetector(self, html):
"""
param html string html code after connecting to target
"""
# TODO : think to use regex
for cms in self.cmsTags.keys():
for cmsTag in self.cmsTags.get(cms):
if cmsTag in html:
return cms
return "not detected"
"""
Method pageSearcher(self, url)
check if url is exist using method connetion.isExist in class connector after parse it
return url if is found and False if is not found
"""
def pageSearcher(self,url, uris):
"""
param urls string
"""
parsedUrl = self.connector.parser(url)
for path in uris:
fullUrl = parsedUrl.scheme +"://"+ parsedUrl.netloc + path
self.sc.prInfo("Looking for",fullUrl,rtn=True)
if self.connector.isExist(self.connector.connection(fullUrl).status):
return fullUrl
return False
"""
Method validation (self,validation,html)
return true if validation param found in the html code and False else
"""
def validation (self,validation,html):
"""
param validation, html String
"""
if validation in html :
return True
return False
"""
Method updtaeCecker(self)
return True if a new version is available or False if not
"""
def updateChecker(self):
getVersion = self.regex.findRegex(r"<!-- Version (\d+\.\d+) -->",str(self.connector.connection("https://raw.githubusercontent.com/SuicV/Scanner-web/master/README.md").response.read()))[0]
if float(getVersion) > self.version :
return True
return False