提示:本文需要讀者對HSTS預加載的相關概念有基本理解。
添加Expect-CT和/或Expect-Staple
想要更改預加載列表,根據需要添加或更新條目,你必須對Chromium源提交一個更改。
首先,需要檢查Chromium源,避免拉下整個代碼庫,可以使用此腳本來拉下所需的部分。 可通過創建一個新目錄解決問題,你可以隨時隨地進行此操作。mkdir ~/chromium
cd ~/chromium
wget https://gist.githubusercontent.com/lgarron/73cf22ed381ef9786739ee5abd816c59/raw/241c176168d9cbec8c2b5e9e90a81da77d518f76/checkout-chromium-preload-list.sh
chmod +x checkout-chromium-preload-list.sh
現在腳本已經準備就緒,可以檢出Chromium源並更改到文件夾中。
./checkout-chromium-preload-list.sh
cd chromium-hsts
nano net/http/transport_security_state_static.json
該文件非常大,按照預加載列表中的當前列表(如果有的話),進行的更改內容。如果已有條目並且通過HSTS預裝站點提交,則需要找到該條目並將其剪切粘貼到手動條目部分。 如果您還沒有條目,需要新建到手動條目部分。
{ “name”: “scotthelme.co.uk”, “include_subdomains”: true, “mode”: “force-https” },
無論是構建現有條目還是創建新條目,都需要啟用相關功能添加適當的字段。 以下是需要分別為Expect-CT和Expect-Staple添加的值。
“expect_ct”: true, “expect_ct_report_uri”: “https://scotthelme.report-uri.com/r/d/ct/reportOnly”, “include_subdomains_for_expect_ct”: true
“expect_staple”: true, “expect_staple_report_uri”: “https://scotthelme.report-uri.io/r/d/staple/reportOnly”, “include_subdomains_for_expect_staple”: true
這是現有的HSTS預加載入口,且同時包含Expect-CT和Expect-Staple最後的結果如下:
{ “name”: “scotthelme.co.uk”, “include_subdomains”: true, “mode”: “force-https”, “expect_ct”: true, “expect_ct_report_uri”: “https://scotthelme.report-uri.com/r/d/ct/reportOnly”, “include_subdomains_for_expect_ct”: true, “expect_staple”: true, “expect_staple_report_uri”: “https://scotthelme.report-uri.com/r/d/staple/reportOnly”, “include_subdomains_for_expect_staple”: true},
這個新條目需要放在手動輸入部分。可以通過搜索//START OF MANUAL ENTRIES來查找整個部分的初始內容,也可以搜//END OF MANUAL ENTRIES找到末尾信息。將新條目放在最後。一旦保存了更改,如果沒有全局設置或者想要再度更改,則需要在Git中操作。
git config user.name “Scott Helme”
git config user.email “[email protected]”
git config core.autocrlf false
git config core.filemode false
git config branch.autosetuprebase always
git config gerrit.host true
email地址必須使用谷歌賬號且在驗證過後才能生效。轉到此鏈接並選擇合適的Google帳戶(如果您有多個帳戶),就會提示您運行配置git所需的命令,列出的命令為:
touch .gitcookies
chmod 0600 .gitcookies
git config http.cookiefile .gitcookies
tr , \\t <>.gitcookies
*stuff here*
__END__
這裡修改了刪除全局設置的命令,並將.cookies文件放在本地目錄中而非用戶主目錄。
git commit -a
最後一步是下載depot_tools:
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
export PATH=`pwd`/depot_tools:”$PATH”
現在可以上傳更改了!
git cl upload -r [email protected]
該命令將上傳您的更改,並將其標記為當前HSTS預壓列表維護人Lucas Garron審核。 該命令還會提供一個地址,您可以查看提交的更改。 需要跳到此鏈接,並登陸您的Google帳戶,然後點擊“開始審核”,否則您的更改無法進行。 隨著更改提交併等待審核,現在需要證明此請求來自域的真正所有者/管理員。 只需要提交NS TXT記錄來批准請求。 格式在HSTS預加載列表Wiki上的報告URI客戶部分中概述,如下所示。
example.com. … “Please preload example.com for [Expect-CT/Expect-Staple/Expect-CT and Expect-Staple] using [subdomain].report-uri.com”
然後收到長這樣的記錄:
scotthelme.co.uk. 299 IN TXT “Please preload scotthelme.co.uk for Expect-CT and Expect-Staple using scotthelme.report-uri.com”
為您的域名以及想要啟用的功能更新這個記錄。然後待審核員(Lucas)過目後,您的域名就可以出現在下一版Chrome中的預加載列表中啦!
文章翻譯於scotthelme.co.uk
閱讀更多 GDCA數安時代 的文章