[C++] Recv packets from webbrowser...

03/19/2012 14:52 stronka111#1
Hello guys!
I have a question to you. I want make bot as:
Code:
http://www.elitepvpers.com/forum/browsergames/1763240-release-seafight-antistealth-wartool-bot.html
and I don't know how recv packets which seafight server send to webbrowser?
I must use winsock or winpcap?
I try make serwer:
PHP Code:
#include <cstdio>
#include <winsock2.h>
#include <iostream>
using namespace std;
int main()
{
//********************START**********************************
    
WSADATA wsaData;

    
int result WSAStartupMAKEWORD2), & wsaData );
    if( 
result != NO_ERROR )
        
printf"Initialization error.\n" );

    
SOCKET mainSocket socketAF_INETSOCK_STREAMIPPROTO_TCP );
    if( 
mainSocket == INVALID_SOCKET )
    {
    
printf"Error creating socket: %ld\n"WSAGetLastError() );
    
WSACleanup();
    return 
1;
    }

    
sockaddr_in service;
    
memset( & service0sizeofservice ) );
    
service.sin_family AF_INET;
    
service.sin_addr.s_addr inet_addr"127.0.0.1" );
    
service.sin_port htons1111 );
//********************START**********************************
    
if( bindmainSocket,( SOCKADDR * ) & servicesizeofservice )) == SOCKET_ERROR)
    {
        
printf"bind() failed.\n" );
        
closesocketmainSocket );
        
WSACleanup();
        return 
1;
    }
    if( 
listenmainSocket) == SOCKET_ERROR )
        
printf"Error listening on socket.\n" );

    
SOCKET acceptSocket SOCKET_ERROR;
    
printf"Waiting for a client to connect...\n" );

    while( 
acceptSocket== SOCKET_ERROR )
        {
        
acceptSocket acceptmainSocketNULLNULL );
        }

    
printf"Client connected.\n" );
    
mainSocket acceptSocket;
//****************END***************************

int bytesSent;
int bytesRecv SOCKET_ERROR;
char sendbuf32 ] = "answer...";
char recvbuf1024 ] = "";

bytesRecv recvmainSocketrecvbuf1024);
printf"Bytes received: %ld\n"bytesRecv );
printf"Received text: %s\n"recvbuf );

bytesSent sendmainSocketsendbufstrlensendbuf ), );
printf"Bytes sent: %ld\n"bytesSent );

cin.get();
    return 
0;

and in webbrowser set ip: 127.0.0.1 and socket: 1111; but webbrowser can't connect to game..
I need way to make it!
Please help me:handsdown:
03/20/2012 11:54 MoepMeep#2
This looks like c&p code ;o
03/20/2012 20:12 .Infinite#3
Your "server" is not a proxy... It does not know how to answer the browsers requests. Neither does your browser know how to handle your server's packets.

First you need to know how communication between a browser and a proxy server works in order to emulate one.
03/20/2012 21:09 stronka111#4
So i must make proxy local and listen:)
03/20/2012 21:42 .Infinite#5
Quote:
but webbrowser can't connect to game..
Your "server" has to redirect the packets:

Browser ---GET---> Local Proxy(your server) ---GET---> Gameserver