Skip to content

Instantly share code, notes, and snippets.

@krofna
Created April 11, 2013 15:19
Show Gist options
  • Save krofna/5364243 to your computer and use it in GitHub Desktop.
Save krofna/5364243 to your computer and use it in GitHub Desktop.
#include <SFML/Network.hpp>
#include <iostream>
using namespace std;
sf::Uint8 RawPacket[] =
{
0x00, 0x00, 0x00, 0x00, 0x37, 0x50, 0x61, 0x63, 0x6b, 0x73, 0x56, 0x65, 0x65, 0x44, // ....7P acksVeeD
0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x74, 0x75, 0x74, 0x6f, 0x72, 0x69, 0x61, 0x6c, 0x35, 0x33, // efaulttu torial53
0x32, 0x38, 0x36, 0x63, 0x35, 0x62, 0x61, 0x34, 0x39, 0x64, 0x61, 0x30, 0x62, 0x62, 0x66, 0x33, // 286c5ba4 9da0bbf3
0x61, 0x66, 0x39, 0x31, 0x32, 0x62, 0x39, 0x39, 0x39, 0x37, 0x31, 0x33, 0x65, 0x36, 0x00, 0x00, // af912b99 9713e6..
0x80, 0x3f, 0x00, 0x00, 0x00, 0x09, 0x77, 0x69, 0x72, 0x65, 0x73, 0x68, 0x61, 0x72, 0x6b, 0x35, // .?....wi reshark5
0x7b, 0xbe, 0x40, 0x00, 0x00, 0x00, 0x20, 0x64, 0x37, 0x34, 0x64, 0x35, 0x61, 0x32, 0x32, 0x36, // {.@... d 74d5a226
0x38, 0x65, 0x64, 0x39, 0x65, 0x30, 0x35, 0x30, 0x38, 0x64, 0x33, 0x64, 0x34, 0x39, 0x66, 0x33, // 8ed9e050 8d3d49f3
0x38, 0x38, 0x62, 0x62, 0x33, 0x62, 0x61, /*Terminator*/ 0xFF /*Terminator*/ // 88bb3ba
};
int main()
{
sf::Packet Packet;
for (sf::Uint16 i = 0; RawPacket[i] != 0xFF; ++i)
Packet << RawPacket[i];
sf::TcpSocket Socket;
while (true)
{
sf::Packet RecPacket;
sf::Uint8 Opcode, Good;
Socket.disconnect();
Socket.connect("209.236.124.147", 27272);
if (Socket.send(Packet) != sf::Socket::Done)
{
cout << "Couldn't send packet.\n" << flush;
continue;
}
if (Socket.receive(RecPacket) != sf::Socket::Done)
{
cout << "Couldn't get response.\n" << flush;
continue;
}
if (RecPacket >> Opcode >> Good)
{
if (Opcode == 0x10 && Good == 0)
cout << "Packet was accepted!\n";
else
cout << "Packet was NOT accepted!\n";
}
else
{
cout << "Response packet is invalid.\n";
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment