Last active
March 20, 2024 00:28
-
-
Save TimoReusch/68048955d78810a36dac87e8e5bae6c6 to your computer and use it in GitHub Desktop.
A simple website, that hides your personal email behind a captcha.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$secretKey = "SECRET_CAPTCHA_KEY_HERE"; | |
$responseKey = $_POST['g-recaptcha-response']; | |
$userIP = $_SERVER['REMOTE_ADDR']; | |
$url = "https://www.google.com/recaptcha/api/siteverify?secret=$secretKey&response=$responseKey&remoteip=$userIP"; | |
$response = file_get_contents($url); | |
$response = json_decode($response); | |
if ($response->success) { | |
echo json_encode(array("email" => "EMAIL_HERE")); // Send the email address back | |
} else { | |
echo json_encode(array("error" => "Captcha verification failed")); | |
} | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Mail | timo-reusch.de</title> | |
<script src="https://www.google.com/recaptcha/api.js" async defer></script> | |
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" | |
integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous"> | |
<script> | |
function onSubmit(token) { | |
document.getElementById("captcha-form").submit(); | |
} | |
function verifyCaptcha() { | |
fetch('captcha-verify.php', { | |
method: 'POST', | |
body: new URLSearchParams('g-recaptcha-response=' + grecaptcha.getResponse()) | |
}) | |
.then(response => response.json()) | |
.then(data => { | |
if(data.email) { | |
document.getElementById('email-display').innerText = data.email; | |
} else { | |
alert('Captcha verification failed.'); | |
} | |
}); | |
} | |
</script> | |
</head> | |
<body data-bs-theme="dark"> | |
<div class="d-flex justify-content-center align-items-center vh-100"> | |
<div class="row"> | |
<div class="col-12"> | |
<div class="card"> | |
<div class="card-body"> | |
<h5 class="card-title">E-Mail Address</h5> | |
<br> | |
<form id="captcha-form" action="javascript:verifyCaptcha()"> | |
<div class="g-recaptcha" data-sitekey="CAPTCHA_SITEKEY_HERE" data-callback="onSubmit"></div> | |
</form> | |
<div class="text-center mt-3" id="email-display"></div> | |
</div> | |
</div> | |
</div> | |
</div> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment