Exemplo n.º 1
0
def fileScan(scanfile, md5Hash, msg_id):
	yaraRules = yara.compile(yaraRuleFile)
	matches = []
	if os.path.getsize(scanfile) > 0:
		for match in yaraRules.match(scanfile):
			matches.append({"name" : match.rule, "meta" : match.meta})
	db = Maildatabase()
	for m in matches:
		yaraRule = m["name"]
		try:
			yaraDesc = m["meta"]["maltype"]
		except:
			yaraDesc = None
		sqlYara = (msg_id, md5Hash, yaraRule, yaraDesc)
		db.storeYara(sqlYara)
	return matches
Exemplo n.º 2
0
def fileScan(scanfile, md5Hash, msg_id):
    yaraRules = yara.compile(yaraRuleFile)
    matches = []
    if os.path.getsize(scanfile) > 0:
        for match in yaraRules.match(scanfile):
            matches.append({"name": match.rule, "meta": match.meta})
    db = Maildatabase()
    for m in matches:
        yaraRule = m["name"]
        try:
            yaraDesc = m["meta"]["maltype"]
        except:
            yaraDesc = None
        sqlYara = (msg_id, md5Hash, yaraRule, yaraDesc)
        db.storeYara(sqlYara)
    return matches
Exemplo n.º 3
0
 def reset(self):
     db.conn.close()
     os.remove(DBFile)
     shutil.rmtree(reportRoot)
     if not os.path.exists(reportRoot):
         os.mkdir(reportRoot)
     if not os.path.exists(os.path.join(MaildbRoot, "tmp")):
         os.mkdir(os.path.join(MaildbRoot, "tmp"))
     from db.db import Maildatabase
     Maildatabase().generate()
     logging.info('Maildb Application Reset')
Exemplo n.º 4
0
        def setup(self):
            # Setup up after a clear or initial install
            if not os.path.exists(reportRoot):
                os.mkdir(reportRoot)

            if not os.path.exists(os.path.join(MaildbRoot, "tmp")):
                os.mkdir(os.path.join(MaildbRoot, "tmp"))

            ## Setup The Tables ###

            from db.db import Maildatabase
            Maildatabase().generate()
            logging.info('DB Tables Created')
Exemplo n.º 5
0
Copyright (C) 2012-2013 Kevin Breen.
This file is part of the Maildb web application
See the 'LICENSE' File for copying permission.
'''

import codecs
import sys
import os.path, os
import subprocess
import shutil
import time
from core.hashing import MailHash
from datetime import datetime
from db.db import Maildatabase
from config.config import reportRoot, transferDir, MaildbRoot
db = Maildatabase()
global newPath
import logging


def submit(tmpDir, comment):  # THis is for txt files
    for emlfile in os.listdir(tmpDir):  #Run for each email file
        from core.parse import emlParse
        lastPath = db.lastLine()
        newPath = str(lastPath)
        logging.info('Record %s Submitted', newPath)
        reportDir = os.path.join(reportRoot, newPath)
        if not os.path.exists(reportDir):
            os.makedirs(reportDir)  #Create the Dir Structure
            os.makedirs(os.path.join(reportDir, "attatchments"))
        # SMTP Headers break the parser so remove them
Exemplo n.º 6
0
#!/usr/bin/env python
'''
Copyright (C) 2012-2013 Kevin Breen.
This file is part of the Maildb web application
See the 'LICENSE' File for copying permission.
'''

import os
import sys

from config.config import MaildbRoot, DBFile
from core.common import Dictionary

## Setup The Folder Structure ###
if not os.path.exists(os.path.join(MaildbRoot, "store")):
    os.mkdir(os.path.join(MaildbRoot, "store"))

if not os.path.exists(os.path.join(MaildbRoot, "tmp")):
    os.mkdir(os.path.join(MaildbRoot, "tmp"))

## Setup The Tables ###
from db.db import Maildatabase

Maildatabase().generate()

## Restart the APP ###

# Manual for now