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

Fix issue #106 #129

Merged
merged 1 commit into from
Jul 9, 2024
Merged

Fix issue #106 #129

merged 1 commit into from
Jul 9, 2024

Conversation

N0fix
Copy link
Contributor

@N0fix N0fix commented Jul 9, 2024

Hello,

I tested this comment fix, and it seems to work, so here is the PR.

Context

Some context about issue #106: an error occurs within sigmake while processing pattern files that provide invalid function length, with "invalid" meaning that the function length should be an hexadecimal number with either 8 or 4 digits. In the current code of idb2pat, function sizes were calculated to at least 4 digits, but not forced to 8 digits if the number exceeds 4 digits. Analyzing any function which size exceeds 0xFFFF would result in an invalid pattern file.

The fix

Changed the %04X format to %08X format. This should not have any impact on the signature generation.

Testing the PR

The following shows what I did to test this PR.

Create a simple C program such as:

#include<stdio.h>
#include <stdlib.h>

int call_h(){
    int x = 2;
    int y = 4;
    puts("Hello");
    return x * 4 - 2;
}

void main(){
    printf("%x\n", call_h());
}

Compile it:

gcc -m32 a.c -o a32.out
gcc a.c -o a.out

Then:

  • create pat signatures with idb2pat
  • create a valid signature with sigmake
  • stripp the executables and load them in IDA to check that the signature applies correctly.

I also tried on serde_derive_internals executable from Rust's serde crate, which has a proc_macro function that was exceeding 0xFFFF bytes, and it works perfectly.

@N0fix
Copy link
Contributor Author

N0fix commented Jul 9, 2024

Also seems to be related to #107 and #59 , but doesn't fix all the issues presented in those GitHub issues.

Copy link
Contributor

@williballenthin williballenthin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!

@williballenthin williballenthin merged commit 238dc52 into mandiant:master Jul 9, 2024
1 check passed
@N0fix N0fix deleted the fix#106 branch July 15, 2024 09:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants