diff --git a/config/offsets.go b/config/offsets.go index f56b09f..6549224 100644 --- a/config/offsets.go +++ b/config/offsets.go @@ -10,11 +10,11 @@ import ( type Offsets struct { Timestamp string `yaml:"timestamp"` Signatures struct { - OffsetLocalPlayer int `yaml:"dwLocalPlayer"` - OffsetForceJump int `yaml:"dwForceJump"` + OffsetLocalPlayer uintptr `yaml:"dwLocalPlayer"` + OffsetForceJump uintptr `yaml:"dwForceJump"` } `yaml:"signatures"` Netvars struct { - OffsetLocalPlayerFlags int `yaml:"m_fFlags"` + OffsetLocalPlayerFlags uintptr `yaml:"m_fFlags"` } `yaml:"netvars"` } diff --git a/go.mod b/go.mod index a940312..3d1301c 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.13 require ( github.com/sirupsen/logrus v1.4.2 - golang.org/x/lint v0.0.0-20190930215403-16217165b5de // indirect - golang.org/x/tools v0.0.0-20191122232904-2a6ccf25d769 // indirect + golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f // indirect + golang.org/x/tools v0.0.0-20191216052735-49a3e744a425 // indirect gopkg.in/yaml.v2 v2.2.7 ) diff --git a/go.sum b/go.sum index 26940a6..f26596a 100644 --- a/go.sum +++ b/go.sum @@ -7,12 +7,18 @@ github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6Mwd github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/lint v0.0.0-20190930215403-16217165b5de h1:5hukYrvBGR8/eNkX5mdUezrA6JiaEZDtJb9Ei+1LlBs= golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f h1:J5lckAjkw6qYlOZNj90mLYNTEKDvWeuc1yieZ8qUzUE= +golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs= +golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/tools v0.0.0-20190311212946-11955173bddd h1:/e+gpKk9r3dJobndpTytxS2gOy6m5uvpg+ISQoEcusQ= @@ -27,7 +33,11 @@ golang.org/x/tools v0.0.0-20191121040551-947d4aa89328 h1:t3X42h9e6xdbrCD/gPyWqAX golang.org/x/tools v0.0.0-20191121040551-947d4aa89328/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191122232904-2a6ccf25d769 h1:nIPDpirk90v9eLG0L8usrehSoJ1rWd6wX7BdjAKhZ4I= golang.org/x/tools v0.0.0-20191122232904-2a6ccf25d769/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191216052735-49a3e744a425 h1:VvQyQJN0tSuecqgcIxMWnnfG5kSmgy9KZR9sW3W5QeA= +golang.org/x/tools v0.0.0-20191216052735-49a3e744a425/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.7 h1:VUgggvou5XRW9mHwD/yXxIYSMtY0zoKQf/v226p2nyo= gopkg.in/yaml.v2 v2.2.7/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/main.go b/main.go index c995761..e8597ee 100644 --- a/main.go +++ b/main.go @@ -6,54 +6,46 @@ import ( win32 "github.com/jamesmoriarty/gohack/win32" log "github.com/sirupsen/logrus" "os" - "time" "unsafe" ) -const url = "https://raw.githubusercontent.com/frk1/hazedumper/master/csgo.yaml" +const ( + url = "https://raw.githubusercontent.com/frk1/hazedumper/master/csgo.yaml" + processName = "csgo.exe" + moduleName = "client_panorama.dll" +) func main() { - config.PrintBanner() + // Dynamic adresses + var ( + addressLocal uintptr + addressLocalForceJump uintptr + addressLocalPlayer uintptr + addressLocalPlayerFlags uintptr + ) log.SetFormatter(&log.TextFormatter{ForceColors: true}) + config.PrintBanner() + log.WithFields(log.Fields{"url": url}).Info("GetLatestOffsets") offsets, err := config.GetLatestOffsets(url) - if err != nil { log.Fatal("Failed getting offsets ", err) os.Exit(1) } - var ( - // Constants - PROCESSNAME = "csgo.exe" - MODULENAME = "client_panorama.dll" - VKSPACE = 0x20 // https://docs.microsoft.com/en-gb/windows/win32/inputdev/virtual-key-codes - // Player flags https://github.com/ValveSoftware/source-sdk-2013/blob/master/mp/src/public/const.h#L147 - playerFlagsJump = uintptr(0x6) - // Offsets https://github.com/frk1/hazedumper/blob/master/csgo.cs - offsetLocalPlayerFlags = uintptr(offsets.Netvars.OffsetLocalPlayerFlags) - offsetLocalPlayer = uintptr(offsets.Signatures.OffsetLocalPlayer) - offsetForceJump = uintptr(offsets.Signatures.OffsetForceJump) - // Dynamic adresses - addressLocal uintptr - addressLocalForceJump uintptr - addressLocalPlayer uintptr - addressLocalPlayerFlags uintptr - ) - - pid, success := win32.GetProcessID(PROCESSNAME) - log.WithFields(log.Fields{"pid": pid}).Info("GetProcessID ", PROCESSNAME) + pid, success := win32.GetProcessID(processName) + log.WithFields(log.Fields{"pid": pid}).Info("GetProcessID ", processName) if !success { - log.Fatal("Failed to get pid ", PROCESSNAME) + log.Fatal("Failed to get pid ", processName) os.Exit(1) } - _, success, address := win32.GetModule(MODULENAME, pid) - log.WithFields(log.Fields{"address": address}).Info("GetModule ", MODULENAME) + _, success, address := win32.GetModule(moduleName, pid) + log.WithFields(log.Fields{"address": address}).Info("GetModule ", moduleName) if !success { - log.Fatal("Failed to get module address ", MODULENAME) + log.Fatal("Failed to get module address ", moduleName) os.Exit(1) } @@ -63,25 +55,16 @@ func main() { addressLocal = uintptr(unsafe.Pointer(address)) log.WithFields(log.Fields{"value": util.ConvertPtrToHex(addressLocal)}).Info("- addressLocal") - addressLocalForceJump = addressLocal + offsetForceJump + addressLocalForceJump = addressLocal + offsets.Signatures.OffsetForceJump log.WithFields(log.Fields{"value": util.ConvertPtrToHex(addressLocalForceJump)}).Info("- addressLocalForceJump") - win32.ReadProcessMemory(processHandle, win32.LPCVOID(addressLocal+offsetLocalPlayer), &addressLocalPlayer, 4) + win32.ReadProcessMemory(processHandle, win32.LPCVOID(addressLocal+offsets.Signatures.OffsetLocalPlayer), &addressLocalPlayer, 4) log.WithFields(log.Fields{"value": util.ConvertPtrToHex(addressLocalPlayer)}).Info("- addressLocalPlayer") - addressLocalPlayerFlags = addressLocalPlayer + offsetLocalPlayerFlags + addressLocalPlayerFlags = addressLocalPlayer + offsets.Netvars.OffsetLocalPlayerFlags log.WithFields(log.Fields{"value": util.ConvertPtrToHex(addressLocalPlayerFlags)}).Info("- addressLocalPlayerFlags") - var flagsCurrent uintptr + go util.NeverExit(func() { util.DoBHOP(processHandle, addressLocalPlayerFlags, addressLocalForceJump) }) - for { - if win32.GetAsyncKeyState(VKSPACE) > 0 { - win32.ReadProcessMemory(processHandle, win32.LPCVOID(addressLocalPlayerFlags), &flagsCurrent, 1) - - if flagsCurrent != 0 { - win32.WriteProcessMemory(processHandle, addressLocalForceJump, unsafe.Pointer(&playerFlagsJump), 1) - } - } - time.Sleep(35) - } + select {} } diff --git a/util/bhop.go b/util/bhop.go new file mode 100644 index 0000000..797fadd --- /dev/null +++ b/util/bhop.go @@ -0,0 +1,29 @@ +package util + +import ( + win32 "github.com/jamesmoriarty/gohack/win32" + "time" + "unsafe" +) + +const ( + vkSpace = 0x20 // https://docs.microsoft.com/en-gb/windows/win32/inputdev/virtual-key-codes +) + +func DoBHOP(processHandle win32.HANDLE, addressLocalPlayerFlags uintptr, addressLocalForceJump uintptr) { + var ( + flagsCurrent uintptr + playerFlagsJump = uintptr(0x6) + ) + + for { + if win32.GetAsyncKeyState(vkSpace) > 0 { + win32.ReadProcessMemory(processHandle, win32.LPCVOID(addressLocalPlayerFlags), &flagsCurrent, 1) + + if flagsCurrent != 0 { + win32.WriteProcessMemory(processHandle, addressLocalForceJump, unsafe.Pointer(&playerFlagsJump), 1) + } + } + time.Sleep(35) + } +} diff --git a/util/routines.go b/util/routines.go new file mode 100644 index 0000000..a9641a1 --- /dev/null +++ b/util/routines.go @@ -0,0 +1,10 @@ +package util + +func NeverExit(f func()) { + defer func() { + if v := recover(); v != nil { + go NeverExit(f) + } + }() + f() +} diff --git a/util/strings.go b/util/strings.go index b4b64ee..fdc5165 100644 --- a/util/strings.go +++ b/util/strings.go @@ -1,4 +1,4 @@ -package strings +package util import ( "fmt"