Skip to content

Instantly share code, notes, and snippets.

@iamahuman
iamahuman / test_memory.c
Last active May 6, 2017 23:37
/home/angr/binaries/tests_src/test_memory.c
/*
* gcc -c -fzero-initialized-in-bss -o test_memory.o test_memory.c
*/
int common_test[8];
int bss_test[8] = {0};
int data_test[8] = {-1, -2, -3, -4, -5, -6, -7, -8};
const char rodata_test[8] = "Sample!";
int main(void) {
@iamahuman
iamahuman / ifconfig
Last active February 24, 2017 01:40
ifconfig wrapper with SSH connection protection
#!/bin/bash
if [ -n "$SSH_CONNECTION" ] && [ "$2" = "down" ]; then
IFS=' ' read -ra conn_info <<< "$SSH_CONNECTION"
if ip address show "$1" | grep -q "${conn_info[2]}"; then
echo "Warning: Current SSH connection is bound on ${conn_info[2]} ($1)" >&2
exit 1
fi
fi
exec /sbin/ifconfig "$@"
@iamahuman
iamahuman / palindrome.py
Last active March 18, 2017 10:29
Tokyo Westerns MMA CTF - palindrome [ppc warmup]
#!/usr/bin/env python
from pwn import *
context(log_level='debug')
def has_common_prefix(a, b):
return a[:len(b)] == b[:len(a)]
def solve(prefix, postfix, words):
pre_flat = ''.join(prefix)
post_flat = ''.join(postfix)
@iamahuman
iamahuman / simplify.py
Last active February 24, 2017 01:38
Simple rules for claripy AST simplification for human readability (total ordering, Reverse() simplification, ...)
import itertools
import claripy
import operator
top = 'T' # lambda a: True
ident = '=' # lambda a: a
inv = '!' # lambda a: not a
bot = '_' # lambda a: False
@iamahuman
iamahuman / lge-acpi-spec
Created February 2, 2017 16:36
LG 그램 ACPI/WMI 인터페이스 명세 요약
\CDP0: Get available devices as mask
bit0@retval: phy (\WLE0 || \WLE1)
bit1@retval: hci (\BTPR)
<WMAB 0x3c>
\CDP1:
<WMAB 0x3d>
\OWNE: Devices to do Airplane mode toggle, if AIRP == 0 or OSYS <= 0x7d0c and INTK == 1 (otherwise do the rfkill manually in the OS, via \WPC0 or whatever)
bit0@retval: phy
@iamahuman
iamahuman / lge-laptop.c
Last active February 24, 2017 01:37
LGE HotKey driver
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/types.h>
#include <linux/err.h>
#include <linux/platform_device.h>
#include <linux/slab.h>
#include <linux/input.h>
@iamahuman
iamahuman / fields.py
Created February 24, 2017 01:37
Virtual Field for Django
from django.db.models import Field
from django.conf import settings
from django.utils.decorators import cached_property
class VirtualField(object):
"""
A virtual field, mainly used for caching and seamless computed field retrieval.
This acts both like a (cached) property and a virtual field if supported.
"""
@iamahuman
iamahuman / acpidbg.sh
Created March 15, 2017 11:39
Linux ACPI debugger
#!/bin/bash
set -e
path=/sys/kernel/debug/acpi/acpidbg
history -r ~/.acpidbg_history 2> /dev/null || true
if ! [ -r "$path" -a -w "$path" ]
then
echo >&2 "acpidbg: not enough privileges"
exit 1
fi
cat "$path" & out_pid=$!
@iamahuman
iamahuman / sp
Created March 15, 2017 11:44
Speak Selection
#!/bin/bash
PIDFILE=/tmp/.sp.pid
on_exit() {
code="$?"
echo "Killing $pid"
kill -TERM "$pid"
exit "$code"
}
[ -r "$PIDFILE" ] && pkill -TERM -F "$PIDFILE" 2> /dev/null || true
while pgrep -F "$PIDFILE" 2> /dev/null