6.2.8 re DefcampCTF2015 entry_language
这是一题标准的密码验证题,输入一个字符串,程序验证对误。
Enter the password: ABCD
Incorrect password!
整理后可以得到下面的伪代码:
int fcn_004006fd(int *passwd) {
char *str_1 = "Dufhbmf";
char *str_3 = "ewUglpt";
if((&str_3)[i % 3][2 * (1 / 3)] - *(i + passwd) != 1) {
return 1;
}
}
return 0;
}
逆向算法似乎也很简单,但如果连算法都不用逆的话,下面就是见证 angr 魔力的时刻,我们只需要指定让程序运行到 0x400844
,即验证通过时的位置,而不用管验证的逻辑是怎么样的。
import angr
project = angr.Project("entry_language", auto_load_libs=False)
@project.hook(0x400844)
def print_flag(state):
print "FLAG SHOULD BE:", state.posix.dump_fd(0)
project.terminate_execution()
project.execute()
Bingo!!!