encoder.php 860 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. include_once("oracles/base.php");
  3. class encoder extends oracle {
  4. public $info = [
  5. "name" => "text encoder/hasher"
  6. ];
  7. private $special_types = [
  8. "rot13",
  9. "base64"
  10. ];
  11. public function check_query($q) {
  12. $types = array_merge($this->special_types, hash_algos());
  13. foreach ($types as $type) {
  14. $type .= " ";
  15. if (str_starts_with($q, $type)) {
  16. return true;
  17. }
  18. }
  19. return false;
  20. }
  21. public function generate_response($q)
  22. {
  23. $type = explode(" ", $q)[0];
  24. $victim = substr($q, strlen($type)+1);
  25. if (in_array($type, hash_algos())) {
  26. return [$type." hash" => hash($type, $victim)];
  27. }
  28. switch ($type) {
  29. case "rot13":
  30. return ["rot13 encoded" => str_rot13($victim)];
  31. case "base64":
  32. return [
  33. "base64 encoded" => base64_encode($victim),
  34. "base64 decoded" => base64_decode($victim)
  35. ];
  36. }
  37. return "";
  38. }
  39. }
  40. ?>