您的位置:首页 > 编程语言 > Java开发

Java实现WinPcap+Wireshark数据抓包模拟联通客户端签到功能

2017-01-20 14:53 746 查看
本编博客通过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();
}
}

}
调用结果:

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: