Skip to content

Instantly share code, notes, and snippets.

View smlu's full-sized avatar
🙈
I may be slow to respond.

Crt Vavros smlu

🙈
I may be slow to respond.
View GitHub Profile
@smlu
smlu / pfa_memlist.py
Created January 3, 2024 18:30
Windows Predictive Failure Analysis (PFA) Memory List Generator
import mmap
from typing import List
def get_bcdedit_set_badmemory_command(start_addr: int, end_addr: int) -> str:
pages: str = ''
pstart = start_addr // mmap.PAGESIZE
pend = (end_addr + mmap.PAGESIZE - 1) // mmap.PAGESIZE
for p in range(pstart, pend + 1):
pages += f'{hex(p)} '
return f'bcdedit /set {{badmemory}} badmemorylist {pages}'
@smlu
smlu / rsassa-pss.py
Created July 29, 2022 15:05
RSASSA-PSS signature verification script
# Author: Crt Vavros
# MIT license
# Script implements RSASSA-PSS signature verification scheme as specified in RFC 8017 sec. 8.1.2
# https://datatracker.ietf.org/doc/html/rfc8017#section-8.1.2
# RSASSA-PSS MGF1 signature verification
# positional arguments:
# n RSA public key modulus as hex string
@smlu
smlu / eos_keyfmt.py
Last active April 5, 2021 13:39
Encode public key and signature to EOSIO string format
import argparse
from binascii import hexlify, unhexlify
b58_digits = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
def b58_encode(b):
"""Encode bytes to a base58-encoded string"""
# Convert big-endian bytes to integer
n = int(b, 16)
@smlu
smlu / eosabi2bin.cpp
Last active March 11, 2021 17:17
Converts JSON format of EOSIO contract abi to binary.
#include <filesystem>
#include <fstream>
#include <iostream>
#include <string>
#include <string_view>
#include <vector>
#include <eosio/abi.hpp>
#include <eosio/from_json.hpp>
#include <eosio/to_bin.hpp>
@smlu
smlu / py_eos_account_conv.py
Last active January 23, 2020 13:16
Python EOS account name converter from/to string
eos_charmap = ".12345abcdefghijklmnopqrstuvwxyz"
def eos_account_to_string(num):
mask = 0xF800000000000000
out = ""
for i in range(0, 13):
if num == 0: return out
indx = (num & mask) >> (60 if i == 12 else 59)
out += eos_charmap[indx]
@smlu
smlu / Timer.cpp
Last active March 30, 2017 06:39
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <functional>
#include <mutex>
#include <thread>
#include <utility>
#include <vector>