mirror of
https://github.com/nganhkhoa/CTF-All-In-One.git
synced 2024-12-25 11:41:16 +07:00
fix gcc
This commit is contained in:
parent
bcb1c6f683
commit
cf816d28bd
@ -2,7 +2,7 @@
|
||||
|
||||
- [技术简介](#技术简介)
|
||||
- [编译参数](#编译参数)
|
||||
- [保护技术检测](#保护技术检测)
|
||||
- [保护机制检测](#保护机制检测)
|
||||
|
||||
|
||||
## 技术简介
|
||||
@ -56,7 +56,7 @@ void main() {
|
||||
}
|
||||
```
|
||||
首先我们关闭 ASLR,使用 `-pie` 进行编译:
|
||||
```
|
||||
```text
|
||||
# echo 0 > /proc/sys/kernel/randomize_va_space
|
||||
# gcc -m32 -pie random.c -o a.out
|
||||
# checksec --file a.out
|
||||
@ -69,7 +69,7 @@ Partial RELRO No canary found NX enabled PIE enabled No RPATH No RU
|
||||
0x5655553d
|
||||
```
|
||||
我们虽然开启了 `-pie`,但是 ASLR 被关闭,入口地址不变。
|
||||
```
|
||||
```text
|
||||
# ldd a.out
|
||||
linux-gate.so.1 (0xf7fd7000)
|
||||
libc.so.6 => /usr/lib32/libc.so.6 (0xf7dd9000)
|
||||
@ -80,7 +80,7 @@ Partial RELRO No canary found NX enabled PIE enabled No RPATH No RU
|
||||
/lib/ld-linux.so.2 (0xf7fd9000)
|
||||
```
|
||||
可以看出动态链接库地址也不变。然后我们开启 ASLR:
|
||||
```
|
||||
```text
|
||||
# echo 2 > /proc/sys/kernel/randomize_va_space
|
||||
# ./a.out
|
||||
0x5665353d
|
||||
@ -98,7 +98,7 @@ Partial RELRO No canary found NX enabled PIE enabled No RPATH No RU
|
||||
入口地址和动态链接库地址都变得随机。
|
||||
|
||||
接下来关闭 ASLR,并使用 `-no-pie` 进行编译:
|
||||
```
|
||||
```text
|
||||
# echo 0 > /proc/sys/kernel/randomize_va_space
|
||||
# gcc -m32 -no-pie random.c -o b.out
|
||||
# checksec --file b.out
|
||||
@ -119,7 +119,7 @@ Partial RELRO No canary found NX enabled No PIE No RPATH No RU
|
||||
/lib/ld-linux.so.2 (0xf7fd9000)
|
||||
```
|
||||
入口地址和动态库都是固定的。下面开启 ASLR:
|
||||
```
|
||||
```text
|
||||
# echo 2 > /proc/sys/kernel/randomize_va_space
|
||||
# ./b.out
|
||||
0x8048406
|
||||
@ -154,7 +154,7 @@ RELRO 设置符号重定向表为只读或在程序启动时就解析并绑定
|
||||
各种安全技术的编译参数如下:
|
||||
|
||||
安全技术 | 完全开启 | 部分开启 | 关闭
|
||||
--- | --- | --- |
|
||||
--- | --- | --- | ---
|
||||
Canary | -fstack-protector-all | -fstack-protector | -fno-stack-protector
|
||||
NX | -z noexecstack | | -z execstack
|
||||
PIE | -pie | | -no-pie
|
||||
|
Loading…
Reference in New Issue
Block a user