// Decompiled with JetBrains decompiler
// Type: Starksoft.Net.Proxy.Socks4aProxyClient
// Assembly: svchost, Version=3.2.4.0, Culture=neutral, PublicKeyToken=null
// MVID: 8F51F928-E1DB-4815-857F-7D580385B815
// Assembly location: C:\Users\Administrateur\Downloads\Virusshare-00000-msil\Backdoor.MSIL.IrcBot.lp-4dd7df88cffbf85a5894bc1b38660fa613c24b0e6c004ac00b2b119c03a35d3f.exe

using System;
using System.Net.Sockets;
using System.Text;

namespace Starksoft.Net.Proxy
{
  public class Socks4aProxyClient : Socks4ProxyClient
  {
    private const string PROXY_NAME = "SOCKS4a";

    public Socks4aProxyClient()
    {
    }

    public Socks4aProxyClient(TcpClient tcpClient)
      : base(tcpClient)
    {
    }

    public Socks4aProxyClient(string proxyHost, string proxyUserId)
      : base(proxyHost, proxyUserId)
    {
    }

    public Socks4aProxyClient(string proxyHost, int proxyPort, string proxyUserId)
      : base(proxyHost, proxyPort, proxyUserId)
    {
    }

    public Socks4aProxyClient(string proxyHost)
      : base(proxyHost)
    {
    }

    public Socks4aProxyClient(string proxyHost, int proxyPort)
      : base(proxyHost, proxyPort)
    {
    }

    public override string ProxyName => "SOCKS4a";

    internal override void SendCommand(
      NetworkStream proxy,
      byte command,
      string destinationHost,
      int destinationPort,
      string userId)
    {
      if (userId == null)
        userId = "";
      byte[] numArray1 = new byte[4]
      {
        (byte) 0,
        (byte) 0,
        (byte) 0,
        (byte) 1
      };
      byte[] destinationPortBytes = this.GetDestinationPortBytes(destinationPort);
      byte[] bytes1 = Encoding.ASCII.GetBytes(userId);
      byte[] bytes2 = Encoding.ASCII.GetBytes(destinationHost);
      byte[] buffer = new byte[10 + bytes1.Length + bytes2.Length];
      buffer[0] = (byte) 4;
      buffer[1] = command;
      destinationPortBytes.CopyTo((Array) buffer, 2);
      numArray1.CopyTo((Array) buffer, 4);
      bytes1.CopyTo((Array) buffer, 8);
      buffer[8 + bytes1.Length] = (byte) 0;
      bytes2.CopyTo((Array) buffer, 9 + bytes1.Length);
      buffer[9 + bytes1.Length + bytes2.Length] = (byte) 0;
      proxy.Write(buffer, 0, buffer.Length);
      this.WaitForData(proxy);
      byte[] numArray2 = new byte[8];
      proxy.Read(numArray2, 0, 8);
      if (numArray2[1] == (byte) 90)
        return;
      this.HandleProxyCommandError(numArray2, destinationHost, destinationPort);
    }
  }
}
