Instantly share code, notes, and snippets.

Embed
What would you like to do?
# vi /etc/init/twistedintel.conf
start on runlevel [2345]
stop on runlevel [016]
set uid
set gid
exec /usr/bin/python /opt/TwistedIntel.py
respawn
# crontab –e
# 0 * * * * stop twistedintel && start twistedintel
#!/usr/bin/python
from twisted.web import server, resource
from twisted.internet import reactor, endpoints, defer, utils
import os
artifacts = []
file = open('/opt/critical-stack/frameworks/intel/master-public.bro.dat','r')
file.readline()
for line in file:
out = line.split('\t')
artifacts.append(out[0])
class TwistedIntel(resource.Resource):
isLeaf = True
def render_GET(self, request):
request.setHeader("content-type", "text/plain")
path = request.postpath
if path[0] in artifacts:
result = path[0]+' - FOUND'
else:
result = path[0]
return str(result)
endpoints.serverFromString(reactor, "tcp:8080").listen(server.Site(TwistedIntel()))
reactor.run()
#http://0.0.0.0:8080/0800fc577294c34e0b28ad2839435945
#!/usr/bin/python
from twisted.web import server, resource
from twisted.internet import reactor, endpoints, defer, utils
import os
artifacts = []
file = open('/opt/critical-stack/frameworks/intel/master-public.bro.dat','r')
file.readline()
for line in file:
out = line.split('\t')
artifacts.append(out)
class TwistedIntel(resource.Resource):
isLeaf = True
def render_GET(self, request):
request.setHeader("content-type", "text/plain")
path = request.postpath
matching = [s for s in artifacts if path[0] in s]
if(matching):
result = matching
else:
result = ''
return str(result)
endpoints.serverFromString(reactor, "tcp:8080").listen(server.Site(TwistedIntel()))
reactor.run()
#http://0.0.0.0:8080/0800fc577294c34e0b28ad2839435945
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment