近日玩网页游戏七雄争霸,觉得还可以,但是玩起来太累,所以想自己开发个辅助试试
从网上找到了个《流年网页游戏辅助VIP系列教程》,看了下,遇到了一个问题
特来请高手指点。。。。。。
代码如下:
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.Net;
using System.Web;
using System.Net.Sockets;
using System.IO;
using FluorineFx;
using FluorineFx.IO;
using FluorineFx.Messaging;
using FluorineFx.Messaging.Messages;
using FluorineFx.AMF3;
using FluorineFx.Net;
using System.Threading;
namespace 异步传输
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Btn_CLose_Click(object sender, EventArgs e)
{
Application.Exit();
}
public static byte[] bbb;
public static byte[] ZuiZhong;
private void Btn_ShengChengAmf_Click(object sender, EventArgs e)
{
txt_log.Clear();
ByteArray g = new ByteArray();//声明一个byteArray数组
AMFMessage _amf3 = new AMFMessage(3);//定义一条AMF消息
AMFBody _amfbody = new AMFBody(txt_Target.Text, txt_Respones.Text,null);//定义一个body消息
_amf3.AddBody(_amfbody);
MemoryStream _Memory = new MemoryStream();//内存流
AMFSerializer _Serializer = new AMFSerializer(_Memory);//序列化
_Serializer.WriteMessage(_amf3);//将消息写入
byte[] _buffer = _Memory.ToArray();
txt_LogAmf.Text = System.BitConverter.ToString(_buffer).ToString();
byte[] pinjie = { 00, 00, 00, 12, 10, 00, 00, 00, 01, 17, 12, 09, 48, 130, 174, 83 };//需要拼接的参数
byte[] data3 = new byte[_buffer.Length + pinjie.Length - 5];//定义data3的长度
System.Array.Copy(_buffer, 0, data3, 0, _buffer.Length - 5);//复制两个字节数组到一个字节数组,复制到data3
System.Array.Copy(pinjie, 0, data3, _buffer.Length - 5, pinjie.Length);//↑
bbb = data3;
txt_LogAll.Text = System.BitConverter.ToString(data3);//将data3转换成为16进制
foreach (byte uu in data3)
{
txt_LogString.Text += uu.ToString()+";";//遍历data3中的十进制字节
}
foreach (byte jj in _buffer)
{
txt_log.Text += jj.ToString() + "
";
}
}
private void btn_AllClearn_Click(object sender, EventArgs e)
{
txt_LogAmf.Clear();
txt_log.Clear();
}
//用Socket发送消息的封装类定义
public class SocketSendReceiveMs
{
public AutoResetEvent ThreadEvent = new AutoResetEvent(false);
public byte[] recvBytes = new byte[1024];
public MemoryStream Stream1 = new MemoryStream();
public Socket c;
public AMFMessage SendMsg;
public AcknowledgeMessage ReceMsg;
public object ReslutValue = null;
public SocketSendReceiveMs()//构造函数
{
c = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
c.ReceiveTimeout = 100;
}
}
private void Btn_SendAMF_Click(object sender, EventArgs e)
{
SocketSendReceiveMs ssrems = new SocketSendReceiveMs();
string sendString = "POST /dynasty/messagebroker/amf HTTP/1.1
Accept: */*
Accept-Language: zh-CN
Referer:" + txt_Referer.Text.Trim() + "
x-flash-version: 11,5,502,110
Content-Type: application/x-amf
Accept-Encoding: gzip, deflate
Host:"+txt_Host.Text+"
"
+ "User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; Trident/4.0; EmbeddedWB 14.52 from: http://www.bsalsa.com/ EmbeddedWB 14.52; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0)
"
+ "Connection: Keep-Alive
Content-Length:57
"
+ "Cache-Control: no-cache
"
+ "Cookie:" + txt_Cook.Text.Trim() + "
";
Byte[] ByteGet = Encoding.ASCII.GetBytes(sendString);
MemoryStream _MemoryStream = new MemoryStream();
_MemoryStream.Write(ByteGet, 0, ByteGet.Length);
_MemoryStream.Write(bbb, 0, bbb.Length);
IPAddress _ip = IPAddress.Parse(txt_Ip.Text);
IPEndPoint EPhost = new IPEndPoint(_ip, 80);
ssrems.c = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
try
{
ssrems.c .Connect(EPhost);
}
catch
{
MessageBox.Show("对不起,链接出错!请检查网络链接!");
}
if (!ssrems.c.Connected)
{
MessageBox.Show("链接失败!");
}
try
{
ssrems.c.Send(_MemoryStream.ToArray(), _MemoryStream.ToArray().Length, 0);
ssrems.ThreadEvent.WaitOne(6000);
}
catch
{
MessageBox.Show("sorry!SendMessage Erro!");
}
try
{
ssrems.c.BeginReceive(ssrems.recvBytes, 0, 1024, SocketFlags.None, new AsyncCallback(EX), ssrems);
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
public void EX(IAsyncResult ar)
{
SocketSendReceiveMs tmpSRMsg = (SocketSendReceiveMs)ar.AsyncState;
int re = 0;
try
{
re = tmpSRMsg.c.EndReceive(ar);
tmpSRMsg.ThreadEvent.Set();
}
catch (Exception se)
{
MessageBox.Show("错误" + se.Message, "提示信息", MessageBoxButtons.RetryCancel, MessageBoxIcon.Information);
}
}
private void Form1_Load(object sender, EventArgs e)
{
if (File.Exists(Application.StartupPath + "/文本信息.txt"))
{
string hh = File.ReadAllText(Application.StartupPath + "/文本信息.txt", UTF8Encoding.UTF8);
string[] _ShuZu = hh.Split('~');
txt_Cook.Text = _ShuZu[0].ToString();
txt_Host.Text = _ShuZu[2].ToString();
txt_Referer.Text = _ShuZu[1].ToString();
txt_Ip.Text = _ShuZu[3].ToString();
txt_Respones.Text = _ShuZu[4].ToString();
txt_Target.Text = _ShuZu[5].ToString();
}
else
{
return;
}
}
private void Btn_SavePeiZhi_Click(object sender, EventArgs e)
{
string str = string.Format("{0}~{1}~{2}~{3}~{4}~{5}~",
txt_Cook.Text,
txt_Referer.Text,
txt_Host.Text,
txt_Ip.Text,
txt_Respones.Text,
txt_Target.Text);
File.WriteAllText(Application.StartupPath + "/文本信息.txt", str, UTF8Encoding.UTF8);
}
private void Btn_Close_Click_1(object sender, EventArgs e)
{
Application.Exit();
}
}
}
标红的地方即为不明之处。
生成了AMF消息,序列化为字节数组。
“byte[] pinjie = { 00, 00, 00, 12, 10, 00, 00, 00, 01, 17, 12, 09, 48, 130, 174, 83 };//需要拼接的参数”,从何而来,又是干什么用的。
水平有限
请高手指点