Skip to content

Instantly share code, notes, and snippets.

#!/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;
@kungfulon
kungfulon / RezExtractor.cpp
Created November 5, 2019 17:30
CrossFire VN Rez Extractor
#include <iostream>
#include <fstream>
#include <algorithm>
#include <experimental/filesystem>
#include <cstdlib>
using namespace std;
typedef unsigned int DWORD;
typedef unsigned char BYTE;
@kungfulon
kungfulon / CryptoUnlocker.py
Created November 4, 2019 17:45
SVATTT 2019 - CryptoLocker. Requires Python 3 and openssl binaries installed.
#!/usr/bin/env python3
import sys
import struct
import glob
import os
import tempfile
import subprocess
PRIVATE_KEY_PATH = '/tmp/private_key.pem'