text stringlengths 1 93.6k |
|---|
# 计算跳转变量的过程中的变量的地址都需要nop
|
for used_var in info["var_read"]:
|
used_var: binaryninja.mediumlevelil.SSAVariable
|
use_sites = used_var.use_sites
|
for use in use_sites:
|
# 通过运算再给自己复制到变量 不能认为是计算过程中的变量,有的变量的定义有几行il组成
|
# 38 @ 0009cc4c w12 = &__elf_rela_table[0x95].r_addend+1
|
# 39 @ 0009cc50 w12 = w12 & 0xffff
|
# 40 @ 0009cc50 w12 = w12 | 0xa31c0000
|
if isinstance(use.src,list):# 自己经过操作再给自己赋值,源操作数一定至少有两个
|
_var = use.dest.var
|
_flag = False
|
for _src in use.src:
|
if _src.var == _var:
|
_flag = True
|
break
|
if _flag:
|
continue
|
procedure_addr.add(use.address)
|
out[jump_to.address] = {
|
"cmp_addr": info['cmp'].address,
|
"true_addr": jump_target['true'][list(jump_target['true'])[0]] ,
|
"false_addr": jump_target['false'][list(jump_target['false'])[0]] ,
|
}
|
# 比较 的过程也需要nop 后面会直接把比较的条件放到 后面去 (br reg 改成 if(cmp) true else false)
|
procedure_addr.add(info['cmp'].address)
|
out["procedure_addr"] =[i for i in list(procedure_addr)]
|
# 收集所有 if, 不能是上面出现的nop( if的cmp和跳转都 需要nop)的地址 ,这些地址会设置 跳转的索引,去跳转到下一个真实块
|
if_list = find_operation(func.llil, LowLevelILOperation.LLIL_IF)
|
if_fillter = []
|
for if_il in if_list:
|
if if_il.address not in out["procedure_addr"]:
|
if_fillter.append(if_il)
|
reg2values ={
|
}
|
# 拿到所有固定的常量
|
for blocks in func.llil:
|
# 最后一个return 的 block 里面会给当前 函数需要恢复的寄存器恢复,所以不能遍历这个
|
if blocks[-1].operation == LowLevelILOperation.LLIL_RET:
|
continue
|
for il in blocks:
|
# 需要not的地址,不需要记录寄存器的值
|
if il.address in out["procedure_addr"]:
|
continue
|
for operand in il.operands:
|
if isinstance(operand, LowLevelILReg):
|
reg_value = get_reg_const_value_after(il,operand.src)
|
if reg_value is not None:
|
if reg2values.get(il.address) == None:
|
reg2values[il.address] = {
|
operand.src.name: reg_value.value,
|
}
|
else:
|
reg2values[il.address][operand.src.name] = reg_value.value
|
continue
|
if not isinstance(operand,LowLevelILInstruction):
|
continue
|
for inner_operands in operand.operands:
|
if not isinstance(inner_operands,LowLevelILReg):
|
continue
|
reg_value = get_reg_const_value_after(inner_operands,inner_operands.src)
|
if reg_value is None:
|
continue
|
if reg2values.get(il.address) == None:
|
reg2values[il.address]={
|
inner_operands.src.name:reg_value.value,
|
}
|
else:
|
reg2values[il.address][inner_operands.src.name] = reg_value.value
|
out["reg2values"] = reg2values
|
# pp_print(out)
|
current_work_dir = os.path.dirname(__file__)
|
file_path =current_work_dir+"\\data.json"
|
with open(file_path,"w") as f:
|
f.write(json.dumps(out))
|
# func.llil.generate_ssa_form()
|
# workflows.functionWorkflow
|
# setting = Settings()
|
# for k in setting.keys():
|
# print(k)
|
# project = angr.Project('D:/TMP/libtprt.so', load_options={"auto_load_libs": False})
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.