Exemplo n.º 1
0
def init(name=__name__, fields=None, timer=None, emitter=log.emit_simple, save_actions=None, save_errors=None, hook_tb=tb.long_tb):
    if isinstance(name, tuple):
        name, code = name
        code = log.register_action(str(name), int(code))
    else:
        code = log.register_action(name)
    log.start_root_log(code, fields, timer)
    if emitter:
        log.add_global_emit(emitter)
    sys.path = []
    set_builtins()
    tb.set_excepthook(hook_tb)
    #
    if save_errors:
        log.save_errors(save_errors)
    if save_actions:
        log.save_actions(save_actions)
Exemplo n.º 2
0
def init(name=__name__,
         fields=None,
         timer=None,
         emitter=log.emit_simple,
         save_actions=None,
         save_errors=None,
         hook_tb=tb.long_tb):
    if isinstance(name, tuple):
        name, code = name
        code = log.register_action(str(name), int(code))
    else:
        code = log.register_action(name)
    log.start_root_log(code, fields, timer)
    if emitter:
        log.add_global_emit(emitter)
    sys.path = []
    set_builtins()
    tb.set_excepthook(hook_tb)
    #
    if save_errors:
        log.save_errors(save_errors)
    if save_actions:
        log.save_actions(save_actions)
Exemplo n.º 3
0
import struct
import sys

import pysec
from pysec import binary
from pysec.io import fd
from pysec import log
from pysec.strings import erepr
from pysec import tb


MAX_LINE = 4096


# register actions
ACT_LOADDB = log.register_action('LOAD_DB')
ACT_SCANFILE = log.register_action('SCAN_FILE')
ACT_CALCOFFSET = log.register_action('CALCULATE_OFFSET')
ACT_SEARCHSIGNS = log.register_action('SEARCH_SIGNATURES')


# register errors
ERR_WRONGFMT = log.register_error('WRONG_FILE_FORMAT')
ERR_NOTFOUND = log.register_error('SIGNATURE_NOT_FOUND')
ERR_LINETOOBIG = log.register_error('LINE_TOO_LONG')


DOS_HEADER = '<HHHHHHHHHHHHHH8sHH20sI'
FILE_HEADER_SIZE = struct.calcsize('<HHIIIHH')
OPT_HEADER = '<HBBIIIIIIIIIHHHHHHIIIIHHIIIIII'
              
Exemplo n.º 4
0
import glob
import os
import struct
import sys

import pysec
from pysec import binary
from pysec.io import fd
from pysec import log
from pysec.strings import erepr
from pysec import tb

MAX_LINE = 4096

# register actions
ACT_LOADDB = log.register_action('LOAD_DB')
ACT_SCANFILE = log.register_action('SCAN_FILE')
ACT_CALCOFFSET = log.register_action('CALCULATE_OFFSET')
ACT_SEARCHSIGNS = log.register_action('SEARCH_SIGNATURES')

# register errors
ERR_WRONGFMT = log.register_error('WRONG_FILE_FORMAT')
ERR_NOTFOUND = log.register_error('SIGNATURE_NOT_FOUND')
ERR_LINETOOBIG = log.register_error('LINE_TOO_LONG')

DOS_HEADER = '<HHHHHHHHHHHHHH8sHH20sI'
FILE_HEADER_SIZE = struct.calcsize('<HHIIIHH')
OPT_HEADER = '<HBBIIIIIIIIIHHHHHHIIIIHHIIIIII'


def get_offset(data):