架設 Tor Hidden Service === ###### tags: `web` `tor` ## Windows 1. 先找個地方建立要放置的目錄(ex: C:\hidden_service)。 2. 啟動 Apache。 3. 到 Tor 資料夾中 ``Tor Browser\Browser\TorBrowser\Data\Tor`` 找到 ``torrc`` 檔案。 4. 在最下方加上 ``` HiddenServiceDir C:\hidden_service HiddenServicePort 80 127.0.0.1:80 ``` 5. 重啟 Tor 後可在 hidden_service 資料夾中發現多了兩個檔案,其中一個是私鑰,另外一個是網址,可以把此網址丟到 Tor 中,正常會出現 apache 的主頁。 6. 到 Apache 安裝目錄物中找到 ``C:\xampp\apache\conf\extra\httpd-vhosts.conf`` 開啟。 7. 先備份好原先內容,然後隨便修改其中一段 ``` <VirtualHost *:80> ServerAdmin webmaster@[你的隱藏網址].onion DocumentRoot "C:/xampp/htdocs/[你的隱藏網址].onion" ServerName [你的隱藏網址].onion ServerAlias www.[你的隱藏網址].onion ErrorLog "logs/[你的隱藏網址].onion-error.log" CustomLog "logs/[你的隱藏網址].onion-access.log" common </VirtualHost> ``` 8. 到 ``C:\xampp\htdocs`` 新增一個名為 ``你的隱藏網址.onion`` 的資料夾,在裡面放上網頁內容。 ## Ubuntu 1. 安裝 ``tor`` 2. 在 ``/etc/tor/torrc`` 裡面加上 ``` HiddenServiceDir /var/lib/tor/hidden_service/ HiddenServicePort 80 127.0.0.1:80 ``` :::info 表示 hidden service 的相關資料會放在 `/var/lib/tor/hidden_service/` 下,並且提供 port 80 的服務 (轉到本機 127.0.0.1 的 port 80)。 ::: 3. 重啟 tor: ``service tor restart`` 4. 查看 hostname: ``vim /var/lib/tor/hidden_service/hostname`` 5. apache 啟用虛擬多網站: ``sudo vim /etc/apache2/sites-available/000-default.conf`` ``` <VirtualHost *:80> # ServerName www.normal.com DocumentRoot /var/www/normalsite </VirtualHost> <VirtualHost *:80> ServerName xxx.onion DocumentRoot /var/www/xxx.onion </VirtualHost> ``` 6. 啟用多網站 ``` sudo a2ensite default ``` 7. 重啟 apache ``` service apache2 restart ``` 8. 禁止IP訪問: ``sudo vim /etc/apache2/sites-available/000-default.conf`` ``` <VirtualHost *:80> ServerName x.x.x.x(VPS IP) <Location /> Order Allow,Deny Deny from all </Location> </VirtualHost> ``` 9. 關閉目錄瀏覽: ``sudo vim /etc/apache2/apache2.conf`` ``` 找到 Options Indexes FollowSymLinks 然後把 Indexes 刪掉 ``` 10. 隱藏敏感資訊: ``sudo vim /etc/apache2/apache2.conf `` ``` ServerTokens Prod ServerSignature Off ``` 11. 禁止Ping ``` // 禁止 echo "net.ipv4.icmp\_echo\_ignore_all=1" >> /etc/sysctl.conf // 以上指令會在重啟server生效,但也可以立即生效 sysctl -p // 允許(立即生效,不需再輸入上面指令) echo 0 > /proc/sys/net/ipv4/icmp\_echo\_ignore_all ``` ## Windows與Linux快速傳輸檔案 參考: [Putty - 使用PSCP在Linux與Windows間傳送檔案](https://jeremysu0131.github.io/Tool-Putty-%E4%BD%BF%E7%94%A8PSCP%E5%9C%A8Linux%E8%88%87Windows%E9%96%93%E5%82%B3%E9%80%81%E6%AA%94%E6%A1%88/) 1. 下載 `pscp.exe` [(32-bit)](https://the.earth.li/~sgtatham/putty/latest/w32/pscp.exe) [(64-bit)](https://the.earth.li/~sgtatham/putty/latest/w64/pscp.exe) 2. 將 `pscp.exe` 放置到你想要的資料夾 3. 打開 terminal 切換到 `pscp.exe` 位置 #### 下載資料 ``` #pscp \[options\] user@host:source target #pscp \[選項\] 使用者名稱@host ip或名稱:要下載檔案的位置 本機存儲的位置 pscp jeremy@8.8.8.8:/home/user/picture.jpg c:/document/picture.jpg ``` #### 上傳資料 ``` #pscp \[options\] target \[user@\]host:source #pscp 要上傳檔案的位置 \[選項\] 使用者名稱@host ip或名稱:遠端存儲的位置 pscp C:/document/picture.jpg jeremy@8.8.8.8:/home/user/picture.jpg ``` ## Reference 1. [架設 Tor 的 Hidden Service](https://blog.gslin.org/archives/2014/03/29/4428/%E6%9E%B6%E8%A8%AD-tor-%E7%9A%84-hidden-service/) 2. [Ubuntu Apache啟用虛擬多網站(VirtualHost)](http://blog.fhps.tp.edu.tw/fhpsmis/?p=845) 3. [Apache2 上同時代管多個網站](https://wiki.gandi.net/zh-tw/hosting/using-linux/tutorials/ubuntu/virtualhosts) 4. [Apache禁止ip和非法域名訪問](https://www.centos.bz/2017/11/debian%E4%B8%8A%E8%AE%BE%E7%BD%AEapache%E7%A6%81%E6%AD%A2ip%E5%92%8C%E9%9D%9E%E6%B3%95%E5%9F%9F%E5%90%8D%E8%AE%BF%E9%97%AE/) 5. [Apache安全設定](https://dywang.csie.cyut.edu.tw/dywang/rhel7/) 6. [IPTable](https://www.phpini.com/linux/iptables-command)
×
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
.