Skip to content

Commit

Permalink
Fixed some minor issues and merged SLOTSCREAMER
Browse files Browse the repository at this point in the history
  • Loading branch information
carmaa committed Apr 12, 2015
1 parent 1f29dd3 commit 678ac75
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 31 deletions.
19 changes: 14 additions & 5 deletions incept
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import traceback
import pkgutil

import inception.modules
import inception.interfaces

from inception import cfg, util, terminal, sound, memory
from inception.exceptions import InceptionException
Expand Down Expand Up @@ -122,10 +123,14 @@ def main(argv):
prog = sys.argv[0]
pkgpath = os.path.dirname(inception.modules.__file__)
modules = [name for _, name, _ in pkgutil.iter_modules([pkgpath])]
epilog = ('Available modules: {}. For module-specific help, '
'type: {} [module name] -h/--help'
.format(', '.join(modules), prog))
parser.epilog = epilog
pkgpath = os.path.dirname(inception.interfaces.__file__)
ifaces = [name for _, name, _ in pkgutil.iter_modules([pkgpath])]
parser.epilog = ('Available modules: {}. '
'For module-specific help, '
'type: {} [module name] -h/--help. '
'Available interfaces: {}.'
.format(', '.join(modules), prog,
', '.join(ifaces)))

command = sys.argv[1]
if not command.startswith('-'):
Expand Down Expand Up @@ -177,7 +182,11 @@ def main(argv):
except InceptionException as e:
term.error(e)

# Catch whatever that hasn't been catched elsewhere
# Catch FireWire-related exeptions
except IOError as e:
term.error(e)

# Catch whatever that hasn't been catched elsewhere and print stack trace
except Exception as e:
term.warn('Something went dreadfully wrong, full stack trace below: '
'{0}'.format(e))
Expand Down
32 changes: 13 additions & 19 deletions inception/interfaces/slotscreamer.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,51 +33,47 @@
Miles Crabilll - miles@milescrabill.com
'''

import os

from inception import cfg, terminal
from inception.exceptions import InceptionException

#import binascii
#import platform
#import sys
import usb.core
import usb.util
import struct
import math


term = terminal.Terminal()


def initialize(opts, module):
#Convenience function to initialize the interface.
# Convenience function to initialize the interface.

#Mandatory arguments:
# Mandatory arguments:

# Lower DMA shield, and set memsize
device = slotscreamer()
device = SlotScreamer()
memsize = cfg.memsize
return device, memsize


class slotscreamer:
#interface to the SlotScreamer native PCIe device over USB with pyusb
class SlotScreamer:
# Interface to the SlotScreamer native PCIe device over USB with pyusb

def __init__(self):

# find our device
dev = usb.core.find(idVendor=0x0525, idProduct=0x3380)
assert dev is not None, 'SLOTSCREAMER device not found'
try:
dev = usb.core.find(idVendor=0x0525, idProduct=0x3380)
except ValueError:
raise InceptionException('SLOTSCREAMER device not found')
dev.set_configuration()
cfg = dev.get_active_configuration()
intf = cfg[0,0]
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')

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=[]
Expand Down Expand Up @@ -113,7 +109,7 @@ def readv(self,req):

def write(self, addr, buf):
offset=addr%256
baseAddress=addr-offset
baseAddress=addr-offset
byteCount=len(buf)
endOffset=(addr+byteCount)%256
endAddress=addr+byteCount-endOffset+256
Expand All @@ -138,5 +134,3 @@ def write(self, addr, buf):

def close(self):
self.cache=[]


3 changes: 1 addition & 2 deletions inception/memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,7 @@ def find(self, target, findtag=False, findall=False, verbose=False):

# Progress bar
prog = term.ProgressBar(max_value=self.memsize,
total_width=term.wrapper.width,
print_data=verbose)
total_width=term.wrapper.width)
prog.draw()

try:
Expand Down
3 changes: 1 addition & 2 deletions inception/modules/dump.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,7 @@ def run(opts, memspace):

# Progress bar
prog = term.ProgressBar(min_value=start, max_value=end,
total_width=term.wrapper.width,
print_data=opts.verbose)
total_width=term.wrapper.width)

if size < cfg.max_request_size:
requestsize = size
Expand Down
2 changes: 1 addition & 1 deletion inception/terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ class ProgressBar:
'''

def __init__(self, min_value=0, max_value=100, total_width=80,
print_data=False):
print_data=True):
'''
Initializes the progress bar
'''
Expand Down
2 changes: 1 addition & 1 deletion inception/test/test_memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ def test_patch(self):
memspace = memory.MemorySpace(device, memsize)
address = 0x00000042
read = memspace.read(address, 4)
backup = memspace.patch(address, sig.chunks)
memspace.patch(address, sig)
sys.stdout = sys.__stdout__ # Restore output
read_back = memspace.read(address, 4)
# print(read_back)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
download_url='http://github.com/carmaa/inception',
license='GPL',
requires=['forensic1394'],
install_requires=['msgpack-python'],
install_requires=['msgpack-python', 'pyusb'],
keywords=['hack', 'physical security', 'firewire', 'pci'],
classifiers=[
'Programming Language :: Python',
Expand Down

0 comments on commit 678ac75

Please sign in to comment.