※ 引述《Schottky (顺风相送)》之铭言:
: ※ 引述《Clangpp (Clang++)》之铭言:
: : 另外还看到很多新手居然把重要参数写在 #define (preprocessor)中...
: : (同事的说法 因为编成binary后还是明码
: : 甚至可以直接开档改 所以建议重要参数不要放在 preprocessor)
: 突然想到一个方便的小实验可以验证上面这个说法,
: 写这样一段小程式:
: #include <stdio.h>
: const char *password = "CrystalBall";
: int main(void) {
: printf("Password = %s\n", password);
: return 0;
: }
: 和
: #include <stdio.h>
: #define PASSWORD "CrystalBall"
: int main(void) {
: printf("Password = %s\n", PASSWORD);
: return 0;
: }
要比较放不放preprocessor #define应该是用
#include <stdio.h>
#define SUPER_SECRET_PASSWORD "CrystalBall"
const char *password = SUPER_SECRET_PASSWORD ;
int main(void) {
printf("Password = %s\n", password);
return 0;
}
吧?
: 把他们 compile 成执行档(假设叫 a.out),然后用这指令:
: strings a.out | grep 'CrystalBall'
: 试试看不同的方法,哪一种可以让简单的文字搜寻指令搜寻不到...
: 这样不用反组译也可以快快乐乐看见密码~~~
: 如果你有 binary editor (vim -b 就办得到) 也可以用 editor 开启档案搜寻。