-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
zignature includes bytes which are a pointer to data #23857
Comments
This can be "fixed" by calling I am not certain this is a correct fix, but
A quick patch is below. I can submit a pull request if this is the correct fix, or update and submit a new one.
|
Can you please submit a pr with the fix and a test checking for the mask line in ao? Maybe other instructions are affected too? |
i can confirm the fix. but this op0_.. call must be done in more optypes, and this can be probably generalized |
like this. please submit a pr with the patch and add a test using the z and ao commands to ensure this feature wont break in the future. thank you! diff --git a/libr/arch/p/x86/plugin_cs.c b/libr/arch/p/x86/plugin_cs.c
index c1fb3a744f..f5236bf922 100644
--- a/libr/arch/p/x86/plugin_cs.c
+++ b/libr/arch/p/x86/plugin_cs.c
@@ -3645,20 +3645,24 @@ static void anop(RArchSession *a, RAnalOp *op, ut64 addr, const ut8 *buf, int le
// are set according to the result.
op->type = R_ANAL_OP_TYPE_ADD;
op->val = 1;
+ op0_memimmhandle (op, insn, addr, regsz);
break;
case X86_INS_DEC:
// The CF flag is not affected. The OF, SF, ZF, AF, and PF flags
// are set according to the result.
op->type = R_ANAL_OP_TYPE_SUB;
op->val = 1;
+ op0_memimmhandle (op, insn, addr, regsz);
break;
case X86_INS_NEG:
op->type = R_ANAL_OP_TYPE_SUB;
op->family = R_ANAL_OP_FAMILY_CPU;
+ op0_memimmhandle (op, insn, addr, regsz);
break;
case X86_INS_NOT:
op->type = R_ANAL_OP_TYPE_NOT;
op->family = R_ANAL_OP_FAMILY_CPU;
+ op0_memimmhandle (op, insn, addr, regsz);
break;
case X86_INS_PSUBB:
case X86_INS_PSUBW:
@@ -3730,8 +3734,10 @@ static void anop(RArchSession *a, RAnalOp *op, ut64 addr, const ut8 *buf, int le
break;
case X86_INS_DIV:
op->type = R_ANAL_OP_TYPE_DIV;
+ op0_memimmhandle (op, insn, addr, regsz);
break;
case X86_INS_IMUL:
+ op0_memimmhandle (op, insn, addr, regsz);
op->type = R_ANAL_OP_TYPE_MUL;
op->sign = true;
break; |
ping |
This sets ->ptr and other values when the operand points to memory. Partial fix for issue radareorg#23857.
I have been through the current instructions and checked x86 reference material for all the standard ones (not MMX / SSE / AVX). The instructions that can reference memory from operand 0/1 should now have the correct calls (where relevant). I need to understand the tests a little better before writing one. |
I’m happy to merge the pr as is, we can have the tests later. But i’m happy to get more coverage and verifications on all this logic. |
This sets ->ptr and other values when the operand points to memory. Partial fix for issue #23857.
Some more testing:
|
Environment
Description
I have been generating signatures for some executables using rasign and then using them with YARA.
I noticed with some samples that certain bytes aren't masked, even though they point to data.
Test
For example, loading this sample1 and creating a signature for the following function (
aaaa; s 0x4070A0; zaf
):In the signature the corresponding bytes for the address 0x4945b8 are not masked:
I believe the instruction is
inc dword ptr ds:0x4945b8
, so it should be possible to detect this is a pointer to data that might change if the data moves in a subsequent compilation.Footnotes
8632a8578ffb6350d07244460f1386c9 ↩
The text was updated successfully, but these errors were encountered: