【内核漏洞利用】绕过CONFIG_SLAB_FREELIST_HARDENED防护—kernoob两种解法

环境下载download

题目来源:XCTF高校战"疫"分享赛

1.漏洞分析

功能分析

// 共 4 个功能:add_note、del_note、show_note、edit_note,用户输入 user_input 格式——(index+user_addr+size),全局数组pool处存放(note+size)。、
// 1.add_note  cmd=0x30000
signed __int64 __usercall add_note@<rax>(__int64 a1@<rbp>, unsigned __int64 *user_input@<rdi>, __int64 a3@<rsi>)
{
   
   
  unsigned __int64 index; // [rsp-20h] [rbp-20h]
  __int64 chunk; // [rsp-18h] [rbp-18h]

  _fentry__(user_input, a3);                    // index + ___ + size
  index = *user_input;
  if ( user_input[2] > 0x70 || user_input[2] <= 0x1F )// 0x20 =< size =< 0x70    漏洞 double-fetch
    return -1LL;
  if ( index > 0x1F || *((_QWORD *)&pool + 2 * index) )
    return -1LL;
  chunk = _kmalloc(user_input[2], 0x14000C0LL);
  if ( !chunk )
    return -1LL;
  *((_QWORD *)&pool + 2 * index) = chunk;
  pool_0x8[2 * index] = user_input[2];
  return 0LL;
}
// 2.del_note  cmd=0x30001
signed __int64 __usercall del_note@<rax>(__int64 a1@<rbp>, _QWORD *index@<rdi>, __int64 a3@<rsi>)
{
   
   
  __int64 chunk; // [rsp-10h] [rbp-10h]

  _fentry__(index, a3);
  chunk = *((_QWORD *)&pool + 2 * *index);
  if ( *index > 0x1FuLL )
    return -1LL;
  if ( !chunk )
    return -1LL;
  kfree(chunk);                                 // 漏洞 UAF
  return 0LL;
}
// 3.show_note   cmd=0x30003
signed __int64 __usercall show_note@<rax>(__int64 a1@<rbp>, __int64 *user_input@<rdi>, __int64 a3@<rsi>)
{
   
   
  __int64 user_addr; // ST20_8
  __int64 chunk; // ST28_8
  __int64 index; // [rsp-50h] [rbp-50h]
  unsigned __int64 size; // [rsp-48h] [rbp-48h]

  _fentry__(user_input, a3);                    // index+user_addr+size
  index = *user_input;
  size = user_input[2];
  if ( (unsigned __int64)*user_input > 0x1F )
    return -1LL;
  if ( !*((_QWORD *)&pool + 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值