监控链分析

此分析只用作学习用途
cnzz可以用来统计网页的相关信息,总结来说就是,ip,ua,时间这3个信息,那它是怎么统计的呢
1.在cnzz后台加一个自己的网站统计
具体步骤自己百度,挺简单的,这里不说了。
2.打开加了cnzz统计的网页进行分析

发现有3条cnzz相关的链接
第一条和第二条返回的是js文件
第3条是监控链,上传相关参数。相关参数的生成是根据反回的js文件生成的。
看下监控链里面的参数

11个参数,分别是
id,r,lg,ntime,cnzz_eid,showp,p,t,umuuid,h,rnd

1.id

这个值是cnzz给你网页生成的对应的唯一的值,不会变的,固定就好。

2.rnd

3.showp

屏幕的分辨率,可自己伪造

# 安卓的常见分辨率
screen = ["480*854*1.5", "1080*1920*2.6", "1440*2560*3.5", "720*1280*2.0", "1080*1920*3.0",
                  "1080*1920*3.0", "1080*1920*2.6", "1440*2560*3.5", "1440*2560*3.5", "1440*2960*4.0",
                  "1440*2960*4.0", "1440*2560*3.0", "1440*2560*3.0", "1080*1920*3.0", "1440*2560*4.0",
                  "1440*2560*4.0", "1080*1920*3.0", "1080*1920*3.0", "1440*2560*3.0", "1080*1920*3.0",
                  "1080*1920*3.0", "1080*1920*3.0", "1080*1920*3.0", "1080*1920*3.0", "720*1280*2.0",
                  "720*1280*2.0", "720*1280*2.0", "1080*2160*3.0", "1080*2040*3.0", "1080*1920*3.0",
                  "1080*1920*3.0", "1080*1920*3.0", "1080*1920*3.0", "1080*1920*3.0", "1080*1920*3.0",
                  "1080*1920*3.0", "720*1280*2.0", "1080*1920*3.0", "1080*1920*3.0", "1080*1920*3.0",
                  "1440*2560*4.0", "1800*2560*2.0", "1536*2048*2.0", "1536*2048*2.0", "480*854*1.5",
                  "1080*1920*2.6", "1440*2560*3.5", "720*1280*2.0", "1080*1920*3.0", "1080*1920*3.0",
                  "1080*1920*2.6", "1440*2560*3.5", "1440*2560*3.5", "1440*2960*4.0", "1440*2960*4.0",
                  "1440*2560*3.0", "1440*2560*3.0", "1080*1920*3.0", "1440*2560*4.0", "1440*2560*4.0",
                  "1080*1920*3.0", "1080*1920*3.0", "1440*2560*3.0", "1080*1920*3.0", "1080*1920*3.0",
                  "1080*1920*3.0", "1080*1920*3.0", "1080*1920*3.0", "720*1280*2.0", "720*1280*2.0",
                  "720*1280*2.0", "1080*2160*3.0", "1080*2040*3.0", "1080*1920*3.0", "1080*1920*3.0",
                  "1080*1920*3.0", "1080*1920*3.0", "1080*1920*3.0", "1080*1920*3.0", "1080*1920*3.0",
                  "720*1280*2.0", "1080*1920*3.0", "1080*1920*3.0", "1080*1920*3.0", "1440*2560*4.0",
                  "1800*2560*2.0", "1536*2048*2.0", "1536*2048*2.0"]
#ios常见分辨率
screen_ios = ["1125*2436*3.0", "1242*2208*3.0", "750*1334*2.0", "640*1136*2.0", "1536*2048*2.0",
                      "1536*2048*2.0", "1536*2048*2.0", "1668*2224*2.0", "2048*2732*2.0", "1125*2436*3.0",
                      "1242*2208*3.0", "750*1334*2.0", "640*1136*2.0", "1536*2048*2.0", "1536*2048*2.0",
                      "1536*2048*2.0", "1668*2224*2.0", "2048*2732*2.0"]
if str(ua).find("iPhone") == -1:
  r = random.randint(0, len(screen))
  width = int(screen[r].split("*")[0])
  height = int(screen[r].split("*")[1])
else:
  r = random.randint(0, len(screen_ios))
  width = int(screen_ios[r].split("*")[0])
  height = int(screen_ios[r].split("*")[1])
showp = str(height) + "x" + str(width)

4.p,t

p是你网页的地址
t是你当前网页的title

5.umuuid

生成的唯一的值
全局搜索umuuid
定位到参数
打上断点
重新加载页面
停止断点处

发现this.a.R就是那个值
在当前文件搜a.R

红框就是生成a.R值的地方,我们在601行打上断点

重新加载页面,停在601行,按步执行,进入m,
一直执行到405行
这里d是有值的,不过他是拿cookie的,我们要它的生成方法
这里我们把d制空后,他就会重新生成一个值
在下面控制台制空d,再下一步调试

进入fa

控制台输出一下 b() + "-" + Math.random().toString(16).replace(".", "") + "-" + a() + "-" + c + "-" + b()
发现就是这里生成的了,接下来就把它扣下来就行了
扣下来,再结合一下python就是这个样子

ua = 'Mozilla/5.0 (Linux; U; Android 6.0.1; zh-CN; SM-C7000 Build/MMB29M) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/40.0.2214.89 UCBrowser/11.6.2.948 Mobile Safari/537.36'
ctx = execjs.compile("""
            function b() {
                        for (var c = 1 * new Date, d = 0; c == 1 * new Date; )
                            d++;
                        return c.toString(16) + d.toString(16)
                    }
            function m(){
                return  Math.random().toString(16).replace(".", "");
            }
            function a(ua){
                function c(w, v) {
                        var r, y = 0;
                        for (r = 0; r < v.length; r++)
                            y |= k[r] << 8 * r;
                        return w ^ y
                    }
                var d = ua, f, k = [], n = 0;
                for (f = 0; f < d.length; f++) {
                    var u = d.charCodeAt(f);
                    k.unshift(u & 255);
                    4 <= k.length && (n = c(n, k),
                    k = [])
                }
                0 < k.length && (n = c(n, k));
                return n.toString(16)
            }
            function c(width,height){
                return (height * width).toString(16)
            }

            function d(D){
             return Math.floor(2147483648 * Math.random()) + "-" + D + "-" 
             }

             function rnd(){
                return  Math.floor(2147483648 * Math.random())
             }
        """)

        valueB1 = ctx.call("b")
        valueM = ctx.call("m")
        valueA = ctx.call("a", ua)
        valueC = ctx.call("c", width, height)
        valueB2 = ctx.call("b")
        umuuid = valueB1 + "-" + valueM + "-" + valueA + "-" + valueC + "-" + valueB2




6.cnzz_eid

把断点全部去掉
全局搜索cnzz_eid
进入,发现有5处地方有出现

明显,这个就是生成cnzz_eid的地方

url = 'https://s19.cnzz.com/z_stat.php?id=1272833594&web_id=1272833594'
ua = 'Mozilla/5.0 (Linux; U; Android 6.0.1; zh-CN; SM-C7000 Build/MMB29M) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/40.0.2214.89 UCBrowser/11.6.2.948 Mobile Safari/537.36'
header = {
    'User-Agent': ua
}
r = requests.get(url, headers=header, timeout=(1, 3))
D = r.text.split('this.D="')[1].split('"')[0]
 ctx = execjs.compile("""
            function d(D){
             return Math.floor(2147483648 * Math.random()) + "-" + D + "-" 
             }
        """)
cnzz_eid = ctx.call("d", str(D))

3.python模拟请求

整理一下上面的代码

import requests
import random
import execjs
import time

url = 'https://s19.cnzz.com/z_stat.php?id=1272833594&web_id=1272833594'
ua = 'Mozilla/5.0 (Linux; U; Android 6.0.1; zh-CN; SM-C7000 Build/MMB29M) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/40.0.2214.89 UCBrowser/11.6.2.948 Mobile Safari/537.36'
header = {
    'User-Agent': ua
}
r = requests.get(url, headers=header, timeout=(1, 3))
print(r.text)
D = r.text.split('this.D="')[1].split('"')[0]
print(D)
cookies = requests.utils.dict_from_cookiejar(r.cookies)
if r.status_code == 200:
    url = 'https://c.cnzz.com/core.php?web_id=1272833594&t=z'
    r = requests.get(url, headers=header, timeout=(1, 3), cookies=cookies)
    if r.status_code == 200:
        screen = ["480*854*1.5", "1080*1920*2.6", "1440*2560*3.5", "720*1280*2.0", "1080*1920*3.0",
                  "1080*1920*3.0", "1080*1920*2.6", "1440*2560*3.5", "1440*2560*3.5", "1440*2960*4.0",
                  "1440*2960*4.0", "1440*2560*3.0", "1440*2560*3.0", "1080*1920*3.0", "1440*2560*4.0",
                  "1440*2560*4.0", "1080*1920*3.0", "1080*1920*3.0", "1440*2560*3.0", "1080*1920*3.0",
                  "1080*1920*3.0", "1080*1920*3.0", "1080*1920*3.0", "1080*1920*3.0", "720*1280*2.0",
                  "720*1280*2.0", "720*1280*2.0", "1080*2160*3.0", "1080*2040*3.0", "1080*1920*3.0",
                  "1080*1920*3.0", "1080*1920*3.0", "1080*1920*3.0", "1080*1920*3.0", "1080*1920*3.0",
                  "1080*1920*3.0", "720*1280*2.0", "1080*1920*3.0", "1080*1920*3.0", "1080*1920*3.0",
                  "1440*2560*4.0", "1800*2560*2.0", "1536*2048*2.0", "1536*2048*2.0", "480*854*1.5",
                  "1080*1920*2.6", "1440*2560*3.5", "720*1280*2.0", "1080*1920*3.0", "1080*1920*3.0",
                  "1080*1920*2.6", "1440*2560*3.5", "1440*2560*3.5", "1440*2960*4.0", "1440*2960*4.0",
                  "1440*2560*3.0", "1440*2560*3.0", "1080*1920*3.0", "1440*2560*4.0", "1440*2560*4.0",
                  "1080*1920*3.0", "1080*1920*3.0", "1440*2560*3.0", "1080*1920*3.0", "1080*1920*3.0",
                  "1080*1920*3.0", "1080*1920*3.0", "1080*1920*3.0", "720*1280*2.0", "720*1280*2.0",
                  "720*1280*2.0", "1080*2160*3.0", "1080*2040*3.0", "1080*1920*3.0", "1080*1920*3.0",
                  "1080*1920*3.0", "1080*1920*3.0", "1080*1920*3.0", "1080*1920*3.0", "1080*1920*3.0",
                  "720*1280*2.0", "1080*1920*3.0", "1080*1920*3.0", "1080*1920*3.0", "1440*2560*4.0",
                  "1800*2560*2.0", "1536*2048*2.0", "1536*2048*2.0"]
        screen_ios = ["1125*2436*3.0", "1242*2208*3.0", "750*1334*2.0", "640*1136*2.0", "1536*2048*2.0",
                      "1536*2048*2.0", "1536*2048*2.0", "1668*2224*2.0", "2048*2732*2.0", "1125*2436*3.0",
                      "1242*2208*3.0", "750*1334*2.0", "640*1136*2.0", "1536*2048*2.0", "1536*2048*2.0",
                      "1536*2048*2.0", "1668*2224*2.0", "2048*2732*2.0"]
        if str(ua).find("iPhone") == -1:
            r = random.randint(0, len(screen))
            width = int(screen[r].split("*")[0])
            height = int(screen[r].split("*")[1])
        else:
            r = random.randint(0, len(screen_ios))
            width = int(screen_ios[r].split("*")[0])
            height = int(screen_ios[r].split("*")[1])

        ctx = execjs.compile("""
            function b() {
                        for (var c = 1 * new Date, d = 0; c == 1 * new Date; )
                            d++;
                        return c.toString(16) + d.toString(16)
                    }
            function m(){
                return  Math.random().toString(16).replace(".", "");
            }
            function a(ua){
                function c(w, v) {
                        var r, y = 0;
                        for (r = 0; r < v.length; r++)
                            y |= k[r] << 8 * r;
                        return w ^ y
                    }
                var d = ua, f, k = [], n = 0;
                for (f = 0; f < d.length; f++) {
                    var u = d.charCodeAt(f);
                    k.unshift(u & 255);
                    4 <= k.length && (n = c(n, k),
                    k = [])
                }
                0 < k.length && (n = c(n, k));
                return n.toString(16)
            }
            function c(width,height){
                return (height * width).toString(16)
            }

            function d(D){
             return Math.floor(2147483648 * Math.random()) + "-" + D + "-" 
             }

             function rnd(){
                return  Math.floor(2147483648 * Math.random())
             }
        """)

        valueB1 = ctx.call("b")
        valueM = ctx.call("m")
        valueA = ctx.call("a", ua)
        valueC = ctx.call("c", width, height)
        valueB2 = ctx.call("b")
        umuuid = valueB1 + "-" + valueM + "-" + valueA + "-" + valueC + "-" + valueB2
        # ntime = str(round(time.time()))
        ntime = "none"
        cnzz_eid = ctx.call("d", str(D))
        id = 1272833594
        r = ''
        t = '你的标题'
        showp = str(height) + "x" + str(width)
        p = '你的网址'
        rnd = ctx.call("rnd")
        url = 'https://z3.cnzz.com/stat.htm?id=' + str(id) + '&r=' + str(r) + '&lg=zh-cn&ntime=' + str(
            ntime) + '&cnzz_eid=' + cnzz_eid + '&showp=' + showp + '&p=' + p + '&t='+t+'&umuuid=' + umuuid + '&h=1&rnd=' + str(
            rnd)
        print(url)
        r = requests.get(url, headers=header, timeout=(1, 3), cookies=cookies)
        print(r.status_code)
        print(r.text)


这样cnzz后台就可以出数据了

你可能感兴趣的:(监控链分析)