import
idautils
import
idc
start_addr
=
idc.get_inf_attr(idc.INF_MIN_EA)
end_addr
=
idc.get_inf_attr(idc.INF_MAX_EA)
print
(
"Start"
)
for
addr
in
idautils.Heads(start_addr, end_addr):
mnem
=
idc.print_insn_mnem(addr)
if
mnem
=
=
"SVC"
:
prev1_addr
=
idc.prev_head(addr)
prev2_addr
=
idc.prev_head(prev1_addr)
prev3_addr
=
idc.prev_head(prev2_addr)
prev4_addr
=
idc.prev_head(prev3_addr)
prev5_addr
=
idc.prev_head(prev4_addr)
if
(
idc.print_insn_mnem(prev1_addr)
=
=
"MOV"
and
idc.print_operand(prev1_addr,
0
)
=
=
"W16"
and
idc.print_operand(prev1_addr,
1
)
=
=
"#0x1A"
and
idc.print_insn_mnem(prev2_addr)
=
=
"MOV"
and
idc.print_operand(prev2_addr,
0
)
=
=
"X3"
and
idc.print_operand(prev2_addr,
1
)
=
=
"#0"
and
idc.print_insn_mnem(prev3_addr)
=
=
"MOV"
and
idc.print_operand(prev3_addr,
0
)
=
=
"X2"
and
idc.print_operand(prev3_addr,
1
)
=
=
"#0"
and
idc.print_insn_mnem(prev4_addr)
=
=
"MOV"
and
idc.print_operand(prev4_addr,
0
)
=
=
"X1"
and
idc.print_operand(prev4_addr,
1
)
=
=
"#0"
and
idc.print_insn_mnem(prev5_addr)
=
=
"MOV"
and
idc.print_operand(prev5_addr,
0
)
=
=
"X0"
and
idc.print_operand(prev5_addr,
1
)
=
=
"#0x1F"
):
print
'查找到一条MOV指令'
idc.PatchDword(addr,
0xd503201f
)
idc.PatchDword(prev1_addr,
0xd503201f
)
idc.PatchDword(prev2_addr,
0xd503201f
)
idc.PatchDword(prev3_addr,
0xd503201f
)
idc.PatchDword(prev4_addr,
0xd503201f
)
idc.PatchDword(prev5_addr,
0xd503201f
)
print
(
"End"
)