Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error in parsing opcodes with certain prefixes #1

Open
GoogleCodeExporter opened this issue Apr 22, 2015 · 1 comment
Open

error in parsing opcodes with certain prefixes #1

GoogleCodeExporter opened this issue Apr 22, 2015 · 1 comment

Comments

@GoogleCodeExporter
Copy link

What steps will reproduce the problem?

from miasm.arch.ia32_arch import x86_mn
from miasm.core import parse_asm
from miasm.core import asmbloc
from elfesteem.pe_init import PE

e=PE()
s_text= e.SHList.add_section(name='.text',addr=0x1000,rawsize=0x1000)
t='''
entry_point:
                repz movsb
                ret
'''
all_bloc, symbol_pool = parse_asm.parse_txt(x86_mn,t)
symbol_pool.set_offset(symbol_pool.getby_name("entry_point"), 
e.rva2virt(s_text.addr))
resolved_b, patches = asmbloc.asm_resolve_final(x86_mn, all_bloc[0], 
symbol_pool)
for p in patches:
    e.virt[p] = patches[p]
e.Opthdr.AddressOfEntryPoint = 0x1000
open ('bug.exe','wb').write(str(e))



What is the expected output? What do you see instead?
Traceback (most recent call last):
  File "beta.py", line 13, in <module>
    all_bloc, symbol_pool = parse_asm.parse_txt(x86_mn,t)
  File "/usr/local/lib/python2.7/dist-packages/miasm/core/parse_asm.py", line 164, in parse_txt
    c+=mnemo.prefix2hex(prefix)
  File "/usr/local/lib/python2.7/dist-packages/miasm/arch/ia32_arch.py", line 1397, in prefix2hex
    return reduce(lambda x,y:x+chr(y), prefix, "")
  File "/usr/local/lib/python2.7/dist-packages/miasm/arch/ia32_arch.py", line 1397, in <lambda>
    return reduce(lambda x,y:x+chr(y), prefix, "")
TypeError: an integer is required



Please provide any additional information below.
miasm/core/parse_asm.py
comment out line 164
 c+=mnemo.prefix2hex(prefix)
for a quick fix

Original issue reported on code.google.com by christos...@gmail.com on 17 Mar 2014 at 7:50

@GoogleCodeExporter
Copy link
Author

Hi
The commit c9bbdcd3d9cc (major commit) should fix the issue.
Warning, API have changed, see example/asm_box_x86_32.py for API usage

Original comment by serpilli...@gmail.com on 7 Jun 2014 at 11:57

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant