Skip to content

Instantly share code, notes, and snippets.

View T1T4N's full-sized avatar
👽

Robert Armenski T1T4N

👽
View GitHub Profile
@T1T4N
T1T4N / uac_bypass.c
Created October 17, 2016 00:04 — forked from Cr4sh/uac_bypass.c
void TestCopy()
{
BOOL cond = FALSE;
IFileOperation *FileOperation1 = NULL;
IShellItem *isrc = NULL, *idst = NULL;
BIND_OPTS3 bop;
SHELLEXECUTEINFOW shexec;
HRESULT r;
do {
@T1T4N
T1T4N / gist:a735f4f5239fb9d9192a7839d5445774
Created October 17, 2016 00:04 — forked from Cr4sh/gist:fe910f0d1b0559efd43d
Dynamically finding sys_call_table on Linux x86_64 systems
void **find_sys_call_table(void *kernel_addr, int kernel_size)
{
/*
Check for the system_call_fastpath() signature, hand-written piece of
assembly code from arch/x86/kernel/entry_64.S:
ja badsys
mov rcx, r10
call sys_call_table[rax * 8]
mov [rsp + 20h], rax
@T1T4N
T1T4N / gksudo.applescript
Last active December 14, 2016 08:49
gksudo implementation for macOS
#!/usr/bin/osascript
on convertListToString(theList, theDelimiter)
set output to (item 1 of theList)
if (count theList) > 1 then
set theList to items 2 through (count theList) of theList
repeat with listItem in theList
set parsedItem to listItem
if space is in listItem then
set parsedItem to (quoted form of listItem)
@T1T4N
T1T4N / xcode_dyn_dev_dir.sh
Created August 7, 2017 14:34
Specify Xcode developer dir by version
DEVELOPER_DIR=$(XCODE_VER=9; TMP_RET=$(ls "/Applications" | grep -E "Xcode-?${XCODE_VER}.*\.app" | head -n 1 | xargs -I {} echo "/Applications/{}/Contents/Developer"); [[ ${TMP_RET} ]] || TMP_RET=$(/usr/bin/xcrun xcode-select -p); echo $TMP_RET) eval echo '$DEVELOPER_DIR'
@T1T4N
T1T4N / Collection+SafeSubscript.swift
Created August 8, 2017 09:29
Safe collection indexing that returns an optional if index out of bounds
extension Collection {
/// Returns the element at the specified index iff it is within bounds, otherwise nil.
subscript (safe index: Index) -> Element? {
return indices.contains(index) ? self[index] : nil
}
}
@T1T4N
T1T4N / retain_count.m
Created September 8, 2017 12:28
Get retain count
NSLog(@"RC: %ld", CFGetRetainCount((__bridge CFTypeRef)m_object));
@T1T4N
T1T4N / restore_shell_opts.sh
Created September 15, 2017 09:33
Save shell options (set command) and restore them
local -r SAVED_OPTIONS=$(set +o)
source "script_that_modifies_shell_options.sh"
set +x; eval "${SAVED_OPTIONS}"
@T1T4N
T1T4N / send_mixpanel_event.sh
Created October 10, 2017 08:37
Send a mixpanel event from bash
#!/usr/bin/env bash
send_mixpanel_event() {
local token="<TOKEN>"
local distinct_id="<DISTINCT-ID>"
local time_now=$(date +%s)
local event
read -d '' event <<-EOF
{
"event": "Install",
@T1T4N
T1T4N / home_row_arrows.json
Last active October 20, 2017 09:47
Home row as arrows using Karabiner Elements
{
"title": "Home row cursor",
"rules": [
{
"description": "Change fn + H/J/K/L to Arrow Keys",
"manipulators": [
{
"type": "basic",
"from": {
"key_code": "h",
@T1T4N
T1T4N / home_row_navigation_finder.json
Last active October 20, 2017 10:00
Home row navigation for Finder using Karabiner Elements
{
"title": "Home row navigation for Finder",
"rules": [
{
"description": "Use right ⌘ +j/k to go down/up in Finder",
"manipulators": [
{
"type": "basic",
"from": {
"key_code": "j",