minor fixes and formatting
							parent
							
								
									8d8df2ab5a
								
							
						
					
					
						commit
						ba8d38e56b
					
				|  | @ -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 | ||||||
|  |  | ||||||
|  | @ -4,7 +4,8 @@ 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() | ||||||
| 
 | 
 | ||||||
|     for opcode in capstone.disasm(shellcode, 0): |     for opcode in capstone.disasm(shellcode, 0): | ||||||
|  | @ -12,7 +13,8 @@ def disasm(shellcode: bytes)->list: | ||||||
| 
 | 
 | ||||||
|     return opcodes |     return opcodes | ||||||
| 
 | 
 | ||||||
| def objdump(shellcode: bytes)->str: | 
 | ||||||
|  | def objdump(shellcode: bytes) -> str: | ||||||
|     opcodes = str() |     opcodes = str() | ||||||
| 
 | 
 | ||||||
|     for opcode in capstone.disasm(shellcode, 0): |     for opcode in capstone.disasm(shellcode, 0): | ||||||
|  |  | ||||||
|  | @ -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, | ||||||
|         } |         } | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	 JoYo
						JoYo