-
Notifications
You must be signed in to change notification settings - Fork 0
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
The file, calc_msg.h, not found in Keystone/struct-padding. #2
Comments
Hi @a2102107 , thanks for your interest in our research! I checked and indeed something went wrong here and I tried to find back the original PoC but can't immediately find it anymore and I also don't have a working Keystone installation on my current machine. Based on the sample output from the README, it is possible to reconstruct the struct though:
To validate I quickly hacked the following C program which yields identical output to the README on my machine (gcc) afais (not validated on Keystone!): #include <stdio.h>
#include <string.h>
#include <stdint.h>
typedef struct calc_message
{
uint16_t msg_type;
uint64_t len;
} calc_message_t;
unsigned long ocall_print_string(calc_message_t* str)
{
printf("sizeof(calc_message_t) = %ld\n", sizeof(calc_message_t));
printf("sizeof(msg_type) = %ld\n", sizeof(str->msg_type));
printf("sizeof(len) = %ld\n", sizeof(str->len));
unsigned char* p = (char*)str;
for(unsigned int i = 0; i < sizeof(calc_message_t); i++)
{
printf("%02x ", p[i]);
}
printf("\n\n");
return 0;
}
void do_print()
{
calc_message_t m;
m.msg_type = 0xab;
m.len = 0x12;
ocall_print_string(&m);
}
void secret_stuff()
{
volatile char secret[128];
memset((char*) secret, 0x41, 128);
}
int main(void)
{
secret_stuff();
do_print();
} Hope this helps! Do let me know if you figure it out :) |
Dear Author, Thank you for your quick response. I am pleased to inform you that I have successfully replicated the issue in the latest version of Keystone. I found that can be reproduced by setting the compiler optimization level to O0. Your provided C program was very helpful. Below is the PoC(eapp_native.c):
Thank you once again for your valuable assistance. |
hi @a2102107 Great, happy to hear you could reproduce the issue! In case any future readers stumble on the same problem, perhaps consider if you'd like the above code to be included in this repo? Please feel free to open a PR with the above code and perhaps reference output/instructions in the keystone directory! |
In line 22 of the keystone/struct-padding/keystone-struct-padding.diff file, there is
+#include "../calc_msg.h"
. But I can't find this header file.I tried to construct a simple data structure, calc_message_t, on my own from the output of the readme file. But it didn't work out.
Here is the simple data structure I constructed:
Can you provide
calc_msg.h
file? thank you.The text was updated successfully, but these errors were encountered: