鄭
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
      • Invitee
    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Versions and GitHub Sync Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
Invitee
Publish Note

Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

Your note will be visible on your profile and discoverable by anyone.
Your note is now live.
This note is visible on your profile and discoverable online.
Everyone on the web can find and read all notes of this public team.
See published notes
Unpublish note
Please check the box to agree to the Community Guidelines.
View profile
Engagement control
Commenting
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
  • Everyone
Suggest edit
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
Emoji Reply
Enable
Import from Dropbox Google Drive Gist Clipboard
   owned this note    owned this note      
Published Linked with GitHub
1
Subscribed
  • Any changes
    Be notified of any changes
  • Mention me
    Be notified of mention me
  • Unsubscribe
Subscribe
# Kali Linux 教學環境建置 ## 專案背景與目標 資安社在教授駭客技術時,面臨一個關鍵挑戰:大部分學員無法攜帶電腦進行實作練習,導致無法實際操作基礎的 Kali Linux 系統。為解決此問題,本專案透過自架伺服器並運行多個 Docker 容器來提供遠端 Kali Linux 環境。由於校園網路限制大多數埠口,需要將所有 Docker 容器的流量統一導向 80 埠口。 ## 專有名詞說明 - **Kali Linux**: 基於 Debian 的 Linux 發行版,預裝多種資訊安全與滲透測試工具,專為資安專業人員設計。 - **Docker**: 開源的容器化平台,允許將應用程式與其依賴項打包成獨立的容器,實現輕量級虛擬化。 - **SSH (Secure Shell)**: 一種加密的網路協議,用於安全地遠端登入和檔案傳輸。 - **Proxy**: 代理伺服器,作為客戶端和目標伺服器之間的中介,轉發請求和回應。 - **Nginx**: 高性能的 Web 伺服器軟體,常用於反向代理、負載平衡和 Web 加速。 - **DNS (Domain Name System)**: 將域名轉換為 IP 地址的網路服務系統。 ## 技術實作流程 ### 1. SSH 遠端管理設定 首先建立安全的遠端管理環境: - 在家中路由器設定 port forwarding:將 public IP 的 2222 埠口映射至伺服器的 22 埠口 - 加強 SSH 安全性設定: - 停用密碼登入,僅允許 SSH 金鑰認證 - 修改 `/etc/ssh/sshd_config` 設定: ``` PubkeyAuthentication yes PasswordAuthentication no ``` - SSH 金鑰結構: ``` ~/.ssh/ ├── authorized_keys ├── id_rsa ├── id_rsa.pub ├── known_hosts └── known_hosts.old ``` ### 2. SSH Tunnel 與 Proxy 設定 SSH 連線指令: ```bash ssh -i server_ssh_id_rsa kali@118.232.99.232 -p 2222 -D 9050 ``` 設定說明: * -i 用 id_rsa * -p 指定端口 * -D 啟動一個本地 SOCKS 代理伺服器 - **ProxyChains**: SSH 主要是用來進行命令行交互的,但是當需要在遠端伺服器上進行一些如設定 router port fowording ,直接通過終端無法滿足這些需求。這時候,利用 proxychains 來將流量通過你已經建立的 SSH 連線進行轉發,從而實現對流量的控制。 - EX: `proxychains firefox`,透過這樣開起來的 firefox 就可以在遠端透過 SSH 流量,訪問內網,因此就可以去到 router 設定頁面去設定 port forwording ### 3. Docker 容器部署 ![image](https://flowygo.com/wp-content/uploads/2021/01/ArquiteturaDocker-1024x524.png) 使用 [kalilinux-docker](https://github.com/csalab-id/kalilinux-docker) 專案建立多個 Kali Linux 環境: - 建立多個容器目錄: ``` kalilinux-docker0/ 到 kalilinux-docker10/ ``` ```bash ┌──(kali㉿kali)-[~/kali_pc] └─$ l kalilinux-docker/ kalilinux-docker2/ kalilinux-docker6/ nginx/ kalilinux-docker0/ kalilinux-docker3/ kalilinux-docker7/ note.txt kalilinux-docker1/ kalilinux-docker4/ kalilinux-docker8/ setup.sh* kalilinux-docker10/ kalilinux-docker5/ kalilinux-docker9/ unset.sh* ``` - 自動化部署腳本(setup.sh): ```bash for i in $(seq 0 10) do cd "kalilinux-docker$i" && docker-compose up -d cd .. done ``` - `./setup.sh` 執行起來 ```bash ┌──(kali㉿kali)-[~/kali_pc] └─$ ./setup.sh [+] Running 2/2 ✔ Network kalilinux-docker0_default Created 0.1s ✔ Container kalilinux-docker0-kalilinux-1 Started 0.3s [+] Running 2/2 ✔ Network kalilinux-docker1_default Created 0.1s ✔ Container kalilinux-docker1-kalilinux-1 Started 0.3s [+] Running 2/2 ✔ Network kalilinux-docker2_default Created 0.0s ✔ Container kalilinux-docker2-kalilinux-1 Started 0.3s [+] Running 2/2 ✔ Network kalilinux-docker3_default Created 0.1s ✔ Container kalilinux-docker3-kalilinux-1 Started 0.3s [+] Running 2/2 ✔ Network kalilinux-docker4_default Created 0.1s ✔ Container kalilinux-docker4-kalilinux-1 Started 0.4s [+] Running 2/2 ✔ Network kalilinux-docker5_default Created 0.1s ✔ Container kalilinux-docker5-kalilinux-1 Started 0.4s [+] Running 2/2 ✔ Network kalilinux-docker6_default Created 0.1s ✔ Container kalilinux-docker6-kalilinux-1 Started 0.6s [+] Running 2/2 ✔ Network kalilinux-docker7_default Created 0.1s ✔ Container kalilinux-docker7-kalilinux-1 Started 0.8s [+] Running 2/2 ✔ Network kalilinux-docker8_default Created 0.1s ✔ Container kalilinux-docker8-kalilinux-1 Started 0.8s [+] Running 2/2 ✔ Network kalilinux-docker9_default Created 0.1s ✔ Container kalilinux-docker9-kalilinux-1 Started 0.8s [+] Running 2/2 ✔ Network kalilinux-docker10_default Created 0.2s ✔ Container kalilinux-docker10-kalilinux-1 Started 1.0s ``` ### 4. Nginx 反向代理設定 配置 Nginx 使所有容器通過 80 埠口訪問: ```nginx server { listen 80; server_name kali0.chengyunpu.com; location / { proxy_pass http://127.0.0.1:8000/; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection 'upgrade'; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; } } #剩下的以此類推 ``` - listen 80:監聽 HTTP 80 埠。 - server_name:指定子域名(例如 kali0.chengyunpu.com)。 - proxy_pass:反向代理到容器的指定 Port(如 8000)。 ### 5. DNS 設定與 Cloudflare 整合 在 Cloudflare 上設定 DNS A 記錄,將各個子網域(kali0~kali10.chengyunpu.com)指向家中 public IP。 ![image](https://hackmd.io/_uploads/SJKTYFfS1l.png) **Cloudflare 優勢**: - 提供 CDN 服務加速訪問 - DDoS 防護功能 - SSL/TLS 加密支援 - DNS 管理介面直觀易用 ## 技術架構圖 ```mermaid graph TD A[使用者] --> B[Cloudflare DNS] B --> C[Nginx Reverse Proxy] C --> D[Docker Container 0] C --> E[Docker Container 1] C --> F[Docker Container ...] C --> G[Docker Container 10] ``` ## 結論 透過以上設定,成功建立了一個可供多人同時使用的 Kali Linux 實作環境,解決了學員無法攜帶設備的問題。該系統具有以下特點: - 安全的遠端管理機制 - 統一的 80 埠口訪問 - 可擴展的容器化架構 - 方便的子網域存取方式 - 完整的安全防護體系 ## 實際使用 ![image](https://hackmd.io/_uploads/SyybeqfS1x.png)

Import from clipboard

Paste your markdown or webpage here...

Advanced permission required

Your current role can only read. Ask the system administrator to acquire write and comment permission.

This team is disabled

Sorry, this team is disabled. You can't edit this note.

This note is locked

Sorry, only owner can edit this note.

Reach the limit

Sorry, you've reached the max length this note can be.
Please reduce the content or divide it to more notes, thank you!

Import from Gist

Import from Snippet

or

Export to Snippet

Are you sure?

Do you really want to delete this note?
All users will lose their connection.

Create a note from template

Create a note from template

Oops...
This template has been removed or transferred.
Upgrade
All
  • All
  • Team
No template.

Create a template

Upgrade

Delete template

Do you really want to delete this template?
Turn this template into a regular note and keep its content, versions, and comments.

This page need refresh

You have an incompatible client version.
Refresh to update.
New version available!
See releases notes here
Refresh to enjoy new features.
Your user state has changed.
Refresh to load new user state.

Sign in

Forgot password

or

By clicking below, you agree to our terms of service.

Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
Wallet ( )
Connect another wallet

New to HackMD? Sign up

Help

  • English
  • 中文
  • Français
  • Deutsch
  • 日本語
  • Español
  • Català
  • Ελληνικά
  • Português
  • italiano
  • Türkçe
  • Русский
  • Nederlands
  • hrvatski jezik
  • język polski
  • Українська
  • हिन्दी
  • svenska
  • Esperanto
  • dansk

Documents

Help & Tutorial

How to use Book mode

Slide Example

API Docs

Edit in VSCode

Install browser extension

Contacts

Feedback

Discord

Send us email

Resources

Releases

Pricing

Blog

Policy

Terms

Privacy

Cheatsheet

Syntax Example Reference
# Header Header 基本排版
- Unordered List
  • Unordered List
1. Ordered List
  1. Ordered List
- [ ] Todo List
  • Todo List
> Blockquote
Blockquote
**Bold font** Bold font
*Italics font* Italics font
~~Strikethrough~~ Strikethrough
19^th^ 19th
H~2~O H2O
++Inserted text++ Inserted text
==Marked text== Marked text
[link text](https:// "title") Link
![image alt](https:// "title") Image
`Code` Code 在筆記中貼入程式碼
```javascript
var i = 0;
```
var i = 0;
:smile: :smile: Emoji list
{%youtube youtube_id %} Externals
$L^aT_eX$ LaTeX
:::info
This is a alert area.
:::

This is a alert area.

Versions and GitHub Sync
Get Full History Access

  • Edit version name
  • Delete

revision author avatar     named on  

More Less

Note content is identical to the latest version.
Compare
    Choose a version
    No search result
    Version not found
Sign in to link this note to GitHub
Learn more
This note is not linked with GitHub
 

Feedback

Submission failed, please try again

Thanks for your support.

On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

Please give us some advice and help us improve HackMD.

 

Thanks for your feedback

Remove version name

Do you want to remove this version name and description?

Transfer ownership

Transfer to
    Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

      Link with GitHub

      Please authorize HackMD on GitHub
      • Please sign in to GitHub and install the HackMD app on your GitHub repo.
      • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
      Learn more  Sign in to GitHub

      Push the note to GitHub Push to GitHub Pull a file from GitHub

        Authorize again
       

      Choose which file to push to

      Select repo
      Refresh Authorize more repos
      Select branch
      Select file
      Select branch
      Choose version(s) to push
      • Save a new version and push
      • Choose from existing versions
      Include title and tags
      Available push count

      Pull from GitHub

       
      File from GitHub
      File from HackMD

      GitHub Link Settings

      File linked

      Linked by
      File path
      Last synced branch
      Available push count

      Danger Zone

      Unlink
      You will no longer receive notification when GitHub file changes after unlink.

      Syncing

      Push failed

      Push successfully