HITCON CTF 2016 已經出來了。現在可以在 Github 的 Orange 大大的帳號中的 repo 找的到。這是其中一題的重現環境的 server 建置
首先,要先有一台 server (或是使用 VPS) 接著上面已經安裝好 LAMP stack (或PHP + Apache) 推薦的 Linux Distribution 為 Ubuntu 14.04 LTS
接著到專案的網址:把 repository clone 回來。
1 | git clone https: //github .com /orangetw/My-CTF-Web-Challenges .git |
接著,把目錄 hitcon-ctf-2016/papapa/ 底下的移到 server 上,並修改 /etc/apache2/sites-available/000-default.conf
下面的設定檔將專案中的 default-ssl.conf 整併到 000-default.conf
1 | sudo vi /etc/apache2/sites-available/000-default .conf |
修改的範例檔如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | # 基本上,前面的 80 port 是都不用更改的,使用預設的設定就好。 <IfModule mod_ssl.c> <VirtualHost *:443> ServerAdmin webmaster@localhost ServerName your-ip-address DocumentRoot /var/www/html/papapa ErrorLog ${APACHE_LOG_DIR} /error .log CustomLog ${APACHE_LOG_DIR} /access .log combined SSLEngine on SSLCertificateFile /path/to/crt-file SSLCertificateKeyFile /path/to/key-file SSLCACertificateFile /path/to/crt-file <FilesMatch "\.(cgi|shtml|phtml|php)$" > SSLOptions +StdEnvVars < /FilesMatch > <Directory /usr/lib/cgi-bin > SSLOptions +StdEnvVars < /Directory > <Directory "/var/www/html" > AllowOverride All < /Directory > BrowserMatch "MSIE [2-6]" \ nokeepalive ssl-unclean- shutdown \ downgrade-1.0 force-response-1.0 # MSIE 7 and newer should be able to use keepalive BrowserMatch "MSIE [17-9]" ssl-unclean- shutdown < /VirtualHost > <VirtualHost *:443> ServerAdmin webmaster@localhost DocumentRoot /var/www/html/secret/ ServerName very-secret-area- for -ctf.orange.tw ErrorLog ${APACHE_LOG_DIR} /error .log CustomLog ${APACHE_LOG_DIR} /access .log combined SSLEngine on SSLCertificateFile /path/to/crt-file SSLCertificateKeyFile /path/to/key-file SSLCACertificateFile /path/to/crt-file <Directory /secret/ > Options FollowSymLinks AllowOverride None Require all granted < /Directory > <FilesMatch "\.(cgi|shtml|phtml|php)$" > SSLOptions +StdEnvVars < /FilesMatch > BrowserMatch "MSIE [2-6]" \ nokeepalive ssl-unclean- shutdown \ downgrade-1.0 force-response-1.0 # MSIE 7 and newer should be able to use keepalive BrowserMatch "MSIE [17-9]" ssl-unclean- shutdown < /VirtualHost > < /IfModule > |
設定完成之後,在 /var/www/html 的目錄下建立一個 secret 的目錄並把 index-secret.php 放到此目錄中。
重啟 Apache service
1 | sudo service apache2 restart |
接著:開始攻擊(?
開始攻擊時,先想辦法拿到:very-secret-area-for-ctf.orange.tw 這個網域名稱。
可以從主控台看到類似這樣的憑證圖示:
接著使用 cURL
1 |