Compare commits
3 Commits
857063da34
...
0b709669b0
Author | SHA1 | Date |
---|---|---|
JoYo | 0b709669b0 | |
JoYo | 0562454923 | |
JoYo | 91cf527253 |
|
@ -11,4 +11,3 @@ services:
|
|||
- scraps:/out
|
||||
working_dir: /app
|
||||
command: python3 -m sins -o /out/
|
||||
# command: yasm seed.asm -o seed
|
||||
|
|
|
@ -4,10 +4,18 @@ import json
|
|||
|
||||
capstone = Cs(CS_ARCH_X86, CS_MODE_64)
|
||||
|
||||
def disasm(shellcode: bytes)->str:
|
||||
def disasm(shellcode: bytes)->list:
|
||||
opcodes = list()
|
||||
|
||||
for opcode in capstone.disasm(shellcode, 0):
|
||||
opcodes.append([opcode.mnemonic, opcode.op_str])
|
||||
|
||||
return opcodes
|
||||
|
||||
def objdump(shellcode: bytes)->str:
|
||||
opcodes = str()
|
||||
|
||||
for opcode in capstone.disasm(shellcode, 0):
|
||||
opcodes += f'{opcode.mnemonic} {opcode.op_str}\n'
|
||||
|
||||
return opcodes
|
||||
|
|
|
@ -8,7 +8,7 @@ from sqlalchemy.orm import Session, relationship, backref
|
|||
from sqlalchemy.orm.collections import attribute_mapped_collection
|
||||
import json
|
||||
|
||||
from .disassemble import disasm
|
||||
from .disassemble import objdump
|
||||
|
||||
now = '{0:%Y%m%dT%H%M%S}'.format(datetime.utcnow())
|
||||
Base = declarative_base()
|
||||
|
@ -29,7 +29,7 @@ class ScrapNode(Base):
|
|||
mtime = Column(DateTime, onupdate=datetime.utcnow)
|
||||
parent_id = Column(Integer, ForeignKey(id))
|
||||
checksum = Column(String)
|
||||
disasm = Column(String)
|
||||
objdump = Column(String)
|
||||
image = Column(LargeBinary)
|
||||
|
||||
children = relationship(
|
||||
|
@ -43,18 +43,17 @@ class ScrapNode(Base):
|
|||
self.image = child
|
||||
self.length = len(child)
|
||||
self.sha1sum
|
||||
self.disasm = str(disasm(child))
|
||||
self.objdump = objdump(child)
|
||||
|
||||
def __repr__(self):
|
||||
values = {
|
||||
'checksum': self.checksum,
|
||||
'length': self.length,
|
||||
'disasm': self.disasm,
|
||||
'parent_id': self.parent_id,
|
||||
'id': self.id,
|
||||
}
|
||||
|
||||
return json.dumps(values, indent=1)
|
||||
return f'{values}\n{self.objdump}'
|
||||
|
||||
@property
|
||||
def sha1sum(self):
|
||||
|
|
Loading…
Reference in New Issue