-
Notifications
You must be signed in to change notification settings - Fork 191
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
HLIL optimization is aggressive. #3049
Comments
Fyi expected output (IDA)
|
Reply, you are missing the point of the issue in question. IDA finds the |
If the only difference in analysis is the creation of a stack array then this is a duplicate of #1637 so it's a useful comment, thanks! I will double check and if I can confirm I will close this after this comment links it to the other issue as extra samples are always helpful but we wouldn't need an extra issue. |
Well its related for sure, yet assigning it a buffer size of 0x2d (45) would be incorrect as the buffer size of 0x28 (40).
|
The thing is the source code is "incorrect" from the start, so we could argue that the buffer size is in fact 45, not 40, since it is the size used by I guess if we compile the following program, we would have more or less the same binary, thus only having a 45 bytes buffer : #include <unistd.h>
#include <sys/types.h>
#include <stdlib.h>
#include <stdio.h>
#define CHECK *(int*)&buf[40]
int main()
{
int var;
char buf[45];
fgets(buf,45,stdin);
printf("\n[buf]: %s\n", buf);
printf("[check] %p\n", CHECK);
if ((CHECK != 0x04030201) && (CHECK != 0xdeadbeef))
printf ("\nYou are on the right way!\n");
if (CHECK == 0xdeadbeef)
{
printf("Yeah dude! You win!\nOpening your shell...\n");
setreuid(geteuid(), geteuid());
system("/bin/bash");
printf("Shell closed! Bye.\n");
}
return 0;
} Personally, I think it is a good thing that HLIL eliminates dead branches "aggressively" the way it does, to me it is one aspect where BN is better than IDA, because the control flow presented in the decompiled view directly reflects the information provided by the user (i.e. user variable values, or in your case, variable types and sizes). EDIT: however, like you said, the problem is that BN does not come up with any size for the |
Additionally it would be nice if we offered some way to allow people to see that branches have been eliminated. Also it would be nice if we supported "volatile" for stack variables to tell HLIL that it should assume that value can change at anytime. |
Issue tracking dead branch display: #2219 |
Follow: #2570 for updates on stack array creation. |
Binary Ninja version 3.0.3233 Personal Build e250f0a3.
Rootme System 1:
Results in the following HLIL:
The text was updated successfully, but these errors were encountered: