Repository: Gallopsled/pwntools

Issue:
disasm does not work on MIPS
```
In [7]: disasm("\xa2\x0f\x02$\x0c\x01\x01\x01", arch="mips")
[ERROR] There was an error running ['/usr/bin/mips-linux-gnu-objcopy', '-I', 'binary', '-O', 'elf32-littlemips', '-B', 'mips', '--set-section-flags', '.data=code', '--rename-section', '.data=.text', '-w', '-N', '*', '/tmp/pwn-disasm-eIvedJ/step1', '/tmp/pwn-disasm-eIvedJ/step2']:
    It had the exitcode 1.
    It had this on stdout:
    /usr/bin/mips-linux-gnu-objcopy:/tmp/pwn-disasm-eIvedJ/step2: Invalid bfd target

[ERROR] An error occurred while disassembling:
    �$
       
    Traceback (most recent call last):
      File "/home/jonas/code/pwntools/pwnlib/asm.py", line 454, in disasm
        res = _run(objcopy + [step1, step2])
      File "/home/jonas/code/pwntools/pwnlib/asm.py", line 270, in _run
        log.error(msg)
      File "/home/jonas/code/pwntools/pwnlib/log.py", line 361, in error
        raise PwnlibException(message % args)
    PwnlibException: There was an error running ['/usr/bin/mips-linux-gnu-objcopy', '-I', 'binary', '-O', 'elf32-littlemips', '-B', 'mips', '--set-section-flags', '.data=code', '--rename-section', '.data=.text', '-w', '-N', '*', '/tmp/pwn-disasm-eIvedJ/step1', '/tmp/pwn-disasm-eIvedJ/step2']:
    It had the exitcode 1.
    It had this on stdout:
    /usr/bin/mips-linux-gnu-objcopy:/tmp/pwn-disasm-eIvedJ/step2: Invalid bfd target

---------------------------------------------------------------------------
PwnlibException                           Traceback (most recent call last)
<ipython-input-7-73b2f8a203d4> in <module>()
----> 1 disasm("\xa2\x0f\x02$\x0c\x01\x01\x01", arch="mips")

/home/jonas/code/pwntools/pwnlib/asm.pyc in disasm(data, vma, **kwargs)
    462             result = output1[1].strip('\n').rstrip().expandtabs()
    463         except:
--> 464             log.exception("An error occurred while disassembling:\n%s" % data)
    465         else:
    466             shutil.rmtree(tmpdir)

/home/jonas/code/pwntools/pwnlib/asm.pyc in disasm(data, vma, **kwargs)
    452                 fd.write(data)
    453 
--> 454             res = _run(objcopy + [step1, step2])
    455 
    456             output0 = subprocess.check_output(objdump + [step2])

/home/jonas/code/pwntools/pwnlib/asm.pyc in _run(cmd, stdin)
    268         if stderr != '':
    269             msg += 'It had this on stdout:\n%s\n' % stderr
--> 270         log.error(msg)
    271 
    272     return stdout

/home/jonas/code/pwntools/pwnlib/log.pyc in error(self, message, *args, **kwargs)
    359         """
    360         self._log(logging.ERROR, message, args, kwargs, 'error')
--> 361         raise PwnlibException(message % args)
    362 
    363     def exception(self, message, *args, **kwargs):

PwnlibException: There was an error running ['/usr/bin/mips-linux-gnu-objcopy', '-I', 'binary', '-O', 'elf32-littlemips', '-B', 'mips', '--set-section-flags', '.data=code', '--rename-section', '.data=.text', '-w', '-N', '*', '/tmp/pwn-disasm-eIvedJ/step1', '/tmp/pwn-disasm-eIvedJ/step2']:
It had the exitcode 1.
It had this on stdout:
/usr/bin/mips-linux-gnu-objcopy:/tmp/pwn-disasm-eIvedJ/step2: Invalid bfd target
```



Discussion:

Resolving patch:
diff --git a/pwnlib/asm.py b/pwnlib/asm.py
--- a/pwnlib/asm.py
+++ b/pwnlib/asm.py
@@ -215,7 +215,7 @@ def _bfdname():
         'amd64'   : 'elf64-x86-64',
         'arm'     : 'elf32-littlearm',
         'thumb'   : 'elf32-littlearm',
-        'mips'    : 'elf32-%smips' % context.endianness,
+        'mips'    : 'elf32-trad%smips' % context.endianness,
         'alpha'   : 'elf64-alpha',
         'cris'    : 'elf32-cris',
         'ia64'    : 'elf64-ia64-%s' % context.endianness,


Test patch: