Skip to content

Commit

Permalink
feature: added trigger bot.
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesmoriarty committed May 10, 2021
1 parent a7605fa commit efce2ab
Show file tree
Hide file tree
Showing 8 changed files with 81 additions and 14 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@

Experimental CSGO external game exploit.

## Features

- Trigger Bot (hold shift)
- Bunny Hop (hold space)

![Screenshot](docs/screenshot.png)

## Usage
Expand Down
Binary file modified docs/screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 7 additions & 14 deletions gohack_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,16 @@ package gohack

import (
"errors"
"fmt"
"github.com/jamesmoriarty/gohack/internal/gohack"
"github.com/jamesmoriarty/gomem"
log "github.com/sirupsen/logrus"
"strconv"
)

var (
Version string
Date string
)

func ToHexString(ptr uintptr) string {
s := fmt.Sprintf("%d", ptr)
n, _ := strconv.Atoi(s)
h := fmt.Sprintf("0x%x", n)

return h
}

func Instrument() (*gohack.Client, error) {
log.SetFormatter(&log.TextFormatter{ForceColors: true})

Expand All @@ -42,14 +32,17 @@ func Instrument() (*gohack.Client, error) {
return nil, err
}
log.WithFields(log.Fields{"handle": process.Handle}).Info("OpenProcess ", process.ID)
log.WithFields(log.Fields{"value": ToHexString(client.Address)}).Info("- Address")
log.WithFields(log.Fields{"value": ToHexString(client.OffsetForceJump())}).Info("- OffsetForceJump")
log.WithFields(log.Fields{"value": ToHexString(client.OffsetPlayer())}).Info("- OffsetPlayer")
log.WithFields(log.Fields{"value": ToHexString(client.OffsetPlayerFlags())}).Info("- OffsetPlayerFlags")
log.WithFields(log.Fields{"value": gohack.ToHexString(client.Address)}).Info("- Address")
log.WithFields(log.Fields{"value": gohack.ToHexString(client.OffsetForceJump())}).Info("- OffsetForceJump")
log.WithFields(log.Fields{"value": gohack.ToHexString(client.OffsetForceAttack())}).Info("- OffsetForceAttack")
log.WithFields(log.Fields{"value": gohack.ToHexString(client.OffsetPlayer())}).Info("- OffsetPlayer")
log.WithFields(log.Fields{"value": gohack.ToHexString(client.OffsetPlayerFlags())}).Info("- OffsetPlayerFlags")
log.WithFields(log.Fields{"value": gohack.ToHexString(client.OffsetEntityId())}).Info("- OffsetEntityId")

return client, err
}

func Execute(c *gohack.Client) {
go gohack.RunTrigger(c)
gohack.RunBHOP(c)
}
8 changes: 8 additions & 0 deletions internal/gohack/bhop.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package gohack
import (
"github.com/jamesmoriarty/gomem"
"time"
"runtime"
"unsafe"
)

Expand All @@ -22,7 +23,10 @@ func RunBHOP(client *Client) {
client.Process.Write(client.OffsetForceJump(), writeValuePtr, unsafe.Sizeof(writeValue))
}

// N.B. writing can silently fails so we need to verify the write. I suspect we might need to re-open the process handle.

readValue = 0x0

client.Process.Read(client.OffsetForceJump(), readValuePtr, unsafe.Sizeof(readValuePtr))

if readValue == 0x0 {
Expand All @@ -31,5 +35,9 @@ func RunBHOP(client *Client) {
}

time.Sleep(90)

// N.B. guard against buffer gc.
runtime.KeepAlive(&readValue)
runtime.KeepAlive(&writeValue)
}
}
15 changes: 15 additions & 0 deletions internal/gohack/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ func (a *Client) OffsetForceJump() uintptr {
return a.Address + a.Offsets.Signatures.OffsetdwForceJump
}

func (a *Client) OffsetForceAttack() uintptr {
return a.Address + a.Offsets.Signatures.OffsetdwForceAttack
}

func (a *Client) OffsetPlayer() uintptr {
var (
readValue uintptr
Expand All @@ -48,3 +52,14 @@ func (a *Client) OffsetPlayer() uintptr {
func (a *Client) OffsetPlayerFlags() uintptr {
return a.OffsetPlayer() + a.Offsets.Netvars.Offsetm_fFlags
}

func (a *Client) OffsetEntityId() uintptr {
var (
readValue uintptr
readValuePtr = (uintptr)(unsafe.Pointer(&readValue))
)

a.Process.Read(a.OffsetPlayer() + a.Offsets.Netvars.Offsetm_iCrosshairId, readValuePtr, 4)

return readValue
}
2 changes: 2 additions & 0 deletions internal/gohack/offsets.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ type Offsets struct {
Signatures struct {
OffsetdwLocalPlayer uintptr `yaml:"dwLocalPlayer"`
OffsetdwForceJump uintptr `yaml:"dwForceJump"`
OffsetdwForceAttack uintptr `yaml:"dwForceAttack"`
} `yaml:"signatures"`
Netvars struct {
Offsetm_fFlags uintptr `yaml:"m_fFlags"`
Offsetm_iCrosshairId uintptr `yaml:"m_iCrosshairId"`
} `yaml:"netvars"`
}

Expand Down
30 changes: 30 additions & 0 deletions internal/gohack/trigger.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package gohack

import (
"github.com/jamesmoriarty/gomem"
"time"
"runtime"
"unsafe"
)


func RunTrigger(client *Client) {
var (
writeValue = byte(0x6)
writeValuePtr = (uintptr)(unsafe.Pointer(&writeValue))
)

for {
if gomem.IsKeyDown(0x10) { // https://docs.microsoft.com/en-gb/windows/win32/inputdev/virtual-key-codes
if client.OffsetEntityId() > 0 && client.OffsetEntityId() <= 64 {
client.Process.Write(client.OffsetForceAttack(), writeValuePtr, unsafe.Sizeof(writeValue))
}
}

time.Sleep(50)

// N.B. guard against buffer gc.
runtime.KeepAlive(&writeValue)
}

}
14 changes: 14 additions & 0 deletions internal/gohack/util.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package gohack

import (
"fmt"
"strconv"
)

func ToHexString(ptr uintptr) string {
s := fmt.Sprintf("%d", ptr)
n, _ := strconv.Atoi(s)
h := fmt.Sprintf("0x%x", n)

return h
}

0 comments on commit efce2ab

Please sign in to comment.