[WP] Hackergame 2019 没有BUG的教务系统 1
查看源码发现程序对输入进行了一系列加密操作
- temp_password[i] = ((temp_password[i] | temp_password[i + 1]) & ~(temp_password[i] & temp_password[i + 1]) | i) & ~((temp_password[i] | temp_password[i + 1]) & ~(temp_password[i] & temp_password[i + 1]) & i)
最后与一个序列进行比较
加密每个字节使用了字节本身与它后面的那个字节 因此这题要从后往前推
程序给输入加了一个'\x00'
因此最后一个字节是'\x00'
编写脚本依次爆破前面的字节
- #include<stdio.h>
- int main(){
- char temp_password[2];
- int key[]={0x44,0x00,0x02,0x41,0x43,0x47,0x10,0x63,0x00};
- temp_password[0]=0;
- int k=7;
- for(int j=0;j<=7;j++){
- for(int i=1;i<128;i++){
- temp_password[0]=i;
- temp_password[0] = ((temp_password[0] | temp_password[0 + 1]) & ~(temp_password[0] & temp_password[0 + 1]) | k) & ~((temp_password[0] | temp_password[0+ 1]) & ~(temp_password[0] & temp_password[0+ 1]) & k);
- // printf("%d ",temp_password[0]);
- if(temp_password[0]==key[k]){
- printf("%c",i);
- temp_password[1]=i;
- k--;
- break;
- }
- }
- }
- }
输出是倒过来的,我们需要再给它倒一下
flag{p455w0rd}