Skip to content
This repository has been archived by the owner on Dec 16, 2017. It is now read-only.

Commit

Permalink
Refactors Cuckoo submission into a separate function
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyle Maxwell committed Jul 6, 2014
1 parent 19ec3e8 commit 4ad813b
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions maltrieve.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,9 @@ def get_malware(q, dumpdir):
f.write(mal)
logging.info("Stored %s in %s", md5, dumpdir)
if 'vxcage' in cfg:
store_vxcage(os.path.join(dumpdir,md5))
store_vxcage(os.path.join(dumpdir, md5))
if 'cuckoo' in cfg:
f = open(os.path.join(dumpdir, md5), 'rb')
form = MultiPartForm()
form.add_file('file', md5, fileHandle=f)
body = str(form)
url = 'http://localhost:8090/tasks/create/file'
headers = {'User-agent': 'Maltrieve', 'Content-type': form.get_content_type(), 'Content-length': len(body)}
response = requests.post(url, headers=headers, data=body)
response_data = response.json()
logging.info("Submitted %s to cuckoo, task ID %s", md5, response_data["task_id"])
submit_cuckoo(os.path.join(dumpdir, md5))
hashes.add(md5)
q.task_done()

Expand All @@ -103,6 +95,19 @@ def store_vxcage(filepath):
logging.info("Exception caught from VxCage")


def submit_cuckoo(filepath):
if os.path.exists(filepath):
files = {'file': (os.path.basename(filepath), open(filepath, 'rb'))}
url = 'http://localhost:8090/tasks/create/file'
headers = {'User-agent': 'Maltrieve'}
try:
response = requests.post(url, headers=headers, files=files)
response_data = response.json()
logging.info("Submitted %s to cuckoo, task ID %s", filepath, response_data["task_id"])
except:
logging.info("Exception caught from Cuckoo")


def get_xml_list(feed_url, q):

feed = feedparser.parse(feed_url)
Expand Down

0 comments on commit 4ad813b

Please sign in to comment.