Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 712071
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T04:48:26+00:00 2026-05-14T04:48:26+00:00

I’ve written the following code to (successfully) connect to a socks5 proxy. I send

  • 0

I’ve written the following code to (successfully) connect to a socks5 proxy.

I send a user/pw auth and get an OK reply (0x00), but as soon as I tell the proxy to connect to whichever ip:port, it gives me 0x01 (general error).

Socket socket5_proxy = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
IPEndPoint proxyEndPoint = new IPEndPoint(IPAddress.Parse("111.111.111.111"), 1080); // proxy ip, port. fake for posting purposes.
socket5_proxy.Connect(proxyEndPoint);
byte[] init_socks_command = new byte[4];
init_socks_command[0] = 0x05;
init_socks_command[1] = 0x02;
init_socks_command[2] = 0x00;
init_socks_command[3] = 0x02;
socket5_proxy.Send(init_socks_command);
byte[] socket_response = new byte[2];
int bytes_recieved = socket5_proxy.Receive(socket_response, 2, SocketFlags.None);

if (socket_response[1] == 0x02)
{
    byte[] temp_bytes;
    string socks5_user = "foo";
    string socks5_pass = "bar";
    byte[] auth_socks_command = new byte[3 + socks5_user.Length + socks5_pass.Length];
    auth_socks_command[0] = 0x05;
    auth_socks_command[1] = Convert.ToByte(socks5_user.Length);
    temp_bytes = Encoding.Default.GetBytes(socks5_user);
    temp_bytes.CopyTo(auth_socks_command, 2);
    auth_socks_command[2 + socks5_user.Length] = Convert.ToByte(socks5_pass.Length);
    temp_bytes = Encoding.Default.GetBytes(socks5_pass);
    temp_bytes.CopyTo(auth_socks_command, 3 + socks5_user.Length);
    socket5_proxy.Send(auth_socks_command);
    socket5_proxy.Receive(socket_response, 2, SocketFlags.None);
    if (socket_response[1] != 0x00)
        return;
    byte[] connect_socks_command = new byte[10];
    connect_socks_command[0] = 0x05;
    connect_socks_command[1] = 0x01; // streaming
    connect_socks_command[2] = 0x00;
    connect_socks_command[3] = 0x01; // ipv4
    temp_bytes = IPAddress.Parse("222.222.222.222").GetAddressBytes(); // target connection. fake ip, obviously
    temp_bytes.CopyTo(connect_socks_command, 4);
    byte[] portBytes = BitConverter.GetBytes(3333);
    connect_socks_command[8] = portBytes[0];
    connect_socks_command[9] = portBytes[1];
    socket5_proxy.Send(connect_socks_command);
    socket5_proxy.Receive(socket_response);
    if (socket_response[1] != 0x00)
        MessageBox.Show("Damn it"); // I always end here, 0x01

I’ve used this as a reference: http://en.wikipedia.org/wiki/SOCKS#SOCKS_5

Have I completely misunderstood something here? How I see it, I can connect to the socks5 fine. I can authenticate fine. But I/the proxy can’t “do” anything?

  1. Yes, I know the proxy works.
  2. Yes, the target ip is available and yes the target port is open/responsive.
  3. I get 0x01 no matter what I try to connect to.

Any help is VERY MUCH appreciated!

Thanks,

  • Chuck
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T04:48:26+00:00Added an answer on May 14, 2026 at 4:48 am

    You might be getting bitten by endianness. Is BitConverter.GetBytes returning you the right bytes, for instance? Did you step through it and check if your byte arrays contain what you expect them to?

    That looks like little endian, and networking-related things usually use big endian. BitConverter always uses system endianness, so you’ll have to reverse bytes by hand if you’re running on a little endian system (which you would seem to be doing). BitConverter.IsLittleEndian will tell you whether your system is little endian or not.

    Also, it’d be a good idea to cast your value to short, e.g. BigConverter.GetBytes((short)3333). That way you’ll get just the two bytes you need.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to clean up various Word 'smart' characters in user input, including but
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.