本文整理汇总了Python中miasm2.core.parse_asm.parse_txt函数的典型用法代码示例。如果您正苦于以下问题:Python parse_txt函数的具体用法?Python parse_txt怎么用?Python parse_txt使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了parse_txt函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_ParseTxt
def test_ParseTxt(self):
from miasm2.arch.x86.arch import mn_x86
from miasm2.core.parse_asm import parse_txt
ASM0 = '''
;
.LFB0:
.LA:
.text
.data
.bss
.string
.ustring
.byte 0 0x0
.byte a
.comm
.split
.dontsplit
.file
.cfi_0
label:
JMP EAX ;comment
'''
ASM1 = '''
.XXX
'''
self.assertTrue(parse_txt(mn_x86, 32, ASM0))
self.assertRaises(ValueError, parse_txt, mn_x86, 32, ASM1)
开发者ID:Junraa,项目名称:miasm,代码行数:28,代码来源:parse_asm.py
示例2: compute_txt
def compute_txt(ir, mode, txt, inputstate={}, debug=False):
blocs, symbol_pool = parse_asm.parse_txt(mn, mode, txt)
symbol_pool.set_offset(symbol_pool.getby_name("main"), 0x0)
patches = asmbloc.asm_resolve_final(mn, blocs[0], symbol_pool)
interm = ir(symbol_pool)
for bbl in blocs[0]:
interm.add_bloc(bbl)
return symb_exec(interm, inputstate, debug)
开发者ID:CaineQT,项目名称:miasm,代码行数:8,代码来源:sem.py
示例3: compute_txt
def compute_txt(ir, mode, txt, inputstate={}, debug=False):
asmcfg, loc_db = parse_asm.parse_txt(mn, mode, txt)
loc_db.set_location_offset(loc_db.get_name_location("main"), 0x0)
patches = asmblock.asm_resolve_final(mn, asmcfg, loc_db)
ir_arch = ir(loc_db)
lbl = loc_db.get_name_location("main")
ircfg = ir_arch.new_ircfg_from_asmcfg(asmcfg)
return symb_exec(lbl, ir_arch, ircfg, inputstate, debug)
开发者ID:commial,项目名称:miasm,代码行数:8,代码来源:sem.py
示例4: compute_txt
def compute_txt(ir, mode, txt, inputstate={}, debug=False):
asmcfg, symbol_pool = parse_asm.parse_txt(mn, mode, txt)
symbol_pool.set_offset(symbol_pool.getby_name("main"), 0x0)
patches = asmblock.asm_resolve_final(mn, asmcfg, symbol_pool)
interm = ir(symbol_pool)
lbl = symbol_pool.getby_name("main")
for bbl in asmcfg.blocks:
interm.add_block(bbl)
return symb_exec(lbl, interm, inputstate, debug)
开发者ID:guedou,项目名称:miasm,代码行数:9,代码来源:sem.py
示例5: asm
def asm(self):
blocs, symbol_pool = parse_asm.parse_txt(mn_aarch64, "l", self.TXT, symbol_pool=self.myjit.ir_arch.symbol_pool)
# fix shellcode addr
symbol_pool.set_offset(symbol_pool.getby_name("main"), 0x0)
s = StrPatchwork()
patches = asmbloc.asm_resolve_final(mn_aarch64, blocs, symbol_pool)
for offset, raw in patches.items():
s[offset] = raw
self.assembly = str(s)
开发者ID:winchester1887,项目名称:miasm,代码行数:10,代码来源:asm_test.py
示例6: asm
def asm(self):
blocks, loc_db = parse_asm.parse_txt(mn_aarch64, 'l', self.TXT,
loc_db = self.myjit.ir_arch.loc_db)
# fix shellcode addr
loc_db.set_location_offset(loc_db.get_name_location("main"), 0x0)
s = StrPatchwork()
patches = asmblock.asm_resolve_final(mn_aarch64, blocks, loc_db)
for offset, raw in patches.items():
s[offset] = raw
self.assembly = str(s)
开发者ID:commial,项目名称:miasm,代码行数:11,代码来源:asm_test.py
示例7: assemble_text
def assemble_text(src_text, symbols=[], mach_name="x86_64", mach_attr=64):
# 指定アーキテクチャのニーモニックを取得
mnemo = Machine(mach_name).mn
# セクションとシンボルの取得
sections, symbol_pool = parse_asm.parse_txt(mnemo, mach_attr, src_text)
# シンボル毎のアドレスを設定
for name, addr in symbols:
symbol_pool.set_offset(symbol_pool.getby_name(name), addr)
# アセンブル
patches = asmbloc.asm_resolve_final(mnemo, sections[0], symbol_pool)
# アセンブル結果の構築
patch_worker = StrPatchwork()
for offset, raw in patches.items():
patch_worker[offset] = raw
return str(patch_worker)
开发者ID:C1tas,项目名称:black-hat-python-jp-support,代码行数:16,代码来源:bhpasm.py
示例8: test_DirectiveDontSplit
def test_DirectiveDontSplit(self):
from miasm2.arch.x86.arch import mn_x86
from miasm2.core.parse_asm import parse_txt
from miasm2.core.asmblock import asm_resolve_final
ASM0 = '''
lbl0:
INC EAX
JNZ lbl0
INC EAX
JZ lbl2
lbl1:
NOP
JMP lbl0
.dontsplit
lbl2:
MOV EAX, ECX
RET
.dontsplit
lbl3:
ADD EAX, EBX
.dontsplit
lbl4:
.align 0x10
.string "test"
lbl5:
.string "toto"
'''
asmcfg, symbol_pool = parse_txt(mn_x86, 32, ASM0)
patches = asm_resolve_final(mn_x86,
asmcfg,
symbol_pool)
lbls = []
for i in xrange(6):
lbls.append(symbol_pool.getby_name('lbl%d' % i))
# align test
offset = symbol_pool.loc_key_to_offset(lbls[5])
assert(offset % 0x10 == 0)
lbl2block = {}
for block in asmcfg.blocks:
lbl2block[block.loc_key] = block
# dontsplit test
assert(lbls[2] == lbl2block[lbls[1]].get_next())
assert(lbls[3] == lbl2block[lbls[2]].get_next())
assert(lbls[4] == lbl2block[lbls[3]].get_next())
assert(lbls[5] == lbl2block[lbls[4]].get_next())
开发者ID:guedou,项目名称:miasm,代码行数:47,代码来源:parse_asm.py
示例9: asm
def asm(self):
mn_x86 = self.machine.mn
blocks, symbol_pool = parse_asm.parse_txt(
mn_x86,
self.arch_attrib,
self.TXT,
symbol_pool=self.myjit.ir_arch.symbol_pool
)
# fix shellcode addr
symbol_pool.set_offset(symbol_pool.getby_name("main"), 0x0)
output = StrPatchwork()
patches = asm_resolve_final(mn_x86, blocks, symbol_pool)
for offset, raw in patches.items():
output[offset] = raw
self.assembly = str(output)
开发者ID:guedou,项目名称:miasm,代码行数:17,代码来源:dse.py
示例10: asm
def asm(self):
mn_x86 = self.machine.mn
blocks, loc_db = parse_asm.parse_txt(
mn_x86,
self.arch_attrib,
self.TXT,
loc_db=self.myjit.ir_arch.loc_db
)
# fix shellcode addr
loc_db.set_location_offset(loc_db.get_name_location("main"), 0x0)
output = StrPatchwork()
patches = asm_resolve_final(mn_x86, blocks, loc_db)
for offset, raw in patches.items():
output[offset] = raw
self.assembly = str(output)
开发者ID:commial,项目名称:miasm,代码行数:17,代码来源:dse.py
示例11: test_DirectiveSplit
def test_DirectiveSplit(self):
from miasm2.arch.x86.arch import mn_x86
from miasm2.core.parse_asm import parse_txt
ASM0 = '''
lbl0:
JNZ lbl0
.split
lbl1:
RET
'''
blocks, symbol_pool = parse_txt(mn_x86, 32, ASM0)
lbls = []
for i in xrange(2):
lbls.append(symbol_pool.getby_name('lbl%d' % i))
lbl2block = {}
for block in blocks:
lbl2block[block.label] = block
# split test
assert(lbl2block[lbls[1]].get_next() is None)
开发者ID:Junraa,项目名称:miasm,代码行数:21,代码来源:parse_asm.py
示例12: open
data = open(args[0]).read()
bs = bin_stream_str(data)
mdis = dis_engine(bs)
addr = int(options.address, 16)
ir_arch = machine.ir(mdis.loc_db)
ircfg = ir_arch.new_ircfg()
symbexec = SymbolicExecutionEngine(ir_arch)
asmcfg, loc_db = parse_asm.parse_txt(machine.mn, 32, '''
init:
PUSH argv
PUSH argc
PUSH ret_addr
''',
loc_db=mdis.loc_db)
argc_lbl = loc_db.get_name_location('argc')
argv_lbl = loc_db.get_name_location('argv')
ret_addr_lbl = loc_db.get_name_location('ret_addr')
init_lbl = loc_db.get_name_location('init')
argc_loc = ExprLoc(argc_lbl, 32)
argv_loc = ExprLoc(argv_lbl, 32)
ret_addr_loc = ExprLoc(ret_addr_lbl, 32)
开发者ID:commial,项目名称:miasm,代码行数:29,代码来源:solve_condition_stp.py
示例13: ExprId
return reg_and_id.get(t, ExprId(t, size=32))
my_var_parser = parse_ast(my_ast_id2expr, my_ast_int2expr)
base_expr.setParseAction(my_var_parser)
st = StrPatchwork()
blocs, symbol_pool = parse_asm.parse_txt(
mn_msp430,
None,
"""
main:
mov.w 0x10, R10
mov.w 0x0, R11
loop:
add.w 1, R11
sub.w 1, R10
jnz loop
mov.w @SP+, PC
""",
)
# fix shellcode addr
symbol_pool.set_offset(symbol_pool.getby_name("main"), 0)
for b in blocs[0]:
print b
resolved_b, patches = asmbloc.asm_resolve_final(mn_msp430, blocs[0], symbol_pool)
print patches
开发者ID:rootml,项目名称:miasm,代码行数:32,代码来源:asm_msp430_sc.py
示例14: from_asm
def from_asm(self, asm_text):
all_bloc, symbol_pool = parse_asm.parse_txt(self.mn,0, asm_text)
self.blks = all_bloc
raise Exception("Not correctly implemented")
开发者ID:jbcayrou,项目名称:ethRE,代码行数:4,代码来源:ethre.py
示例15: ExprId
ret_addr = ExprId('ret_addr')
reg_and_id[argc.name] = argc
reg_and_id[argv.name] = argv
reg_and_id[ret_addr.name] = ret_addr
my_symbols = [argc, argv, ret_addr]
my_symbols = dict([(x.name, x) for x in my_symbols])
my_symbols.update(mn_x86.regs.all_regs_ids_byname)
ir_arch = ir_x86_32(mdis.symbol_pool)
sb = symbexec(ir_arch, symbols_init)
blocs, symbol_pool = parse_asm.parse_txt(mn_x86, 32, '''
PUSH argv
PUSH argc
PUSH ret_addr
''')
b = list(blocs)[0]
print b
# add fake address and len to parsed instructions
for i, l in enumerate(b.lines):
l.offset, l.l = i, 1
ir_arch.add_bloc(b)
irb = get_bloc(ir_arch, mdis, 0)
sb.emulbloc(irb)
sb.dump_mem()
# reset ir_arch blocs
开发者ID:Junraa,项目名称:miasm,代码行数:31,代码来源:solve_condition_stp.py
示例16: bin_stream_str
bs = bin_stream_str(data)
mdis = dis_engine(bs)
addr = int(options.address, 16)
symbols_init = dict(machine.mn.regs.regs_init)
ir_arch = machine.ir(mdis.symbol_pool)
symbexec = SymbolicExecutionEngine(ir_arch, symbols_init)
asmcfg, symbol_pool = parse_asm.parse_txt(machine.mn, 32, '''
init:
PUSH argv
PUSH argc
PUSH ret_addr
''',
symbol_pool=mdis.symbol_pool)
argc_lbl = symbol_pool.getby_name('argc')
argv_lbl = symbol_pool.getby_name('argv')
ret_addr_lbl = symbol_pool.getby_name('ret_addr')
init_lbl = symbol_pool.getby_name('init')
argc = ExprLoc(argc_lbl, 32)
argv = ExprLoc(argv_lbl, 32)
ret_addr = ExprLoc(ret_addr_lbl, 32)
开发者ID:guedou,项目名称:miasm,代码行数:29,代码来源:solve_condition_stp.py
示例17: StrPatchwork
PUSH {LR}
SUB SP, 0x100
MOV R0, SP
ADD R1, PC, mystr-$+6
MOV R0, R0
EORS R2, R2
ADDS R2, R2, 0x4
BL memcpy
ADD SP, 0x100
POP {PC}
mystr:
.string "toto"
'''
blocs_b, symbol_pool_b = parse_asm.parse_txt(my_mn, "b", txt)
blocs_l, symbol_pool_l = parse_asm.parse_txt(my_mn, "l", txt)
# fix shellcode addr
symbol_pool_b.set_offset(symbol_pool_b.getby_name("main"), 0)
symbol_pool_l.set_offset(symbol_pool_l.getby_name("main"), 0)
# graph sc####
g = asmbloc.bloc2graph(blocs_b[0])
open("graph.txt", "w").write(g)
s_b = StrPatchwork()
s_l = StrPatchwork()
print "symbols"
print symbol_pool_b
开发者ID:13572293130,项目名称:miasm,代码行数:31,代码来源:asm_armt.py
示例18: my_ast_id2expr
def my_ast_id2expr(t):
return reg_and_id.get(t, ExprId(t, size=64))
my_var_parser = parse_ast(my_ast_id2expr, my_ast_int2expr)
base_expr.setParseAction(my_var_parser)
blocs, symbol_pool = parse_asm.parse_txt(mn_x86, 64, '''
main:
MOV R9, 0x0
MOV R8, title
MOV RDX, msg
MOV RCX, 0x0
MOV RAX, QWORD PTR [ MessageBoxA ]
CALL RAX
RET
title:
.string "Hello!"
msg:
.string "World!"
''')
# fix shellcode addr
symbol_pool.set_offset(symbol_pool.getby_name("main"), e.rva2virt(s_text.addr))
symbol_pool.set_offset(symbol_pool.getby_name_create("MessageBoxA"),
e.DirImport.get_funcvirt('MessageBoxA'))
e.Opthdr.AddressOfEntryPoint = s_text.addr
for b in blocs[0]:
开发者ID:13572293130,项目名称:miasm,代码行数:29,代码来源:asm_box_x86_64.py
示例19: StrPatchwork
else:
st = StrPatchwork()
addr_main = 0
virt = st
output = st
# Get and parse the source code
with open(args.source) as fstream:
source = fstream.read()
loc_db = LocationDB()
asmcfg, loc_db = parse_asm.parse_txt(machine.mn, attrib, source, loc_db)
# Fix shellcode addrs
loc_db.set_location_offset(loc_db.get_name_location("main"), addr_main)
if args.PE:
loc_db.set_location_offset(loc_db.get_or_create_name_location("MessageBoxA"),
pe.DirImport.get_funcvirt('USER32.dll',
'MessageBoxA'))
# Print and graph firsts blocks before patching it
for block in asmcfg.blocks:
print block
open("graph.dot", "w").write(asmcfg.dot())
# Apply patches
开发者ID:commial,项目名称:miasm,代码行数:31,代码来源:shellcode.py
示例20: interval
from miasm2.core import asmblock
from miasm2.arch.x86 import arch
from miasm2.core import parse_asm
from miasm2.core.interval import interval
my_mn = arch.mn_x86
asmcfg, loc_db = parse_asm.parse_txt(my_mn, 64, r'''
main:
PUSH RBP
MOV RBP, RSP
loop_dec:
CMP RCX, RDX
JB loop_dec
end:
MOV RSP, RBP
POP RBP
RET
''')
loc_db.set_location_offset(loc_db.get_name_location("main"), 0x100001000)
dst_interval = interval([(0x100001000, 0x100002000)])
patches = asmblock.asm_resolve_final(
my_mn,
asmcfg,
loc_db,
dst_interval
)
开发者ID:commial,项目名称:miasm,代码行数:30,代码来源:test_asm_x86_64.py
注:本文中的miasm2.core.parse_asm.parse_txt函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论