Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/guitmz/offsetter
Convert between file offsets and virtual addresses with Go
https://github.com/guitmz/offsetter
debugging golang reverse-engineering
Last synced: 3 days ago
JSON representation
Convert between file offsets and virtual addresses with Go
- Host: GitHub
- URL: https://github.com/guitmz/offsetter
- Owner: guitmz
- License: mit
- Created: 2019-08-14T10:39:15.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2019-08-22T09:36:23.000Z (about 5 years ago)
- Last Synced: 2024-06-20T17:44:25.211Z (5 months ago)
- Topics: debugging, golang, reverse-engineering
- Language: Go
- Homepage: https://www.guitmz.com
- Size: 8.79 KB
- Stars: 1
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# offsetter
[![Go Report Card](https://goreportcard.com/badge/github.com/guitmz/offsetter)](https://goreportcard.com/report/github.com/guitmz/offsetter)Small package to convert between file offsets and virtual addresses (partialy inspired by some code of [pwnlib](https://github.com/Gallopsled/pwntools/tree/dev/pwnlib)). For the moment, only `ELF` files are supported.
# Install
Install with `go get -u github.com/guitmz/offsetter`# Example
```
$ cat example.go
``````go
package mainimport (
"debug/elf"
"fmt""github.com/guitmz/offsetter"
)func check(err error) {
if err != nil {
panic(err)
}
}func main() {
targetFile, err := elf.Open("/bin/ls")
check(err)
defer targetFile.Close()loadAddress, err := offsetter.GetLoadAddress(targetFile)
check(err)hexOffset, uintOffset, err := offsetter.VaddrToOffset(targetFile, loadAddress, targetFile.Entry)
check(err)
fmt.Printf("Offset: %s (%d)\n", hexOffset, uintOffset)hexVaddr, uintVaddr, err := offsetter.OffsetToVaddr(targetFile, uintOffset)
check(err)
fmt.Printf("Vaddr: %s (%d)\n", hexVaddr, uintVaddr)
}
``````
$ go run example.go
Offset: 0x42d4 (17108)
Vaddr: 0x4042d4 (4211412)
```