-
Notifications
You must be signed in to change notification settings - Fork 0
/
job.py
75 lines (60 loc) · 2.14 KB
/
job.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
import csv
from openpyxl import load_workbook #Lectura excel de dominios
wb = load_workbook(filename='LISTADO.xlsx')
#ws = wb['Poner nombre de la hoja']
colDominios = ws['A']
malDominis = list(colDominios)
dominis=[]
for x in range (5,len(malDominis)):
dominis.append(malDominis[x].value.encode("utf-8"))
from subprocess import call
header = ["dominio"]
aux = []
for domini in dominis:
try:
call(["python", "dnsrecon/dnsrecon.py", "-d", domini, "-t", "std", "-c", "csv_"+domini])
with open ("csv_"+domini,"rb") as csvfile:
spamreader = csv.reader(csvfile, delimiter=',')
tipus = []
textAcumulat = []
for row in spamreader:
#print(row)
trobat=False
cont= 0
while (not trobat and cont < len(tipus)):
if (row[0] not in header):
header.append(row[0])
if (row[0] == tipus[cont]):
trobat=True
textAcumulat[cont]=textAcumulat[cont]+" + "+row[1]+" "+row[2]
cont=cont+1
if (not trobat):
tipus.append(row[0])
textAcumulat.append(row[1]+" "+row[2])
aux2 = [domini,tipus,textAcumulat]
aux.append(aux2)
call(["rm", "csv_"+domini])
except Exception:
aux2 = [domini,[],[]]
aux.append(aux2)
#abrimos csv final
trash=[]
with open('dnsfinal.csv', 'wb') as csvfile:
spamwriter = csv.writer(csvfile, delimiter=",")
spamwriter.writerow(header)
for domini,nomdomini in enumerate(dominis):
trash=[]
trash.append(aux[domini][0])
index=1
while (index < len(header)):
trobat3=False
cont=1
while (not trobat3 and cont < len(aux[domini][1])):
if(aux[domini][1][cont] == header[index]):
trobat3=True
trash.append(aux[domini][2][cont])
cont=cont+1
if (not trobat3):
trash.append(",")
index=index+1
spamwriter.writerow(trash)