基於docker的蜜罐學習

信安之路發表於2017-10-26

本文作者:J_drops

首發:微信公眾號【信安之路】

 

學習蜜罐之間先介紹兩個概念,低互動式蜜罐和高互動式蜜罐。

 

低互動式蜜罐

 

低互動式蜜罐只是模擬出了真正作業系統的一部分,例如模擬一個 FTP 服務。雖然低互動式蜜罐容易建立和維護,但模擬可能不足以吸引攻擊者,還可能導致攻擊者繞過系統發起攻擊,從而使蜜罐在這種情況下失效。

 

高互動式蜜罐

 

高互動式蜜罐是一部裝有真正作業系統,並可完全被攻破的系統。與攻擊者進行互動的是一部包含了完整服務的真實系統。用於網路安全的高互動式蜜罐提供了真實作業系統的服務和應用程式,使其可以獲得關於攻擊者更可靠的資訊。但是部署和維護起來十分困難,而且被攻破的系統可能會被用來攻擊網際網路上其他的系統,這必須承擔很高的風險。 資料收集是設定蜜罐的技術挑戰。蜜罐監控者只要記錄下進出系統的每個資料包,就能夠對黑客的所作所為一清二楚。蜜罐本身上面的日誌檔案也是很好的資料來源。但日誌檔案很容易被攻擊者刪除,所以通常的辦法就是讓蜜罐向在同一網路上但防禦機制較完善的遠端系統日誌伺服器傳送日誌備份。(務必同時監控日誌伺服器。如果攻擊者用新手法闖入了伺服器,那麼蜜罐無疑會證明其價值。)

蜜罐的優點

蜜罐系統的優點之一就是它們大大減少了所要分析的資料。對於通常的網站或郵件伺服器,攻擊流量通常會被合法流量所淹沒。而蜜罐進出的資料大部分是攻擊流量。因而,瀏覽資料、查明攻擊者的實際行為也就容易多了。

安裝步驟

root@ubuntu:~# mkdir DROPS

root@ubuntu:~#apt-get install python-dev openssl python-openssl python-pyasn1 python-twisted python-mysqldb

root@ubuntu:~# cd DROPS/

root@ubuntu:~/ DROPS# svn checkout

安全配置


新增一個獨立的使用者組給 drops:

root@ubuntu:~/ DROPS# useradd -s /bin/bash -d /home/DROPS -m DROPS

新增一個獨立的 MYSQL 使用者給 drops:

1.webp.jpg

 

帳號和資料庫一樣密碼 123456

匯入預設資料庫

root@ubuntu:~/DROPS# cd doc/sql/

root@ubuntu:~/ DROPS /doc/sql# ls

mysql.sql update2.sql update3.sql update4.sql update5.sql update6.sql

root@ubuntu:~/DROPS/doc/sql# mysql -udrops -p123456 drops < mysql.sql

編輯配置 kippo.cfg.dist

root@ubuntu:~/DROPS# mv drops.cfg.dist drops.cfg

 

編輯之後如下(可以點選原文連結檢視完整配置):

 

2.webp.jpg

 

安裝監聽工具

root@ubuntu:~/DROPS # apt-get install authbind

 

配置

root@ubuntu:~/DROPS # chown drops: drops /etc/authbind/byport/22

root@ubuntu:~/DROPS # chmod 777 /etc/authbind/byport/22

root@ubuntu:~/ DROPS # chown -R drops: drops /root/drops/

 

建立一個啟動指令碼

root@ubuntu:~/DROPS# echo "twistd -y drops.tac -l log/drops.log --pidfile drops.pid" > 1.sh

root@ubuntu:~/DROPS# cat 1.sh

twistd -y drops.tac -l log/kippo.log --pidfile drops.pid

 

移動工具位置

root@ubuntu:~# mv DROPS / /opt/

root@ubuntu:~# cd /opt/

root@ubuntu:/opt# ls

DROPS

root@ubuntu:/opt# cd DROPS /

 

更改下 DROPS 使用者密碼,切換到 DROPS

root@ubuntu:~/kippo# passwd DROPS

Enter new UNIX password:

Retype new UNIX password:

passwd: password updated successfully

root@ubuntu:~/DROPS# su DROPS

DROPS@ubuntu:/root/DROPS$ id

uid=1002(DROPS) gid=1002(DROPS) groups=1002(DROPS)

DROPS@ubuntu:/root/DROPS$

 

啟動

DROPS@ubuntu:/opt/DROPS$ pwd

/opt/DROPS

kippo@ubuntu:/opt/DROPS$ ./start.sh

Starting drops in background...Loading dblog engine: mysql

Generating RSA keypair...

done.

 

3.webp.jpg

 

檢視監聽的埠

 

4.webp.jpg

 

5.webp.jpg

 

查詢 2222 埠的程式

kippo@ubuntu:/opt/DROPS$ ps -ef | grep 4615

kippo 4615 1 0 13:47 ? 00:00:00 /usr/bin/python /usr/bin/twistd -y drops.tac -l log/kippo.log --pidfile drops.pid

drops 4626 4588 0 13:48 pts/0 00:00:00 grep --color=auto 4615

 

掃描測試一下

root@Dis9Team:~# nmap -sV 192.168.1.10 -p 2222

Nmap scan report for 192.168.1.10

Host is up (0.00024s latency).

PORT STATE SERVICE VERSION

2222/tcp open ssh OpenSSH 5.1p1 Debian 5 (protocol 2.0)

MAC Address: 00:0C:29:9E:3F:14 (VMware)

Service Info: OS: Linux

Service detection performed. Please report any incorrect results at Nmap done: 1 IP address (1 host up) scanned in 0.40 seconds

root@Dis9Team:~#

 

OPENSSH 服務出現了。

 

drops 的配置檔案的密碼定義為 123456 測試一下:

root@Dis9Team:~# ssh root@192.168.1.10 -p2222

The authenticity of host '[192.168.1.10]:2222 ([192.168.1.10]:2222)' can't be established.

RSA key fingerprint is d9:f0:74:99:58:5e:32:74:a1:7b:27:78:2e:b1:83:a8.

Are you sure you want to continue connecting (yes/no)? yes

Warning: Permanently added '[192.168.1.10]:2222' (RSA) to the list of known hosts.

Password:

Password:

ubuntu:~# id

uid=0(root) gid=0(root) groups=0(root)

ubuntu:~#

 

邪惡的操作:

 

6.webp.jpg

 

刪除全部檔案:

 

7.webp.jpg

 

刪除不了 讀下預設檔案

 

8.webp.jpg

 

至此一個簡單的蜜罐系統就完成了。

總結


 

本文主要簡單介紹了一下一個蜜罐的搭建與測試,在企業安全防護中,蜜罐系統對於檢測攻擊者的攻擊非常有效,一旦攻擊者誤入蜜罐,我們就可以第一時間得知訊息,然後及時進行應急響應,儘量在最短的時間內將攻擊者踢出大門之外,保護企業的資料免受損壞丟失之險。

歡迎加群與我們一起交流

圖片描述

相關文章