forked from pronto/ifconfig.pro
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.py
69 lines (54 loc) · 1.64 KB
/
server.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
from flask import Flask, render_template, send_from_directory, request
import os, socket, time, re
socket.setdefaulttimeout(3)
app = Flask(__name__)
app.debug=False
def lookup(addr):
try:
return socket.gethostbyaddr(addr)
except socket.herror:
return "No dns record for host", "No dns record for host", "No dns record for host"
@app.route('/')
def main():
ip=request.remote_addr
agent=str(request.user_agent)
if "curl" in agent:
return request.remote_addr + "\n"
elif "PowerShell" in agent:
return request.remote_addr + "\n"
else:
hostname = lookup(ip)[0]
return render_template('main.html',
ip=request.remote_addr,
hostname=hostname ,
agent=agent,
lang=request.accept_languages ,
enco=request.accept_encodings,
xip=request.access_route[0]
)
@app.route('/ip.host')
def iphost():
hostname=lookup(request.remote_addr)[0]
return request.remote_addr + " - " + hostname + "\n"
@app.route('/host')
def host():
hostname=lookup(request.remote_addr)[0]
return hostname + "\n"
@app.route('/help')
def help():
f=open('/home/pronto/python/templates/main.html', 'r')
out = f.read()
start = out.find('Fea')
end = out.find('<!--')
return out[start:end]
@app.route('/freedooooom')
def freedom():
return render_template('freedom.html')
@app.route('/robots.txt')
def robots():
return render_template('robots.txt')
@app.route('/ping')
def ping():
return render_template('ping.html')
if __name__ == '__main__':
app.run(host='0.0.0.0')