開心網刷分程序詳解以及web遊戲破解思路分析(二)

 

************本人水平有限,在學習時請用批判的態度學習,有問題給我留言************

開心網刷分程序詳解以及 web 遊戲破解思路分析(二)

 

1 、黃開刷分程序提交失敗,他們更改了遊戲限制的策略,經過對截取的 http 請求的分析得出,他們在請求中加入了對 referer 的驗證,如何模擬請求頭中的 referer 呢,在老牌請求包 apache commons httpclient 中沒有設置 referer 請求的實現方法。

上網搜索,查詢到用 java.net 包中的類就能搞定,混合提交也可以應用,就是先用 httpclient 提交請求,然後用 java.net 中的類提交,最後還是用 httpclient 提交,沒問題,搞定。

最後需要寫個定時提交,需要隔一段時間提交一次,隔多長時間要看你的遊戲玩了多長時間

 

需要用到的包和配置文件:

commons-codec.jar

commons-httpclient.jar

commons-logging.jar

commons-logging.properties

js.jar

log4j-1.2.8.jar

log4j.properties

 

2 、現在公佈程序源代碼:

************** 程序中賬號、密碼、遊戲名稱等參數可以做相應的更改 **************

定時執行類:

package httpClint;

import java.text.SimpleDateFormat;

/**
 * 定時
 * @author caohua
 */
public class FormLoginDemo {
    private static java.util.Timer timer = new java.util.Timer(false);
    public static void startTimer() {
        timer.schedule(new timerTask(), 0, 30000);
        System.out.println("start:");
    }
    public static void stopTimer() {
        timer.cancel();
        System.out.println("stop:");
    }
    public static void main(String args[]) {
        System.out.println("開始刷分:"
                + new SimpleDateFormat("yyyy-MM-dd:HH:mm:ss"));
        timer.schedule(new timerTask(), 0, 30000);
    }
}

 

提交類

package httpClint;

import java.io.IOException;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimerTask;

import org.apache.commons.httpclient.Header;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpException;
import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.httpclient.NameValuePair;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.methods.PostMethod;

public class timerTask extends TimerTask {

    static final String LOGON_SITE = "login.kaixin.com";

    static final int LOGON_PORT = 80;

    public timerTask() {}

    public void run() {
      
        try{
            HttpClient client = new HttpClient();
            client.getHostConfiguration().setHost(LOGON_SITE, LOGON_PORT);
            PostMethod post = new PostMethod("/Login.do");
            NameValuePair name = new NameValuePair("email", "[email protected]");
            NameValuePair pass = new NameValuePair("password", "111111");
            post.setRequestBody(new NameValuePair[] { name, pass });// 設置post參數
            client.executeMethod(post);// 執行post方法
            post.releaseConnection(); // 關閉連接
  
            // 檢查是否重定向
            int statuscode = post.getStatusCode();// 得到相應狀態碼
  
            // 判斷是否是請求轉發 是的話請求轉發的地址
            if ((statuscode == HttpStatus.SC_MOVED_TEMPORARILY)
                    || (statuscode == HttpStatus.SC_MOVED_PERMANENTLY)
                    || (statuscode == HttpStatus.SC_SEE_OTHER)
                    || (statuscode == HttpStatus.SC_TEMPORARY_REDIRECT)) {
                // 讀取新的URL地址
                Header header = post.getResponseHeader("location");
                if (header != null) {
                    String newuri = header.getValue();
                    if ((newuri == null) || (newuri.equals("")))
                        newuri = "/";
                    GetMethod redirect = new GetMethod(newuri);
                    client.executeMethod(redirect);// 請求轉發的地址
                    redirect.releaseConnection();
  
                } else
                    System.out.println("error");
            }
  
            runGetMethod(client, "http://xyx.kaixin.com/?mm_id=49");// 請求模塊url
            runGetMethod(client,
                    "http://xyx.kaixin.com/upload/detail.php?game=puppyred_2");// 請求遊戲url
  
            runPostMethod();// 發送帶referer的請求
  
            // 計算時間 提交時服務器端會判斷時間是否是開始時間減結束時間
            long l = new Date().getTime();
            String starttime1 = String.valueOf(l);
            l = l + 230000;// 對應playertime
            String endtime = String.valueOf(l);
  
            // Thread.sleep(23000);
  
            PostMethod post1 = new PostMethod(
                    "http://xyx.kaixin.com/upload/plugins.php");
            // 加入請求參數
            NameValuePair bonus = new NameValuePair("bonus", "0");
            NameValuePair level = new NameValuePair("level", "7");
            NameValuePair fscore = new NameValuePair("fscore", "7210");
            NameValuePair playertime = new NameValuePair("playertime", endtime);
            NameValuePair playedtime = new NameValuePair("playedtime", "23");
            NameValuePair starttime = new NameValuePair("starttime", starttime1);
            NameValuePair action1 = new NameValuePair("action", "swfrecord");
            NameValuePair game1 = new NameValuePair("game", "puppyred_2");
            NameValuePair p1 = new NameValuePair("p", "nkflash");
  
            post1.setRequestBody(new NameValuePair[] { bonus, level, fscore,
                    playertime, playedtime, starttime, action1, game1, p1 });
            client.executeMethod(post1);// 發送請求
            post1.releaseConnection();
  
            // 請求遊戲首頁 得到當前分數
            GetMethod get1 = new GetMethod("http://xyx.kaixin.com/index.php");
            client.executeMethod(get1);
  
            String responsekaixin2 = get1.getResponseBodyAsString();
            int i1 = responsekaixin2.lastIndexOf("牛糞");
            System.out.print("您現在有:" + responsekaixin2.substring( i1 - 4 , i1) + "牛糞了!" );
            System.out.println("   " + new SimpleDateFormat("yyyy-MM-dd:HH:mm:ss").format(new Date()));
            get1.releaseConnection();
        }catch(Exception e){
            e.printStackTrace();
        }
    }
 
    /**
     * 發送get請求的方法
     * @param client
     * @param url
     * @return
     * @throws HttpException
     * @throws IOException
     */
    public static GetMethod runGetMethod(HttpClient client , String url) throws HttpException, IOException{
        GetMethod get1 = new GetMethod(url);
        client.executeMethod(get1);
        get1.releaseConnection();
      
        return get1;
    }
  
    /**
     * 發送帶referer的post請求
     * @throws IOException
     */
    public static void runPostMethod() throws IOException{
      
        URL url = new URL("http://xyx.kaixin.com/getMessageInfo.do");
        HttpURLConnection connection = null;
        connection = (HttpURLConnection) url.openConnection();
        //設置允許output
        connection.setDoOutput(true);
        //設置爲post方式
        connection.setRequestMethod("POST");
      
        connection.setRequestProperty("referer", "http://xyx.kaixin.com/upload/detail.php?game=puppyred_2");
        StringBuffer sb = new StringBuffer();
        sb.append("referrer="+"xyx");
      
        //post信息
        OutputStream os = connection.getOutputStream();
        os.write(sb.toString().getBytes("GBK"));
        os.close();
      
    }

}


配置文件 1  commons-logging.properties

 org.apache.commons.logging.simplelog.defaultlog=error
org.apache.commons.logging.Log=org.apache.commons.logging.impl.Log4JCategoryLog

配置文件 2  log4j.properties

 log4j.rootCategory=fatal, stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%5p [%d] %c{2} /"%m/"%n

 

java工程源碼下載:http://download.csdn.net/source/1474043

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章