document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. <?php
  2. require("conn.php");
  3. ?>
  4. <html>
  5. <head>
  6. <script>
  7. function generar(inf,sup){
  8. numP = sup - inf;
  9.     rnd = Math.random() * numP;
  10.     rnd = Math.round(rnd);
  11.     document.formulario.challengen.value=parseInt(inf) + rnd;
  12. }
  13.  
  14.  
  15. </script>
  16. </head>
  17. <a href="script.py">Descargar script</a>
  18. <form name="formulario" method="POST" action="validar.php" >
  19. <b>Challenge:</b><input type="text" name="challengen"><input type="button" value="Generate" onclick="generar(0,100)">
  20. <br><b>User:</b><select name="user">
  21. <?php
  22. $query="SELECT user FROM users";
  23. $result=mysql_query($query,$conn);
  24. while($row=mysql_fetch_array($result)){
  25. echo "<option value=\'".$row["user"]."\'>".$row["user"]."</option>";
  26. }
  27. ?>
  28.  </select>
  29.  <br><b>Response:</b><input type="text" name="response">
  30.  <br><input type="submit" value="submit">
  31.  
  32.  <?php
  33.  function f($x){
  34.     return ($x*10+3);
  35. }
  36.  
  37. function fastmodexp($x, $y, $mod){
  38.   $p = 1;
  39.   $aux = $x;
  40.   while($y > 0){
  41.       if ($y % 2 == 1){
  42.           $p = ($p * $aux) % $mod;
  43.       }
  44.       $aux = ($aux * $aux) % $mod;
  45.       $y = $y >> 1;
  46.   }
  47.   return ($p);
  48. }
  49.  
  50.  
  51. if(isset($_POST[\'response\']) and isset($_POST[\'user\']) and isset($_POST[\'challengen\'])){
  52.    $usuario = $_POST[\'user\'];
  53.    $x = $_POST[\'challengen\'];
  54.    $r = $_POST[\'response\'];
  55.    $query="SELECT E,N From users WHERE user = \'". $usuario."\'";
  56.     $result=mysql_query($query,$conn);
  57.    $publica = mysql_fetch_array($result);
  58.    
  59.  
  60.    $e = $publica["E"];
  61.    $n = $publica["N"];  
  62.  
  63.    $y = f($x);
  64.    $num = fastmodexp($r, $e, $n);
  65.  
  66.    if ($y == $num){
  67.       echo "<strong><h2>Yes, it was ". $usuario ." :)</h2></strong>";
  68.    } else {
  69.       echo "<strong><h2>No, it wasn\'t ". $usuario ." :(</h2></strong>";
  70.    }
  71. } ?>
  72. </form>
  73. </html>
  74.  
  75. --------------------------------------SCRIPT---------------------------------------------
  76.  
  77. def f(x):
  78.     return x*x+7
  79.  
  80. def fastmodexp(x, y, mod):
  81.     p = 1
  82.     aux = x
  83.     while y > 0:
  84.         if y % 2 == 1:
  85.             p = (p * aux) % mod
  86.         aux = (aux * aux) % mod
  87.         y = y >> 1
  88.     return p
  89.  
  90. def main():
  91.     x = int(raw_input("x: "))
  92.     d = int(raw_input("d: "))
  93.     n = int(raw_input("n: "))
  94.     y = f(x)
  95.     r = fastmodexp(y, d, n)
  96.     print "La r es = " + str(r)
  97.  
  98. main()
  99. ----------------------------------------------------------------------------
');