Advertisement
captmicro

LHK CSS Lua Aimb0t Version NEW

Dec 22nd, 2012
486
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 8.16 KB | None | 0 0
  1. SetDebugPrivileges()
  2.  
  3. local hwnd = 0
  4. while (hwnd == 0) do
  5.     hwnd = FindWindow("Counter-Strike Source")
  6. end
  7.  
  8. local procID = GetProcessId(hwnd)
  9. WriteConsole("Process ID: " .. tostring(procID) .. "\n")
  10. local procHandle = OpenProcess(PROCESS_ALL_ACCESS, procID)
  11. WriteConsole("Process Handle: " .. tostring(procHandle) .. " [" .. tostring(PROCESS_ALL_ACCESS) .. "]\n")
  12.  
  13. local engine = GetBaseAddress(procHandle, "engine.dll")
  14. local client = GetBaseAddress(procHandle, "client.dll")
  15.  
  16. local r_drawothermodels = client + 0x741F20
  17.  
  18. local EntTable = client + 0x00751FFC --hardcode for now
  19. WriteConsole("Entity Table @ " .. tostring(EntTable) .. "\n");
  20. local GetEntity = function(idx)
  21.     return ReadInt(procHandle, EntTable + (0x10 * idx))
  22. end
  23. local Player = {
  24.     lifeState = function(base) return ReadInt(procHandle, base + 0x8F) end,
  25.     m_iHealth = function(base) return ReadInt(procHandle, base + 0x90) end,
  26.     m_iTeamNum = function(base) return ReadInt(procHandle, base + 0x98) end,
  27.     m_vecMins = function(base) return ReadFloat(procHandle, base + 0x20),
  28.         ReadFloat(procHandle, base + 0x24), ReadFloat(procHandle, base + 0x28) end,
  29.     m_vecMaxs = function(base) return ReadFloat(procHandle, base + 0x2C),
  30.         ReadFloat(procHandle, base + 0x30), ReadFloat(procHandle, base + 0x34) end,
  31.     m_vecOrigin = function(base) return ReadFloat(procHandle, base + 0x2FC),
  32.         ReadFloat(procHandle, base + 0x300), ReadFloat(procHandle, base + 0x304) end,
  33.     m_angRotation = function(base) return ReadFloat(procHandle, base + 0x308),
  34.         ReadFloat(procHandle, base + 0x308), ReadFloat(procHandle, base + 0x308) end,
  35.     m_fFlags = function(base) return ReadInt(procHandle, base + 0x314) end,
  36.     m_flFOVStart = function(base) return ReadFloat(procHandle, base + 0xF8C) end,
  37.     m_hGroundEntity = function(base) return ReadInt(procHandle, base + 0x220) end,
  38.     m_bDucked = function(base) return ReadByte(procHandle, base + 0x44) end,
  39.     m_bDucking = function(base) return ReadByte(procHandle, base + 0x45) end,
  40.     m_bInDuckJump = function(base) return ReadFloat(procHandle, base + 0x46) end,
  41.     m_flFallVelocity = function(base) return ReadFloat(procHandle, base + 0x58) end,
  42.     m_szLastPlaceName = function(base) return ReadStr(procHandle, base + 0x120C, 20) end,
  43.     m_flStamina = function(base) return ReadFloat(procHandle, base + 0x13E8) end,
  44.     m_bHasHelmet = function(base) return ReadFloat(procHandle, base + 0x144C) end,
  45.     m_iTargetEntIdx = function(base) return ReadInt(procHandle, base + 0x14A8) end,
  46. }
  47.  
  48. local RadarPtr = client + 0x791240 --hardcode for now
  49. WriteConsole("Radar Base @ " .. tostring(RadarPtr) .. "\n");
  50. local GetRadarEntity = function(idx)
  51.     return ReadInt(procHandle, RadarPtr + (0x140 * idx))
  52. end
  53. local RadarPlayer = {
  54.     name = function(base) return ReadStr(procHandle, base + 0x38, 0) end,
  55.     health = function(base) return ReadStr(procHandle, base + 0x5C, 0) end,
  56.     pos = function(base) return ReadFloat(procHandle, base + 0x60),
  57.         ReadFloat(procHandle, base + 0x64), ReadFloat(procHandle, base + 0x68) end,
  58.     ang = function(base) return ReadFloat(procHandle, base + 0x6C),
  59.         ReadFloat(procHandle, base + 0x70), ReadFloat(procHandle, base + 0x74) end,
  60. }
  61.  
  62. local o_EyeP = engine + 0x43140C
  63. local o_EyeY = engine + 0x431410
  64. local o_EyeR = engine + 0x431414
  65.  
  66. local NamePtr = ReadInt(procHandle, engine + 0x40FAEC)
  67. local o_NameStr = ReadStr(procHandle, NamePtr, 0) --read till NULL byte
  68. WriteConsole("Local player name found: " .. o_NameStr .. "\n")
  69.  
  70. local function AngleToTarget(pX,pY,pZ, tX,tY,tZ)
  71.     local deltaX = pX - tX
  72.     local deltaY = pY - tY
  73.     local deltaZ = pZ - tZ
  74.     local hyp = math.sqrt((deltaX*deltaX) + (deltaY*deltaY))
  75.     local angP = math.deg(math.asin(deltaZ / hyp))
  76.     local angY = math.deg(math.atan(deltaY / deltaX))
  77.     local angR = 0
  78.     if (deltaX >= 0) then angY = angY + 180 end
  79.     return angP,angY,angR
  80. end
  81.  
  82. local function Distance3D(pX,pY,pZ, tX,tY,tZ)
  83.     local deltaX = pX - tX
  84.     local deltaY = pY - tY
  85.     local deltaZ = pZ - tZ
  86.     return math.sqrt((deltaX*deltaX) + (deltaY*deltaY) + (deltaZ*deltaZ))
  87. end
  88.  
  89. local function RotatePoint2D(pX,pY, oX,oY, degrees)
  90.     local theta = math.rad(degrees)
  91.     local newX = (math.cos(theta) * (pX-oX)) - (math.sin(theta) * (pY-oY)) + oX
  92.     local newY = (math.sin(theta) * (pX-oX)) + (math.cos(theta) * (pY-oY)) + oY
  93.     return newX, newY
  94. end
  95.  
  96. WriteConsole("INITIALIZED.\n");
  97.  
  98. local aimbot = false
  99. local bhop = false
  100. local trigbot = false
  101. local localidx = -1
  102. local lastgroundent = -1
  103.  
  104. while (not IsKeyDown(VK_END)) do --END
  105.     if (IsKeyDown(VK_F11)) then
  106.         if (ReadInt(procHandle, r_drawothermodels) == 1) then
  107.             WriteInt(procHandle, r_drawothermodels, 2)
  108.             WriteConsole("Wallhack on\n")
  109.         else
  110.             WriteInt(procHandle, r_drawothermodels, 1)
  111.             WriteConsole("Wallhack off\n")
  112.         end
  113.         Sleep(100)
  114.     end
  115.    
  116.     if (IsKeyDown(VK_F10)) then
  117.         aimbot = not aimbot
  118.         if (aimbot) then WriteConsole("Aimbot on\n")
  119.         else WriteConsole("Aimbot off\n") end
  120.         Sleep(100)
  121.     end
  122.    
  123.     if (IsKeyDown(VK_F9)) then
  124.         bhop = not bhop
  125.         if (bhop) then WriteConsole("BunnyHop on\n")
  126.         else WriteConsole("BunnyHop off\n") end
  127.         Sleep(100)
  128.     end
  129.    
  130.     if (IsKeyDown(VK_F8)) then
  131.         trigbot = not trigbot
  132.         if (trigbot) then WriteConsole("TriggerBot on\n")
  133.         else WriteConsole("TriggerBot off\n") end
  134.         Sleep(100)
  135.     end
  136.    
  137.     if (aimbot or bhop or trigbot) then
  138.         if (localidx ~= -1) then
  139.             local test = GetRadarEntity(localidx)
  140.             if (RadarPlayer.name(test) ~= o_NameStr) then
  141.                 localidx = -1
  142.             end
  143.         end
  144.         if (localidx == -1) then
  145.             WriteConsole("Finding local player index... ")
  146.             local i = 0
  147.             for i=0,128 do
  148.                 local test = GetRadarEntity(i)
  149.                 local name = RadarPlayer.name(test)
  150.                 if (name == o_NameStr) then
  151.                     localidx = i
  152.                 end
  153.             end
  154.             if (localidx ~= -1) then
  155.                 WriteConsole(" Found! Index #" .. tostring(localidx) .. ". @ " .. tostring(GetEntity(localidx)) .. "\n")
  156.             else
  157.                 WriteConsole(" Not found!\n")
  158.             end
  159.         end
  160.     end
  161.    
  162.     if (trigbot) then
  163.         local Me = GetEntity(localidx)
  164.         local target = Player.m_iTargetEntIdx(Me)
  165.         local Nme = GetEntity(target)
  166.         local ok = false
  167.         if (Nme ~= 0) then
  168.             if ((Player.m_iTeamNum(Nme) ~= Player.m_iTeamNum(Me)) and (Player.m_iTeamNum(Nme) ~= 0)) then
  169.                 ok = true
  170.             end
  171.         end
  172.         if ((target > 0) and ok) then
  173.             SendMessage(hwnd, WM_LBUTTONDOWN, MK_LBUTTON, 0)
  174.             Sleep(10)
  175.             SendMessage(hwnd, WM_LBUTTONUP, MK_LBUTTON, 0)
  176.         end
  177.     end
  178.    
  179.     if (bhop) then
  180.         local Me = GetEntity(localidx)
  181.         local groundent = Player.m_hGroundEntity(Me)
  182.         if (groundent ~= lastgroundent) then
  183.             SendMessage(hwnd, WM_KEYDOWN, VK_SPACE, 0x390000)
  184.             Sleep(10)
  185.             SendMessage(hwnd, WM_KEYUP, VK_SPACE, 0x390000)
  186.             lastgroundent = groundent
  187.         end
  188.     end
  189.    
  190.     if (aimbot) then
  191.        
  192.         local Me = GetEntity(localidx)
  193.         local OrgX, OrgY, OrgZ = Player.m_vecOrigin(Me)
  194.         local EyeX = OrgX
  195.         local EyeY = OrgY
  196.         local EyeZ = OrgZ + (Player.m_bDucked(Me) and 32 or 65)
  197.        
  198.         local TgtX = 0
  199.         local TgtY = 0
  200.         local TgtZ = 0
  201.         local CheckDist = 99999999
  202.        
  203.         for i=0,128 do
  204.             if (i ~= localidx) then
  205.                 local Nme = GetEntity(i)
  206.                 if (Nme ~= 0) then
  207.                     if ((Player.m_iTeamNum(Nme) ~= Player.m_iTeamNum(Me)) and
  208.                         (Player.m_iTeamNum(Nme) ~= 0))
  209.                     then
  210.                         local NmeX, NmeY, NmeZ = Player.m_vecOrigin(Nme)
  211.                         local NyeX = NmeX
  212.                         local NyeY = NmeY
  213.                         local NyeZ = NmeZ + (Player.m_bDucked(Nme) and 32 or 65)
  214.                         --in CS:S the head is a bit forward of (0,0) on the XY plane
  215.                         local NmeP, NmeYaw, NmeR = Player.m_angRotation(Nme)
  216.                         local NmoX, NmoY = RotatePoint2D(5,5, NyeX,NyeY, NmeYaw)
  217.                         NyeX = NyeX + NmoX
  218.                         NyeY = NyeY + NmoY
  219.                        
  220.                         --target selection here
  221.                         local Dist = Distance3D(EyeX,EyeY,EyeZ, NyeX,NyeY,NyeZ)
  222.                         if (Dist < CheckDist) then
  223.                             TgtX = NyeX
  224.                             TgtY = NyeY
  225.                             TgtZ = NyeZ
  226.                             CheckDist = Dist
  227.                         end
  228.                     end
  229.                 end
  230.             end
  231.         end
  232.        
  233.         if (not IsKeyDown(VK_V)) then
  234.             if ((TgtX ~= 0) and (TgtY ~= 0) and (TgtZ ~= 0)) then
  235.                 local pitch, yaw, roll = AngleToTarget(EyeX,EyeY,EyeZ, TgtX,TgtY,TgtZ)
  236.                 if (pitch ~= (1/0)) then
  237.                     WriteFloat(procHandle, o_EyeP, math.NormalizeAngle(pitch))
  238.                 end
  239.                 if (yaw ~= (1/0)) then
  240.                     WriteFloat(procHandle, o_EyeY, math.NormalizeAngle(yaw))
  241.                 end
  242.             end
  243.         end
  244.     end
  245. end
  246.  
  247. CloseHandle(procHandle)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement