Advertisement
Combreal

cesarCrypto.php

Jul 18th, 2020
1,370
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.38 KB | None | 0 0
  1. <?php
  2. function getContent($url, $cookiePath)
  3. {
  4. //used Export Cookies extension to get NC cookie
  5. $ch = curl_init ();
  6. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
  7. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  8. curl_setopt ( $ch, CURLOPT_URL, $url );
  9. curl_setopt ( $ch, CURLOPT_HEADER, 0 );
  10. curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1 );
  11. curl_setopt ( $ch, CURLOPT_CONNECTTIMEOUT, 0 );
  12. curl_setopt($ch, CURLOPT_COOKIEFILE, $cookiePath);
  13. curl_setopt($ch, CURLOPT_VERBOSE, true);
  14. $file_contents = curl_exec ( $ch );
  15. if (curl_errno ( $ch )) {
  16.     echo curl_error ( $ch );
  17.     curl_close ( $ch );
  18.     exit ();
  19. }
  20. curl_close ( $ch );
  21. return $file_contents;
  22. }
  23. $content = getContent("https://www.newbiecontest.org/epreuves/prog/prog5.php", 'C:/Temp/cookies.txt');
  24. $key = (int) filter_var($content, FILTER_SANITIZE_NUMBER_INT);
  25. if (preg_match("/'(.+)'/", $content, $m))
  26. {
  27.     $m[0] = substr($m[0], 1);
  28.     $m[0] = substr($m[0], 0, strpos($m[0],"'"));
  29. }
  30. $alphabet = "abcdefghijklmnopqrstuvwxyz";
  31. $newAlphabet = substr($alphabet, $key);
  32. $rest = substr($alphabet, 0, $key);
  33. $newAlphabet = $newAlphabet.$rest;
  34. $myArray = str_split($m[0]);
  35. $decrypt = "";
  36. foreach($myArray as $character)
  37. {
  38.     $pos = strpos($newAlphabet, $character);
  39.     $decrypt = $decrypt.$alphabet[$pos];
  40. }
  41. $subm = "https://www.newbiecontest.org/epreuves/prog/verifpr5.php?solution=" . $decrypt;
  42. header("Location: $subm");
  43. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement