C # QQ Farm plug-in development practices

Source: Internet
Author: User

I was bored during the National Day when I watched other people play on the farm. I also activated it and found that the money was not enough and it was very troublesome to steal it. So I wanted to write a program to steal food automatically, so with this article:

QQ Farm is based on the http protocol. Therefore, you only need to intercept http data packets through tools to further analyze the meaning of submitted and received data, and then simulate a flash client to deal with the server.

To achieve this goal, download and install the tool ethereal, which intercepts TCP/IP data packets. After installation, log on to QQ to enter the farm and enable ethereal to intercept data packets, then, click the refresh friends list button in the farm, and then go to ethereal to check the intercepted data packets. The url to read the friends list is:

Http://happyfarm.qzone.qq.com/api.php? Mod = friend

The required parameters include login_time, skey, and uin.

After knowing the address, you can use apache httpclient to simulate a flash client. The specific code is as follows:

String login_time = ConfigProperties. getProperty ("login_time ");
String skey = ConfigProperties. getProperty ("skey ");
String _ s _ = ConfigProperties. getProperty ("_ s _");
String uin = ConfigProperties. getProperty ("uin ");
HttpClient hc = new HttpClient ();
// Create an instance of the GET Method
GetMethod getMethod = new GetMethod (url );
//
GetMethod. addRequestHeader ("Accept ","*/*");
GetMethod
. AddRequestHeader (
"User-Agent ",
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1;. net clr 1.1.4322;. net clr 2.0.50727; 360SE )");
GetMethod. addRequestHeader ("Accept-Encoding", "gzip, deflate ");
GetMethod. addRequestHeader ("Accept-Language", "zh-CN ");
GetMethod. addRequestHeader ("Connection", "Keep-Alive ");
GetMethod. addRequestHeader ("Pragma", "no-cache ");
Hc. getState (). clearCookies ();
//
String cookies = "1" + "; _ s _ =" + _ s _ + "; uin =" + uin + "; skey ="
+ Skey + "; login_time =" + login_time;
Hc. getState (). addCookie (
New Cookie ("happyfarm.qzone.qq.com", "jump", cookies ,"/",
New Date (2011, 12, 8), false ));

// Execute getMethod
Int statusCode = hc.exe cuteMethod (getMethod );
//
String result = getMethod. getResponseBodyAsString ();

In this way, you can find the url of a friend farm information:

Http://nc.qzone.qq.com/cgi-bin/cgi_farm_index? Mod = user & act = run & ownerId =

The url used to steal a friend from one or more places is:

Http://nc.qzone.qq.com/cgi-bin/cgi_farm_steal? Mod = farmlandstatus & act = scrounge

Okay, all of this is done. In addition, you need to submit a parameter farmKey for the url address of the food stealing. This method is difficult to generate. The specific method is as follows:

Int curTime = (int) (System. currentTimeMillis ()/1000L );

String s = "sdoit78sdopig7w34057 ";
Int yushu = curTime % 10;
S = s. substring (yushu, 20 );
String farmKey = com. sourceware. util. StringUtil
. GetMD5 (curTime + s );
 

In addition, you need to analyze the data packet format returned by the server. Currently, all data packets are in json format,

For example, the data in the friend list is:

[{"UserId": 1905432, "userName": "u6c38u8fdcu7684u9ed1", "headPic": "http://qlogo2.store.qq.com/qzonelogo/1265877/1/1242884728", "yellowlevel": 0, "yellowstatus": 0, "exp ": 7776, "money": 38961, "pf": 0 },{ "userId": 159805, "userName": "u8f7bu63cfu6de1u5199", "headPic": "http://imgcache.qq.com/qzone_v4/client/userinfo_icon/5001.gif ", "yellowlevel": 0, "yellowstatus": 0, "exp": 20332, "currency": 22665, "pf": 0 },{ "userId": 65178, "userName": "Air-F", "headPic is omitted...

If java is used for development, you can use the json-lib package for parsing.

In addition, sort the returned error prompts as follows:

If {"code": 0, "direction": "is returned, nothing can be picked! "," FarmlandIndex ": 2," fkey ":" success "," poptype ": 1}
It should be that this land is mature and has been stripped (mature land has a yield, a surplus, and a minimum surplus. Here we can get a maximum of several stolen items).

If {"code": 0, "direction": "failed to retrieve Farmland Information", "fkey": "success", "poptype": 0} is returned}
It should be that this land has been stolen before it is mature; or it has been harvested by the master; or there is nothing to plant in this land;

If {"code": 0, "direction": "cannot be greedy! "," FarmlandIndex ": 1," fkey ":" empty "," poptype ": 1 },{" code ": 0," direction ":" You cannot be greedy! "," FarmlandIndex ": 2," poptype ": 1}
It indicates that you have already stolen it and want to steal it;

Functions:

1. My information, view my level, experience, money, and other information

2. My farm: Check my farm information, what crops are planted, and when they are mature.

3. My repository can view items in the repository and sell them.

4. My backpack: You can browse the items in the backpack and play the shovel automatically (useless seeds are immediately removed and experience is obtained)

5. My decorations: view all the decorations I purchased

6. Store: You can purchase all the decorative products worth buying (less than 120 pieces of decoration are required for less than 2 points of experience)

7. Logs: steal logs, refresh logs, and be bitten by dogs

8. Setting: You can set Automatic weeding and other things as needed.

9. Mobile phone control: You can use text message alerts to send and receive verification codes. Then, the mobile phone browses the verification code image through the wap website and enters the verification code. (In this way, even if a person is not in front of the computer, you can enter the verification code on your mobile phone)
 


C # The Code is as follows: // obtain the c # code of all friends list:
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 (); // obtain the current time; String s = "sdoit78sdopig7w34057 ";
Int yushu = curTime % 10;
S = s. Substring (yushu, 20-yushu );
& N

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.