Access denied!
Warning: Cannot modify header information - headers already sent by (output started at /homepages/19/d27199060/htdocs/typo3/fileadmin/j-asm/download.php:4) in /homepages/19/d27199060/htdocs/typo3/fileadmin/j-asm/download.php on line 9
#!/usr/bin/python2 #
# Copyright (c) 2012 Jakob Heinemann 

from __future__ import with_statement

import sys
from os.path import exists

from disasm import (DISASM)

from util import buf_t, PEFILE

loglevel=0
smartmode=False
withraw = False

class DECOMP():
    pe = None
    def __init__(self, buf):
        pe = PEFILE(buf)
        if pe.isValid:            
            print ["32-Bit", "64-Bit"][pe.is64Bit], "PE file detected!"
            print "ImageBase: 0x%08X"%pe.PE.ImageBase
            print "BaseOfCode: 0x%08X"%pe.PE.BaseOfCode
            print "BaseOfData: 0x%08X"%pe.PE.BaseOfData
            codeSects = pe.getCodeSections()
            dataSects = pe.getDataSections()
            print dataSects
            for d in dataSects:
                print d.Name
                print "0x%08X"%d.Characteristics
            if len(codeSects) > 1:
                print "Multiple code sections not yet implemented! Using first one!"
            if len(dataSects) > 1:
                print "Multiple data sections not yet implemented! Using first one!"
            c = codeSects[0]
            d = dataSects[0]
            DISASM(buf[c.PointerToRawData:c.PointerToRawData+c.SizeOfRawData], buf[d.PointerToRawData:d.PointerToRawData+d.SizeOfRawData], pe.PE.ImageBase, pe.PE.BaseOfCode, pe.PE.BaseOfData, [32, 64][pe.is64Bit], pe.PE.EntryPoint, smartmode, loglevel, withraw)

def usage():
    print "Usage: [SWITCHES] %s file" % sys.argv[0]
    print "[SWITCHES]:"
    print "    -s      smart mode - follows function calls"
    print "    -r      with raw hex output"
    print "    -v      verbose"
    print "    -vv     very verbose (debug mode)"
    print "    -h      this help"
    sys.exit(-1)

def main():
    global loglevel
    global smartmode
    global withraw
    filename = ""
    
    if len(sys.argv) < 2:
        usage()

    for a in sys.argv[1:]:
        if a=="-vv":
            loglevel = 2
        elif a=="-v":
            loglevel = 1
        elif a=="-r":
            withraw = True
        elif a=="-s":
            smartmode = True
        elif a=="-h":
            usage()
        else:
            filename = a

    if filename == "":    
        usage()

    decomp = None    

    if exists(filename):
        with open(filename, "rb") as fd:
            decomp = DECOMP(fd.read())


if __name__ == "__main__":
    main()
#