Skip to content

Commit

Permalink
Merge pull request #65 from MetehanGulduren/main
Browse files Browse the repository at this point in the history
Captcha Bypass
  • Loading branch information
mozlercelik authored Mar 15, 2024
2 parents 0502b85 + 81a0b75 commit 6aace85
Show file tree
Hide file tree
Showing 6 changed files with 105 additions and 24 deletions.
10 changes: 6 additions & 4 deletions app/lab/captcha-bypass/bypass/en.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ name="Name-Surname"
sendmessage="Forward Message"
captcha="Captcha"
submit="Send"
basarili="Congratulations, verification successful!"
basarisiz="Verification failed."
yenile='Refresh'
empty='Please enter a value.'
successful="Congratulations, verification successful!"
unsuccessful="Verification failed."
refresh='Refresh'
empty='Please enter a value.'
view_messages='View Messages'
message1='Messages'
10 changes: 6 additions & 4 deletions app/lab/captcha-bypass/bypass/fr.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ name="Prénom - nom de famille"
sendmessage="Transférer le mMessage"
captcha="Captcha"
submit="Envoyer"
basarili="Félicitations, vérification réussie !"
basarisiz="Échec de la vérification."
yenile='Rafraîchir'
empty='Veuillez entrer une valeur.'
successful="Félicitations, vérification réussie !"
unsuccessful="Échec de la vérification."
refresh='Rafraîchir'
empty='Veuillez entrer une valeur.'
view_messages='Afficher les messages'
message1='Messages'
29 changes: 18 additions & 11 deletions app/lab/captcha-bypass/bypass/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,25 @@ function generateCaptchaImage($num1, $num2)
if (isset($num1_posted, $num2_posted)) {
$captchaSonuc = $captchaAnswer == ($num1_posted + $num2_posted);

$message = $captchaSonuc ? "basarili" : "basarisiz";
$message = $captchaSonuc ? "successful" : "unsuccessful";

if ($captchaSonuc) {
$httpStatus = 200;
$_SESSION['num1'] = rand(1, 10);
$_SESSION['num2'] = rand(1, 10);

$username = isset($_POST['username']) ? htmlspecialchars($_POST['username']) : '';
$customMessage = isset($_POST['customMessage']) ? htmlspecialchars($_POST['customMessage']) : '';

$submittedMessage = "$username, $customMessage";
$_SESSION['messages'][] = $submittedMessage;
} else {
$httpStatus = 400;
$_SESSION['num1'] = $oncekiNum1;
$_SESSION['num2'] = $oncekiNum2;
}
} else {
$message = $strings['basarisiz'];
$message = $strings['unsuccessful'];
}
}

Expand Down Expand Up @@ -107,24 +113,25 @@ function generateCaptchaImage($num1, $num2)
<label for="customMessage"><?= $strings['sendmessage']; ?></label>
<textarea class="form-control" id="customMessage" name="customMessage" rows="3" placeholder="..."></textarea>
</div>
<div class="form-group <?php echo ($message === "basarisiz") ? 'wrong-answer' : ''; ?>">
<div class="form-group <?php echo ($message === "unsuccessful") ? 'wrong-answer' : ''; ?>">
<label for="captcha"><?= $strings['captcha']; ?> <br></label>
<div class="d-flex justify-content-between align-items-center captcha-answer" id="captcha-result">
<img src="data:image/png;base64,<?= generateCaptchaImage($num1, $num2) ?>" alt="Captcha Resmi" id="captcha-image">
<div>
<button type="button" class="btn btn-secondary btn-sm refresh-button" id="refresh-button"><?= $strings['yenile']; ?></button>
<button type="button" class="btn btn-secondary btn-sm refresh-button" id="refresh-button"><?= $strings['refresh']; ?></button>
</div>
</div> <br>
<input type="hidden" name="num1" id="num1" value="<?= $num1; ?>">
<input type="hidden" name="num2" id="num2" value="<?= $num2; ?>">
<input type="text" class="form-control" id="captcha" name="captcha" placeholder="<?= $strings['captcha']; ?>" value="<?= isset($_POST['captcha']) ? htmlspecialchars($_POST['captcha']) : '' ?>">
</div>
<button type="submit" class="btn btn-primary btn-block"><?= $strings['submit']; ?></button>
<a href="view_messages.php" class="btn btn-danger btn-block"><?= $strings['view_messages']; ?></a>
<?php
if ($message === "basarili") {
echo '<p class="mt-3 text-success">' . $strings['basarili'] . '</p>';
} elseif ($message === "basarisiz") {
echo '<p id="error-message" class="mt-3 text-danger">' . $strings['basarisiz'] . '</p>';
if ($message === "successful") {
echo '<p class="mt-3 text-success">' . $strings['successful'] . '</p>';
} elseif ($message === "unsuccessful") {
echo '<p id="error-message" class="mt-3 text-danger">' . $strings['unsuccessful'] . '</p>';
}
?>
</form>
Expand Down Expand Up @@ -188,7 +195,7 @@ function validateForm() {

document.addEventListener('DOMContentLoaded', function () {

<?php if ($message !== 'basarisiz') { ?>
<?php if ($message !== 'unsuccessful') { ?>
refreshCaptcha();
<?php } ?>

Expand All @@ -202,8 +209,8 @@ function validateForm() {
var errorMessageElement = document.getElementById('error-message');
var message = '<?= $message; ?>';

if (message === 'basarisiz' && errorMessageElement) {
errorMessageElement.innerHTML = '<?= $strings["basarisiz"]; ?>';
if (message === 'unsuccessful' && errorMessageElement) {
errorMessageElement.innerHTML = '<?= $strings["unsuccessful"]; ?>';
}
});
</script>
Expand Down
10 changes: 6 additions & 4 deletions app/lab/captcha-bypass/bypass/tr.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ name="Ad-Soyad"
sendmessage="Mesaj İlet"
captcha="Captcha"
submit="Gönder"
basarili="Tebrikler, doğrulama başarılı!"
basarisiz="Doğrulama başarısız."
yenile='Yenile'
empty='Lütfen bir değer girin.'
successful="Tebrikler, doğrulama başarılı!"
unsuccessful="Doğrulama başarısız."
refresh='Yenile'
empty='Lütfen bir değer girin.'
view_messages='Mesajları Görüntüle'
message1='Mesajlar'
68 changes: 68 additions & 0 deletions app/lab/captcha-bypass/bypass/view_messages.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?php
session_start();
$messages = isset($_SESSION['messages']) ? $_SESSION['messages'] : [];

require("../../../lang/lang.php");
$strings = tr();

?>
<!DOCTYPE html>
<html lang="tr">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<style>
body {
font-family: Arial, sans-serif;
background-color: #f8f9fa;
margin: 20px;
}

table {
width: 100%;
border-collapse: collapse;
margin-top: 20px;
}

th,
td {
border: 1px solid #dee2e6;
padding: 10px;
text-align: left;
}

th {
background-color: #007bff;
color: #ffffff;
}
</style>
<title><?= $strings['title']; ?></title>
</head>

<body>
<div class="container">
<h2 class="mt-4"><?= $strings['view_messages']; ?></h2>
<table class="table">
<thead>
<tr>
<th><?= $strings['name']; ?></th>
<th><?= $strings['message1']; ?></th>
</tr>
</thead>
<tbody>
<?php foreach ($messages as $message) : ?>
<?php list($name, $customMessage) = explode(', ', $message, 2); ?>
<tr>
<td><?= htmlspecialchars($name); ?></td>
<td><?= htmlspecialchars($customMessage); ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<script id="VLBar" title="<?= $strings['title']; ?>" category-id="14" src="/public/assets/js/vlnav.min.js"></script>
</body>

</html>
2 changes: 1 addition & 1 deletion app/lab/captcha-bypass/bypass1/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,4 +267,4 @@ function generateCaptcha($width, $height, $length = 6)
</html>


<script id="VLBar" title="<?= $strings["title"]; ?>" category-id="13" src="/public/assets/js/vlnav.min.js"></script>
<script id="VLBar" title="<?= $strings["title"]; ?>" category-id="14" src="/public/assets/js/vlnav.min.js"></script>

0 comments on commit 6aace85

Please sign in to comment.