parent
							
								
									ba8d38e56b
								
							
						
					
					
						commit
						a3ba591077
					
				| 
						 | 
				
			
			@ -54,19 +54,13 @@ def generation(queue: Queue, shellcode: bytes):
 | 
			
		|||
    queue.put(result)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def growth(*, shellcode: bytes, length: int) -> bytes:
 | 
			
		||||
    if length <= len(shellcode):
 | 
			
		||||
        return bytes(shellcode)
 | 
			
		||||
 | 
			
		||||
    opcodes = disasm(shellcode)
 | 
			
		||||
 | 
			
		||||
def growth(*, shellcode: bytes, objdump: str) -> bytes:
 | 
			
		||||
    max_op_len = 15
 | 
			
		||||
 | 
			
		||||
    if len(shellcode) > len(opcodes) * max_op_len:
 | 
			
		||||
    if len(shellcode) > objdump.count('\n') * max_op_len:
 | 
			
		||||
        return bytes(shellcode)
 | 
			
		||||
 | 
			
		||||
    for mnemonic, op_str in opcodes:
 | 
			
		||||
        if mnemonic == 'nop':
 | 
			
		||||
    if objdump.count('nop'):
 | 
			
		||||
        return bytes(shellcode)
 | 
			
		||||
 | 
			
		||||
    shellcode = bytearray(shellcode)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -10,6 +10,7 @@ import logging
 | 
			
		|||
 | 
			
		||||
from .mutation import generation, mutate, seed_shell, growth
 | 
			
		||||
from .orm import db_config, ScrapNode
 | 
			
		||||
from .disassemble import objdump
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def sins():
 | 
			
		||||
| 
						 | 
				
			
			@ -94,13 +95,17 @@ def sins():
 | 
			
		|||
                lineage += 1
 | 
			
		||||
                continue
 | 
			
		||||
 | 
			
		||||
            if not result:
 | 
			
		||||
            if result != len(scrap):
 | 
			
		||||
                lineage += 1
 | 
			
		||||
                continue
 | 
			
		||||
 | 
			
		||||
            scrap = growth(shellcode=scrap, length=result)
 | 
			
		||||
            logger.debug(f'result: {result}, {len(scrap)}')
 | 
			
		||||
 | 
			
		||||
            opcodes = objdump(scrap)
 | 
			
		||||
            scrap = growth(shellcode=scrap, objdump=opcodes)
 | 
			
		||||
 | 
			
		||||
            parent = ScrapNode(child=scrap, parent_id=parent.id)
 | 
			
		||||
            parent.objdump = opcodes
 | 
			
		||||
            session.add(parent)
 | 
			
		||||
            session.commit()
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue