Upgrade to Pro — share decks privately, control downloads, hide ads and more …

WordPress 基本安全性檢測與防範方式 / WordPress Security Check and How to Prevent Them_呂明璋 / John Lu

WordPress 基本安全性檢測與防範方式 / WordPress Security Check and How to Prevent Them_呂明璋 / John Lu

本主題將針對使用 VPS 自架站的人提出一些基本的網站安全性檢測與防範,包含 WordPress 資訊隱藏、目錄權限設定、Security Header 檢測與設定、.htaccess 安全性設定、簡易的自動化備份流程等等,希望在自架站的同時,也能對於基本的資安知識有所瞭解。 接著也會介紹網站被駭之後的處理方式,包含網站復原、重新提交網頁漏洞檢測報告(Sucuri、McAfee),避免被防毒軟體當作惡意網站阻擋。

WordCamp Taipei

December 28, 2019
Tweet

More Decks by WordCamp Taipei

Other Decks in Technology

Transcript

  1. 大綱 1 1. WordPress 常見漏洞來源 2. 網站基本掃描 3. WordPress 版本資訊隱藏

    4. 目錄權限設定 5. Security Header 檢測與設定 6. 自動化備份 7. 網站被駭之處理方法 8. Q&A WordPress 基本安全性檢測與防範方式 呂明璋/John Lu
  2. 大綱 3 1. WordPress 常見漏洞來源 2. 網站基本掃描 3. WordPress 版本資訊隱藏

    4. 目錄權限設定 5. Security Header 檢測與設定 6. 自動化備份 7. 網站被駭之處理方法 8. Q&A 投影片:https://www.johntool.com/wordcamp
  3. 7 暴力攻擊 定義: 尋找出使用者,嘗試各種密碼, 運用大量的算法與字典來爆破。 攻擊: • wpscan --url domain

    --enumerate u -t 50 • wpscan --url domain --wordlist wpw_pwd_dictionary.txt --username admin
  4. SQL Injection 定義: 透過表單、網址,輸入SQL語法, 繞過資料庫的判斷,進而得到資料庫權限或資料。 攻擊: ' OR 1 =

    1 -- 預防: • 使用 WPScan 或是 Sucuri 掃描確認 • 定期備份資料庫 • 更新PHP、SQL版本。 9
  5. 26 目錄權限 • Hardening WordPress • 資料夾:755 ◦ find WP_Root

    -type d -exec chmod 755 {} \; • 檔案:644 ◦ find WP_Root -type f -exec chmod 644 {} \; • Owner, Group:通常為www-data ◦ sudo chown -R www-data:www-data WP_Root
  6. 27 .htaccess • 純文字檔案,Apache 伺服器配置相關的指令 用途: • 限定網頁讀取 IP •

    設定保密資料夾 • 自訂錯誤頁面 • php.ini 參數值設定 • 重新導向頁面
  7. 32 wp-includes 安全性 # Block the include-only files. <IfModule mod_rewrite.c>

    RewriteEngine On RewriteBase / RewriteRule ^wp-admin/includes/ - [F,L] RewriteRule !^wp-includes/ - [S=3] RewriteRule ^wp-includes/[^/]+\.php$ - [F,L] RewriteRule ^wp-includes/js/tinymce/langs/.+\.php - [F,L] RewriteRule ^wp-includes/theme-compat/ - [F,L] </IfModule>
  8. 36

  9. 39 設定方式 • 加入 .htaccess 或是 apache2.conf Header set Strict-Transport-Security:

    max-age=2592000 Header set X-Frame-Options: SAMEORIGIN Header set Referrer-Policy: no-referrer Header set X-XSS-Protection: “1; mode=block” Header set X-Content-Type-Options: nosniff
  10. 42 自動化備份推薦方式 • 主機商: ◦ 注意備份留存時間 ◦ 檔案能不能隨時取得 • 外掛:

    ◦ UpdraftPlus(教學文章) ◦ VaultPress • Shell Script: ◦ 資料夾+資料庫
  11. 43 備份注意事項 • 中文圖片檔名 ◦ 注意編碼方式(UTF-8)壓縮 ◦ 修改檔名(Media File Renamer)

    ◦ 上傳自動修改檔名(RY Nice Upload FileName) • 主機資源上限 ◦ 備份時,IO, CPU 會特別高 • 避免尖峰時段 ◦ 盡量在半夜進行備份
  12. • 比對檔案時間 • 特別注意 wp-content, wp-config, .htaccess • 確認檔案權限 •

    資料庫被更改? • 查詢 error.log / access.log 46 確認問題