mirror of
https://github.com/adulau/pdns-qof-server.git
synced 2024-11-21 17:47:09 +00:00
Big refactoring, make the server similar to misp-modules
This commit is contained in:
parent
1878f64c45
commit
6a2b5e317c
4 changed files with 64 additions and 4 deletions
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
__pycache__
|
||||||
|
*.swp
|
||||||
|
*.pyc
|
||||||
|
qos_server.egg-info/
|
10
README.md
10
README.md
|
@ -10,6 +10,14 @@ Requirements
|
||||||
- [Tornado](http://www.tornadoweb.org)
|
- [Tornado](http://www.tornadoweb.org)
|
||||||
- Python [redis](https://pypi.python.org/pypi/redis/) client
|
- Python [redis](https://pypi.python.org/pypi/redis/) client
|
||||||
|
|
||||||
|
Installation
|
||||||
|
------------
|
||||||
|
|
||||||
|
```
|
||||||
|
pip3 install .
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
Running the qof-server
|
Running the qof-server
|
||||||
----------------------
|
----------------------
|
||||||
|
|
||||||
|
@ -17,7 +25,7 @@ The server is using the default Redis configuration for the pdns-toolkit. Don't
|
||||||
configuration for your Passive dns data store.
|
configuration for your Passive dns data store.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
python3 ./bin/qos-server.py
|
qos-server
|
||||||
```
|
```
|
||||||
|
|
||||||
Usage
|
Usage
|
||||||
|
|
|
@ -15,13 +15,22 @@
|
||||||
# Copyright (c) 2013 Alexandre Dulaunoy - a@foo.be
|
# Copyright (c) 2013 Alexandre Dulaunoy - a@foo.be
|
||||||
|
|
||||||
import tornado.escape
|
import tornado.escape
|
||||||
import tornado.ioloop
|
from tornado.ioloop import IOLoop
|
||||||
import tornado.web
|
import tornado.web
|
||||||
|
import tornado.process
|
||||||
|
from tornado.concurrent import run_on_executor
|
||||||
|
from concurrent.futures import ThreadPoolExecutor
|
||||||
|
|
||||||
|
import argparse
|
||||||
from ipaddress import ip_address
|
from ipaddress import ip_address
|
||||||
import redis
|
import redis
|
||||||
import json
|
import json
|
||||||
import sys
|
import sys
|
||||||
|
import signal
|
||||||
|
|
||||||
|
|
||||||
|
def handle_signal(sig, frame):
|
||||||
|
IOLoop.instance().add_callback(IOLoop.instance().stop)
|
||||||
|
|
||||||
|
|
||||||
def getFirstSeen(t1=None, t2=None):
|
def getFirstSeen(t1=None, t2=None):
|
||||||
|
@ -170,6 +179,7 @@ class FullQueryHandler(tornado.web.RequestHandler):
|
||||||
to_return.append(JsonQOF(getRecord(t=x.strip())))
|
to_return.append(JsonQOF(getRecord(t=x.strip())))
|
||||||
return to_return
|
return to_return
|
||||||
|
|
||||||
|
@tornado.gen.coroutine
|
||||||
def get(self, q):
|
def get(self, q):
|
||||||
print("fquery: " + q)
|
print("fquery: " + q)
|
||||||
try:
|
try:
|
||||||
|
@ -187,6 +197,15 @@ def main():
|
||||||
global r
|
global r
|
||||||
global rrset_supported
|
global rrset_supported
|
||||||
global origin
|
global origin
|
||||||
|
signal.signal(signal.SIGINT, handle_signal)
|
||||||
|
signal.signal(signal.SIGTERM, handle_signal)
|
||||||
|
argParser = argparse.ArgumentParser(description='qof-server server')
|
||||||
|
argParser.add_argument('-p', default=8888, help='qof-server TCP port (default 8888)')
|
||||||
|
argParser.add_argument('-l', default='localhost', help='misp-modules listen address (default localhost)')
|
||||||
|
args = argParser.parse_args()
|
||||||
|
port = args.p
|
||||||
|
listen = args.l
|
||||||
|
|
||||||
rrset = [
|
rrset = [
|
||||||
{"Reference": "[RFC1035]", "Type": "A", "Value": "1", "Meaning": "a host address", "Template": "", "Registration Date": ""},
|
{"Reference": "[RFC1035]", "Type": "A", "Value": "1", "Meaning": "a host address", "Template": "", "Registration Date": ""},
|
||||||
{"Reference": "[RFC1035]", "Type": "NS", "Value": "2", "Meaning": "an authoritative name server", "Template": "", "Registration Date": ""},
|
{"Reference": "[RFC1035]", "Type": "NS", "Value": "2", "Meaning": "an authoritative name server", "Template": "", "Registration Date": ""},
|
||||||
|
@ -281,8 +300,10 @@ def main():
|
||||||
(r"/info", InfoHandler)
|
(r"/info", InfoHandler)
|
||||||
])
|
])
|
||||||
|
|
||||||
application.listen(8888)
|
application.listen(port, address=listen)
|
||||||
tornado.ioloop.IOLoop.instance().start()
|
IOLoop.instance().start()
|
||||||
|
IOLoop.instance().stop()
|
||||||
|
return 0
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
sys.exit(main())
|
sys.exit(main())
|
27
setup.py
Normal file
27
setup.py
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from setuptools import setup, find_packages
|
||||||
|
|
||||||
|
setup(
|
||||||
|
name='qos-server',
|
||||||
|
version='1.0',
|
||||||
|
author='Alexandre Dulaunoy',
|
||||||
|
author_email='alexandre.dulaunoy@circl.lu',
|
||||||
|
maintainer='Alexandre Dulaunoy',
|
||||||
|
url='https://github.com/adulau/pdns-qof-server',
|
||||||
|
description='pdns-qof server is a "Common Output Format" compliant passive DNS query interface',
|
||||||
|
packages=find_packages(),
|
||||||
|
entry_points={'console_scripts': ['qos-server = qos_server:main']},
|
||||||
|
classifiers=[
|
||||||
|
'License :: OSI Approved :: GNU Affero General Public License v3',
|
||||||
|
'Development Status :: 5 - Production/Stable',
|
||||||
|
'Environment :: Console',
|
||||||
|
'Intended Audience :: Science/Research',
|
||||||
|
'Programming Language :: Python :: 3',
|
||||||
|
'Topic :: Security',
|
||||||
|
],
|
||||||
|
install_requires=[
|
||||||
|
'tornado',
|
||||||
|
'redis',
|
||||||
|
]
|
||||||
|
)
|
Loading…
Reference in a new issue