Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am jrsa on github.
  • I am jrsa (https://keybase.io/jrsa) on keybase.
  • I have a public key ASBjer_7MgfZk47mS2S77nyZ7wMnSnHKx3iAIZmgrKlPbAo

To claim this, I am signing this object:

@jrsa
jrsa / gist:f2f0d30d60ad4dac05a2262e02b8af5a
Created September 19, 2017 22:09
control core build
RefDes Part # Value Type Qty
J1, J2, J3A, J3B, PRT00116 40 Pin IDC Male Header 2
J4A, J4B, J5, J6, J8
Hardware-PCB PRT-00115 40 Pin IDC Female Header 1
Headers (unmarked,
@jrsa
jrsa / main_snip.c
Last active August 3, 2017 02:07
ADC initialization code for PIC18F4620, using the official compiler, XC8
// all inputs for portA
TRISA = 0xFF;
// led outputs
TRISD = RD0 | RD1;
// set pin PA0 to analog routing, all other "analog allowed" pins are
// still in digital mode
ADCON1bits.PCFG = 0b1110;
0x007d0fe0 55 push ebp ; CODE XREF=__ZN14PLAYERNAMEDESC15CreateWorldTextE13WORLDTEXTTYPEPKcPK9CImVectorPKi+1001, __ZN15WORLDTEXTSTRING6UpdateEm+131, __Z29SpellVisualsPlayCameraShakeIDjRK8C3Vector+88, __Z29SpellVisualsPlayCameraShakeIDjRK8C3Vector+120, __Z29SpellVisualsPlayCameraShakeIDjRK8C3Vector+146, __ZN17CGDynamicObject_C15HandleAnimEventEjjRK8C3Vectorj+151, __ZN17CGDynamicObject_C15HandleAnimEventEjjRK8C3Vectorj+178, __ZN17CGDynamicObject_C15HandleAnimEventEjjRK8C3Vectorj+205, __ZN28CGGameObject_C_Type_TrapDoor11UpdateStateEii+149, __ZN33CGGameObject_C_Type_TransportBase7DisableEv+15, __ZN33CGGameObject_C_Type_TransportBase14MovePassengersEPi+65, …
0x007d0fe1 89E5 mov ebp, esp
0x007d0fe3 8B15E8D92D01 mov edx, dword [__ZN12CGWorldFrame19s_currentWorldFrameE]
0x007d0fe9 31C0 xor eax, eax
0x007d0feb 85D2 test edx, edx ; return null if worldframe is null
0x007d0f
@jrsa
jrsa / group.py
Last active July 9, 2017 17:31
hopper script that tags functions which refer to the same global (or static) variable
doc = Document.getCurrentDocument()
textseg = doc.getSegmentByName('__TEXT')
dataseg = doc.getSegmentByName('__TEXT')
addr = doc.getCurrentAddress()
seg = doc.getSegment(doc.getSegmentIndexAtAddress(addr))
xrefs = seg.getReferencesOfAddress(addr)
doc.log("found {} xrefs to {}".format(len(xrefs), addr))
tagstr = doc.ask("tag to apply? (press cancel for no changes)")
#! /usr/bin/env ruby
require 'aws-sdk'
region = 'us-west-2'
s3 = Aws::S3::Resource.new(region: region)
bucket_name = ARGV[0]
s3.buckets.limit(50).each do |b|
@jrsa
jrsa / smemalloc_hook.cy.js
Created June 23, 2017 18:52
demonstration of function hooking inside world of warcraft, using cycript (http://www.cycript.org/)
var log = [];
var oldf = {}; // this object is used to access the original function from the hook
// address of smemalloc taken from:
// wow build 12340, macOS i386 build, md5: 1abfcf2cb17cdbe804c1c77d0525f1fa
var smemalloc = @encode(void*(int, char*, int, int))(0x9bad0)
var hook = function(a1, file, a3, a4) {
var ptr = (*oldf)(a1, file, a3, a4);
log.push([a1, file.toString(), a3, a4]);
#! /usr/bin/env python
"""
R andom R ecursive R ename
obfuscate the names of a bunch of stuff whilst preserving directory structure
"""
from random import randint
from os import *
#include "stm32f10x.h"
const uint16_t kPinClk = GPIO_Pin_11;
const uint16_t kPinEnable = GPIO_Pin_10;
const uint16_t kPinData = GPIO_Pin_1;
const uint16_t kCharacterEnablePins[] = {
GPIO_Pin_5,
GPIO_Pin_6,
GPIO_Pin_7,
@jrsa
jrsa / gist:2603ee0498d8524ca0848fa664ae84a2
Created May 25, 2017 21:34
output of braids flashing command
make -f braids/makefile upload_jtag_erase_first
openocd -f interface/stlink-v2-1.cfg -f target/stm32f1x.cfg -f stmlib/programming/jtag/prelude.cfg \
-c "flash erase_address 0x08000000 32768" \
-c "reset halt" \
-c "flash write_image erase build/braids/braids.bin 0x08000000" \
-c "verify_image build/braids/braids.bin" \
-f stmlib/programming/jtag/postlude.cfg
Open On-Chip Debugger 0.9.0 (2015-11-15-05:39)
Licensed under GNU GPL v2
For bug reports, read