|
QQ农场是基于http协议的,因此只要通过工具软件截取http数据包,从而进一步进行分析提交和接收到的数据含义,然后再模拟一个flash client和服务器打交道即可。 为了实现以上目标,下载安装截获tcp/ip数据包的工具软件ethereal,安装好以后,登陆QQ进入农场,然后开启ethereal软件开始截获数据包,然后在农场里点刷新好友列表按钮,然后去ethereal里看看截获到的数据包,发现读取好友列表的url地址是: http://happyfarm.qzone.qq.com/api.php?mod=friend 需要的参数有:login_time 、skey、uin 三个 知道这个地址以后,可以用apache httpclient模拟一个flash client,具体代码如下:
String login_time = ConfigProperties.getProperty("login_time");
// 执行getMethod 按照这种方法,可以找到获取某个好友农场信息的url地址是: http://nc.qzone.qq.com/cgi-bin/cgi_farm_index?mod=user&act=run&ownerId= 偷某个好友某块或多块地的url地址是: http://nc.qzone.qq.com/cgi-bin/cgi_farm_steal?mod=farmlandstatus&act=scrounge ok,这些都搞定了,另外偷菜的 url地址需要提交一个参数farmKey,这个生成方法有点难度,具体方法为: int curTime = (int) (System.currentTimeMillis() / 1000L);
String s = "sdoit78sdopig7w34057"; 另外需要分析一下服务器返回的数据包格式,目前看到的都是 json格式, 比如得到好友列表的数据为: [{"userId":1905432,"userName":"\u6c38\u8fdc\u7684\u9ed1","headPic":"http:\/\/qlogo2.store.qq.com\/qzonelogo\/1265877\/1\/1242884728","yellowlevel":0,"yellowstatus":0,"exp":7776,"money":38961,"pf":0},{"userId":159805,"userName":"\u8f7b\u63cf\u6de1\u5199","headPic":"http:\/\/imgcache.qq.com\/qzone_v4\/client\/userinfo_icon\/5001.gif","yellowlevel":0,"yellowstatus":0,"exp":20332,"money":22665,"pf":0},{"userId":65178,"userName":"Air-F","headPic 后面省略... 如果是用java开发的话可以用json-lib包来解析。 另外根据返回的错误提示语整理如下:
如果返回{"code":0,"direction":"这块地没东西可摘的!","farmlandIndex":2,"fkey":"8297832f9f305bd1ad2d083c35148d815069b5c61da3382c0119b74f65b8e42e6d597313b9101acb","poptype":1}
如果返回的是{"code":0,"direction":"获取农田信息失败","fkey":"e3c2806e13df1092281157971b0f9466dcfbe7433a368f4d2398b0721398add7afc8c76f889555d5","poptype":0}
如果返回的是:{"code":0,"direction":"做人不能贪得无厌!","farmlandIndex":1,"fkey":"2848bb16cb28e1929822cb716b0e87292864ea9068ebe95b5d6d51580fb4b13718e3c2787af58294","poptype":1},{"code":0,"direction":"做人不能贪得无厌!","farmlandIndex":2,"poptype":1} 大致功能有: 1。我的资料,查看我的等级,经验,金钱等信息 2。我的农场:可以查看我的农场信息,种了哪些作物,什么时候成熟 3。我的仓库,可以浏览仓库里的物品,并可以卖掉 4。我的背包:可以浏览背包里的东西,并可以自动播铲(没用的种子种了马上铲掉又种获取经验) 5。我的装饰:查看我购买的所有装饰 6。商店:可以购买全部值得购买的装饰用品(没2点经验需要120块以内的装饰) 7。日志:偷窃日志,刷新日志,被狗咬日志等等 8。设置:可以按自己需要设置一些自动除草之类的东西
9。手机控制:可以利用手机短信警报你出入验证码,然后手机通过wap网站浏览验证码图片,输入验证码。(这样即使人不在电脑前,也可以用手机输入验证码了) ![]() C#代码如下:
//得到所有好友列表的c#代码:
public static int getFriendList() { string url = "http://happyfarm.qzone.qq.com/api.php?mod=friend";
Program.allFriend.Clear();
Program.mainFrm.myFriendList.Items.Clear(); try { int curTime = com.sourceware.util.DateUtil.getCurTime();//得到当前时间;
String s = "sdoit78sdopig7w34057";
int yushu = curTime % 10; s = s.Substring(yushu, 20 - yushu); String farmKey = com.sourceware.util.MD5Util.MD5(curTime + s); //以上是生成farmKey System.Net.WebClient wc = new System.Net.WebClient(); string uin = com.sourceware.util.IniProperties.getValue("login", "uin"); string skey = com.sourceware.util.IniProperties.getValue("login", "skey"); string login_time = com.sourceware.util.IniProperties.getValue("login", "login_time"); wc.Headers.Add(System.Net.HttpRequestHeader.Cookie, "uin=" + uin + ";skey=" + skey + ";login_time=" + login_time); //以上是session值,每次提交必须把这3个参数放到cookie当中提交。 System.Collections.Specialized.NameValueCollection coll = new System.Collections.Specialized.NameValueCollection(); coll.Add("user", "true"); coll.Add("farmTime", "" + curTime); coll.Add("farmKey", farmKey.ToLower()); coll.Add("refresh", "true"); //以上是得到好友列表必须post的参数
byte[] b = wc.UploadValues(url, coll);
ServerUtil.trickConnect2server();
String result = System.Text.Encoding.UTF8.GetString(b);
//得到服务器返回的内容,为 json格式,可以用json4net分析它; return 0; }catch (Exception ex) {
log.Error(ex.Message + ex.StackTrace);
return -2;
}
} |
