Skip to content

Instantly share code, notes, and snippets.

@kungfulon
kungfulon / ex.py
Created January 3, 2021 03:39
TetCTF 2020 - cache_v1
#!/usr/bin/env python3
from pwn import *
context.os = 'linux'
context.arch = 'amd64'
context.terminal = ['tmux', 'new-window']
l = ELF('./libc-2.31.so')
@kungfulon
kungfulon / secret_keeper.py
Created November 28, 2020 19:09
ASCIS 2020 Final - Secret Keeper (pwn01)
#!/usr/bin/env python3
from pwn import *
context.os = 'linux'
context.arch = 'amd64'
context.terminal = ['tmux', 'sp', '-v', '-p', '90']
b = ELF('./secret_keeper')
l = ELF('/lib/x86_64-linux-gnu/libc-2.31.so')
#!/usr/bin/env python3
from pwn import *
import ctypes
context.os = 'linux'
context.arch = 'amd64'
LIBC = ctypes.cdll.LoadLibrary('/lib/x86_64-linux-gnu/libc-2.27.so')
@kungfulon
kungfulon / hash.cpp
Created June 5, 2020 20:21
Simple rolling hash
class Hash {
public:
Hash(const std::string &s) : hash1(s.size() + 1), hash2(s.size() + 1) {
if (base == -1) {
base = genBase(minBase, mod);
pow1.push_back(1);
pow2.push_back(1);
}
while (pow1.size() <= s.size()) {

acm01

Use dynamic programming:

ans[i] = 0 # i < 4
ans[i] = ans[i - 1] + (i - 1) * (i - 1) // 4 - (i - (i // 2 + 1)) # i >= 4

acm02

// Source: https://github.com/vdisasm/ScyllaHideForIda7
// Patch win32_user.dll
unsigned char pattern[6] =
{
0x49, 0x83, 0xFB, 0x02, // cmp r11, 2
0x72, 0x20 // jb +0x20
};
unsigned char JmpRel = 0xEB;