Browse Source

minor fixes and formatting

master
JoYo 3 years ago
parent
commit
ba8d38e56b
  1. 1
      sins/__init__.py
  2. 6
      sins/disassemble.py
  3. 5
      sins/orm.py

1
sins/__init__.py

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

6
sins/disassemble.py

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

5
sins/orm.py

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

Loading…
Cancel
Save