I have a problem when i`m sending my last packet,as I said in the comentary,I’m getting an warning sayng that i returned an unexpected answer follow by a different hex number every time i run it.
I am using Proxifier to test this,it always give me this when i try to connect to google:
[06:22] Starting: Test 1: Connection to the Proxy Server
[06:22] IP Address: 127.0.0.1
[06:22] Connection established
[06:22] Test passed.
[06:22] Starting: Test 2: Connection through the Proxy Server
[06:22] Authentication was successful.
[06:22] Warning : the proxy server has returned an unexpected answer (0x32).
[06:22] Connection to www.google.com:80 established through the proxy server.
`void HandleConnection()
{
cout << "You are connected !!!" << endl;
char temp[30];
Recv(temp, sizeof(temp));
if(temp[0] == 5) // test for version
{
cout << "Version good" << endl;
char* reply = new char[2];
reply[0] = 5; // version
reply[1] = 0; // method choosed (no auth required)
Send(reply, sizeof(reply));
delete [] reply;
memset(temp, '\0', sizeof(temp));
Recv(temp, sizeof(temp));
temp[sizeof(temp)] = '\0';
if(temp[0] == 5) // test for version
{
if(temp[4] == 14) // test for lenght of www.google.com
{
char* domain = new char[temp[4]];
for(int i = 0; i < temp[4]; ++i)
{
domain[i] = temp[i + 5]; // copy domain name
}
domain[14] = '\0';
cout << endl;
cout << domain << endl;
int domainLen = strlen(domain);
//with this packet i get a warning that i send an unexpected answer
char* reply = new char[domainLen + 6];
reply[0] = 5; // version
reply[1] = 0; // succed
reply[2] = 0; // reserved
reply[3] = 3; // its a domain
reply[4] = domainLen; // lenght of domain
for(int j = 0; j < domainLen; ++j)
{
reply[j + 5] = domain[j];
}
reply[4 + domainLen] = 80; // port
Send(reply, domainLen);
delete [] reply;
}
}
}
}`
Following those lines of code:
Maybe it should be
domain[13] = '\0';instead ofdomain[14] = '\0';