Virtualization for Cybersecurity- Virtualbox
虛擬化技術被廣泛用在資安防護與研析,本課程以建構ELK、Suricata及Kali演練環境,藉此熟悉Virtualbox之實務技術,以專題導向方式進行。
為了讓硬體效能有效的發揮,尤其當我們知道電腦大部分是在閒置的時候,如何壓榨出更多的運算與網路資源,是虛擬化技術發展很大的驅動力。
除了從有效利用硬體資源的角度,系統相容性議題往往是開發人員成本所在,資安人員建構攻防場域,更需要彈性且動態的平台技術,虛擬化技術也希望能讓動態架構系統的建制更有彈性。
本課程聚焦虛擬化技術以及容器化技術的基本概念以及建置演練,並結合網路安全主題,如:入侵偵測系統、資安日誌倉儲、惡意程式分析環境等。
課程進行方式以專題為核心,分為技術介紹與技術演練,技術介紹會從全球資安發展趨勢(5G、OT、Cloud)說明虛擬化技術扮演的重要性。接著,對於虛擬化技術進行深度探討。技術演練的部分,將以IDS與Elasticsearch整合技術作為課程上機演練的目標。
相關工具與資料:https://drive.google.com/drive/u/0/folders/1GvYR--OwP522WkY6eRb2sLr85shs2Gbr
虛擬化技術介紹 (8 hours)
從VMWare大廠的角度來看什麼是虛擬化?(包含影片) https://www.vmware.com/tw/solutions/virtualization.html
問題討論 1: 大廠與開放源碼的虛擬化技術有什麼差別?可否分享過去的使用經驗。
虛擬化技術介紹,此份簡報是由國網中心線上公開簡報資源,作為本課程建構基礎知識之資料。 https://slidesplayer.com/slide/14707489/
此份資料著重虛擬化技術及應用,此份資料更聚焦於系統架構堆疊,很適合從系統角度了解虛擬化技術的層次。 https://www.slideserve.com/hammer/3841515
問題討論 2: 虛擬化技術對於資安防護與情資研析的用途?
由教育部補助中山大學所編纂的虛擬化技術,此份教材詳細從不同虛擬化平台說明,也探像是虛擬化處理器等技術核心,順帶一提,其中QEMU就被常用在IoT Honeypot用來模擬不同硬體。 http://dns2.asia.edu.tw/~jdwang/TeachingCourses/Virtualization/Part1-_.pdf
從虛擬化使用面向來探討,包含從伺服器、桌面虛擬化、環境管理虛擬化以及在虛擬化產品的實務經驗。 http://ilms.csu.edu.tw/sys/read_attach.php?id=1424740
虛擬機(VM)與容器(Container)之技術價值與比較分析,值得一讀有乾貨的文章,兩個容易被混淆的議題融合起來探討。 https://medium.com/mr-efacani-teatime/%E6%B7%BA%E8%AB%87%E8%99%9B%E6%93%AC%E5%8C%96%E6%8A%80%E8%A1%93-%E8%99%9B%E6%93%AC%E6%A9%9F-vm-%E8%88%87%E5%AE%B9%E5%99%A8-container-%E4%B9%8B%E6%8A%80%E8%A1%93%E5%83%B9%E5%80%BC%E8%88%87%E6%AF%94%E8%BC%83%E5%88%86%E6%9E%90-5c10457aad62
問題討論 3: 虛擬機與容器的共同性與差異性為何?
CPU進階技術講解,這份資料針對CPU的技術有不錯的討論,當然我們聚焦在虛擬化最相關的技術來探討。
VirtualBox實戰 (10 hours)
Lab 1: 安裝與建置 安裝VirtualBox,安裝以Ubuntu 18.04的GuestOS,以及Kali Linux,並分別透過HostOS以SSH連線進入。
在Linux查網路設定?
若碰到ifconfig not found,請執行
sudo apt install net-tools參考來源:https://blog.csdn.net/hanpenghu/article/details/84678503
設定固定網路IP位置(建議設定192.168.56.102)
設定從從host os透過SSH連到Guest OS(Ubuntu Linux)
sudo apt-get updatesudo apt-get install openssh-server設定openssh-server,目標允許遠端用密碼登入及可以登入(0.0.0.0, specified IP)
sudo vim /etc/ssh/sshd_config
ListenAddress 0.0.0.0PermitRootLogin yes
設定防火牆
sudo ufw allow ssh
啟動openssh-server
service ssh start
在Host OS,透過SSH Client(如: Putty)連入Guest OS。
Lab 2: 建構一個可自我檢測分析的入侵偵測系統 依照Suricata安裝步驟。
專案規劃:
在Host-only的環境中建置攻防主機各一台
網路配置
Gateway 192.168.56.1
防禦主機(Suricata) 192.168.56.102
攻擊主機(Kali) 192.168.56.101
安裝Suricata
sudo add-apt-repository ppa:oisf/suricata-stablesudo apt-get updatesudo apt-get install suricatasudo vim /etc/suricata/suricata.yaml所有為eth0的地方替換為要偵測的網卡名稱(如:enp0s8) 可使用以下指令進行安裝測試
sudo suricata -c /etc/suricata/suricata.yaml -T
啟動Suricata...
sudo systemctl start suricata.service可到
/var/log/suricata/suricata-start.log檢視啟動時有無問題 (例如:忘了把eth0改成enp0s8)
安裝與設定Elasticsearch
wget -qO -https://artifacts.elastic.co/GPG-KEY-elasticsearch| sudo apt-key add -sudo apt-get install apt-transport-httpsecho "debhttps://artifacts.elastic.co/packages/7.x/aptstable main" | sudo tee -a /etc/apt/sources.list.d/elastic-7.x.listsudo apt-get update && sudo apt-get install elasticsearchsudo apt-get install elasticsearchsudo vim /etc/elasticsearch/elasticsearch.yml在Elasticsearch.yml中,設定以下屬性:
node.name: node-1
cluster.name: my-application
network.host: 192.168.56.103
cluster.initial_master_nodes: ["node-1"]
檢視與啟動Elasticsearch服務狀態
sudo systemctl status elasticsearch.servicesudo systemctl start elasticsearch.service
Elasticsearch有可能無法啟動,起因為 elasticsearch.service: Start operation timed out. Terminating.,可參考 https://discuss.elastic.co/t/debian-elasticsearch-service-start-operation-timed-out-terminating/223262
運送資料
以Filebeats運送suricata的告警檔案eve.json至Elasticsearch
安裝Filebeats
sudo apt-get install filebeat
設定Filebeats
sudo vim /etc/filebeat/filebeat.ymlFilebeat inputs
paths: /var/log/suricata/eve.json
enabled: true
Kibana
host: "localhost:5601"
Outputs> Elasticsearch Output
hosts:["192.168.56.102:9200"]
運作Filebeats
sudo systemctl start filebeatsudo systemctl status filebeat
確認filebeat已將eve.json傳送至Elasticsearch
掛載Kali Linux到Virtualbox
ID/PW: kali/password@@
開啟NMAP,掃描192.168.56.103
或是直接在host os安裝NMAP (https://nmap.org/download.html)
加掛Logstash進行資料處理
安裝Logstash
sudo apt-get updatesudo apt install openjdk-11-jre-headlesssudo apt-get install -y logstashsudo systemctl daemon-reloadsudo systemctl enable logstash.service
設定Logstash
Logstash的scripts預設目錄為 /etc/logstash/conf.d/
參考10-input.conf (file) 與 30-outputs.conf (file)
在10-input.conf中,請確認path是否已指向 /var/log/suricata/eve.json
input {file {path => ["/var/log/suricata/eve.json"]sincedb_path => ["/var/lib/logstash/sincedb"]codec => json type => "SuricataIDPS"}}在30-outputs.conf中,請確認Elasticsearch位置以及index名稱
output {elasticsearch {hosts => ["http://192.168.56.102:9200"]index=> "logstash-%{+YYYY.MM.dd}"}}
使用Evebox套件檢視Suricata觸發事件
安裝Evebox
sudo apt-get install wget gnupg
wget -qO - https://evebox.org/files/GPG-KEY-evebox | sudo apt-key add -
echo "deb http://evebox.org/files/debian stable main" | sudo tee /etc/apt/sources.list.d/evebox.list
sudo apt-get update
sudo apt-get install evebox
啟動指令
sudo cp evebox.yaml.example evebox.yamlsudo vim /etc/evebox/evebox.yamlLINE 42 elasticsearch:index: logstash-*
disable-certificate-check: false
LINE 110 input:
enabled: true
filename: "/var/log/sricata/eve.json
sudo evebox server -c /etc/evebox.yaml
Lab 3: 採用Script控制
Shell scripts
Docker Python scripts (problem)

實作補充資料
How To Set Up a Firewall with UFW on Ubuntu 18.04
https://www.digitalocean.com/community/tutorials/how-to-set-up-a-firewall-with-ufw-on-ubuntu-18-04
Logstash Kibana and Suricata JSON output
入侵偵測系統結合大數據分析: Suricata 與 ELK Stack 之實際應用
Elasticsearch 安裝與啟動 https://yq.aliyun.com/articles/746610
Elasticsearch 狀態查看 https://blog.csdn.net/kwame211/article/details/83786212
How To Install and Configure Elasticsearch on Ubuntu 16.04 https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-elasticsearch-on-ubuntu-16-04
How to setup up an Elastic version 7 cluster, http://blogs.bmc.com/elasticsearch-v7-cluster/?print=pdf
Setup Elasticsearch Cluster over Oracle Virtualbox https://discuss.elastic.co/t/setup-elasticsearch-cluster-over-oracle-virtualbox/13071/2
ELK 教學 - 從無到有安裝 ELK (CentOS/Red Hat) https://blog.johnwu.cc/article/how-to-install-elasticsearch-logstash-and-kibana-elk-stack-on-centos-red-hat.html
Get started with Filebeat https://www.elastic.co/guide/en/beats/filebeat/current/filebeat-getting-started.html
Last updated

