-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathlondly.py
178 lines (163 loc) · 5.99 KB
/
londly.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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
# 调用各类插件获取子域名信息
# -*- coding:utf-8 -*-
import sys
import os
# from gevent import monkey
# monkey.patch_all()
import urllib3
import xlrd
import openpyxl
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
from uuid import uuid4
import dns.resolver
import re
from threading import Thread
from IPy import IP
import shutil
from collections import Counter
from queue import Queue
from urllib.parse import urlparse
from termcolor import cprint
from optparse import OptionParser
import os
import platform
from uuid import uuid4
import csv
import time
import socket
import socks
import configparser
from tqdm import *
from colorama import Fore
import requests
def BruteDomain(domain):
path=os.getcwd()
if os.path.exists(path + r"/url.txt"):
os.remove(path + r"/url.txt")
os.remove(path + r"/ksubdomain.txt")
# os.remove("url.txt")
os.remove("nucleiresult.txt")
cprint('-' * 50 + '正在调用oneforall,配置oneforall API效果更佳' + '-' * 50, 'green')
print(os.system('python3 OneForAll/oneforall.py --target ' + domain + ' run'))
outputFile=r"OneForAll/results/" + domain + ".csv"
if not os.path.exists(outputFile):
exit("Not found the OneForAll's output file ")
return outputFile
def csvcheck(domain):
path=os.getcwd()
with open(path+r"/OneForAll/results/"+domain+".csv","r") as f:
reader=csv.reader(f)
for i in reader:
read=i[5]
file = open(path+r"/url.txt", "a")
file.write(read + "\n")
def ksub(domain):
path = os.getcwd()
if os.path.exists(path + r"/ksubdomain.txt"):
os.remove(path + r'/ksubdomain.txt')
if os.path.exists(path + r"/d.txt"):
os.remove(path + r'/d.txt')
os.system('./ksubdomain/ksubdomain -d ' + domain + ' -full ' + r' -o ' + path + r'/d.txt')
path = os.getcwd()
dir = path + r"/d.txt"
list = []
with open(dir, encoding='utf-8') as dir:
c = dir.readlines()
for i in c:
d = i.split(" => ")
list.append(d[0])
for i in list:
file = open(path + r"/ksubdomain.txt", "a")
file.write(i + "\n")
if os.path.exists(path + r"/d.txt"):
os.remove(path + r'/d.txt')
# 文件合并
def merge(domain):
path = os.getcwd()
file1 = path + r'/url.txt'
file2 = path + r'/ksubdomain.txt'
f1 = open(file1, 'a', encoding='utf-8')
with open(file2, 'r', encoding='utf-8') as f2:
f1.write('\n')
for i in f2:
f1.write(i)
if os.path.exists(path + r"/.ksubdomain.txt"):
os.remove(path + r'ksubdomain.txt')
def finger(domain):
cprint('-' * 50 + '正在调用Finger进行重点资产和指纹识别!!' + '-' * 50, 'green')
path=os.getcwd()
print(os.system('python3 Finger/Finger.py -f ' + path+r"/url.txt"))
output1 = os.getcwd()
files = output1 + r"/Finger/output/"
b = os.listdir(files)
for j in b:
# jiuwenjianjia
new1 = output1 + r"/Finger/output/" + j
# xin wenjianjia
new2 = output1 + r"/result/onedomain/" + domain + '.xlsx'
os.rename(new1, new2)
new = output1 + r"/result/onedomain"
c = os.listdir(files)
for f in c:
shutil.move(files + f, new)
if os.path.exists(path+r"/url.txt"):
os.remove(path+r'/url.txt')
def Observer(domain):
cprint('-' * 50 + '正在对所有子域名进行指纹识别!!' + '-' * 50, 'green')
path = os.getcwd()
path1 = path + r'/result/onedomain/'+domain+'.xlsx'
wb = xlrd.open_workbook(path1)
sh = wb.sheet_by_name('Finger scan')
lie = sh.col_values(colx=0, start_rowx=1, end_rowx=None)
for i in lie:
file = open(path + r"/url.txt", "a")
file.write(i + "\n")
os.system('./Observer/observer -f ' + path + r"/url.txt -c" + path + r'/result/onedomain/' + domain+'Observer.txt')
def xray_nuclei(domain):
cprint('-' * 50 + '正在对所有子域名进行漏扫!!' + '-' * 50, 'green')
if os.path.exists("url.txt"):
os.system('./nuclei -l url.txt -s medium,high,critical -o nucleiresult.txt')
os.system('./xray_linux_amd64 webscan -url-file url.txt --html-output xray.html')
# os.remove("url.txt")
# os.remove("ksubdomain.txt")
# 获取one 域名
def run_subdomain():
OneForAll_File = BruteDomain(domain)
csvcheck(domain)
ksub(domain)
merge(domain)
finger(domain)
Observer(domain)
xray_nuclei(domain)
def banner():
banner = '''
__ __ __
| \ | \| \
| $$ ______ _______ ____| $$| $$ __ __
| $$ / \ | \ / $$| $$| \ | \
| $$ | $$$$$$\| $$$$$$$\| $$$$$$$| $$| $$ | $$
| $$ | $$ | $$| $$ | $$| $$ | $$| $$| $$ | $$
| $$____| $$__/ $$| $$ | $$| $$__| $$| $$| $$__/ $$
| $$ \$$ $$| $$ | $$ \$$ $$| $$ \$$ $$
\$$$$$$$$\$$$$$$ \$$ \$$ \$$$$$$$ \$$ _\$$$$$$$
| \__| $$
\$$ $$
\$$$$$$
`----' `-'----'
'''
print(banner)
# 初始配置
def _init():
global domain
banner()
usage = '\n\t' \
'python3 %prog -d domain.com\n\t' \
parse = OptionParser(usage=usage)
parse.add_option('-d', '--domain', dest='domain', type='string', help='target domain')
options, args = parse.parse_args()
domain = options.domain
if domain:
cprint('-' * 50 + 'Start {} information collection'.format(domain) + '-' * 50, 'green')
run_subdomain()
if __name__ == '__main__':
_init()