"ddos challenge" style script #4

Open
luna wants to merge 20 commits from claude/ddos-protection-challenge-01CMAtrK6Dt24x9Q3v6Gz9fS into mistress
Showing only changes of commit 89dc5da94e - Show all commits

View file

@ -25,6 +25,79 @@ local function getCookieValue(cookie_header, cookie_name)
return value return value
end end
-- Common CSS styles for all challenge pages
local COMMON_STYLES = [[
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
margin: 0;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}
.container {
background: white;
padding: 3rem;
border-radius: 1rem;
box-shadow: 0 20px 60px rgba(0,0,0,0.3);
max-width: 450px;
text-align: center;
}
h1 {
color: #333;
margin-bottom: 1rem;
font-size: 1.75rem;
}
p {
color: #666;
margin-bottom: 2rem;
line-height: 1.6;
}
button {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
border: none;
padding: 1rem 2rem;
font-size: 1rem;
border-radius: 0.5rem;
cursor: pointer;
font-weight: 600;
transition: transform 0.2s, box-shadow 0.2s;
width: 100%;
}
button:hover {
transform: translateY(-2px);
box-shadow: 0 10px 25px rgba(102, 126, 234, 0.4);
}
button:active {
transform: translateY(0);
}
.honeypot {
position: absolute;
left: -9999px;
width: 1px;
height: 1px;
overflow: hidden;
}
.spinner {
display: none;
border: 3px solid #f3f3f3;
border-top: 3px solid #667eea;
border-radius: 50%;
width: 30px;
height: 30px;
animation: spin 1s linear infinite;
margin: 1rem auto;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
.loading button { display: none; }
.loading .spinner { display: block; }
]]
-- Question pool for multiple-choice challenges -- Question pool for multiple-choice challenges
local QUESTIONS = { local QUESTIONS = {
{q = "What is 7 + 5?", answers = {"10", "12", "14", "15"}, correct = 2}, {q = "What is 7 + 5?", answers = {"10", "12", "14", "15"}, correct = 2},
@ -58,7 +131,6 @@ local function challengeInit(cfg)
end end
local function serveButtonChallenge(original_uri) local function serveButtonChallenge(original_uri)
-- Simple button challenge page with honeypot
local html = [[ local html = [[
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
@ -66,78 +138,7 @@ local function serveButtonChallenge(original_uri)
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Security Check</title> <title>Security Check</title>
<style> <style>]] .. COMMON_STYLES .. [[</style>
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
margin: 0;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}
.container {
background: white;
padding: 3rem;
border-radius: 1rem;
box-shadow: 0 20px 60px rgba(0,0,0,0.3);
max-width: 400px;
text-align: center;
}
h1 {
color: #333;
margin-bottom: 1rem;
font-size: 1.75rem;
}
p {
color: #666;
margin-bottom: 2rem;
line-height: 1.6;
}
button {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
border: none;
padding: 1rem 2rem;
font-size: 1rem;
border-radius: 0.5rem;
cursor: pointer;
font-weight: 600;
transition: transform 0.2s, box-shadow 0.2s;
width: 100%;
}
button:hover {
transform: translateY(-2px);
box-shadow: 0 10px 25px rgba(102, 126, 234, 0.4);
}
button:active {
transform: translateY(0);
}
/* Honeypot link - invisible to humans but crawlable by bots */
.honeypot {
position: absolute;
left: -9999px;
width: 1px;
height: 1px;
overflow: hidden;
}
.spinner {
display: none;
border: 3px solid #f3f3f3;
border-top: 3px solid #667eea;
border-radius: 50%;
width: 30px;
height: 30px;
animation: spin 1s linear infinite;
margin: 1rem auto;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
.loading button { display: none; }
.loading .spinner { display: block; }
</style>
</head> </head>
<body> <body>
<div class="container" id="container"> <div class="container" id="container">
@ -148,7 +149,6 @@ local function serveButtonChallenge(original_uri)
<button type="submit">Verify I'm Human</button> <button type="submit">Verify I'm Human</button>
</form> </form>
<div class="spinner"></div> <div class="spinner"></div>
<!-- Honeypot link for bots -->
<a href="/__aproxy_challenge_trap" class="honeypot">Click here to continue</a> <a href="/__aproxy_challenge_trap" class="honeypot">Click here to continue</a>
</div> </div>
</body> </body>
@ -189,39 +189,18 @@ local function serveQuestionChallenge(original_uri, state)
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Security Check</title> <title>Security Check</title>
<style> <style>
body { ]] .. COMMON_STYLES .. [[
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; .question {
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
margin: 0;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}
.container {
background: white;
padding: 3rem;
border-radius: 1rem;
box-shadow: 0 20px 60px rgba(0,0,0,0.3);
max-width: 450px;
text-align: center;
}
h1 {
color: #333;
margin-bottom: 1rem;
font-size: 1.75rem;
}
.question {
color: #444; color: #444;
font-size: 1.1rem; font-size: 1.1rem;
margin: 2rem 0; margin: 2rem 0;
font-weight: 500; font-weight: 500;
} }
.options { .options {
text-align: left; text-align: left;
margin: 2rem 0; margin: 2rem 0;
} }
.option { .option {
display: block; display: block;
padding: 1rem; padding: 1rem;
margin: 0.75rem 0; margin: 0.75rem 0;
@ -229,37 +208,14 @@ local function serveQuestionChallenge(original_uri, state)
border-radius: 0.5rem; border-radius: 0.5rem;
cursor: pointer; cursor: pointer;
transition: all 0.2s; transition: all 0.2s;
} }
.option:hover { .option:hover {
border-color: #667eea; border-color: #667eea;
background: #f8f9ff; background: #f8f9ff;
} }
.option input[type="radio"] { .option input[type="radio"] {
margin-right: 0.75rem; margin-right: 0.75rem;
} }
button {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
border: none;
padding: 1rem 2rem;
font-size: 1rem;
border-radius: 0.5rem;
cursor: pointer;
font-weight: 600;
transition: transform 0.2s, box-shadow 0.2s;
width: 100%;
}
button:hover {
transform: translateY(-2px);
box-shadow: 0 10px 25px rgba(102, 126, 234, 0.4);
}
.honeypot {
position: absolute;
left: -9999px;
width: 1px;
height: 1px;
overflow: hidden;
}
</style> </style>
</head> </head>
<body> <body>
@ -297,59 +253,19 @@ local function servePowChallenge(original_uri, state)
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Security Check</title> <title>Security Check</title>
<style> <style>
body { ]] .. COMMON_STYLES .. [[
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; .status {
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
margin: 0;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}
.container {
background: white;
padding: 3rem;
border-radius: 1rem;
box-shadow: 0 20px 60px rgba(0,0,0,0.3);
max-width: 450px;
text-align: center;
}
h1 {
color: #333;
margin-bottom: 1rem;
font-size: 1.75rem;
}
p {
color: #666;
margin-bottom: 1rem;
line-height: 1.6;
}
.status {
font-family: monospace; font-family: monospace;
color: #667eea; color: #667eea;
font-weight: 600; font-weight: 600;
margin: 1rem 0; margin: 1rem 0;
} }
.spinner { .spinner {
border: 3px solid #f3f3f3; display: block;
border-top: 3px solid #667eea;
border-radius: 50%;
width: 40px; width: 40px;
height: 40px; height: 40px;
animation: spin 1s linear infinite;
margin: 1.5rem auto; margin: 1.5rem auto;
} }
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
.honeypot {
position: absolute;
left: -9999px;
width: 1px;
height: 1px;
overflow: hidden;
}
</style> </style>
</head> </head>
<body> <body>