From d40b757d0a4d574e12f9a14c9392e0854c624641 Mon Sep 17 00:00:00 2001 From: mikemirzayanov Date: Sun, 24 Dec 2023 20:15:37 +0300 Subject: [PATCH] PowFilter: : -> _ --- .../java/org/nocturne/ddos/PowFilter.java | 36 ++++++++++--------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/code/src/main/java/org/nocturne/ddos/PowFilter.java b/code/src/main/java/org/nocturne/ddos/PowFilter.java index 457befc..3a6e2cc 100644 --- a/code/src/main/java/org/nocturne/ddos/PowFilter.java +++ b/code/src/main/java/org/nocturne/ddos/PowFilter.java @@ -190,26 +190,30 @@ private void doInternalFilter(HttpServletRequest request, HttpServletResponse re powCookie.setMaxAge((int) TimeUnit.DAYS.toSeconds(1)); response.addCookie(powCookie); response.setContentType("text/html"); - PrintWriter writer = response.getWriter(); - writer.println("\n

Please wait. Your browser is being checked. It may take a few seconds...

"); - writer.println(""); - writer.flush(); + printResponse(response); info("writer.flush(), Set-Cookie: pow=" + half + "."); } } + private static void printResponse(HttpServletResponse response) throws IOException { + PrintWriter writer = response.getWriter(); + writer.println("\n

Please wait. Your browser is being checked. It may take a few seconds...

"); + writer.println(""); + writer.flush(); + } + private boolean isResult(String cookie, String halfSecret) { - if (cookie.endsWith(":" + halfSecret)) { + if (StringUtil.isNotEmpty(cookie) && cookie.endsWith("_" + halfSecret)) { String hash = DigestUtils.sha1Hex(cookie); return hash.startsWith("0000"); } else { @@ -399,7 +403,7 @@ private static String getPowCode() { " var c = getCookie('pow').substring(0, 20);\n" + " var i = 0;\n" + " for (i = 0;; i++) {\n" + - " var s = i.toString() + ':' + c;\n" + + " var s = i.toString() + '_' + c;\n" + " var hash = sha1(s);\n" + " var prefix = hash.substring(0, 4);\n" + " if (prefix === \"0000\") {\n" +