1. 程式人生 > >Java實現WinPcap+Wireshark資料抓包模擬聯通客戶端簽到功能

Java實現WinPcap+Wireshark資料抓包模擬聯通客戶端簽到功能

本編部落格通過WinPcap+Wireshark進行無線網路抓包,獲取基本資訊,進而模擬其他使用者的app請求。

本編部落格主要學習交流,其次告訴廣大網友切勿貪小便宜使用未知WiFi。

讀者們首先需要下載並安裝WinPcap和Wireshark,安裝Wireshark之前必須安裝winPcap,可以通過官網下載:

Wireshark :https://www.wireshark.org/download.html

WinPcap:http://www.winpcap.org/install/

1、安裝成功之後,使用360WiFi、獵豹WiFi等開放自己的WiFi,開啟Wireshark監測自己的無線網路


2、使用接入WIFI的裝置,這時將捕獲到裝置操作資訊。


通過捕獲到的資料包,可以查詢通訊的協議protocol、請求的資訊request以及響應資訊response等

3、通過前兩步,能過查詢資料資訊,接下來模擬一個客戶端,以聯通簽到領金幣為例,使用java實現,相關jar包及說明http://blog.csdn.net/myfmyfmyfmyf/article/details/46860025

package com;

import java.io.IOException;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.CookieStore;
import org.apache.http.client.HttpClient;
import org.apache.http.client.ResponseHandler;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;

/**
 * 
 * 
 * @author muyunfei
 * @qq  1147417467
 * <p>Modification History:</p> 
 * <p>Date       Author      Description</p>
 * <p>------------------------------------------------------------------</p>
 * <p>Oct 9, 2016           牟雲飛       		 新建</p>
 */
public class BugMain_chinaUnicom {
	
	public static  CookieStore cookieStore = null;
	
	public static void main(String[] args) {
		try{
			 HttpClient httpclient = HttpClients.createDefault();
			 HttpPost httpPost= new HttpPost("http://m.client.10010.com/SigninApp/signin/signInNow.htm");
//			 httpPost.setHeader("Cookie", "*****************0");
			 httpPost.setHeader("Cookie","**************");
			 httpPost.setHeader("User-Agent","Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36");
			 httpPost.setHeader("Accept","text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");
			 httpPost.setHeader("Host","m.client.10010.com");
			 httpPost.setHeader("Proxy-Connection","keep-alive");
			 // Create a custom response handler
			 ResponseHandler<String> responseHandler = new ResponseHandler<String>() {
				//成功呼叫連線後,對返回資料進行的操作
	            public String handleResponse(
	                    final HttpResponse response) throws ClientProtocolException, IOException {
	                int status = response.getStatusLine().getStatusCode();
	                if (status >= 200 && status < 300) {
	                	//獲得呼叫成功後  返回的資料
	                    HttpEntity entity = response.getEntity();
	                    if(null!=entity){
	                    	String result= EntityUtils.toString(entity);
	                    	System.out.println(result);
	                    	return result;
	                    }else{
	                    	return null;
	                    }
	                } else {
	                    throw new ClientProtocolException("Unexpected response status: " + status);
	                }
	            }
	
	        };
	      //返回的json物件
	        String responseBody = httpclient.execute(httpPost, responseHandler);
	        System.out.println(responseBody);
		}catch (Exception e) {
			e.printStackTrace();
		}
	}

}
呼叫結果: