This code essentially opens 2 files, flag.txt and output.txt. Then it initiate a PRNG using the current time as a seed. It then encrypt the content if flag.txt using XOR against a randomly generated number. After that, it will output the encrypted flag to output.txt
Solve
To decrypt the flag, we first need to find out what seed is used when initiating the PRNG.
When we are using the same seed for some PRNG. The sequence of the generated random value will always be the same.
But when i try to decrypt using the exact timestamp given on the output.txt, it doesn't outputs a flag.
So my instant thought is to bruteforce the timestamp, with the range of 10 minutes before and 10 minutes after. And we will get the flag.
Flag: RAMADAN{1_60nn4_b3_m3}
Mencari PW
Description
Author: b4r
Mas bisa bantu aku buat login? Aku lupa passwordnya :(
Initial Analysis
We are given a file:
If we try to run it, we will get this error:
We identify that it is a PyInstaller executable:
To get the code, we need to extract the .pyc files first, we can use pyinstxtractor.
from ctypes import CDLL
libr = CDLL("/lib/x86_64-linux-gnu/libc.so.6")
def decrypt(seed, flag_enc):
libr.srand(seed)
flag = b""
for byte in flag_enc:
flag += bytes([byte ^ (libr.rand() % 0x100)])
return flag
with open("output.txt", "rb") as f:
for i in range(68):
f.readline()
flag_enc = f.readline().strip()
seed = 1740929089
for s in range(seed - 600, seed + 601):
flag = decrypt(s, flag_enc)
if b"RAMADAN{" in flag:
print(f"Seed: {s}")
print(flag)
break
ββ[mirai@parrot]β[~/ctf/TCP1P Ramadhan 2025/Mencari PW]
ββββΌ $./chall
[PYI-198843:ERROR] Failed to load Python shared library '/tmp/_MEIQpunxn/libpython3.13.so': dlopen: /lib/x86_64-linux-gnu/libm.so.6: version `GLIBC_2.38' not found (required by /tmp/_MEIQpunxn/libpython3.13.so)
ββ[mirai@parrot]β[~/ctf/TCP1P Ramadhan 2025/nomolog/wu]
ββββΌ $file look
look: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=2193600f0adbd69c95356ec4443a3052a47477ab, for GNU/Linux 3.2.0, with debug_info, not stripped
output.txt
vinnie: π g what are you doin in my room ππ
.effie: ====REDACTED====
.effie: dw i aint doin ya dirty if im paid first ;>
vinnie: yeah aight here some $699
.effie: 111312211{111312211_13211213211s13211713211h111312211_111312211d1113122110111312211n1113122117111312211_111312211l132112132110111312211k111312211_1113122110111312211r111312211_11131221151113122114111312211y111312211_1113122114111312211n111312211y1113122117111312211h31131122211n1113122116111312211_132123211o13211813211k111312211?111312211_111312211}
vinnie: what?? i cant understand this! anyway idk help >_<
from pwn import *
from string import printable
elf = ELF('./look', checksec=False)
context.log_level = 'warn'
count = 0
for i in printable:
io = process(elf.path)
io.sendlineafter(b'.effie:', i.encode())
io.sendlineafter(b'vinnie:', b'699')
io.recvuntil(b': ')
print(i, io.recvline().decode().strip(), count)
io.close()
count += 1
io.interactive()
0 1113122110 0
1 312211 1
2 1113122112 2
3 1113122113 3
4 1113122114 4
5 1113122115 5
6 1113122116 6
7 1113122117 7
8 1113122118 8
9 1113122119 9
a 111312211a 10
b 111312211b 11
c 111312211c 12
d 111312211d 13
e 111312211e 14
f 111312211f 15
g 111312211g 16
h 111312211h 17
i 111312211i 18
j 111312211j 19
k 111312211k 20
l 111312211l 21
m 111312211m 22
n 111312211n 23
o 111312211o 24
p 111312211p 25
q 111312211q 26
r 111312211r 27
s 111312211s 28
t 111312211t 29
u 111312211u 30
v 111312211v 31
w 111312211w 32
x 111312211x 33
y 111312211y 34
z 111312211z 35
A 111312211A 36
B 111312211B 37
C 111312211C 38
D 111312211D 39
E 111312211E 40
F 111312211F 41
G 111312211G 42
H 111312211H 43
I 111312211I 44
J 111312211J 45
K 111312211K 46
L 111312211L 47
M 111312211M 48
N 111312211N 49
O 111312211O 50
P 111312211P 51
Q 111312211Q 52
R 111312211R 53
S 111312211S 54
T 111312211T 55
U 111312211U 56
V 111312211V 57
W 111312211W 58
X 111312211X 59
Y 111312211Y 60
Z 111312211Z 61
! 111312211! 62
" 111312211" 63
# 111312211# 64
$ 111312211$ 65
% 111312211% 66
& 111312211& 67
' 111312211' 68
( 111312211( 69
) 111312211) 70
* 111312211* 71
+ 111312211+ 72
, 111312211, 73
- 111312211- 74
. 111312211. 75
/ 111312211/ 76
: 111312211: 77
; 111312211; 78
< 111312211< 79
= 111312211= 80
> 111312211> 81
? 111312211? 82
@ 111312211@ 83
[ 111312211[ 84
\ 111312211\ 85
] 111312211] 86
^ 111312211^ 87
_ 111312211_ 88
` 111312211` 89
{ 111312211{ 90
| 111312211| 91
} 111312211} 92
~ 111312211~ 93
run with `RUST_BACKTRACE=1` environment variable to display a backtrace 94
run with `RUST_BACKTRACE=1` environment variable to display a backtrace 95
ParseIntError { kind: Empty } 96
run with `RUST_BACKTRACE=1` environment variable to display a backtrace 97
\x0b run with `RUST_BACKTRACE=1` environment variable to display a backtrace 98
\x0c run with `RUST_BACKTRACE=1` environment variable to display a backtrace 99
{__d0n7_lk_0r_54y_any76_k?}
ββ[mirai@parrot]β[~/ctf/TCP1P Ramadhan 2025/nomolog/wu]
ββββΌ $./look
vinnie: π g what are you doin in my room ππ
.effie: ss
.effie: dw i aint doin ya dirty if i paid first ;>
vinnie: yeah aight here some $699
.effie: 13211213211s
vinnie: what?? i cant understand this! anyway idk help >_<
{_ss_d0n7__0r_54y_any76_k?}
ββ[mirai@parrot]β[~/ctf/TCP1P Ramadhan 2025/nomolog/wu]
ββββΌ $./look
vinnie: π g what are you doin in my room ππ
.effie: {_sshhhhhhh
.effie: dw i aint doin ya dirty if i paid first ;>
vinnie: yeah aight here some $699
.effie: 111312211{111312211_13211213211s13211713211h
vinnie: what?? i cant understand this! anyway idk help >_<
{_sshhhhhhh_d0n7_lk_0r_54y_any76_k?}
ββ[mirai@parrot]β[~/ctf/TCP1P Ramadhan 2025/nomolog/wu]
ββββΌ $./look
vinnie: π g what are you doin in my room ππ
.effie: {_sshhhhhhh_d0n7_
.effie: dw i aint doin ya dirty if i paid first ;>
vinnie: yeah aight here some $699
.effie: 111312211{111312211_13211213211s13211713211h111312211_111312211d1113122110111312211n1113122117111312211_
vinnie: what?? i cant understand this! anyway idk help >_<
ββ[mirai@parrot]β[~/ctf/TCP1P Ramadhan 2025/nomolog/wu]
ββββΌ $./look
vinnie: π g what are you doin in my room ππ
.effie: {_sshhhhhhh_d0n7_l00k_
.effie: dw i aint doin ya dirty if i paid first ;>
vinnie: yeah aight here some $699
.effie: 111312211{111312211_13211213211s13211713211h111312211_111312211d1113122110111312211n1113122117111312211_111312211l132112132110111312211k111312211_
vinnie: what?? i cant understand this! anyway idk help >_<
{_sshhhhhhh_d0n7_l00k_0r_54y_any76_k?}
ββ[mirai@parrot]β[~/ctf/TCP1P Ramadhan 2025/nomolog/wu]
ββββΌ $./look
vinnie: π g what are you doin in my room ππ
.effie: {_sshhhhhhh_d0n7_l00k_0r_54y_4ny7h1n6_
.effie: dw i aint doin ya dirty if i paid first ;>
vinnie: yeah aight here some $699
.effie: 111312211{111312211_13211213211s13211713211h111312211_111312211d1113122110111312211n1113122117111312211_111312211l132112132110111312211k111312211_1113122110111312211r111312211_11131221151113122114111312211y111312211_1113122114111312211n111312211y1113122117111312211h31131122211n1113122116111312211_
vinnie: what?? i cant understand this! anyway idk help >_<
{_sshhhhhhh_d0n7_l00k_0r_54y_4ny7h1n6_k?}
ββ[mirai@parrot]β[~/ctf/TCP1P Ramadhan 2025/nomolog/wu]
ββββΌ $./look
vinnie: π g what are you doin in my room ππ
.effie: {_sshhhhhhh_d0n7_l00k_0r_54y_4ny7h1n6_oookkkkkkkk?_}
.effie: dw i aint doin ya dirty if i paid first ;>
vinnie: yeah aight here some $699
.effie: 111312211{111312211_13211213211s13211713211h111312211_111312211d1113122110111312211n1113122117111312211_111312211l132112132110111312211k111312211_1113122110111312211r111312211_11131221151113122114111312211y111312211_1113122114111312211n111312211y1113122117111312211h31131122211n1113122116111312211_132123211o13211813211k111312211?111312211_111312211}
vinnie: what?? i cant understand this! anyway idk help >_<
14:55:42 ! effie ~thedaa@user/effie has joined #gamabargabukber
14:55:42 effie heyy, anyone wanna play poker? :p
[#gamabargabukber]
14:55:42 effie okay, whatever! here's the deck!! ;)
Black 6 Clubs
Black 6 Clubs
Red 6 Clubs
Red 7 Clubs
Black 7 Clubs
Black 8 Clubs
Red 10 Clubs
Red Jack Clubs
Red King Clubs
Red Hero Clubs
Black Hero Clubs
Black Hero Clubs
Red Hero Clubs
Red Hero Clubs
Black Hero Clubs
Black Hacker Clubs
Red Hacker Clubs
Black Hacker Clubs
Black Hacker Clubs
Red Queen Clubs
Black Queen Clubs
Red Queen Clubs
Black Queen Clubs
Red Queen Clubs
Red 4 Diamonds
Red 6 Diamonds
Black 6 Diamonds
Red 6 Diamonds
Black 6 Diamonds
Red 6 Diamonds
Red 7 Diamonds
Black 10 Diamonds
Red Jack Diamonds
Black Jack Diamonds
Red King Diamonds
Red King Diamonds
Red King Diamonds
Red King Diamonds
Black King Diamonds
Red Hero Diamonds
Red Hacker Diamonds
Red Hacker Diamonds
Red Hacker Diamonds
Black Queen Diamonds
Red Queen Diamonds
Red Queen Diamonds
Black Queen Diamonds
Black 3 Hearts
Black 4 Hearts
Black 5 Hearts
Black 5 Hearts
Black 6 Hearts
Black 6 Hearts
Black 7 Hearts
Black 8 Hearts
Black 9 Hearts
Black Jack Hearts
Black Jack Hearts
Black Jack Hearts
Red King Hearts
Black King Hearts
Black King Hearts
Black King Hearts
Black Hero Hearts
Red Hero Hearts
Black Hero Hearts
Red Hero Hearts
Black Hacker Hearts
Black 3 Spades
Black 5 Spades
Red 5 Spades
Black 6 Spades
Red 6 Spades
Black 7 Spades
Red 9 Spades
Black 10 Spades
Black 10 Spades
Black Jack Spades
Black Jack Spades
Black Jack Spades
Red King Spades
Black King Spades
Red King Spades
Black King Spades
Red King Spades
Black King Spades
Black Hero Spades
Red Hero Spades
Black Hacker Spades
Black Hacker Spades
[#gamabargabukber]
14:55:42 ! connection error! disconnected from #gamabargabukber