Skip to content

Commit

Permalink
Fixed a bunch of stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
cloughrm committed May 11, 2014
1 parent d997020 commit 18dbb50
Show file tree
Hide file tree
Showing 11 changed files with 31 additions and 25 deletions.
2 changes: 1 addition & 1 deletion analys-dev.ini
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ plugin_dirs = static

[server:main]
use = egg:waitress#main
host = 127.0.0.1
host = 0.0.0.0
port = 6543

[server:datastore]
Expand Down
2 changes: 1 addition & 1 deletion analys/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def _submit_file(file_data, filename, parent=False):

file_response = {'resource': filename,
'file_id': file_id,
'resource_type': 'FILE',
'resource_type': 'FILE',
'extension': filename.split('.')[-1]} # TODO: Hack in order to remove deadlock a couple lines below
if parent:
file_response.update({"parent": parent})
Expand Down
4 changes: 2 additions & 2 deletions analys/plugins/pluginmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,5 +101,5 @@ def load_plugins(self, plugin_dirs):
"analys.plugins.%s.%s.plugin" %
(dir, module),
fromlist=['blah']), config._sections,))
else:
log.warning("No config file found in {}, Plugin was not loaded.".format(root))
# else:
# log.warning("No config file found in {}, Plugin was not loaded.".format(root))
6 changes: 5 additions & 1 deletion analys/plugins/static/bluecoat/bluecoat.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@
A module used for intereaction with bluecoat website review
"""
import logging
from BeautifulSoup import BeautifulSoup

try:
from BeautifulSoup import BeautifulSoup
except ImportError:
from bs4 import BeautifulSoup
import requests

log = logging.getLogger(__file__)
Expand Down
10 changes: 4 additions & 6 deletions analys/plugins/static/swfdump/plugin.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import swfdump
from analys.plugins.interfaces import File
from analys.plugins.plugin import Plugin

class AnalysPlugin(object):
def __init__(self, *args, **kwargs):
self.resource = kwargs['resource']
class AnalysPlugin(Plugin):

def submit(self):
swf = swfdump.SWFDump(self.resource.create_temp_file())
return result
swf = swfdump.SWFDump(self.get_resource().create_temp_file())
return swf

def render(self):
pass
Expand Down
2 changes: 1 addition & 1 deletion analys/plugins/static/swfdump/swfdump.analys-plugin
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ Extensions = swf
[Documentation]
Author = Kevin Glisson ([email protected])
Version = 1.0
Description = "Extracts domains and ip address from swf files"
Description = "Extracts domains and ip address from swf files"
2 changes: 1 addition & 1 deletion analys/plugins/static/swfdump/swfdump.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class SWFDump(object):
def __init__(self, swf_file):
self.swf_file = swf_file
self.swf_file = swf_file

def analyze(self):
"""
Expand Down
11 changes: 7 additions & 4 deletions analys/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import datastore
from rq import Queue
from analys.plugins.pluginmanager import PluginManager
from pprint import pprint

log = logging.getLogger(__name__)

Expand All @@ -35,17 +36,20 @@ def create_async_tasks(datastore, task, message_queue, priority='low'):
jobs (list): List of created jobs
"""
log.debug("Creating async tasks...")

q = Queue(connection=message_queue, async=False) # no args implies default queue
pm = PluginManager()

#TODO load plugin directories from config
pm.load_plugins(['static'])

extension = datastore.get_document_by_id('submissions', task['submission_id'])['extension']

logging.info('Extension: {0}'.format(extension))

#TODO set timeouts via the plugin config
jobs = []
jobs = []
for plugin, config in pm.get_plugins():

#ignore plugins that dont work with this resource type
r_type = task['resource_type']
if r_type.lower() not in config['Core']['datatype'].lower():
Expand All @@ -71,10 +75,9 @@ def create_async_tasks(datastore, task, message_queue, priority='low'):
collection='submissions',
resource_type=r_type)


task_id = datastore.insert('tasks', {'submission_id': task['submission_id'],
'plugin': config['Core']['name']})

job_id = q.enqueue(p.submit).id
jobs.append((config['Core']['name'], job_id, task_id))
log.debug("Creating task with plugin {} and resource_type of {}".format(config['Core']['name'], r_type))
Expand Down
3 changes: 2 additions & 1 deletion analys/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
from analys import datastore
from analys.create import url_submission, file_submission

from pprint import pprint

log = logging.getLogger(__name__)

#TODO figure out how the create renderer for mongo_json data
Expand Down Expand Up @@ -311,7 +313,6 @@ def collection_post(self):
submission_id = task.get('submission_id')
#TODO impliment priority handling
if submission_id:
print task
created_tasks = tasks.create_async_tasks(self.request.datastore, task, self.request.message_queue)
if len(created_tasks) > 0:

Expand Down
12 changes: 6 additions & 6 deletions bin/configure
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ def install():
# TODO: determine different linux distros, will only work on ubuntu atm
elif 'linux' in env.lower():
print '[+] Updating packages...'
subprocess.call(['apt-get', 'update'])
subprocess.call(['apt-get', 'install', '-y', 'python-software-properties'])
# subprocess.call(['apt-get', 'update'])
# subprocess.call(['apt-get', 'install', '-y', 'python-software-properties'])

# Install/test mongodb
if 'n' in raw_input('[+] Would you like to try and install mongodb on this system? (Y/n)').lower():
Expand Down Expand Up @@ -217,15 +217,15 @@ def install():
('text/html', 'html'),
('text/plain', 'html')]

d = Datastore(install_config['mongodb']['hostname'],
install_config['mongodb']['port'])
d = Datastore(config['mongodb']['hostname'],
config['mongodb']['port'])
s = Settings(d)

print "[+] Adding defualt mimetypes..."
for x in mimetypes:
for x in types:
print x

s.create_mimetype_mappings(mimetypes)
s.create_mimetype_mappings(types)

passwords = ['password', 'infected']

Expand Down
2 changes: 1 addition & 1 deletion docs/user/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ Install the project into the virutalenv:
source Analys/bin/activate
python analys/setup.py install

Thats it! Anayls is not installed, make sure you run all of the tests to make sure everything
Thats it! Anayls is now installed, make sure you run all of the tests to make sure everything
looks good:
py.test Analys

0 comments on commit 18dbb50

Please sign in to comment.