本頁說明如何使用 Google Cloud Fraud Defense 偵測及防範帳戶入侵 (ATO) 行為。
攻擊者通常會使用從資料侵害事件取得的憑證 (也稱為密碼傾印),向 API 端點傳送登入要求,藉此發動帳戶盜用攻擊。即使密碼傾印來自不相關的網站,這類攻擊仍可能成功,因為人類傾向在多個帳戶中重複使用密碼。只要使用者養成良好的密碼習慣 (例如使用密碼管理工具),就不會受到這類攻擊影響。
事前準備
準備 Google Cloud Fraud Defense 環境。
偵測及防範帳戶盜用
您可以透過下列任一方式,使用 Fraud Defense 偵測及防範帳戶盜用:
使用「我不是機器人」核取方塊
在網站中加入「我不是機器人」核取方塊,是防範帳戶盜用的最快速簡單方法,不必整合簡訊或電子郵件驗證等額外功能。攻擊者必須付出代價才能破解這項防護措施,因此對某些網站來說,這個選項可能就已足夠。
在網頁上新增「我不是機器人」核取方塊。
以下程式碼是受核取方塊保護的登入頁面即時範例:
function onSuccess(token) {
// The token is included in the POST data in the g-recaptcha-response
// parameter. The backend must create an Assessment with the token
// and verify the token is valid.
console.log(token);
}<form id="loginForm" action="?" method="POST">
Username: <input type="text" name="username"/><br/>
Password: <input type="password" name="password"/><br/>
<div class="g-recaptcha" data-sitekey="reCATCHA_sitekey"
data-action="account_login" data-callback="onSuccess"></div>
</form><script src="https://www.google.com/recaptcha/enterprise.js" async defer></script>
按一下程式碼視窗右上角的 <> 圖示,即可在 JSFiddle 中測試這個程式碼。
<html>
<head>
<title>Account Login - Checkbox</title>
<script src="https://www.google.com/recaptcha/enterprise.js" async defer></script>
<script>
function onSuccess(token) {
// The token is included in the POST data in the g-recaptcha-response
// parameter. The backend must create an Assessment with the token
// and verify the token is valid.
console.log(token);
}
</script>
</head>
<body>
<form id="loginForm" action="?" method="POST">
Username: <input type="text" name="username"/><br/>
Password: <input type="password" name="password"/><br/>
<div class="g-recaptcha" data-sitekey="6LeAkOgUAAAAACcy3uY6N9H9SJMS27n3Zx2OOnYK"
data-action="account_login" data-callback="onSuccess"></div>
</form>
</body>
</html>使用分數和自訂挑戰
如要防範帳戶入侵,請使用以 Fraud Defense 分數為依據的金鑰,並採用多重驗證 (MFA) 挑戰,例如電子郵件和簡訊挑戰,系統會將一次性代碼 (OTP) 傳送給使用者。
如要使用以分數為依據的驗證碼和自訂挑戰,請考慮下列選項:
安裝以分數為準的鍵,偵測大規模帳戶盜用事件中的自動化行為。
如要在網頁上安裝分數制金鑰,請參閱「在網頁上安裝分數制金鑰」。
如要在行動應用程式中安裝評分結果金鑰,請參閱「將 Fraud Defense 整合至 Android 應用程式」或「將 Fraud Defense 整合至 iOS 應用程式」。
在登入或執行敏感操作時,使用多重驗證確認帳戶擁有權。
詳情請參閱「設定多重驗證」。
視用途而定,您可以單獨使用 MFA,也可以搭配根據分數的密鑰使用。舉例來說,您可能只想在分數低於特定門檻時使用多重驗證,以減少阻力。
以下範例說明如何在登入情境中整合以分數為準的索引鍵。
function submitForm() {
grecaptcha.enterprise.ready(function() {
grecaptcha.enterprise.execute(
'reCAPTCHA_site_key', {action: 'account_login'}).then(function(token) {
document.getElementById("token").value = token;
document.getElementByID("loginForm").submit();
});
});
}<form id="loginForm" action="?" method="POST"> Username: <input type="text" name="username"/><br/> Password: <input type="password" name="password"/><br/> <input type="hidden" id="token" name="recaptcha_token"/> <button onclick="submitForm()">Login</button> </form>
<script src="https://www.google.com/recaptcha/enterprise.js" async defer></script>
您可以按一下程式碼視窗右上角的 <> 圖示,在 JSFiddle 中測試這個程式碼。
<html>
<head>
<title>Account Login - Score</title>
<script src="https://www.google.com/recaptcha/enterprise.js" async defer></script>
<script>
function submitForm() {
grecaptcha.enterprise.ready(function() {
grecaptcha.enterprise.execute(
'reCAPTCHA_site_key', {action: 'account_login'}).then(function(token) {
document.getElementById("token").value = token;
document.getElementByID("loginForm").submit();
});
});
}
</script>
</head>
<body>
<form id="loginForm" action="?" method="POST">
Username: <input type="text" name="username"/><br/>
Password: <input type="password" name="password"/><br/>
<input type="hidden" id="token" name="recaptcha_token"/>
<button onclick="submitForm()">Login</button>
</form>
</body>
</html>後續步驟
- 如要瞭解其他帳戶保護功能,請參閱「使用者帳戶保護功能」。