-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
90 lines (77 loc) · 3.82 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Effective OTP Calculator</title>
<style>
body { font-family: Arial, sans-serif; margin: 20px; }
label, input { display: block; margin-top: 10px; }
.results { margin-top: 20px; font-weight: bold; }
</style>
</head>
<body>
<h2>Effective OTP Calculator</h2>
<label>
OTP Requests per Time Frame:
<input type="number" id="otpRequestsPerTimeFrame" value="5">
</label>
<label>
Time Frame for OTP Requests (minutes):
<input type="number" id="otpTimeFrameMinutes" value="60">
</label>
<label>
Max OTP Requests Per Day:
<input type="number" id="otpRequestsPerDay" value="15">
</label>
<label>
Ban Length After Hitting Daily OTP Cap (minutes):
<input type="number" id="otpBanLengthMinutes" value="60">
</label>
<hr>
<label>
Verification Attempts per Time Frame:
<input type="number" id="verificationAttemptsPerTimeFrame" value="3">
</label>
<label>
Time Frame for Verification Attempts (minutes):
<input type="number" id="verificationTimeFrameMinutes" value="5">
</label>
<label>
Max Verification Attempts Per Day:
<input type="number" id="verificationAttemptsPerDay" value="15">
</label>
<label>
Verification Attempts per Single OTP Request:
<input type="number" id="attemptsPerOtp" value="1">
</label>
<button onclick="calculate()">Calculate</button>
<div class="results" id="results"></div>
<script>
function calculate() {
const totalUniqueOtps = 1000000;
const otpRequestsPerTimeFrame = parseInt(document.getElementById("otpRequestsPerTimeFrame").value);
const otpTimeFrameMinutes = parseInt(document.getElementById("otpTimeFrameMinutes").value);
const otpRequestsPerDay = parseInt(document.getElementById("otpRequestsPerDay").value);
const otpBanLengthMinutes = parseInt(document.getElementById("otpBanLengthMinutes").value);
const verificationAttemptsPerTimeFrame = parseInt(document.getElementById("verificationAttemptsPerTimeFrame").value);
const verificationTimeFrameMinutes = parseInt(document.getElementById("verificationTimeFrameMinutes").value);
const verificationAttemptsPerDay = parseInt(document.getElementById("verificationAttemptsPerDay").value);
const attemptsPerOtp = parseInt(document.getElementById("attemptsPerOtp").value);
const otpIntervalsPerDay = Math.floor((24 * 60) / otpTimeFrameMinutes);
const verificationIntervalsPerDay = Math.floor((24 * 60) / verificationTimeFrameMinutes);
const totalOtpRequestsPerDay = Math.min(otpRequestsPerDay, otpRequestsPerTimeFrame * otpIntervalsPerDay);
const totalVerificationAttemptsPerDay = Math.min(verificationAttemptsPerDay, verificationAttemptsPerTimeFrame * verificationIntervalsPerDay);
const effectiveOtpsPerDay = Math.min(totalOtpRequestsPerDay, Math.floor(totalVerificationAttemptsPerDay / attemptsPerOtp));
const bruteForceProbability = 1 - Math.pow(Math.pow((1 - (1 / totalUniqueOtps)), attemptsPerOtp), effectiveOtpsPerDay);
document.getElementById("results").innerHTML = `
<p>Total OTP Requests Possible Per Day: ${totalOtpRequestsPerDay}</p>
<p>Total Verification Attempts Possible Per Day: ${totalVerificationAttemptsPerDay}</p>
<hr>
<p>Effective OTPs that can be Verified in a Day: ${effectiveOtpsPerDay}</p>
<p>Bruteforce Probability: ${(bruteForceProbability * 100).toFixed(6)}%</p>
`;
}
</script>
</body>
</html>