Skip to content

Commit

Permalink
Added more ways to look for an offset as pattern_offset does
Browse files Browse the repository at this point in the history
  • Loading branch information
joanbono committed Feb 25, 2019
1 parent 4d6305f commit 6adcb6f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 7 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,16 @@ Aa0Aa1Aa2Aa3Aa4[...]Ag1Ag2Ag3Ag4Ag5Ag

### Look for an offset

```
```bash
# ASCII
$ gottern -o 6Aj7
[*] 290
# Plain HEX
$ gottern -o 0x36416a37
[*] 290
# Little Endian HEX
$ gottern -o 376a4136
[*] 290
```

***
Expand Down
27 changes: 21 additions & 6 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,37 @@ func PatternOffset(offset string) {
maxPattern = PatternCreate(20280)
i := strings.Index(maxPattern, offset)
if i == -1 {
println("[*] Offset not found")
PatternLittleEndian(offset)
} else {
println("[*]", i)
}
}

func PatternLittleEndian(offset string) {
var offsetLE string
if len(offset) >= 8 {
offsetLE = offset[6:8] + offset[4:6] + offset[2:4] + offset[0:2]
PatternOffsetHex(offsetLE)
} else {
println("[*] Offset not found")
}
}

func PatternOffsetHex(offset string) {
var maxPatternHex string
var offsetAscii []byte
var j int
var err error
maxPatternHex = PatternCreate(20280)
offsetAscii, err := hex.DecodeString(offset[2:])
if offset[:2] == "0x" {
offsetAscii, err = hex.DecodeString(offset[2:])
} else {
offsetAscii, err = hex.DecodeString(offset)
}
if err != nil {
println("[-] Invalid hex offset")
os.Exit(0)
println("[-] Invalid offset")
} else {
j := strings.Index(maxPatternHex, string(offsetAscii))
j = strings.Index(maxPatternHex, string(offsetAscii))

if j == -1 {
println("[*] Offset not found")
Expand Down Expand Up @@ -95,7 +111,6 @@ func main() {
os.Exit(0)
} else if offset == "" && create > 0 {
var patternCreated = PatternCreate(create)
//var patternCreated = PatternCreate(10)
println(patternCreated)
} else if offset != "" && create == 0 {
if len(offset) < 4 || (len(offset) < 10 && offset[:2] == "0x") {
Expand Down

0 comments on commit 6adcb6f

Please sign in to comment.