-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctionsMain.py
154 lines (125 loc) · 4.05 KB
/
functionsMain.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
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
from tabulate import tabulate
import os
import re
from Modules.Menu import Menu
from Modules.Img import Img
import wget
import exiftool
def clear():
if os.name == "nt":
os.system("cls")
else:
os.system("clear")
def endOption():
input("\nPresione cualquier tecla para continuar...")
os.system('clear')
def setTarget(tpl):
(menu, config, scann) = tpl
#Solicitamos el objetivo
t = menu.requestTarget(config.data('target'))
# Se guarda el nuevo objetivo si ha cambiado
if t != config.data('target') : config.data('target', t)
scann.reset()
scann.iniTarget(t)
# Se inicia el scaneo
scann.scanLinks()
#whois del objetivo
# Imprime objetos con el metodo string para impresion en consola
def printObjects(response):
clear()
arrdata = response[1]
for o in arrdata:
print(o.string())
def printResponse(response, header=[], showindex=True):
data = response[1]
for k, v in data.items():
print(k, '->', v)
endOption()
def showImage(response):
print('SHOW IMAGE')
print(response)
# Muestra los datos del scaner
# [index, {url : [datos]}]
def showDataMenu (response, tpl=()):
inFunc=None
outFunc=None
headers=[]
if len(tpl) >= 1: inFunc = tpl[0]
if len(tpl) >= 2: outFunc = tpl[1]
if len(tpl) == 3: headers = tpl[2]
try:
mnu = Menu('Seleccione id para ampliar la información:')
res = response[1]
count = 1
# Establecemos cabecera del menú
if headers:
mnu.setHeader(headers)
# Opciopn salir
mnu.addOption([0, 'Volver'], mnu.exit)
for lbl, data in res[1].items():
if inFunc:
if outFunc:
# Tiene funcion de entrada y de salida
mnu.addOption(data=[count, lbl, data], inOp=[inFunc, lbl], outOp=outFunc)
else:
# Tiene funcion de entrada
mnu.addOption(data=[count, lbl, data], inOp=[inFunc, lbl])
else:
if outFunc:
# Tiene funcion de salida
mnu.addOption(data=[count, lbl, data], inOp=None, outOp=outFunc)
else:
# Sin funciones de retorno
mnu.addOption(data=[count, lbl, data])
count += 1
mnu.start()
#endOption()
except Exception as e:
print('ErrorshowDataMenu:', e)
exit()
def exitProgram(response):
print('\nGracias por usar Scrappy')
print('Hasta pronto!\n')
exit()
# Menu para cambiar el alcance
# Recibe un array con un diccionario {url: estado}
def showLinks(response):
data = response[1]
for k in data:
print(k)
#endOption()
# Menu para cambiar el alcance
def inputScope(response, tpl):
try:
(scann, menuOp, config) = tpl
actualScope = scann.scope()
value = menuOp.input('Seleccione el alcance deseado de 0-3, actual = {}: '.format(actualScope), scann.scope)
# Se guarda el dato en el archivo de configuración
config.data('scope', value)
menuOp.exit()
if actualScope != scann.scope():
# Se reescanea para adaptarlo al nuevo scope
scann.scanLinks()
except Exception as e:
print(e)
def showrawdata(response, scann):
print(scann.data)
def getImage(response):
try:
urlimage = response
filename = re.sub(r'(https|http)+://', '', urlimage).strip()
ext = re.findall(r'(\.[^.]+$)', filename)[0]
filename.replace(ext, '')
namefile = re.sub(r'\W','',filename)
pathimage = 'targets/' + namefile + ext
wget.download(urlimage, pathimage)
# obtenemos los metadata
files = [pathimage]
with exiftool.ExifTool() as et:
metadata = et.get_metadata_batch(files)
for k, v in metadata[0].items():
print(k, '=>' , v)
endOption()
except Exception as e:
print('getImage', e)
exit()