首頁 網絡安全Linux服務器被黑遭敲詐,3小時緊急逆襲!

Linux服務器被黑遭敲詐,3小時緊急逆襲!

運維派隸屬馬哥教育旗下專業運維社區,是國內成立最早的IT運維技術社區,歡迎關注公眾號:yunweipai
領取學習更多免費Linux云計算、Python、Docker、K8s教程關注公眾號:馬哥linux運維

作者介紹

陳浩,北信源研發工程師,五年Linux運維工作經驗,熱衷運維技術研究、實踐和團隊分享。

1.起因

本來在家正常休息了,我們放在上海托管機房的線上服務器突然崩了遠程不了,服務啟動不了,然后讓上海機房重啟了一次,還是直接掛了,一直到我遠程上才行。

2.現象

遠程服務器發現出現這類信息

Hi,?please?view:?http://pastie.org/pastes/10800563/text?key=hzzm4hk4ihwx1jfxzfizzq?for?further?information?in?regards?to?your?files!
Hi,?please?view:?http://pastie.org/pastes/10800563/text?key=hzzm4hk4ihwx1jfxzfizzq?for?further?information?in?regards?to?your?files!
Hi,?please?view:?http://pastie.org/pastes/10800563/text?key=hzzm4hk4ihwx1jfxzfizzq?for?further?information?in?regards?to?your?files!
Hi,?please?view:?http://pastie.org/pastes/10800563/text?key=hzzm4hk4ihwx1jfxzfizzq?for?further?information?in?regards?to?your?files!
Hi,?please?view:?http://pastie.org/pastes/10800563/text?key=hzzm4hk4ihwx1jfxzfizzq?for?further?information?in?regards?to?your?files!
Hi,?please?view:?http://pastie.org/pastes/10800563/text?key=hzzm4hk4ihwx1jfxzfizzq?for?further?information?in?regards?to?your?files!

登錄信息,然后翻墻去了國外網站查看

Linux

這個意思大概是:

問候,
你的服務器被黑客攻擊和你的文件已經被刪除了。
他們被刪除之前,我們支持我們的服務器控制。
你必須發送總共3?BTC地址:1?b1ou6edreyffif3*******
不這么做將導致文件被刪除后5天。
我們也可能泄露你的文件。

你可以通過電子郵件與onewayout@sigaint.org聯系。我們不會提供任何文件之前付款。
再見!

3.開始排查

首先檢查日志,以前做過安全運維,所以寫過類似于檢查命令和工具,開始一一排查。

#查看是否為管理員增加或者修改
find / -type f -perm 4000
#顯示文件中查看是否存在系統以外的文件
rpm -Vf /bin/ls
rpm -Vf /usr/sbin/sshd
rpm -Vf /sbin/ifconfig
rpm -Vf /usr/sbin/lsof
#檢查系統是否有elf文件被替換
#在web目錄下運行
grep -r “getRuntime” ./
#查看是否有木馬
find . -type f -name “*.jsp” | xargs grep -i ?“getRuntime”
#運行的時候被連接或者被任何程序調用
find . -type f -name “*.jsp” | xargs grep -i ?“getHostAddress”
#返回ip地址字符串
find . -type f -name “*.jsp” | xargs grep -i ?“wscript.shell”
#創建WshShell對象可以運行程序、操作注冊表、創建快捷方式、訪問系統文件夾、管理環境變量
find . -type f -name “*.jsp” | xargs grep -i ?“gethostbyname”
#gethostbyname()返回對應于給定主機名的包含主機名字和地址信息的hostent結構指針
find . -type f -name “*.jsp” | xargs grep -i ?“bash”
#調用系統命令提權
find . -type f -name “*.jsp” | xargs grep -i ?“jspspy”
#Jsp木馬默認名字
find . -type f -name “*.jsp” | xargs grep -i ?“getParameter”
fgrep – R “admin_index.jsp” 20120702.log > log.txt
#檢查是否有非授權訪問管理日志
#要進中間件所在日志目錄運行命令
fgrep – R “and1=1″*.log>log.txt
fgrep – R “select “*.log>log.txt
fgrep – R “union “*.log>log.txt
fgrep – R “../../”*.log >log.txt
fgrep – R “Runtime”*.log >log.txt
fgrep – R “passwd”*.log >log.txt
#查看是否出現對應的記錄
fgrep – R “uname -a”*.log>log.txt
fgrep – R “id”*.log>log.txt
fgrep – R “ifconifg”*.log>log.txt
fgrep – R “ls -l”*.log>log.txt
#查看是否有shell攻擊
#以root權限執行
cat /var/log/secure
#查看是否存在非授權的管理信息
tail -n 10 ?/var/log/secure
last cat /var/log/wtmp
cat /var/log/sulog
#查看是否有非授權的su命令
cat /var/log/cron
#查看計劃任務是否正常
tail -n 100 ~./bash_history | more
查看臨時目錄是否存在攻擊者入侵時留下的殘余文件
ls -la /tmp
ls -la /var/tmp
#如果存在.c .py .sh為后綴的文件或者2進制elf文件。
IP地址
檢查出有點類似于黑客的IP,只能猜測然后查看IP地址過濾出這個IP的訪問信息并查看IP地址是那邊的。

Apr 17 03:14:56 localhost sshd[11499]: warning: /etc/hosts.deny, line 14: missing “:” separator
Apr 17 03:15:01 localhost sshd[11499]: Address 46.214.146.198 maps to 46-214-146-198.next-gen.ro, but this does not map back to the address – POSSIBLE BREAK-IN ATTEMPT!
Apr 17 03:15:01 localhost sshd[11499]: Invalid user ubnt from 46.214.146.198
Apr 17 03:15:01 localhost sshd[11500]: input_userauth_request: invalid user ubnt
Apr 17 03:15:01 localhost sshd[11499]: pam_unix(sshd:auth): check pass; user unknown
Apr 17 03:15:01 localhost sshd[11499]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=46.214.146.198?
Apr 17 03:15:01 localhost sshd[11499]: pam_succeed_if(sshd:auth): error retrieving information about user ubnt
Apr 17 03:15:03 localhost sshd[11499]: Failed password for invalid user ubnt from 46.214.146.198 port 34989 ssh2
Apr 17 03:15:03 localhost sshd[11500]: Connection closed by 46.214.146.198
Linux服務器被黑遭敲詐,3小時緊急逆襲!插圖2
就是他了,查看歷史記錄。日志發現 Invalid user ubnt from 46.214.146.198。

歷史記錄和相關訪問日志已經被刪除,痕跡清除。

安裝chrootkit檢查是否有rootkit
mkdir?chrootkit
cd?chrootkit/
wget?ftp://ftp.pangeia.com.br/pub/seg/pac/chkrootkit.tar.gz
tar?zxvf?chkrootkit.tar.gz?
cd?chkrootkit-0.50/
ls
yum?install?-y?glibc-static
make?sense
./chkrootkit
發現檢查沒有異常Linux服務器被黑遭敲詐,3小時緊急逆襲!插圖3

打開 vi /etc/motd 發現

[root@mall?~]#?vi?/etc/motd?
Hi,?please?view:?http://pastie.org/pastes/10800563/text?key=hzzm4hk4ihwx1jfxzfizzq?for?further?information?in?regards?to?your?files!
Hi,?please?view:?http://pastie.org/pastes/10800563/text?key=hzzm4hk4ihwx1jfxzfizzq?for?further?information?in?regards?to?your?files!
Hi,?please?view:?http://pastie.org/pastes/10800563/text?key=hzzm4hk4ihwx1jfxzfizzq?for?further?information?in?regards?to?your?files!
Hi,?please?view:?http://pastie.org/pastes/10800563/text?key=hzzm4hk4ihwx1jfxzfizzq?for?further?information?in?regards?to?your?files!
Hi,?please?view:?http://pastie.org/pastes/10800563/text?key=hzzm4hk4ihwx1jfxzfizzq?for?further?information?in?regards?to?your?files!
Hi,?please?view:?http://pastie.org/pastes/10800563/text?key=hzzm4hk4ihwx1jfxzfizzq?for?further?information?in?regards?to?your?files!
查找不出后門也找不到相關命令,感覺思路受損,暈頭轉向。最后查找下當天的Web訪問日志和相關IP訪問。

發現一條命令讓我好奇,GET /cgi-bin/center.cgi?id=20 HTTP/1.1。

并且有點異常

漏洞

發現像目前最流行的bash shell 漏洞,測試一下,果然存在漏洞。

4.修復升級命令

yum -y install yum-downloadonly

yum -y install bash-4.1.2-33.el6_7.1.x86_64.rpm

[root@mall tmp]# yum -y install bash-4.1.2-33.el6_7.1.x86_64.rpm

已加載插件:fastestmirror,security

設置安裝進程

診斷 bash-4.1.2-33.el6_7.1.x86_64.rpm: bash-4.1.2-33.el6_7.1.x86_64

bash-4.1.2-33.el6_7.1.x86_64.rpm 將作為 bash-4.1.2-15.el6_4.x86_64 的更新

Loading mirror speeds from cached hostfile

* base: ftp.sjtu.edu.cn

* extras: mirrors.skyshe.cn

* updates: ftp.sjtu.edu.cn

解決依賴關系

–> 執行事務檢查

—> Package bash.x86_64 0:4.1.2-15.el6_4 will be 升級

—> Package bash.x86_64 0:4.1.2-33.el6_7.1 will be an update

–> 完成依賴關系計算

依賴關系解決

================================

總文件大?。?.0 M

下載軟件包:

運行 rpm_check_debug

執行事務測試

事務測試成功

執行事務

正在升級 ? : bash-4.1.2-33.el6_7.1.x86_64

清理 : bash-4.1.2-15.el6_4.x86_64

Verifying ?: bash-4.1.2-33.el6_7.1.x86_64

Verifying ?: bash-4.1.2-15.el6_4.x86_64

更新完畢:

bash.x86_64 0:4.1.2-33.el6_7.1

完畢!

重新測試

[root@mall tmp]# env x='() { :;}; echo vulnerable’ bash -c “echo this is a test”

this is a test

5.完成后做了如下措施

  1. 修改了系統賬號密碼;
  2. 修改了sshd端口為2220;
  3. 修改Nginx用戶nologin;
  4. 發現系統服務器存在bash嚴重漏洞 破殼漏洞(Shellshock)并修復;
  5. 更新完成后沒有發現被入侵或者服務器自動宕機現象。

6.漏洞被利用過程

我發送GET請求–>目標服務器cgi路徑

目標服務器解析這個get請求,碰到UserAgent后面的參數,Bash解釋器就執行了后面的命令。

7.Shellshock介紹

Shellshock,又稱Bashdoor,是在Unix中廣泛使用的Bash shell中的一個安全漏洞,首次于2014年9月24日公開。許多互聯網守護進程,如網頁服務器,使用bash來處理某些命令,從而允許攻擊者在易受攻擊的Bash版本上執行任意代碼。這可使攻擊者在未授權的情況下訪問計算機系統。

本文鏈接:http://www.royaladd.com/22780.html

網友評論comments

發表回復

您的電子郵箱地址不會被公開。

  1. 行動派說道:

    然而, 文件恢復了嗎?

Copyright ? 2012-2022 YUNWEIPAI.COM - 運維派 京ICP備16064699號-6
掃二維碼
掃二維碼
返回頂部
欧美激情视频一区二区|国产精品毛片va一区二区|999国内精品永久免费|国产无码sm视频在线观看