Skip to content

Instantly share code, notes, and snippets.

View sum-catnip's full-sized avatar
🌌
sitting on the roof top - watching the moon drop

Σcatnip sum-catnip

🌌
sitting on the roof top - watching the moon drop
View GitHub Profile
@sum-catnip
sum-catnip / main.rs
Last active May 16, 2023 15:28
rust event system type erasure
/// [dependencies]
/// calloop = "0.10.5"
///
/// TODO: in the current implementation when you add a new handler
/// inside another handler
/// and then emit an event before all handlers have been called
/// the new handler will be called twice
/// gotta think about how to fix that
use std::cell::{ RefCell, RefMut };
@sum-catnip
sum-catnip / find_constant_recursive.py
Last active June 30, 2022 08:04
binary ninja snippet for finding a constant in a function / called function recursively
from typing import Iterator, Optional
checked = set()
def check_inst(i: HighLevelILInstruction, const: int) -> Iterator[HighLevelILInstruction]:
if isinstance(i, Constant) and i.constant == const: yield i
for o in filter(lambda i: isinstance(i,HighLevelILInstruction), i.operands):
yield from check_inst(o, const)
def check_func(f: Function, const: int, depth_max: int, depth: int = 0) -> Iterator[HighLevelILInstruction]:
@sum-catnip
sum-catnip / compile-shellcode.ps1
Created May 30, 2022 11:44
powershell script that compiles a nasm .asm file (needs BITS32/64 at the start) into a c style array. only dependency is nasm.
<#
compiles an asm file into a c-style byte array
#>
param (
# path to asm file
[parameter(mandatory=$true)]
[string]$path
)
$nasm = "$env:LOCALAPPDATA\bin\NASM\nasm.exe"
@sum-catnip
sum-catnip / b36dec.py
Last active January 26, 2021 15:46
javascript v8 double base36 decode/encode in python
# this is specific to the v8 js engine
# firefox actually does something slightly different so their encodings are incompatible
import sys
import math
import string
from functools import reduce
import numpy as np
from numpy import float64 as f64
@sum-catnip
sum-catnip / doc.lua
Last active September 15, 2020 13:40
my solution to lua docstrings
local function doc(string)
return setmetatable({doc = string}, {
__concat = function(t, f)
if type(f) == 'function'
then t.func = f; return t
else f.doc = t.doc .. '\n' .. f.doc; return f
end
end,
__call = function(t, ...) return t.func(...) end
})
@sum-catnip
sum-catnip / rotn.asm
Created August 12, 2020 10:07
x86-64asm - linux Caesar Cipher in 93bytes
; challange:
; --------------------
; Challenge #3
; --------------------
; Caesar Cipher
;
; You may know also this as ROT N.
; Your solution should input an arbitrary ROT cipher encoded string and output all shifts.
; The allowed alphabet is [a-zA-Z] any other characters are not shifted and output as is
;
@sum-catnip
sum-catnip / pyswitch.py
Created July 6, 2020 09:16
the legendary python switch case
def switch(target, dict):
for k, v in dict.items():
# could add pattern matching memes here
# instead of just equals
# or maybe the key could be a callable too which will return true or false
# that kinda would just be an if tho
if k == target:
v(target)
break
@sum-catnip
sum-catnip / inject.rs
Created February 18, 2020 16:41
rust simple dll injection
use std::io;
use std::ptr;
use std::mem;
use std::io::Error;
use std::io::ErrorKind;
use std::path::Path;
use std::ffi::CString;
use winapi::um::winnt::HANDLE;
use winapi::um::memoryapi as wmem;
@sum-catnip
sum-catnip / popup.html
Created January 18, 2020 14:45
about:blank popup (not sure why this is possible..)
<html>
<body>
<script>
w = window.open('', '_system', 'width=1, height=1');
var q = '<html><head><title>kektop</title></head><body>kektop</body></html>'
w.document.body.innerHTML = q;
</script>
<body>
</html>

Keybase proof

I hereby claim:

  • I am sum-catnip on github.
  • I am sum_catnip (https://keybase.io/sum_catnip) on keybase.
  • I have a public key ASDhQh7Mx8TZN96gO70LppSJuZGEqEKH-UmOzymJxzRZzwo

To claim this, I am signing this object: