Simple File System
思路
题目给了四个文件,flag,simplefs,image.flag,instruction.txt
打开介绍文件看一下,里面的内容如下
1 2 3 4 5 6 7 8 9 10 11 12
|
I implemented a very simple file system and buried my flag in it.
The image file are initiated as follows: ./simplefs image.flag 500 simplefs> format simplefs> mount simplefs> plantflag simplefs> exit
And you cold run "help" to explore other commands.
|
从这里面和题目的描述就可以看出这是简单的文件系统,通过挂载然后执行命令。
先执行一遍看看,结果发现plantflag后将flag加密输入到flag文件中,IDA找找加密的地方
在21b2处发现了单字节的加密

下面就是依次异或上v4的从小到大BYTE0,BYTE1,BYTE2,HIBYTE,就是相当于每次取v4的两位
现在就需要知道v4的值,这里没有办法直接知道,那就动态调试,在for这里下一个断点

这里动态调试遇到一个坑,忘记设置参数,导致每次打开就自动关掉


运行到这里我们就可以看到ax这是等于
0xDEEDBEEF
因为*CTF{
这个开头肯定是不会变得,所以我们利用这个去找对应的加密段
1 2 3 4 5 6 7 8 9 10 11 12 13
| a='*CTF{' for i in a: x=ord(i) x = (x >> 1) | (x << 7)&0xff x ^= 0xef x = (x >> 2) | (x << 6)&0xff x ^= 0xbe x = (x >> 3) | (32 * x)&0xff x ^= 0xed x = (x >> 4) | (16 * x)&0xff x ^= 0xde x = (x >> 5) | (8 * x)&0xff print(hex(x))
|
解出来是0x0,0xd2,0xfc,0xd8,0xa2 我们就可以去image.flag里面去找

EXP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| flag='' a=[0x00, 0xD2, 0xFC, 0xD8, 0xA2, 0xDA, 0xBA, 0x9E, 0x9C, 0x26, 0xF8, 0xF6, 0xB4, 0xCE, 0x3C, 0xCC,0x96, 0x88, 0x98, 0x34, 0x82, 0xDE, 0x80, 0x36, 0x8A, 0xD8, 0xC0, 0xF0, 0x38, 0xAE, 0x40] for j in range(32): for i in range(32,128): x = i x = (x >> 1) | (x << 7)&0xff x ^= 0xef x = (x >> 2) | (x << 6)&0xff x ^= 0xbe x = (x >> 3) | (32 * x)&0xff x ^= 0xed x = (x >> 4) | (16 * x)&0xff x ^= 0xde x = (x >> 5) | (8 * x)&0xff if(x==a[j]): flag+=chr(i) print(flag)
|