BUUCTF [QCTF2018]Xman-babymips
这题的关键在于 移位的过程中要防止溢出!!!
因为它移的很大(<<6) 可能超过char(8位)的范围
exp:
#include<bits/stdc++.h>
#include<windows.h>
using namespace std;
signed main(){
unsigned char fdata[] = {
'Q','|','j','{','g'
};
for(int i=0;i<5;i++){
cout<<char(fdata[i]^(32-i));
}
unsigned char unk_400B98[64] = {0,0,0,0,0,
0x52, 0xFD, 0x16, 0xA4, 0x89, 0xBD, 0x92, 0x80, 0x13, 0x41, 0x54, 0xA0, 0x8D, 0x45, 0x18, 0x81,
0xDE, 0xFC, 0x95, 0xF0, 0x16, 0x79, 0x1A, 0x15, 0x5B, 0x75, 0x1F, 0x00
};
for(int i=5;i<32;i++){
for(int j=1;j<=200;j++){
int v1;
if((i&1)!=0){
v1 = ((j&0xfc)>>2) | ((j&0x3)<<6);
}
else{
v1 = ((j&0x3f)<<2) | ((j&0xc0)>>6);
}
if(v1 == unk_400B98[i]){
cout<<char(j^(32-i));
// cout<<j;
break;
}
}
}
}
由于这其实是一个循环移位的过程(类似lfsr)所以可以直接逆向还原
过程跟题目的反过来就行了
得到flag