Skip to content

Instantly share code, notes, and snippets.

@c7h
c7h / generate_custom_grammar.py
Created June 17, 2022 18:29
RESTler generate combinations of fuzzing grammar for the NFDiscovery Endpoint.
"""
Generate custom grammar to fuzz Open5GC NFDiscovery
endpoint with a maximum of 13 parameters a a time
"""
import sys
imports = r"""
from __future__ import print_function
import json
from engine import primitives
@c7h
c7h / rce.py
Created July 9, 2020 14:34
RCE Exploit Pickle Cookie
"""
Cookie RCE for Cryptopaste server
"""
import requests
import os
import pickle
import base64
target = "http://localhost:1337/"
@c7h
c7h / ipynb
Created December 9, 2019 10:39
Install a pip package in jupyter (the right way)
# Install a pip package in the current Jupyter kernel
import sys
!{sys.executable} -m pip install plotly
@c7h
c7h / read_portexpander.sh
Created September 6, 2018 11:08
Read an I2C Portexpander
#!/bin/bash
ADDRESS=0x27
printf "76543210 76543210\n"
while :
do
v=$(i2cget -y 0 $ADDRESS 0x00 w)
echo ${v: -4:4} | xxd -r -p | xxd -b | awk '{split($0,a," "); printf "%s %s\r", a[2], a[3]}'
done
/* Rotary Dial encoder
encode the rotary dial of an old analog phone.
by Christoph Gerneth
*/
const int active_pin = 2;
const int pulse_pin = 3;
int number_counter = 0;
int last_pulse_state = 0; // last state of the rotary dial pulser
int last_active_state = 0;
@c7h
c7h / gist:cbba43f1c3d58250f9c9fc7bd39ebba7
Created July 17, 2017 09:52
major and annoying differences between module versions of Pythons JSON Library
Two versions of the same library behave completely different :-/
the PI
```
Python 3.4.2 (default, Oct 19 2014, 13:31:11)
[GCC 4.9.1] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import json
>>> try:
@c7h
c7h / keybase.md
Created January 31, 2017 19:27
keybase.io

Keybase proof

I hereby claim:

  • I am c7h on github.
  • I am c7h (https://keybase.io/c7h) on keybase.
  • I have a public key ASCdetH8IgkxSS8N_CBwRxZhqthPiFpK-iGS4vlIn1vtUQo

To claim this, I am signing this object:

@c7h
c7h / gist:8670768
Last active January 4, 2016 19:59
Hashmap Example - Understanding Hashmap - linear probing
#!/usr/bin/env python
#Hashmap example
#Author: Christoph Gerneth
#usage: python ordinal-hashmap.py map-size x y STR_1 [STR_2 STR_3 .. STR_N]
#x and y are K_x K_y (Glaviner Standard values for Hashfunction
#example python ordinal-hash.py 13 1 3 Petrus Andreas Jakobus Johannes Phillippus Bartholomaus Thomas Matthaus Jakobus Thaddaus Simon Judas
import sys
debug=True
chars_start = int(sys.argv[2])
chars_end = int(sys.argv[3])
@c7h
c7h / gist:6421212
Created September 3, 2013 08:38
read methods from module, starting with a given string and return a list
def read_funcs_from_module(self, functionname_prefix, module):
"""read methods from module, starting with a given string and return a list"""
moduleValues = module.__dict__.values()
functions_in_module = filter(lambda obj: hasattr(obj, '__call__'), moduleValues)
matching_functions = filter(lambda k: k.__name__.startswith(functionname_prefix), functions_in_module)
return matching_functions
@c7h
c7h / gist:5943777
Last active December 19, 2015 10:49
different usage of SQL's stored functions and stored procedures
-- schema for exchange:
CREATE TABLE exchange(cur VARCHAR(3), rate DECIMAL(12,3));
INSERT INTO exchange VALUES ("eur", 1.00), ("usd", 1.28), ("czk", 25.98);
-- stored procedure
DELIMITER :-)
CREATE PROCEDURE exrate(IN cur_in DECIMAL(12,3), IN currency VARCHAR(3), OUT cur_out DECIMAL(12,3))
BEGIN
DECLARE course DECIMAL(12,3) DEFAULT 1;
SET course = (SELECT rate FROM exchange WHERE cur = currency);