#!/usr/bin/env python # # Started on 31, Mar 2011 # # quick 'n' dirty Assembly Language Debugger log collector # ald is available here: http://ald.sourceforge.net/ # depends on python-pexpect (#apt-get install python-pexpect) # build requires libreadline "sudo apt-get install libreadline-dev" # # This file is licensed under the GPLv3 License. # # import sys import pexpect import random # performs ald execution def ald_run(filename): try: p=pexpect.spawn('ald '+ filename[0]) except : print "ald is not installed. exiting" sys.exit(1) ready = p.expect("ald> ") if ready != 0: print "Error in reading file. Exiting " sys.exit(1) p.sendline("disassemble -section .text") p.expect("Hit to continue, or to quit") print p.before # loop till the end of disassembly while p.sendline("\n") == 2: p.expect("Hit to continue, or to quit") # checking the end conditions if p.before.rfind('ald>') != -1: print p.before return if p.before == "": p.sendline("q") p.sendline("quit") else: print p.before # command line parsing def main(): args = sys.argv[1:] if len(args) != 1: print 'usage: disas.py ' sys.exit(-1) # Here we invoke the adl_runner to disassemble and save output ald_run(args) # invoking main if __name__ == '__main__': main()