-
-
Linux下监测并读取内存中本地变量的值
-
发表于: 2022-3-6 16:27 4872
-
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | void gen_rand(unsigned char rand[], int len){ time_t time = time(); int i; for(i=0;i<len;i++) rand[i] = time+i;}void encrypt(unsigned char key[], int ken_len, unsigned char text[], int text_len, unsigned char out[], int &len_out){ ......}void hexdump(unsigned char *buf, int len){ ......}void enc_test(unsigned char text[], int len_text, unsigned char out[], int &out_len){ unsigned char key[32]; gen_rand(key,32); encrypt(key,32,text,32,enc,enc, out_len); }int main(){ int i,out_len,j; unsigned char text[32]; unsigned char enc[64]; for(i=0;i<65536;i++) { for(j=0;j<32;j++) text[j] = i; enc_test(text,32,enc,out_len); hexdump(enc,out_len); sleep(1); }} |
以上是示例程序代码。需求是Linux操作系统下监测并读取enc_test()函数中key的值。要求用C或C++实现,不借助工具。初步想法是用ptrace在gen_rand调用后下断点。但考虑到可能影响速度。不知有什么其它方法?请明确编程方法,谢谢!
赞赏
他的文章
- Linux下监测并读取内存中本地变量的值 4873
赞赏
雪币:
留言: