From b92db2127320f0deaf74e6251a3a5d773c803b9d Mon Sep 17 00:00:00 2001 From: Carsten Maartmann-Moe Date: Fri, 17 Apr 2015 22:43:35 +0200 Subject: [PATCH] Refactoring --- README.md | 17 ++--- inception/interfaces/slotscreamer.py | 96 +++++++++++++++------------- setup.py | 2 +- 3 files changed, 61 insertions(+), 54 deletions(-) diff --git a/README.md b/README.md index c5d5cfd..69bb183 100644 --- a/README.md +++ b/README.md @@ -61,9 +61,9 @@ still vulnerable] [9]. Key data -------- - * Version: 0.4.0 + * Version: 0.4.1 * License: GPL - * Author: Carsten Maartmann-Moe (carsten@carmaa.com) AKA ntropy + * Author: Carsten Maartmann-Moe (carsten@carmaa.com) * Twitter: @breaknenter * Site: http://www.breaknenter.org/projects/inception * Source: https://github.com/carmaa/inception @@ -103,9 +103,9 @@ Installation ------------ On Debian-based distributions the installation command lines can be summarized -as: +as (apply `sudo` as needed if you're not root): - sudo apt-get install git cmake g++ python3 python3-pip + apt-get install git cmake g++ python3 python3-pip On OS X, you can install the tool requirements with [homebrew] [4]: @@ -113,12 +113,12 @@ On OS X, you can install the tool requirements with [homebrew] [4]: After installing the requirements, download and install libforensic1394: - git clone git://git.freddie.witherden.org/forensic1394.git - cd forensic1394 + git clone git://github.com/FreddieWitherden/libforensic1394.git + cd libforensic1394 cmake CMakeLists.txt - sudo make install + make install cd python - sudo python3 setup.py install + python3 setup.py install ### Download and install Inception @@ -419,6 +419,7 @@ Development history * 0.3.4 - Maestro! * 0.3.5 - Added Ubuntu 10.10 and 10.04 x86 signatures * 0.4.0 - Complete restructuring and rewrite. Added implant module + * 0.4.1 - Merged SLOTSCREAMER interface support Disclaimer diff --git a/inception/interfaces/slotscreamer.py b/inception/interfaces/slotscreamer.py index 343b1b0..b83b5ba 100644 --- a/inception/interfaces/slotscreamer.py +++ b/inception/interfaces/slotscreamer.py @@ -18,7 +18,7 @@ along with this program. If not, see . This module provides the ability to use inception using SLOTSCREAMER. -Most of the code is adopted from the slotscreamer samples with slight +Most of the code is adopted from the slotscreamer samples with slight modification. Created on Jan 16th, 2015 @@ -69,68 +69,74 @@ def __init__(self): cfg = dev.get_active_configuration() intf = cfg[0, 0] - self.pciin = usb.util.find_descriptor(intf, custom_match=lambda e: e.bEndpointAddress==0x8e) + self.pciin = usb.util.find_descriptor(intf, custom_match=lambda e: + e.bEndpointAddress == 0x8e) assert self.pciin is not None, 'SLOTSCREAMER pciin endpoint not found' - term.info('SLOTSCREAMER PCIIN found: '+str(self.pciin)+'\n') + term.info('SLOTSCREAMER PCIIN found: ' + str(self.pciin) + '\n') - self.pciout = usb.util.find_descriptor(intf, custom_match=lambda e: e.bEndpointAddress==0xe) + self.pciout = usb.util.find_descriptor(intf, custom_match=lambda e: + e.bEndpointAddress == 0xe) assert self.pciout is not None, 'pciout endpoint not found' - term.info('SLOTSCREAMER PCIOUT found: '+str(self.pciout)+'\n') - self.cache=[] + term.info('SLOTSCREAMER PCIOUT found: ' + str(self.pciout) + '\n') + self.cache = [] def read(self, addr, numb, buf=None): try: # round down to multiple of 256 offset = addr % 256 - baseAddress = addr - offset - endOffset = (addr+numb) % 256 - endAddress = addr + numb - offset+256 + base_addr = addr - offset + end_offset = (addr + numb) % 256 + end_addr = addr + numb - offset + 256 # cache most recent read # check if anything is cached - if (len(self.cache)>0): - if((self.cacheBase<=addr)and((self.cacheBase+len(self.cache))>(addr+numb))): - return bytes(self.cache[(addr-self.cacheBase):(addr+numb)-self.cacheBase]) - self.cache=[] - self.cacheBase=baseAddress - while baseAddress 0): + if((self.cacheBase <= addr) and + ((self.cacheBase + len(self.cache)) > (addr + numb))): + return bytes(self.cache[(addr - self.cacheBase): + (addr + numb) - self.cacheBase]) + self.cache = [] + self.cacheBase = base_addr + while base_addr < end_addr: + self.pciout.write(struct.pack('BBBBI', 0xcf, 0, 0, 0x40, + base_addr)) + self.cache += self.pciin.read(0x100) + base_addr += 256 except IOError: - self.cache=[] + self.cache = [] return bytes(b"bad" + b"\x10") * 64 - return bytes(self.cache[offset:offset+numb]) + return bytes(self.cache[offset:offset + numb]) - def readv(self,req): + def readv(self, req): # sort requests so sequential reads are cached - #req.sort() + # req.sort() for r in req: - yield(r[0], self.read(r[0],r[1])) + yield(r[0], self.read(r[0], r[1])) def write(self, addr, buf): - offset=addr%256 - baseAddress=addr-offset - byteCount=len(buf) - endOffset=(addr+byteCount)%256 - endAddress=addr+byteCount-endOffset+256 - - #readbuffer - readbuf=bytearray(self.read(baseAddress,endAddress-baseAddress)) - - #modify buffer - for i in range(offset,endOffset): - readbuf[i]=buf[i-offset] - - #writebuffer - bufferIndex=0 - while baseAddress