Skip to content

Instantly share code, notes, and snippets.

@martinamps
Created January 16, 2015 19:49
Show Gist options
  • Save martinamps/f713afbaa46188d6db4d to your computer and use it in GitHub Desktop.
Save martinamps/f713afbaa46188d6db4d to your computer and use it in GitHub Desktop.
old code sample of injecting packets into KO
DWORD KO_SEND_FUNC = 0x473430; //0x4736C0;
DWORD KO_SOCKET_BMA = 0xB6D790; //0xB6D770;
std::vector<char> hex2bytes(std::string hex) {
std::vector<char> out;
std::istringstream s;
int b;
for (int i = 0; i < hex.length(); i += 2) {
s.clear();
s.str(hex.substr(i,2));
s >> std::hex >> b;
out.push_back(b);
}
return out;
}
void SendString(std::string hex) {
std::vector<char> bytes = hex2bytes(hex);
SendPackets(&bytes[0], bytes.size());
}
void SendPackets(char *pdata, DWORD psize){
__asm{
mov edx,KO_SOCKET_BMA
mov eax,dword ptr ds:[edx]
mov ecx,dword ptr ds:[edx]
mov edx,psize
push edx
push pdata
mov edi,KO_SEND_FUNC
call edi
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment