This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"debug/elf" | |
"fmt" | |
"log" | |
"os" | |
) | |
func main() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
engine, err := gapstone.New( | |
gapstone.CS_ARCH_X86, | |
gapstone.CS_MODE_64, | |
) | |
if err != nil { | |
log.Fatal(err) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"debug/elf" | |
"fmt" | |
"log" | |
"os" | |
"github.com/bnagy/gapstone" | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
func main() { | |
fmt.Println("this is a test") | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 \ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
func cappy() { | |
x := [23]string{} | |
x[0] = ` _______ _______ _______ _______ _ _______ _____ ` | |
x[1] = `( ____ \( ___ )( ____ )( ____ \|\ /|( \ ( ____ \ / ___ \ ` | |
x[2] = `| ( \/| ( ) || ( )|| ( \/| ) ( || ( | ( \/ ( (___) )` | |
x[3] = `| | | (___) || (____)|| (_____ | | | || | | (__ \ / ` |