Skip to content

Commit

Permalink
Misc
Browse files Browse the repository at this point in the history
  • Loading branch information
hupe1980 committed Aug 22, 2021
1 parent 53258c5 commit 17d7c13
Show file tree
Hide file tree
Showing 11 changed files with 53 additions and 53 deletions.
62 changes: 31 additions & 31 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,21 @@ builds:
- amd64
- arm
- arm64
archives:
- name_template: '{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}'
replacements:
darwin: Darwin
linux: Linux
windows: Windows
386: i386
amd64: x86_64
format_overrides:
- goos: windows
format: zip
files:
- README.md
- LICENSE
- completions/*
# archives:
# - name_template: '{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}'
# replacements:
# darwin: Darwin
# linux: Linux
# windows: Windows
# 386: i386
# amd64: x86_64
# format_overrides:
# - goos: windows
# format: zip
# files:
# - README.md
# - LICENSE
# - completions/*
checksum:
name_template: '{{ .ProjectName }}_checksums.txt'
changelog:
Expand All @@ -44,19 +44,19 @@ changelog:
- Merge pull request
- Merge branch
- go mod tidy
nfpms:
- file_name_template: '{{ .ProjectName }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}'
homepage: https://github.com/hupe1980/gopwn
description: gopwn command-line interface
license: MIT
contents:
- src: ./completions/gopwn.bash
dst: /etc/bash_completion.d/gopwn
- src: ./completions/gopwn.fish
dst: /usr/share/fish/completions/gopwn.fish
- src: ./completions/gopwn.zsh
dst: /usr/local/share/zsh/site-functions/_gopwn
formats:
- apk
- deb
- rpm
# nfpms:
# - file_name_template: '{{ .ProjectName }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}'
# homepage: https://github.com/hupe1980/gopwn
# description: gopwn command-line interface
# license: MIT
# contents:
# - src: ./completions/gopwn.bash
# dst: /etc/bash_completion.d/gopwn
# - src: ./completions/gopwn.fish
# dst: /usr/share/fish/completions/gopwn.fish
# - src: ./completions/gopwn.zsh
# dst: /usr/local/share/zsh/site-functions/_gopwn
# formats:
# - apk
# - deb
# - rpm
14 changes: 7 additions & 7 deletions asm.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func NewAssembler(arch Arch) (*Assembler, error) {
var err error

switch arch {
case ARCH_X86_64:
case ARCH_AMD64:
ks, err = keystone.New(keystone.ARCH_X86, keystone.MODE_64)
case ARCH_I386:
ks, err = keystone.New(keystone.ARCH_X86, keystone.MODE_32)
Expand Down Expand Up @@ -62,8 +62,8 @@ func Assemble(assembly string, arch Arch) ([]byte, error) {
return ks.Assemble(assembly)
}

func AssembleX86_64(assembly string) ([]byte, error) {
return Assemble(assembly, ARCH_X86_64)
func AssembleAMD64(assembly string) ([]byte, error) {
return Assemble(assembly, ARCH_AMD64)
}

func AssembleI386(assembly string) ([]byte, error) {
Expand All @@ -76,13 +76,13 @@ type Disassembler struct {

func NewDisassembler(arch Arch) (*Disassembler, error) {
archs := map[Arch]int{
ARCH_X86_64: gapstone.CS_ARCH_X86,
ARCH_AMD64: gapstone.CS_ARCH_X86,
ARCH_I386: gapstone.CS_ARCH_X86,
ARCH_ARM: gapstone.CS_ARCH_ARM,
ARCH_AARCH64: gapstone.CS_ARCH_ARM64,
}
modes := map[Arch]int{
ARCH_X86_64: gapstone.CS_MODE_64,
ARCH_AMD64: gapstone.CS_MODE_64,
ARCH_I386: gapstone.CS_MODE_32,
ARCH_ARM: gapstone.CS_MODE_ARM,
ARCH_AARCH64: gapstone.CS_MODE_ARM,
Expand Down Expand Up @@ -129,8 +129,8 @@ func Disam(data []byte, vma uint64, arch Arch) (string, error) {
return engine.Disam(data, vma)
}

func DisamX86_64(data []byte, vma uint64) (string, error) {
return Disam(data, vma, ARCH_X86_64)
func DisamAMD64(data []byte, vma uint64) (string, error) {
return Disam(data, vma, ARCH_AMD64)
}

func DisamI386(data []byte, vma uint64) (string, error) {
Expand Down
8 changes: 4 additions & 4 deletions asm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
)

func TestASM(t *testing.T) {
t.Run("x86_64", func(t *testing.T) {
insn, err := AssembleX86_64("mov rax, 0")
t.Run("amd64", func(t *testing.T) {
insn, err := AssembleAMD64("mov rax, 0")
assert.NoError(t, err)
assert.Equal(t, []byte("\x48\xc7\xc0\x00\x00\x00\x00"), insn)
})
Expand All @@ -21,8 +21,8 @@ func TestASM(t *testing.T) {
}

func TestDISASM(t *testing.T) {
t.Run("x86_64", func(t *testing.T) {
assembly, err := DisamX86_64([]byte("\x48\xc7\xc0\x17\x00\x00\x00"), 0)
t.Run("amd64", func(t *testing.T) {
assembly, err := DisamAMD64([]byte("\x48\xc7\xc0\x17\x00\x00\x00"), 0)
assert.NoError(t, err)
assert.Equal(t, "0x0 48 c7 c0 17 00 00 00 mov rax, 0x17", assembly)
})
Expand Down
2 changes: 1 addition & 1 deletion elf.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func NewELFFromReader(r BinaryReader) (*ELF, error) {
case elf.EM_386:
arch = ARCH_I386
case elf.EM_X86_64:
arch = ARCH_X86_64
arch = ARCH_AMD64
case elf.EM_ARM:
arch = ARCH_ARM
case elf.EM_AARCH64:
Expand Down
6 changes: 3 additions & 3 deletions elf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ func TestELF(t *testing.T) {
assert.Equal(t, ARCH_I386.String(), elf.Architecture().String())
})

t.Run("Open x86_64", func(t *testing.T) {
elf, err := NewELF("testdata/elf.x86_64")
t.Run("Open amd64", func(t *testing.T) {
elf, err := NewELF("testdata/elf.amd64")
assert.NoError(t, err)
defer elf.Close()

assert.Equal(t, ARCH_X86_64.String(), elf.Architecture().String())
assert.Equal(t, ARCH_AMD64.String(), elf.Architecture().String())
})

t.Run("Patch i386", func(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions gopwn.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ import "github.com/hupe1980/gopwn/tube"
type Arch int

const (
ARCH_X86_64 Arch = iota
ARCH_AMD64 Arch = iota
ARCH_I386
ARCH_AARCH64
ARCH_ARM
)

func (a Arch) String() string {
archString := map[Arch]string{
0: "x86_64",
0: "amd64",
1: "i386",
2: "arm",
3: "aarch64",
Expand Down
2 changes: 1 addition & 1 deletion macho_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
)

func TestMACHO(t *testing.T) {
macho, err := NewMACHO("testdata/macho.x86_64")
macho, err := NewMACHO("testdata/macho.amd64")
assert.NoError(t, err)
defer macho.Close()
}
6 changes: 3 additions & 3 deletions misc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,15 @@ func TestOpenFile(t *testing.T) {
assert.Equal(t, BINTYPE_ELF, bt)
})

t.Run("ELF IX86_64", func(t *testing.T) {
fh, bt, err := OpenFile("testdata/elf.x86_64")
t.Run("ELF AMD64", func(t *testing.T) {
fh, bt, err := OpenFile("testdata/elf.amd64")
assert.NoError(t, err)
defer fh.Close()
assert.Equal(t, BINTYPE_ELF, bt)
})

t.Run("MACHO", func(t *testing.T) {
fh, bt, err := OpenFile("testdata/macho.x86_64")
fh, bt, err := OpenFile("testdata/macho.amd64")
assert.NoError(t, err)
defer fh.Close()
assert.Equal(t, BINTYPE_MACHO, bt)
Expand Down
2 changes: 1 addition & 1 deletion pe.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func NewPEFromReader(r BinaryReader) (*PE, error) {
case pe.IMAGE_FILE_MACHINE_I386:
arch = ARCH_I386
case pe.IMAGE_FILE_MACHINE_AMD64:
arch = ARCH_X86_64
arch = ARCH_AMD64
case pe.IMAGE_FILE_MACHINE_ARM:
arch = ARCH_ARM
case pe.IMAGE_FILE_MACHINE_ARM64:
Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit 17d7c13

Please sign in to comment.