-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathapp.py
110 lines (95 loc) · 3.24 KB
/
app.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
from flask import Flask,render_template,request,jsonify,send_file
from os import system
app = Flask(__name__)
@app.route('/')
def welcome():
return render_template('index.html')
@app.route('/result', methods = ['POST', 'GET'])
def data():
if request.method == 'GET':
return f"The URL /result is accessed directly. Try going to '/' and Enter domain"
if request.method == 'POST':
form_data = request.form
domain = form_data['domain']
system('./subfinder -silent -d {} > domains/{}.txt'.format(domain, domain))
aa = open('doms/{}.txt'.format(domain), 'r')
bb = aa.readlines()
aa.close()
for i in range(len(bb)):
bb[i] = bb[i].rstrip('\n')
f = open('templates/{}.html'.format(domain),'w')
f.write('''
<!DOCTYPE html>
<html lang="en">
<head>
<title>Subdomain Enumerator by Gokul</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
<style>
.navbar {
margin-bottom: 0;
border-radius: 0;
}
footer {
background-color: #f2f2f2;
padding: 25px;
}
</style>
</head>
<body>
<nav class="navbar navbar-inverse">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#"><center>Subdomain Enumerator</center></a>
</div>
<div class="collapse navbar-collapse" id="myNavbar">
<ul class="nav navbar-nav">
</ul>
<ul class="nav navbar-nav navbar-right">
</ul>
</div>
</div>
</nav>
<div class="jumbotron">
<div class="container text-center">
<h3>Enter Domain</h3>
<form action="/result" method="POST">
<input type="text" name="domain">
<br><br><input type=submit value=submit>
</form>
</div>
</div>
<b><h3><center>Subdomains Found are
''')
# adding all found subdomains using <li> tag and for loop
f.write(' {}</center></h3></b><br><p><center><form method="post" action="download/{}.txt"><button type="submit">Download results!</button></form></center><br><p><ul>'.format(str(len(bb)), domain))
for i in bb:
f.write('<li> {}\n'.format(i))
f.write('''
</ul>
<br><br><br><br>
<footer class="container-fluid text-center">
<p>Created By Gokul</p>
</footer>
</body>
</html>
</div>
</div><br><br>
''')
f.close()
return render_template('{}.html'.format(domain))
@app.route('/download/<filename>', methods=['GET', 'POST'])
def download(filename):
if request.method == "GET":
return "The result is accessed directly go to / and enter domain to download results"
if request.method == "POST":
return send_file('./domains/{}'.format(filename), as_attachment=True, mimetype='txt')
app.run()