C# - Triggerbot only shoots some people, both teams

Posts 1–15 of 19 · Page 1 of 2
C# - Triggerbot only shoots some people, both teams
First off, credit for the code: marcoly1337 (i can't post links or i would just link the thread)
I'm just learning, so yes, I c+p'd code to try to learn from.

here's the code I'm using (changed offsets and stuff):
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;
using System.Runtime.InteropServices;
 
namespace SimpleTriggerbot
{
    class Program
    {
        [DllImport("kernel32.dll")]
        public static extern int OpenProcess(uint dwDesiredAccess, bool bInheritHandle, int dwProcessId);
        [DllImport("kernel32.dll")]
        public static extern bool ReadProcessMemory(int hProcess, int lpBaseAddress, byte[] buffer, int size, int lpNumberOfBytesRead);
        [DllImport("user32.dll")]
        static extern void mouse_event(uint dwFlags, uint dx, uint dy, uint dwData, UIntPtr dwExtraInfo);
        [DllImport("user32.dll")]
        public static extern short GetAsyncKeyState(int vKey);
 
        static int BaseAdressClientDLL = 0;
        static int pHandle = 0;
 
        const int _crosshairID = 0x0000A950;
        const int _localPlayer = 0x00A7D4CC;
        const int _entityList = 0x04A98154;
        const int _teamNum = 0x000000F0;
        const int _iHealth = 0x000000FC;
        const int _vecOrigin = 0x00000134;
 
 
        static void Main(string[] args)
        {
            bool FoundCSGO = false;
            while (true)
            {
                if (FoundCSGO == false)
                {
                    foreach (Process Proc in Process.GetProcesses())
                    {
                        if (Proc.ProcessName.Equals("csgo"))
                        {
                            Console.WriteLine("found csgo process");
                            pHandle = OpenProcess(0x001F0FFF, false, Proc.Id);
                            foreach (ProcessModule Module in Proc.Modules)
                            {
                                if (Module.ModuleName.Equals("client.dll"))
                                {
                                    Console.WriteLine("found base address");
                                    BaseAdressClientDLL = (int)Module.BaseAddress;
                                    FoundCSGO = true;
                                }
                            }
                        }
                    }
                }
                else
                {
                    if (GetAsyncKeyState(0x20) != 0)
                    {
                        int LocalPlayer = readInt(BaseAdressClientDLL + _localPlayer);
                        int CrosshairID = readInt(LocalPlayer + _crosshairID);
                        if (CrosshairID > 0 && CrosshairID <= 64)
                        {
                            int Enemy = readInt(BaseAdressClientDLL + _entityList + ((CrosshairID - 1) * _vecOrigin));
                            int PlayerTeam = readInt(LocalPlayer + _teamNum);
                            int EnemyTeam = readInt(Enemy + _teamNum);
                            int EnemyHealth = readInt(Enemy + _iHealth);
 
                            if (EnemyHealth > 0 && PlayerTeam != EnemyTeam)
                            {
                                mouse_event(0x002, 0, 0, 0, (System.UIntPtr)0);
                                mouse_event(0x004, 0, 0, 0, (System.UIntPtr)0);
                            }
                        }
                    }
                }
                System.Threading.Thread.Sleep(5);
            }
        }
 
        public static int readInt(int address)
        {
            byte[] buffer = new byte[4];
            ReadProcessMemory(pHandle, address, buffer, 4, 0);
            return BitConverter.ToInt32(buffer, 0);
        }
    }
}
Anyway, the triggerbot will shoot teammates and enemies, and only shoots certain people. I can't figure out why. This is against bots btw, if that matters..
Also, since this is external, will this be undetected? If not, how would I get it to be? What makes it undetected?

If anyone can help me out that would be great, thanks in advance.
This line of code is wrong:

Code:
int Enemy = readInt(BaseAdressClientDLL + _entityList + ((CrosshairID - 1) * _vecOrigin));
It should be:
Code:
int Enemy = readInt(BaseAdressClientDLL + _entityList + ((CrosshairID - 1) * 0x10));
I fixed it and ran it, but it still seems to be doing the same thing. Would it have something to do with the fact i'm against bots?
Quote Originally Posted by fullweeb View Post
I fixed it and ran it, but it still seems to be doing the same thing. Would it have something to do with the fact i'm against bots?
No, it has nothing to do with that.

Try adding a sleep of 25 ms between your mouse down and your mouse up event.
Just tried it, it behaves the same way, except for now it kinda taps at them rather than spraying if using a rifle. Though the only shooting some people issue is still there. For instance, out of the 5 enemy bots, it only shoots 1 of them, and out of the 4 teammate bots it shoots 2 of them.
Code:
if (LocalPlayer_crosshairID > 0 && LocalPlayer_crosshairID < 64 && LocalPlayer_teamNum != EntityPlayer_teamNum && !EntityPlayer_isDormant && !EntityPlayer_lifeState)
Try this out.
Quote Originally Posted by Law View Post
Code:
if (LocalPlayer_crosshairID > 0 && LocalPlayer_crosshairID < 64 && LocalPlayer_teamNum != EntityPlayer_teamNum && !EntityPlayer_isDormant && !EntityPlayer_lifeState)
Try this out.
Changed it up a little to work with my current code. Tried it out and doesn't shoot or anything.
Quote Originally Posted by fullweeb View Post
Changed it up a little to work with my current code. Tried it out and doesn't shoot or anything.
You should just use ForceAttack instead of calling a click event but that is besides the point.


Try using these instead of what you have currently (Just convert them to your code)

Code:
int LocalPlayer_crosshairID = mem.Read<int>(LocalPlayer_dwBase + CrossID) - 1;
				int LocalPlayer_teamNum = mem.Read<int>(LocalPlayer_dwBase + 0xF0);
				DWORD EntityPlayer_dwBase = mem.Read<DWORD>(Client.dwBase + EntList + (0x10 * LocalPlayer_crosshairID));
				int EntityPlayer_teamNum = mem.Read<int>(EntityPlayer_dwBase + 0xF0);
				bool EntityPlayer_lifeState = mem.Read<bool>(EntityPlayer_dwBase + 0x25B);
				bool EntityPlayer_isDormant = mem.Read<bool>(EntityPlayer_dwBase + 0xE9);

				if (LocalPlayer_crosshairID > 0 && LocalPlayer_crosshairID < 64 && LocalPlayer_teamNum != EntityPlayer_teamNum && !EntityPlayer_isDormant && !EntityPlayer_lifeState)
				{
					mem.Write<int>(Client.dwBase + ForceAttack, 1);
					Sleep(1);
					mem.Write<int>(Client.dwBase + ForceAttack, 4);
Quote Originally Posted by Law View Post


You should just use ForceAttack instead of calling a click event but that is besides the point.


Try using these instead of what you have currently (Just convert them to your code)

Code:
int LocalPlayer_crosshairID = mem.Read<int>(LocalPlayer_dwBase + CrossID) - 1;
				int LocalPlayer_teamNum = mem.Read<int>(LocalPlayer_dwBase + 0xF0);
				DWORD EntityPlayer_dwBase = mem.Read<DWORD>(Client.dwBase + EntList + (0x10 * LocalPlayer_crosshairID));
				int EntityPlayer_teamNum = mem.Read<int>(EntityPlayer_dwBase + 0xF0);
				bool EntityPlayer_lifeState = mem.Read<bool>(EntityPlayer_dwBase + 0x25B);
				bool EntityPlayer_isDormant = mem.Read<bool>(EntityPlayer_dwBase + 0xE9);

				if (LocalPlayer_crosshairID > 0 && LocalPlayer_crosshairID < 64 && LocalPlayer_teamNum != EntityPlayer_teamNum && !EntityPlayer_isDormant && !EntityPlayer_lifeState)
				{
					mem.Write<int>(Client.dwBase + ForceAttack, 1);
					Sleep(1);
					mem.Write<int>(Client.dwBase + ForceAttack, 4);
Ok I tried this out, it does the same thing where it only shoots some people, but now it doesn't shoot teammates anymore, so that's good.

Also I used a click event to test it. Doesn't writing to memory make it a lot easier to get detected? I'm a noob when it comes to making hacks so I don't think I'd be able to safely write to memory without a lot of practice, haha.
Quote Originally Posted by fullweeb View Post
Ok I tried this out, it does the same thing where it only shoots some people, but now it doesn't shoot teammates anymore, so that's good.

Also I used a click event to test it. Doesn't writing to memory make it a lot easier to get detected? I'm a noob when it comes to making hacks so I don't think I'd be able to safely write to memory without a lot of practice, haha.
It's just personal preference when it comes down to it I guess.
Quote Originally Posted by Law View Post

It's just personal preference when it comes down to it I guess.
Ah I see.

Something I noticed: it seems it only shoots some people at random. For instance: It would shoot 'BOT Scott', then after killing a couple bots it would no longer should 'BOT Scott' but would shoot another bot that it wouldn't shoot previously.
Quote Originally Posted by fullweeb View Post
Ah I see.

Something I noticed: it seems it only shoots some people at random. For instance: It would shoot 'BOT Scott', then after killing a couple bots it would no longer should 'BOT Scott' but would shoot another bot that it wouldn't shoot previously.
That is very odd, you must be missing an error somewhere.
Quote Originally Posted by Law View Post


That is very odd, you must be missing an error somewhere.
That's probably the case. Thanks for your help though!
Quote Originally Posted by fullweeb View Post
That's probably the case. Thanks for your help though!
Could you please post your current code, and most importantly your EntityList offset?

I'm fairly certain that your EntityList offset is misaligned.
The offset in the above code is misaligned, i don't know if you updated it afterwards.

Usually, if the teamcheck doesn't work out, it's because you misalign something.

The EntityList starts at client.dll + 0x4A98164, where the world is taking place. The world is always at that position, therefore 0x4A98174 is the offset which always points to the first player.

In order to use the EntityID's, you subtract the EntityID by one, to align your ID to the EntityList.

Let me show you an example.

Your CrosshairID is returning 1.

This means that the first Entity is currently in your crosshair.
Using the 0x4A98174 offset, the first Entity is located inbetween 0x4A98174 and 0x4A98184 together with some additional data.

The way you grab Entities in your code ( and how pretty much every other external cheat is doing it ) is by doing ID * 0x10, in order to skip the additional data and get right to the next entity.
However, if you'd use the EntityID, it would be 1 * 0x10, which would get you to 0x4A98184, where the next Entity is located.

That's why most people do ID - 1 * 0x10, to align everything up with the list.
This is unnecessary if you use the actual offset for the EntityList, which is supposed to be 0x4A98164.
With this, you don't need to align anything.

Your offset in the code above is 0x4A98154, which would mean that instead of grabbing Entity 3, you grab Entity 1, or instead of Entity 5, you grab Entity 3.
I see, thanks for all the info. It helps a lot.

Here's my current code, it seems to be shooting everyone now, regardless of team, but not just shooting some people like it was.
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Threading;

namespace SimpleTriggerbot
{
	class Program
	{
		[DllImport("kernel32.dll")]
		public static extern int OpenProcess(uint dwDesiredAccess, bool bInheritHandle, int dwProcessId);
		[DllImport("kernel32.dll")]
		public static extern bool ReadProcessMemory(int hProcess, int lpBaseAddress, byte[] buffer, int size, int lpNumberOfBytesRead);
		[DllImport("user32.dll")]
		static extern void mouse_event(uint dwFlags, uint dx, uint dy, uint dwData, UIntPtr dwExtraInfo);
		[DllImport("user32.dll")]
		public static extern short GetAsyncKeyState(int vKey);

		static int BaseAdressClientDLL = 0;
		static int pHandle = 0;

		const int _crosshairID = 0x0000A950;
		const int _localPlayer = 0x00A7D4CC;
		const int _entityList = 0x4A98164;
		const int _teamNum = 0x000000F0;
		const int _iHealth = 0x000000FC;


		static void Main(string[] args)
		{
			bool FoundCSGO = false;
			while (true)
			{
				if (FoundCSGO == false)
				{
					foreach (Process Proc in Process.GetProcesses())
					{
						if (Proc.ProcessName.Equals("csgo"))
						{
							pHandle = OpenProcess(0x001F0FFF, false, Proc.Id);
							foreach (ProcessModule Module in Proc.Modules)
							{
								if (Module.ModuleName.Equals("client.dll"))
								{
									BaseAdressClientDLL = (int)Module.BaseAddress;
									FoundCSGO = true;
								}
							}
						}
					}
				}
				else
				{
					int LocalPlayer = readInt(BaseAdressClientDLL + _localPlayer);
					int LocalPlayer_crosshairID = readInt(LocalPlayer + _crosshairID) - 1;
					int LocalPlayer_teamNum = readInt(LocalPlayer + _teamNum);
					int EntityPlayer_dwBase = readInt(BaseAdressClientDLL + _entityList + (LocalPlayer_crosshairID - 1 * 0x10));
					int EntityPlayer_teamNum = readInt(EntityPlayer_dwBase + _teamNum);
					int EnemyHealth = readInt(EntityPlayer_dwBase + _iHealth);

					if (GetAsyncKeyState(0x20) != 0 && LocalPlayer_crosshairID > 0 && LocalPlayer_crosshairID < 64 && LocalPlayer_teamNum != EntityPlayer_teamNum)
					{
						mouse_event(0x002, 0, 0, 0, (System.UIntPtr)0);
						Thread.Sleep(1);
						mouse_event(0x004, 0, 0, 0, (System.UIntPtr)0);
					}
				}
				Thread.Sleep(5);
			}
		}

		public static int readInt(int address)
		{
			byte[] buffer = new byte[4];
			ReadProcessMemory(pHandle, address, buffer, 4, 0);
			return BitConverter.ToInt32(buffer, 0);
		}
	}
}
Sorry it's so messy, it's just been kind of mashed together by me attempting a lot of different things to get it to work.
Posts 1–15 of 19 · Page 1 of 2
This thread is closed for replies.

Similar Threads

Talk with us