Skip to content

Instantly share code, notes, and snippets.

View grantseltzer's full-sized avatar

grantseltzer grantseltzer

View GitHub Profile

Keybase proof

I hereby claim:

  • I am grantseltzer on github.
  • I am grantseltzer (https://keybase.io/grantseltzer) on keybase.
  • I have a public key ASC1UD_DnAXkpdEZ7hClPkfFE9Sif-Sara8gPPscSOMHSAo

To claim this, I am signing this object:

package main
import "fmt"
func cappy() {
x := [23]string{}
x[0] = ` _______ _______ _______ _______ _ _______ _____ `
x[1] = `( ____ \( ___ )( ____ )( ____ \|\ /|( \ ( ____ \ / ___ \ `
x[2] = `| ( \/| ( ) || ( )|| ( \/| ) ( || ( | ( \/ ( (___) )`
x[3] = `| | | (___) || (____)|| (_____ | | | || | | (__ \ / `
@grantseltzer
grantseltzer / .bashrc
Created November 14, 2017 02:24
Container functions
function chrome() {
docker run \
--rm \
--security-opt seccomp=$HOME/.seccomp/chrome.json \
--net=host \
--memory 512mb \
--cpuset-cpus 0 \
-e DISPLAY=unix$DISPLAY \
-v $HOME/Downloads:$HOME/Downloads \
package main
import "fmt"
func main() {
fmt.Println("this is a test")
}
// A Symbol represents an entry in an ELF symbol table section.
type Symbol struct {
Name string
Info byte
Other byte
Section SectionIndex
Value uint64
Size uint64
}
@grantseltzer
grantseltzer / main.go
Last active September 14, 2018 05:53
// Open the ELF file
elfFile, err := elf.Open(path)
if err != nil {
log.Fatalf("error while opening ELF file %s: %+s", path, err.Error())
}
// Extract the symbol table
symbolTable, err := elfFile.Symbols()
if err != nil {
log.Fatalf("could not extract symbol table: %s", err.Error())
@grantseltzer
grantseltzer / main.go
Created September 14, 2018 04:41
Running bytes through gapstone
input := []byte{0x64, 0x48, 0x8B, 0xC, 0x25, 0xF8, 0xFF, 0xFF, 0xFF}
instructions, err := engine.Disasm(input, 0, 0)
if err != nil {
log.Fatal(err)
}
for _, instruction := range instructions {
fmt.Printf("0x%x:\t%s\t\t%s\n", instruction.Address, instruction.Mnemonic, instruction.OpStr)
}
@grantseltzer
grantseltzer / main.go
Last active September 15, 2018 17:58
// extract the .text section
textSection := elfFile.Section(".text")
if textSection == nil {
log.Fatal("No text section")
}
// extract the raw bytes from the .text section
textSectionData, err := textSection.Data()
if err != nil {
log.Fatal(err)
@grantseltzer
grantseltzer / disassembler.go
Created September 14, 2018 06:08
Full disassembler
package main
import (
"debug/elf"
"fmt"
"log"
"os"
"github.com/bnagy/gapstone"
)
engine, err := gapstone.New(
gapstone.CS_ARCH_X86,
gapstone.CS_MODE_64,
)
if err != nil {
log.Fatal(err)
}