PDA

Просмотр полной версии : [C++] Kreedz Hack by Jeix


Boboh
18.04.2011, 18:28
/*
* KZH.exe by Jeix
*
* Copyright © 2010 Jeix
*
* This program is free software; you can
* redistribute it and/or modify it under
* the terms of the GNU General Public
* License as published by the Free Software
* Foundation; either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope
* that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU
* General Public License along with this
* program; if not, see <[Ссылки могут видеть только зарегистрированные и активированные пользователи]>.
*
*
* Run KZH.exe and keep pressing your buttons!
* Have fun and enjoy!
*
*/



#include <iostream>
#include <ctime>
#include <windows.h>
#include <process.h>

///////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////
// general use functions
int SendKey(unsigned short scancode, bool release, unsigned short vkey=0x00);
int SendMouse(long xlength, long ylength);
void MoveMouse(long xlength, long ylength);
int WheelMouse(long length);

const int SLEEP_TIME = 12; // in ms


///////////////////////////////////////////////////////////////////////
// strafe code
void StrafeLoop(void* dummy);
void Strafe();

const int STEPS = 100; // 80
const int MOUSE_DIFF = 550; // 480
const int STRAFEKEY = VK_XBUTTON2; // VK_LMENU
const int STRAFESCANLEFT = 0x1e; // A
const int STRAFESCANRIGHT = 0x20; // D


///////////////////////////////////////////////////////////////////////
// double duck code
void DoubleDuckLoop(void* dummy);
void DoubleDuck();

//const int WHEEL_DIFF = 1;
const int DOUBLEDUCKKEY = VK_SHIFT;
const int DOUBLEDUCKSCAN = 0x1d; // CTRL
const int DOUBLEDUCKWAIT = 213; // 215


///////////////////////////////////////////////////////////////////////
// bhop code
void BHopLoop(void* dummy);
void BHop();
const int BHOPKEY = VK_SPACE;
const int BHOPSCAN = 0x0b; // '0'


///////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////
// main
int main()
{
std::cout << "KZH rev.83 by Jeix was started" << std::endl;

std::cout << "[?] Launching strafe helper." << std::endl;
if(_beginthread(StrafeLoop, 0, NULL) == -1)
{
std::cout << "[-] Launching strafe helper failed." << std::endl;
return -1;
}

std::cout << "[?] Launching bhop helper." << std::endl;
if(_beginthread(BHopLoop, 0, NULL) == -1)
{
std::cout << "[-] Launching bhop helper failed." << std::endl;
return -1;
}

std::cout << "[?] Launching doubleduck helper." << std::endl;
if(_beginthread(DoubleDuckLoop, 0, NULL) == -1)
{
std::cout << "[-] Launching doubleduck helper failed." << std::endl;
return -1;
}

std::cout << "[+] Going into main loop. Press enter to quit:" << std::endl;
while(true) Sleep(1000);
//std::cin.get();
}


/*
*
* The main loops
*
*/
void StrafeLoop(void* dummy)
{
while(true)
{
if(GetAsyncKeyState(STRAFEKEY) & (1 << 15))
{
Strafe();
}
}
}

void BHopLoop(void* dummy)
{
while(true)
{
if(GetAsyncKeyState(BHOPKEY) & (1 << 15))
{
BHop();
Sleep(SLEEP_TIME);
}
}
}

void DoubleDuckLoop(void* dummy)
{
while(true)
{
if(GetAsyncKeyState(DOUBLEDUCKKEY) & (1 << 15))
{
DoubleDuck();
Sleep(DOUBLEDUCKWAIT);
}
}
}


/*
*
* general use functions
*
*/
int SendKey(unsigned short scancode, bool release, unsigned short vkey)
{
INPUT InputData;
InputData.type = INPUT_KEYBOARD;
InputData.ki.wVk = vkey;
InputData.ki.wScan = scancode;
InputData.ki.time = time(NULL);
InputData.ki.dwExtraInfo = 0;

if(release)
{
InputData.ki.dwFlags = KEYEVENTF_SCANCODE | KEYEVENTF_KEYUP;
if(vkey)
InputData.ki.dwFlags = KEYEVENTF_KEYUP;
}
else
{
InputData.ki.dwFlags = KEYEVENTF_SCANCODE;
if(vkey)
InputData.ki.dwFlags = 0;
}

return SendInput(1, &InputData, sizeof(InputData));
}

int SendMouse(long xlength, long ylength)
{
INPUT InputData;
InputData.type = INPUT_MOUSE;
InputData.mi.dx = xlength;
InputData.mi.dy = ylength;
InputData.mi.mouseData = NULL;
InputData.mi.dwFlags = MOUSEEVENTF_MOVE;
InputData.mi.time = time(NULL);
InputData.mi.dwExtraInfo = GetMessageExtraInfo();

return SendInput(1, &InputData, sizeof(InputData));
}

void MoveMouse(long xlength, long ylength)
{
int xstep = xlength/STEPS;
int ystep = ylength/STEPS;
for(int i=0; i<STEPS; i++)
{
SendMouse(xstep, ystep);
Sleep(1);
}
}

int WheelMouse(long length)
{
INPUT InputData;
InputData.type = INPUT_MOUSE;
InputData.mi.dx = 0;
InputData.mi.dy = 0;
InputData.mi.mouseData = 120 + length;
InputData.mi.dwFlags = MOUSEEVENTF_HWHEEL;
InputData.mi.time = time(NULL);
InputData.mi.dwExtraInfo = GetMessageExtraInfo();

return SendInput(1, &InputData, sizeof(InputData));
}



/*
*
* specifc functions
*
*/
void Strafe()
{
// Press A and move mouse left
SendKey(STRAFESCANLEFT, false);
MoveMouse(-MOUSE_DIFF, 0);
SendKey(STRAFESCANLEFT, true);

// Press D and move mouse right
SendKey(STRAFESCANRIGHT, false);
MoveMouse(MOUSE_DIFF, 0);
SendKey(STRAFESCANRIGHT, true);
}


void DoubleDuck()
{
// press and release CTRL
SendKey(DOUBLEDUCKSCAN, false);
Sleep(SLEEP_TIME);
SendKey(DOUBLEDUCKSCAN, true);
}


void BHop()
{
// press and release SPACE
SendKey(BHOPSCAN, false);
Sleep(SLEEP_TIME);
SendKey(BHOPSCAN, true);
}