我會讓我的代碼。其有關連接到一個Sb0t-服務器的客戶端:如何連接我的程序到服務器槽代理?
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Drawing2D;
using System.Threading;
using System.Net;
using System.Net.Sockets;
using System.IO;
using System.Runtime.InteropServices;
namespace Antiban
{
public partial class Form1 : Form
{
public Socket Socket;
public System.Net.Sockets.NetworkStream Stream;
public byte[] AvatarStream;
public Form1()
{
InitializeComponent();
}
public void ConectarBot(IPAddress ip, int puerto)
{
Socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
label1.Text = "Conectando... por favor espera...";
try
{
Socket.Connect(new IPEndPoint(ip, Convert.ToInt32(puerto)));
}
catch(Exception ex)
{
}
if (Socket.Connected == true)
{
label1.Text = "Conectado. Iniciando protocolo";
Socket.Send(MSG_CHAT_CLIENT_LOGIN());
label1.Text = "Conectado!";
}
}
public byte[] MSG_CHAT_CLIENT_LOGIN()
{
List<byte> buffer = new List<byte>();
buffer.AddRange(new byte[] { 2 });
buffer.AddRange(Guid.NewGuid().ToByteArray());
buffer.AddRange(BitConverter.GetBytes(Convert.ToInt16(666)));
buffer.AddRange(new byte[] { 0 });
buffer.AddRange(BitConverter.GetBytes(Convert.ToInt16(5555)));
buffer.AddRange(new byte[]
{
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
});
buffer.AddRange(Encoding.UTF8.GetBytes(textBox1.Text));
buffer.AddRange(new byte[] { 0 });
buffer.AddRange(Encoding.UTF8.GetBytes("Antiban by Narciso"));
buffer.AddRange(new byte[]
{
0,
127,
0,
0,
1,
6,
6,
6,
6,
0,
0,
0,
0,
20,
1,
69
});
buffer.AddRange(Encoding.UTF8.GetBytes("Ares"));
buffer.AddRange(new byte[] { 0 });
buffer.InsertRange(0, BitConverter.GetBytes(Convert.ToInt16(buffer.Count - 1)));
return buffer.ToArray();
}
private void button1_Click(object sender, EventArgs e)
{
string i = textBox2.Text;
string p = textBox3.Text;
ConectarBot(System.Net.IPAddress.Parse(i), int.Parse(p));
}
private void button2_Click(object sender, EventArgs e)
{
List<byte> buffer = new List<byte>();
buffer.AddRange(new byte[] { 10 });
buffer.AddRange(Encoding.UTF8.GetBytes(textBox4.Text));
buffer.InsertRange(0, BitConverter.GetBytes(Convert.ToInt16(buffer.Count - 1)));
Socket.Send(buffer.ToArray());
textBox4.Clear();
}
}
}
我必須添加連接到Sb0t - 服務器低谷代理? 有些想法?
我認爲它必須首先連接到代理服務器,而不是服務器。但我不知道我該怎麼做。
謝謝:)
你看過這篇文章嗎? http://stackoverflow.com/questions/1938990/c-sharp-connecting-through-proxy –
[C#通過代理連接]的可能重複(http://stackoverflow.com/questions/1938990/c-sharp-connecting-通過代理) –