Advertisement
caasinehc

PurpleMind RSA Cracker

Apr 18th, 2025
365
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (function() {
  2.     const E = 65537n;
  3.     const N = 1000000000100000000002379n;
  4.     const D = 773700352548471672492113n;
  5.    
  6.     function pow_mod(base, exp, mod) {
  7.         let n = 1n;
  8.         while(exp > 0n) {
  9.             if(exp % 2n === 1n) {
  10.                 n *= base;
  11.                 exp -= 1n;
  12.             }
  13.            
  14.             base = base ** 2n % mod;
  15.             exp /= 2n;
  16.  
  17.             n %= mod;
  18.         }
  19.        
  20.         return n;
  21.     }
  22.    
  23.     function crack(cyphertext, d, e, n) {
  24.         let start_plain = cyphertext.substring(0, 30);
  25.         let rest_cypher = cyphertext.substring(30);
  26.    
  27.         let rest_plain = rest_cypher
  28.             // Text pre-processing to strip interwoven words and concatenate and parse lines
  29.             .split("\n").map(line => line.split(" ").filter((_, i) => i % 2 == 0).join("")).map(n => BigInt(n))
  30.             // Decrypting using `d`
  31.             .map(x => pow_mod(x, d, n))
  32.             // Converting the decrypted numbers to ASCII
  33.             .map(n => n.toString().padStart(3 * 8, "0").match(/.{3}/g).map(n => String.fromCharCode(parseInt(n))).join("")).join("");
  34.    
  35.         return start_plain + rest_plain;
  36.     }
  37.  
  38.     for(let comment of document.querySelectorAll("ytd-comment-thread-renderer #content-text")) {
  39.         if(/^(.|\n){30}((\d{3}\s+\w+\s*){8}\n?)+$/g.test(comment.innerText)) {
  40.             comment.innerText = `DECRYPTED: [[[ ${crack(comment.innerText, D, E, N)} ]]]`;
  41.         }
  42.         else if(/(\b\d{3}\b.*){8}/g.test(comment.innerText) && !/^FAILED TO DECRYPT \(invalid format\): \[\[\[ (.|\n)* \]\]\]$/g.test(comment.innerText)) {
  43.             comment.innerText = `FAILED TO DECRYPT (invalid format): [[[ ${comment.innerText} ]]]`;
  44.         }
  45.     }
  46. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement