1. 程式人生 > >Wireshark網路抓包實踐

Wireshark網路抓包實踐

1. 網路抓包相關閱讀

Wireshark

Wireshark

通過ping命令拿到網址的IP

Wireshark

過濾表示式的規則

表示式規則 規則說明
協議過濾 比如TCP,只顯示TCP協議
IP 過濾 比如 ip.src ==192.168.1.102 顯示源地址為192.168.1.102,ip.dst==192.168.1.102,目標地址為192.168.1.102
埠過濾 tcp.port ==80, 埠為80的; tcp.srcport == 80, 只顯示TCP協議的願埠為80的
Http模式過濾 http.request.method==”GET”, 只顯示HTTP GET方法的
邏輯運算子 AND/ OR

常用的過濾表示式

過濾表示式 用途
http 只檢視HTTP協議的記錄
ip.src ==192.168.1.102 過濾源ip地址是192.168.1.102
ip.dst==192.168.1.102 過濾目標ip地址是192.168.1.102
ip.src ==192.168.1.102 or ip.dst==192.168.1.102 源地址或者目標地址是192.168.1.102
http.request.method==”GET” 過濾get請求
http.request.method==”POST” 過濾post請求
http.request.method==”GET” and ip.dst==192.168.1.102

Wireshark抓包實戰

抓取某新聞客戶端的資料

注意事項

  • 在抓取資料之前先清除快取,快取會影響抓包

過濾get請求

通過ping命令獲取新聞資料的目標IP地址,封包資訊中網址帶有163可能就是新聞客戶端的url

拿到目標IP地址,就可以通過目標IP地址過濾資料

用瀏覽器開啟抓到的url,即可得到新聞的資料

新聞分類tid

其中tid是新聞類別的id,startindex是資料的起始索引,count是新聞資料的條數

  • 體育T1348649079062
  • 頭條T1467284926140
  • 娛樂T1348648517839
  • 要聞T1348647909107

新聞Tab標籤

{
    "tList": [
        {
            "template": "normal1",
            "topicid": "0001899N",
            "hasCover": false,
            "weburl": "http://www.163.com/",
            "alias": "Top News",
            "subnum": "3.2萬",
            "recommendOrder": 0,
            "isNew": 0,
            "hashead": 1,
            "img": "",
            "isHot": 0,
            "hasIcon": false,
            "cid": "C1348646712614",
            "recommend": "0",
            "headLine": true,
            "hasAD": 1,
            "color": "",
            "bannerOrder": 0,
            "tname": "頭條",
            "ename": "androidnews",
            "showType": "comment",
            "special": 0,
            "tid": "T1348647909107",
            "ad_type": 1
        },
        {
            "template": "normal1",
            "topicid": "0001899N;000187QQ",
            "hasCover": false,
            "alias": "yaowenspecial",
            "subnum": "10.6萬",
            "recommendOrder": 0,
            "isNew": 0,
            "hashead": 1,
            "img": "",
            "isHot": 0,
            "hasIcon": false,
            "cid": "C1348647991705",
            "recommend": "0",
            "headLine": false,
            "hasAD": 1,
            "color": "",
            "bannerOrder": 0,
            "tname": "要聞",
            "ename": "yaowenspecial",
            "showType": "comment",
            "special": 0,
            "tid": "T1467284926140",
            "ad_type": 1
        },
        {
            "template": "recommend",
            "topicid": "00037VVH",
            "hasCover": false,
            "weburl": "http://ent.163.com/",
            "alias": "Entertainment",
            "subnum": "超過1000萬",
            "recommendOrder": 120,
            "isNew": 0,
            "hashead": 1,
            "img": "T1348648517839",
            "isHot": 0,
            "hasIcon": true,
            "cid": "C1348648351901",
            "recommend": "1",
            "headLine": false,
            "hasAD": 1,
            "color": "",
            "bannerOrder": 0,
            "tname": "娛樂",
            "ename": "yule",
            "showType": "comment",
            "special": 0,
            "tid": "T1348648517839",
            "ad_type": 1
        }
    ]
}

json資料中的tid即為上文中的新聞類別id

新聞詳情頁

其中CG4A99320001899O是docid,如圖所示

docid