From 8aaf23cdacf97fc3f0d786ee753abb18f3e7b124 Mon Sep 17 00:00:00 2001 From: brent s Date: Thu, 5 Oct 2017 21:17:04 -0400 Subject: [PATCH] adding net project with addr subproject --- net/addr/app/__init__.py | 7 ++++++ net/addr/app/models.py | 0 net/addr/app/templates/base.html | 31 ++++++++++++++++++++++++ net/addr/app/templates/index.html | 7 ++++++ net/addr/app/views.py | 40 +++++++++++++++++++++++++++++++ net/addr/config.py | 5 ++++ net/addr/run.py | 4 ++++ net/addr/uwsgi.ini | 18 ++++++++++++++ 8 files changed, 112 insertions(+) create mode 100644 net/addr/app/__init__.py create mode 100644 net/addr/app/models.py create mode 100644 net/addr/app/templates/base.html create mode 100644 net/addr/app/templates/index.html create mode 100644 net/addr/app/views.py create mode 100644 net/addr/config.py create mode 100644 net/addr/run.py create mode 100644 net/addr/uwsgi.ini diff --git a/net/addr/app/__init__.py b/net/addr/app/__init__.py new file mode 100644 index 0000000..4a49fb4 --- /dev/null +++ b/net/addr/app/__init__.py @@ -0,0 +1,7 @@ +from flask import Flask + +app = Flask(__name__, instance_relative_config=True) + +from app import views + +app.config.from_object('config') diff --git a/net/addr/app/models.py b/net/addr/app/models.py new file mode 100644 index 0000000..e69de29 diff --git a/net/addr/app/templates/base.html b/net/addr/app/templates/base.html new file mode 100644 index 0000000..328e38f --- /dev/null +++ b/net/addr/app/templates/base.html @@ -0,0 +1,31 @@ + + + + + {% block title %}{% endblock %} + + + + + + + +
+
+ +
+ {% block body %} {% endblock %} + +
+ + + + diff --git a/net/addr/app/templates/index.html b/net/addr/app/templates/index.html new file mode 100644 index 0000000..dd2a9b3 --- /dev/null +++ b/net/addr/app/templates/index.html @@ -0,0 +1,7 @@ +{% extends "base.html" %} {% block title %}r00t^2 Client Info Revealer{% endblock %}{% block body %} +
+

What this is

+

This is a tool to reveal certain information about your connection that the server sees.

+
+

PLACEHOLDER.

+{% endblock %} diff --git a/net/addr/app/views.py b/net/addr/app/views.py new file mode 100644 index 0000000..7dbaf8b --- /dev/null +++ b/net/addr/app/views.py @@ -0,0 +1,40 @@ +import json +import re +from flask import render_template, make_response, request +from app import app + +@app.route('/', methods = ['GET']) #@app.route('/') +def index(): + # First we define interactive browsers + _intbrowsers = ('camino', 'chrome', 'firefox', 'galeon', 'kmeleon', 'konqueror', + 'links', 'lynx') + # And then we set some parameter options for less typing later on. + _yes = ('y', 'yes', 'true', '1') + _no = ('y', 'no', 'false', '0') + visitor = {'client': {'str': request.user_agent.string, + 'browser': request.user_agent.browser, + 'os': request.user_agent.platform, + 'language': request.user_agent.language, + 'to_header': request.user_agent.to_header(), + 'version': request.user_agent.version}, + 'ip': request.remote_addr, + 'headers': dict(request.headers)} + # We have to convert these to strings so we can do tuple comparisons on lower()s. + _json = str(request.args.get('json')).lower() + _html = str(request.args.get('html')).lower() + # Handle possibly conflicting options. + # This forces JSON if html=0, and forces HTML if json=0. json= is processed first. + if _json in _no: + _html = '1' + elif _html in _no: + _json = '1' + # Set the tabs for JSON + try: + _tabs = int(request.args.get('tabs')) + except (ValueError, TypeError): + _tabs = None + if (visitor['client']['browser'] in _intbrowsers and _json not in _yes) or (_html in _yes): + return(render_template('index.html', visitor = visitor)) + else: + j = json.dumps(visitor, indent = _tabs) + return(j) diff --git a/net/addr/config.py b/net/addr/config.py new file mode 100644 index 0000000..6379da2 --- /dev/null +++ b/net/addr/config.py @@ -0,0 +1,5 @@ +# config.py + +# Flask debugging - DISABLE FOR PRODUCTION ENVIRONMENTS +DEBUG = True +#DEBUG = False diff --git a/net/addr/run.py b/net/addr/run.py new file mode 100644 index 0000000..3a43937 --- /dev/null +++ b/net/addr/run.py @@ -0,0 +1,4 @@ +from app import app + +if __name__ == '__main__': + app.run() diff --git a/net/addr/uwsgi.ini b/net/addr/uwsgi.ini new file mode 100644 index 0000000..9c6531c --- /dev/null +++ b/net/addr/uwsgi.ini @@ -0,0 +1,18 @@ +[uwsgi] +plugin = python +py-autoreload = 1 +#uid = http +#gid = http +socket = /run/uwsgi/netinfo.sock +chown-socket = http:http +processes = 4 +master = 1 +base = /usr/local/lib/optools/net/addr +chdir = %(base) +#mount = /=%(base)/run.py +wsgi-file = %(base)/run.py +chmod-socket = 660 +callable = app +cgi-helper =.py=python +logto = /var/log/uwsgi/%n.log +vacuum