minor fixes and formatting

master
JoYo 2019-02-24 07:38:11 +00:00
parent 8d8df2ab5a
commit ba8d38e56b
3 changed files with 5 additions and 7 deletions

View File

@ -2,3 +2,4 @@
from .run import sins from .run import sins
from .mutation import generation, mutate from .mutation import generation, mutate
from .orm import db_config, ScrapNode from .orm import db_config, ScrapNode
from .disassemble import disasm, objdump

View File

@ -4,6 +4,7 @@ import json
capstone = Cs(CS_ARCH_X86, CS_MODE_64) capstone = Cs(CS_ARCH_X86, CS_MODE_64)
def disasm(shellcode: bytes) -> list: def disasm(shellcode: bytes) -> list:
opcodes = list() opcodes = list()
@ -12,6 +13,7 @@ def disasm(shellcode: bytes)->list:
return opcodes return opcodes
def objdump(shellcode: bytes) -> str: def objdump(shellcode: bytes) -> str:
opcodes = str() opcodes = str()

View File

@ -7,8 +7,6 @@ from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import Session, relationship, backref from sqlalchemy.orm import Session, relationship, backref
from sqlalchemy.orm.collections import attribute_mapped_collection from sqlalchemy.orm.collections import attribute_mapped_collection
from .disassemble import objdump, disasm
now = '{0:%Y%m%dT%H%M%S}'.format(datetime.utcnow()) now = '{0:%Y%m%dT%H%M%S}'.format(datetime.utcnow())
Base = declarative_base() Base = declarative_base()
@ -42,14 +40,11 @@ class ScrapNode(Base):
self.image = child self.image = child
self.length = len(child) self.length = len(child)
self.sha1sum self.sha1sum
self.objdump = objdump(child)
def __repr__(self): def __repr__(self):
values = { values = {
'checksum': self.checksum, 'checksum': self.checksum,
'length': self.length, 'length': self.length,
# todo remove for performance
'operations': len(disasm(self.image)),
'parent_id': self.parent_id, 'parent_id': self.parent_id,
'id': self.id, 'id': self.id,
} }