diff options
-rw-r--r-- | app.py | 30 | ||||
-rw-r--r-- | index.html | 19 |
2 files changed, 49 insertions, 0 deletions
@@ -0,0 +1,30 @@ +import re +import subprocess +import tornado.ioloop +import tornado.web +from tornado import template + +class MainHandler(tornado.web.RequestHandler): + def initialize(self): + self.loader = template.Loader('/Users/filipp/Projects/intercheck') + + def get(self): + self.write(self.loader.load("index.html").generate()) + + +class ScanHandler(tornado.web.RequestHandler): + def get(self): + result = subprocess.check_output(['nmap', self.request.remote_ip]) + for r in re.finditer(r'(\d+/[a-z]{3})\s([a-z]+)\s+(.+)', result): + t = r.groups() + self.write({'port': t[0], 'state': t[1], 'service': t[2]}) + + +application = tornado.web.Application([ + (r'/', MainHandler), + (r'/scan/', ScanHandler), +]) + +if __name__ == '__main__': + application.listen(8888) + tornado.ioloop.IOLoop.instance().start() diff --git a/index.html b/index.html new file mode 100644 index 0000000..89cb1f5 --- /dev/null +++ b/index.html @@ -0,0 +1,19 @@ +<!DOCTYPE html> +<html> +<head> + <title>intercheck 0.001</title> + <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.12/angular.min.js"></script> + <style type="text/css"> + body { + + } + </style> +</head> +<body> +{% block main %} + <form method="post" action="/scan/"> + <button type="submit">Go!</button> + </form> +{% end %} +</body> +</html> |