Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 2764f91

Browse files
author
Sn0rt
committedMar 17, 2017
update: 切换一下项目的组织方式,latex 太难写了
1 parent cb76da1 commit 2764f91

25 files changed

+116
-452
lines changed
 

‎Makefile

Lines changed: 0 additions & 18 deletions
This file was deleted.

‎README-zh.md

Lines changed: 0 additions & 56 deletions
This file was deleted.

‎README.md

Lines changed: 43 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,66 @@
1-
# Linux exploit development tutorial
1+
# linux exploit 开发入门
22

3-
## What's this ?
3+
## 这是什么?
44

5-
A series of tutorial for Linux exploit development to newbie.
5+
这是面向新手的 linux exploit 开发指南.
66

7-
The test machine is ubuntu 14.04 which was a default installment.
7+
发现 Linux 下二进制学习曲线陡峭,而套路零散,于是整理编著这篇文章,来帮助感兴趣的人学习,还想结识更多对 Linux 二进制感兴趣的人.
88

9-
*Read this in other languages: [English](README.md), [简体中文](README-zh.md).*
9+
万事开头难,首先要感谢本文原来的的作者 sploitfun,他开始做了这件事并写出了思路,我在他的基础上进行了补充和翻译.
1010

11-
## How to organize ?
11+
还要要感谢 phrack,乌云知识库,各种 wiki 上面文章的作者,这些作者和安全研究人员讲解了很多关于 exploit 相关技术,是大家的无私分享使很多东西变的可能,我也想把这样的分享精神学习来.
1212

13-
### chapter 1: Basic knowledge
14-
15-
basic knowledge : what's stack and heap ? how to convert c language to assembly language ? what's ELF and memroy layout? etc.
13+
为了防止文档过于臃肿,我们讲分享讨论的话题尽量限制在 Linux,x86,ipv4 范围内,我们假设读者能正常使用 Linux,熟悉 C 语言,了解汇编语言,认识计算机专业词汇,基本体系结构知识(栈,堆,内存之类的).如果不能因为知识储备不够,推荐 0day 安全以补充背景知识.
1614

17-
basic vulnerability problems : what is overflow and memory corruption ? how does the heap work ? etc.
18-
19-
### chapter 2: Stack security
20-
21-
this chapter focuses on userspace stack security mechanism and bypass.
15+
测试机器是 ubuntu 14.04 的默认安装.
2216

23-
### chapter 3: Heap security
24-
25-
this chapter focuses on security mechanism of heap in modern linux.
17+
## 目录
2618

27-
### chapter 4: Kernel security
19+
### 第一章节: [基础知识](./chapter1)
2820

29-
this chapter focuses on mechanism security of modern linux kernel (2.6.32) and to me.
21+
基础部分知识比如: 栈与堆分别是什么? c 语言如何转换成汇编? 内存布局是什么样的? ...
3022

31-
## How to modify and update ?
23+
基础的安全知识如: 什么是堆栈溢出? 堆分配器是如何工作的?...
24+
25+
这个阶段还要介绍基本的漏洞类型和安全机制,然后关闭全部的安全保护机制,学习如何在 Linux 下面编写最基本的 exp.
26+
27+
### 第二章节: [栈的安全](./chapter2)
28+
29+
主要关注在现代 linux 上栈的安全防护机制及其绕过的常规套路.
30+
31+
分为两大类:编译相关(elf 加固),部分编译选项控制着生成更安全的代码(损失部分性能或者空间),还有就说运行时的安全(ASLR),都是为增加了漏洞利用的难度,不能从本质上去除软件的漏洞.
32+
33+
### 第三章节: [堆的安全](./chapter3)
34+
35+
主要关注在现代 linux 上 glibc 下堆的安全防护机制及其绕过的常规套路.
36+
37+
### 第四章节: [内核的安全](./chapter4)
38+
39+
这个阶段学习现代 linux (2.6.32)及其以后版本 kernel 安全相关的文档(安全保护,利用).
40+
41+
在早期 kernel 可以随意访问用户态代码,ret2usr 技术可以让内核执行用户态的代码,不过随着 Linux 的发展 SMAP(禁止 kernel 随意访问用户态,RFLAGE.AC 标志位置位可以),SMEP 禁止 kernel 态直接执行用户态代码,kaslr 也提升了漏洞利用的难度。
42+
43+
### 第五章节: [漏洞发现](./chapter5)
44+
45+
漏洞挖掘的重要性不言而喻,打个比喻上面写的如何吃肉,漏洞挖掘就是肉在哪里.
46+
47+
这个章节对我来说目前也是一个新领域,在这个章节里面主要关注 fuzz 与 代码审计。
48+
49+
## 如何修改和更新 ?
3250

3351
```shell
34-
sudo dnf install texlive-\* -y
3552
git clone git@github.com:hardenedlinux/linux_exploit_development_tutorial.git
3653
cd linux_exploit_development_tutorial
3754
make # preview
3855
```
3956

40-
## How to hand on ?
57+
## 如何实践文档代码 ?
4158

4259
(WIP)
4360

44-
some source code in `lab-code`.
61+
源代码会陆续放到`lab-code`目录中,其实更倾向于提供一个虚拟机镜像供下载.
62+
...
4563

46-
## copyleft
64+
## 版权
4765

48-
This work is licensed under the <a href="http://creativecommons.org/licenses/by-sa/3.0/" target="_blank">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>
66+
这个项目是以 <a href="http://creativecommons.org/licenses/by-sa/3.0/" target="_blank">知识共享署名-相同方式共享 3.0</a> 许可协议授权.

‎chapter1/README.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
在这个 level 我将要花点时间给大家介绍基本的漏洞类型和安全机制,然后关闭全部的安全保护机制,学习如何在 Linux 下面编写最基本的 exp.
2+
3+
# 安全机制
4+
5+
分为两大类:编译相关(elf 加固),部分编译选项控制着生成更安全的代码(损失部分性能或者空间),还有就说运行时的安全,都是为增加了漏洞利用的难度,不能从本质上去除软件的漏洞.
6+
7+
## STACK CANARY
8+
9+
Canary 是放置在缓冲区和控制数据之间的一个 words 被用来检测缓冲区溢出,如果发生缓冲区溢出那么第一个被修改的数据通常是 canary,当其验证失败通常说明发生了栈溢出,更多信息参考这里 [^1].
10+
11+
```shell
12+
gcc -fstack-protector
13+
```
14+
15+
## NX
16+
17+
在早期,指令是数据,数据也是数据,当 PC 指向哪里,那里的数据就会被当成指令被 cpu 执行,后来 NX 标志位被引入来区分指令和数据.更 多信息参考这里[@Intel] [^2] [^3].
18+
19+
```shell
20+
gcc -z execstack
21+
```
22+
23+
## PIE
24+
25+
-fPIC: 类似于-fpic 不过克服了部分平台对偏移表尺寸的限制.生成可用于共享库的位置独立代码。所有的内部寻址均通过全局偏移表(GOT)完成.要确定一个地址,需要将代码自身的内存位置作为表中一项插入.该选项需要操作系统支持,因此并不是在所有系统上均有效.该选项产生可以在共享库中存放并从中加载的目标模块.
26+
参考链接 [^4].
27+
28+
-fPIE:
29+
这选项类似于-fpic 与-fPIC,但生成的位置无关代码只可以链接为可执行文件,它通常的链接选项是-pie.
30+
31+
```shell
32+
gcc -pie -fPIE
33+
```
34+
35+
### RELRO
36+
37+
Hardens ELF programs against loader memory area overwrites by having the loader mark any areas of the relocation table as read-only for any symbols resolved at load-time (“read-only relocations”). This reduces the area of possible GOT-overwrite-style memory corruption attacks [^5].
38+
39+
#### ASLR
40+
41+
[^6]
42+
43+
# 漏洞类型
44+
45+
## 栈溢出
46+
47+
## 整数溢出
48+
49+
## off-by-one(stack base)
50+
51+
## 格式化字符串
52+
53+
%h(短写) %n\$d(直接参数访问) %n(任意内存写) %s(任意内存读)
54+
55+
# Exp 开发
56+
57+
## rop
58+
59+
nop seld + shellcode + ret
60+
61+
## 覆写 GOT
62+
63+
[^1]: <https://en.wikipedia.org/wiki/Buffer_overflow_protection#Canaries>
64+
65+
[^2]: &lt;&lt;Intel® 64 and IA-32 Architectures Software Developer’s Manual&gt;&gt; volumes 3 section 4.6
66+
67+
[^3]: <https://en.wikipedia.org/wiki/NX_bit>
68+
69+
[^4]: <https://en.wikipedia.org/wiki/Position-independent_code#PIE>
70+
71+
[^5]: <http://blog.isis.poly.edu/exploitation%20mitigation%20techniques/exploitation%20techniques/2011/06/02/relro-relocation-read-only/>
72+
73+
[^6]: <https://en.wikipedia.org/wiki/Address_space_layout_randomization>

‎chapter1/chapter_preparation.tex

Lines changed: 0 additions & 91 deletions
This file was deleted.

‎chapter2/README.md

Whitespace-only changes.

‎chapter2/chapter_stack.tex

Lines changed: 0 additions & 31 deletions
This file was deleted.

‎chapter3/README.md

Whitespace-only changes.

‎chapter3/chapter_heap.tex

Lines changed: 0 additions & 16 deletions
This file was deleted.

‎chapter4/README.md

Whitespace-only changes.

0 commit comments

Comments
 (0)