سؤال

I am trying to make my program direct it's traffic through tor by implementing SOCKS5 and so far I've got this:

char first =(0x00,0x01,0x05);
char sec=(0x50,0x00,0xE2,0xE1,0x7D,0x4A,0x01,0x00,0x01,0x05);
send(ProxySocket, &first,(int) 3,0);
send(ProxySocket, &sec, (int) sizeof(sec),0);

But when I run my program tor tells me "[warn] fetching socks handshake failed. closing." is there something wrong with the packets that i am sending?

هل كانت مفيدة؟

المحلول

This code is wrong. Value of char first = (0x00, 0x01, 0x05); will be 0x05. See the rule of parenthesis in the assignment. I think it should be char first[] = {0x00, 0x01, 0x05}; Now you can use sizeof operator in first.

In the second send call, you are using sizeof(sec) which turns out one char.

Use:

 char sec[] = {0x50,0x00,0xE2,0xE1,0x7D,0x4A,0x01,0x00,0x01,0x05};

Your code should be:

char first[] ={0x00,0x01,0x05};
char sec[]={0x50,0x00,0xE2,0xE1,0x7D,0x4A,0x01,0x00,0x01,0x05};
send(ProxySocket, first,(int) sizeof(first),0);
send(ProxySocket, sec, (int) sizeof(sec),0);
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top