Skip to content

Commit

Permalink
Merge pull request #39 from jamesmoriarty/refinement/for-preso
Browse files Browse the repository at this point in the history
refinement: changes for presentation.
  • Loading branch information
jamesmoriarty authored Jun 18, 2021
2 parents 5c44769 + 86adba7 commit ed203b6
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 34 deletions.
19 changes: 10 additions & 9 deletions gohack_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,25 @@ func Instrument() (*gohack.Client, error) {
if err != nil {
return nil, errors.New("Failed to get pid csgo.exe")
}
log.WithFields(log.Fields{"pid": process.ID}).Info("GetFromProcessName csgo.exe")
log.WithFields(log.Fields{"pid": process.ID, "handle": process.Handle}).Info("GetOpenProcessFromName csgo.exe")

client, err := gohack.GetClientFrom(process, offsets)
if err != nil {
return nil, err
}
log.WithFields(log.Fields{"handle": process.Handle}).Info("OpenProcess ", process.ID)
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")
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)
go gohack.RunHop(c)

select{ }
}
21 changes: 0 additions & 21 deletions internal/gohack/bhop.go

This file was deleted.

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

import (
"time"

"github.com/jamesmoriarty/gomem"
)

const (
VK_SPACE = 0x20 // https://docs.microsoft.com/en-gb/windows/win32/inputdev/virtual-key-codes
CSGO_FL_ONGROUND = 1 << 0 // https://github.com/ValveSoftware/source-sdk-2013/blob/master/mp/src/public/const.h
CSGO_FORCEJUMP = 0x6 // https://github.com/ValveSoftware/source-sdk-2013/blob/0d8dceea4310fde5706b3ce1c70609d72a38efdf/sp/src/game/shared/sdk/sdk_playeranimstate.cpp#L517
)

func RunHop(client *Client) {
for {
if gomem.IsKeyDown(VK_SPACE) {
flags, _ := client.Process.ReadByte(client.OffsetPlayerFlags())

if (flags & CSGO_FL_ONGROUND) > 0 {
client.Process.WriteByte(client.OffsetForceJump(), CSGO_FORCEJUMP)
}
}

time.Sleep(100 * time.Millisecond)
}
}
12 changes: 8 additions & 4 deletions internal/gohack/trigger.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,19 @@ import (
"github.com/jamesmoriarty/gomem"
)

const (
VK_SHIFT = 0x10 // https://docs.microsoft.com/en-gb/windows/win32/inputdev/virtual-key-codes
CSGO_FORCEATTACK = 0x6
)

func RunTrigger(client *Client) {
for {
if gomem.IsKeyDown(0x10) { // https://docs.microsoft.com/en-gb/windows/win32/inputdev/virtual-key-codes
if gomem.IsKeyDown(VK_SHIFT) {
if client.OffsetEntityId() > 0 && client.OffsetEntityId() <= 64 {
client.Process.WriteByte(client.OffsetForceAttack(), 0x6)
client.Process.WriteByte(client.OffsetForceAttack(), CSGO_FORCEATTACK)
}
}

time.Sleep(50)
time.Sleep(50 * time.Millisecond)
}

}

0 comments on commit ed203b6

Please sign in to comment.