# 基於軟體定義網路技術之工業控制場域防護系統-環境操作步驟 所需電腦環境: Python3 Version: 3.8.1 OS version: Ubuntu 20.04.4 ## 飲料食品加工廠-網路拓樸:  ### [Ryu Controller安裝](https://github.com/ken7428731/ryu.git): 1. 安裝 pip3 : `sudo apt install git python3-pip -y` 2. 下載 SDN_SCADA: `git clone https://github.com/ken7428731/ryu.git` 3. 進到ryu檔案: `cd ryu/` 4. 安裝環境: `sudo pip3 install .` 執行程式: `ryu-manager ryu/app/simple_switch_15_Scada_System.py` ### [Containernet環境安裝](https://github.com/ken7428731/containernet.git): #### 安裝步驟(Installation Steps): 1. 打開Ubuntu的Terminal。 2. 更新 apt list: `sudo apt-get update` 3. 安裝 git與Ansible: `sudo apt-get install git ansible` 4. 下載 Containernet: `git clone https://github.com/ken7428731/containernet.git` 5. 執行安裝: `sudo ansible-playbook -i "localhost," -c local containernet/ansible/install.yml` 6. 下載OpenPLC的image檔案: `sudo docker pull mfthomps/softplc2.plc.student` #### 執行程式: 進到examples檔案:`cd containernet/examples/` 執行程式: `sudo python3 Scada_Topology.py` #### 執行OpenPLC: 1. 在 containernet上呼叫 openplc containernet> `xterm d1`  2. 開啟後再啟動openplc root@d1:"/OpenPLC_v3#` ./start_openplc.sh`  3. 在打開瀏覽器並打 http://192.168.3.11:8080/dashboard 帳號:openplc 密碼:openplc  4. 再點選左邊的Programs http://192.168.3.11:8080/programs  5. 再將下面設定好的OpenPLC程式上傳上去,並按下Upload program。 [OpenPLC_Program.st](https://drive.google.com/drive/folders/1MOETbarzHGuTUVB_uI-NYxO6iN33DPmu?usp=sharing)  6. 這時會跳出 設定程式名稱,設定完後,再點選Upload program。  7. 編譯完後,先點選再點Go to Dashboard按鈕,在選左邊的 Start PLC 即可完成啟動。  另外一台OpenPLC2手法也類似。 ##### 如果要編輯OpenPLC檔案的話: 1. 首先到[官網](https://openplcproject.com/)下載 OpenPLC Editor編輯器,並安裝。  2. 下載我設定好的Project: [OpenPLC_Program](https://drive.google.com/drive/folders/1qGu3_xm3LTodMDO2zRkNDA247OpTQ7IO?usp=sharing) 3. 開啟OpenPLC Editor編輯器,並打開剛剛下載的Project:  4. 相關設定可以參考[OpenPLC初體驗/03/](https://ruten-proteus.blogspot.com/2020/11/openplc-03-demo-LD-ST-esp8266-as-modbus-slave-device.html)的(02)撰寫 OpenPLC 程式。 ### PLC編輯器的安裝: PLC設備: MITSUBISHI FX5U-32MR/ES PLC編輯器: GX-Works3 編輯器 1. 首先安裝GX-Works3編輯器。 2. 將GX-Works3更新到 1.08 。 3. 下載設計好的PLC專案: [PLC_Project](https://drive.google.com/drive/folders/1bQfxLHoq4Kdv-EmBtRea_UvsVp0we0th?usp=sharing) 4. 打開 GX-Works3 編輯器,並打開此專案。 5. 打開後可以看到我們所設計的PLC製造流程。 6. 先點擊上方的 在線 -> 當前連接目標。 7. 打開後選擇 使用乙太網路介面傳輸,並選擇介面與IP,設定完後可以點選通訊測試。狀態如下圖。  8. 編譯此專案的話,點選上方 轉換 -> 全部轉換。這時會跳出警告,按下事後即可編譯完成。 9. 將此編譯匯入至PLC的話,點選上方 在線 -> 寫入至PLC,這時會挑出匯入PLC得先關資訊,如下圖。  10. 匯入完後,到PLC主機上,將如下圖動作動作。  #### 如果要修改PLC IP位置的話: 1. 首先點選 左邊導覽的 參數 ->FX5UCPU ->模塊參數 ->乙太網路口,如下圖。  2. 點開來以後,可以看到可以設定PLC的IP與設定MODBUS/TCP設定與服務。  3. 設定好IP後,按下應用。 4. 在進行編譯專案。 5. 再將程式匯入進去,即可完成。 #### 如果要修改PLC所啟用的服務的話: 1. 首先點選 左邊導覽的 參數 ->FX5UCPU ->模塊參數 ->乙太網路口,如下圖。  2. 點開來以後,可以看到可以設定PLC的IP與設定MODBUS/TCP設定與服務。  3. 點選 對象設備連接配置 選項。  4. 在按照下圖步驟設定  #### 註:總共會有3個MODBUS/TCP模組。 5. 在進行編譯專案。 6. 再將程式匯入進去,即可完成。 ### HMI的安裝: 1. 首先到 ScadaBR 1.2 的github上: https://github.com/ScadaBR/ScadaBR/releases/tag/v1.2 2. 新增資料夾: mkdir ScadaBR_Setup_Linux 3. 下載 ScadaBR_Setup_Linux.zip檔案到ScadaBR_Setup_Linux資料夾: https://github.com/ScadaBR/ScadaBR/releases/download/v1.2/ScadaBR_Setup_Linux.zip 4. 解壓縮: unzip ScadaBR_Setup_Linux.zip 5. 進到ScadaBR_Setup_Linux資料夾: cd ScadaBR_Setup_Linux 6. 安裝ScadaBR: sudo ./install_scadabr.sh 安裝時會詢問web頁面會開在哪個port,這邊填入9092  接下來會問你資料庫帳密: 這邊按下 Enter按鍵繼續  接下來會問你是否啟動ScadaBR: y  7. 打開瀏覽器,網址打: http://127.0.0.1:9092/ScadaBR/login.htm 帳號: admin 密碼: admin  8. 切到匯入頁面: http://127.0.0.1:9092/ScadaBR/emport.shtm  9. 下載 [ScadaBR_Json.txt](https://drive.google.com/drive/folders/1LuTct-vdzuy68Do13d9ED2erH2L-DB5d?usp=sharing),並將裡面的程式複製到 Data上,並按下 Import按鈕。  10. 按下後等一下,等到完全載入ok  11. 再切到Data Source: http://127.0.0.1:9092/ScadaBR/data_sources.shtm  如果要連接某一個設備的話,再點選 Status的設備,如上圖的紅色框框。 連接完為 綠色。 12. 連接完後再到人機介面上: http://127.0.0.1:9092/ScadaBR/views.shtm  就可以進行操作。 #### 如果要進行PLC編輯相關設定的話: 1. 先點選要修改的設備(記得連接狀態為關閉狀態:紅色):  2. 下面紅色為需要設定的地方,設定完記得案下儲存鈕。  相關設定可以參考[OpenPLC初體驗/03/](https://ruten-proteus.blogspot.com/2020/11/openplc-03-demo-LD-ST-esp8266-as-modbus-slave-device.html)的(04)建立人機介面設定。 ### [滲透程式安裝](https://github.com/ken7428731/modbus_tcp_attack.git): #### 安裝步驟(Installation Steps): 安裝 python3 (Version 3.8.1): `sudo apt install python3-pip` 安裝 pyModbusTCP (Version 0.1.10): `sudo pip install pyModbusTCP` 安裝 nmap3 ( version 1.5.1): `sudo apt-get install nmap` `sudo pip install python3-nmap` 安裝 git : `sudo apt-get install git` 下載滲透程式: `git clone https://github.com/ken7428731/modbus_tcp_attack.git` #### 執行步驟(Execution Steps): 先進到modbus_tcp_attack資料夾裡: `cd modbus_tcp_attack` 執行程式: `sudo python3 auto_modbus_tcp_attack.py 192.168.3.0/24` 如果要修改掃描範圍的話在到 auto_modbus_tcp_attack.py 程式裡的 #407行修改 掃描範圍 ### 參考(Reference) * ryu官網: https://ryu-sdn.org/ * ryu github: https://github.com/faucetsdn/ryu * https://stackoverflow.com/questions/49971882/delete-flows-matching-specific-cookie-openflow-1-3-5-spec-support-by-openvswit * https://gist.github.com/aweimeow/d3662485aa224d298e671853aadb2d0f * https://umodbus.readthedocs.io/en/latest/functions.html * https://stackoverflow.com/questions/53065365/how-can-i-send-with-struct-pack-type-over-modbus-tcp * Containernet: https://containernet.github.io/ * Labtainers: https://nps.edu/web/c3o/labtainers * Labtainers softplc2 plc docker image: https://hub.docker.com/r/mfthomps/softplc2.plc.student * https://github.com/theralfbrown/smod-1.git * https://github.com/nmmapper/python3-nmap.git * Industrial Control Field Protection System Based on Software-defined Network Technology: https://hdl.handle.net/11296/3zh3g6 * https://openplcproject.com/ * https://ruten-proteus.blogspot.com/2020/10/openplc-00-introduction.html * https://www.openvswitch.org/ * https://zh.wikipedia.org/zh-tw/VMware_Workstation *
×
Sign in
Email
Password
Forgot password
or
Sign in via Google
Sign in via Facebook
Sign in via X(Twitter)
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
Continue with a different method
New to HackMD?
Sign up
By signing in, you agree to our
terms of service
.