title: 系统调用的学习
date: 2021-05-25 22:00:00
tags:
- binary security
- study report
- syscall
comments: true
categories: - ctf
- pwn
today新的知识又增长了,发现了getshell的另一种方式:syscall和srop。故事还要源于…(此处省略万字输出)
(note:本作者这次有点懒,没有写AT&T汇编,而是一律用了intel汇编,请悉知)
可能是之前汇编基础不太好吧,竟没有发现syscall这么好用的指令,只要再把/bin/sh传参就能直接打开一个shell,真是妙蛙。但是在系统调用之前要做很多的事情,诸如各类参数传递,以64位的来说,我们要先知道我们要执行的函数系统调用号为59。我也是翻过libc库的,发现system函数实现里面有一段竟然是直接执行execve("/bin/sh")

实属意外了,这是在我有次反汇编libc库的时候发现的,我原来一直是只用system函数getshell的,没想到system内部是通过这样的系统调用来打开shell的。
那这得学啊,这是基础的基础啊。
这边给出一下64位Linux的各个系统调用号,这个在Linux的/usr/include/asm/unistd.h下有,我这里截取部分。
#ifndef _ASM_X86_UNISTD_64_H
#define _ASM_X86_UNISTD_64_H 1
#define __NR_read 0
#define __NR_write 1
#define __NR_open 2
#define __NR_close 3
#define __NR_stat 4
#define __NR_fstat 5
#define __NR_lstat 6
#define __NR_poll 7
#define __NR_lseek 8
#define __NR_mmap 9
#define __NR_mprotect 10
#define __NR_munmap 11
#define __NR_brk 12
#define __NR_rt_sigaction 13
#define __NR_rt_sigprocmask 14
#define __NR_rt_sigreturn 15
#define __NR_ioctl 16

本文详细解析了buuctf比赛中ciscn_s_3挑战的解决过程,涉及64位系统调用、栈溢出漏洞的寻找与利用。通过分析程序,发现栈溢出并利用系统调用实现shell获取。文章介绍了如何寻找gadget,构造payload以执行特定系统调用,并讨论了在找不到相应gadget时的应对策略。
最低0.47元/天 解锁文章
912

被折叠的 条评论
为什么被折叠?



