Back loop XOR. How?

Einklappen
X
 
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

  • Back loop XOR. How?

    Hello mans! I need you help!
    This is XOR encryption:

    PHP-Code:
    for ($i 0$i $suma; ++$i)
    {
      
    $ctxt .= $text[$i] ^ $dlina[$i $hlam] ^ $bite $dbite;
      
    $bite $text[$i];

    $ctxt - encryption text. How decode this text in $ctext ?
    I need back loop!

    Thank you

  • #2
    $text -> XOR encryption -> $ctext

    How create back loop?

    $ctext -> XOR decryption -> $text

    Pleaseeee, heeeeeelllppppp

    Kommentar


    • #3
      What is XOR encryption?
      http://php.net/manual/en/language.operators.bitwise.php
      http://en.wikipedia.org/wiki/Stream_cipher

      Next time ask google first please!
      Zuletzt geändert von onemorenerd; 13.07.2009, 04:59.

      Kommentar


      • #4
        Zitat von onemorenerd Beitrag anzeigen
        Next time ask google first please!
        PHP-Code:
        for ($i 0$i $suma; ++$i

          
        $ctxt .= $text[$i] ^ $dlina[$i $hlam] ^ $bite $dbite
          
        $bite $text[$i]; 

        You don't understand me!
        How create back loop decryption for this operation ? :-))) This operation encryption $text.

        Kommentar


        • #5
          I think I do understand you. You want a piece of code that takes $ctxt and returns the original $text. But you don't seem to know what your snippet does.
          PHP-Code:
          for ($i 0$i $suma; ++$i) {
              
          $key $dlina[$i $hlam] ^ ($i $text[$i-1] : $bite) ^ $dbite;
              
          $ctxt .= $text[$i] ^ $key;

          Better now? Then go on ... XOR decryption is basically XOR encryption with XOR encrypted input.
          The real problem is to compute the dynamic key. I can't help you with that because I don't know the incredients.

          Btw: What are trying to crack? Is it legal?

          Kommentar


          • #6
            Zitat von onemorenerd Beitrag anzeigen
            Btw: What are trying to crack? Is it legal?
            This code write phpcoder for my mother. This encryption text writing in MySQL. My mother want viewing the original text. She asked me to create this. But I don't know how to decode this text. It's legally.

            Kommentar


            • #7
              Zitat von onemorenerd Beitrag anzeigen
              Better now?
              NO

              PHP-Code:
              <?php
              // this POST text
              $text 'Hello man, hello man, hello man, hello man, hello man, hello man, hello man';

              // encrypt XOR
              $dlina 'xGbvdeekRjQFRmyKEyX5Uan880YYEtoVmQ6JCdCNWkhd9TkKhFSaQE';
              $hlam strlen($dlina);
              $but md5($dlina);
              $bite $but[3];
              $dbite $but[1];
              $suma strlen($text);

              for (
              $i 0$i $suma; ++$i)  
              {  
                
              $ctxt .= $text[$i] ^ $dlina[$i $hlam] ^ $bite $dbite;  
                
              $bite $text[$i];  
              }

              echo 
              $ctxt."<br>";

              // Decrypt this XOR
              $txts $ctxt;
              $sumas strlen($txts);

              for (
              $i 0$i $sumas; ++$i) {
                  
              $key $dlina[$i $hlam] ^ ($i $txts[$i-1] : $bite) ^ $dbite;
                  
              $txtss .= $txts[$i] ^ $key;


              echo 
              $txtss;
              ?>
              Zuletzt geändert von Nirvana77; 13.07.2009, 16:35.

              Kommentar


              • #8
                The code in my last post wasn't meant to decrypt. It's just a variant of the snippet you gave with the advantage that the key can be logged.

                PHP-Code:
                <?php
                define
                ('BR'"\n"); echo '<pre>';

                // POSTed
                $input 'Hello man, hello man, hello man, hello man, hello man, hello man, hello man';


                /*
                 * Your XOR encryption
                 */

                // take raw input
                $text $input;

                // incredients
                $dlina 'xGbvdeekRjQFRmyKEyX5Uan880YYEtoVmQ6JCdCNWkhd9TkKhFSaQE';
                $hlam strlen($dlina);
                $but md5($dlina);
                $bite $but[3];
                $dbite $but[1];
                $suma strlen($text);
                $ctxt '';

                // encrypt XOR
                for ($i 0$i $suma; ++$i) {  
                  
                $ctxt .= $text[$i] ^ $dlina[$i $hlam] ^ $bite $dbite;  
                  
                $bite $text[$i];  
                }

                echo 
                $text BR;
                echo 
                $ctxt BR;
                echo 
                BR;
                echo 
                str2bin($text) . BR;
                echo 
                str2bin($ctxt) . BR;
                echo 
                BRBR;


                /*
                 * My variant of the same
                 */

                // this POST text
                $text $input;

                // incredients
                $dlina 'xGbvdeekRjQFRmyKEyX5Uan880YYEtoVmQ6JCdCNWkhd9TkKhFSaQE';
                $hlam strlen($dlina);
                $but md5($dlina);
                $bite $but[3];
                $dbite $but[1];
                $suma strlen($text);
                $ctxt '';
                $keylog '';

                // encrypt XOR
                for ($i 0$i $suma; ++$i) {
                    
                $key $dlina[$i $hlam] ^ ($i $text[$i-1] : $bite) ^ $dbite;
                    
                $keylog .= $key;
                    
                $ctxt .= $text[$i] ^ $key;
                }

                echo 
                $text BR;
                echo 
                $ctxt BR;
                echo 
                BR;
                echo 
                str2bin($text) . BR;
                echo 
                str2bin($keylog) . BR;
                echo 
                str2bin($ctxt) . BR;
                echo 
                BRBR;

                /*
                 * XOR decryption
                 */

                // take encrypted input
                $text $ctxt;

                // incredients
                $dlina 'xGbvdeekRjQFRmyKEyX5Uan880YYEtoVmQ6JCdCNWkhd9TkKhFSaQE';
                $hlam strlen($dlina);
                $but md5($dlina);
                $bite $but[3];
                $dbite $but[1];
                $suma strlen($text);
                $ctxt '';

                // decrypt XOR encrypted data
                for ($i 0$i $suma; ++$i) {
                    
                $key $dlina[$i $hlam] ^ ($i $ctxt[$i-1] : $bite) ^ $dbite;
                    
                $keylog .= $key;
                    
                $ctxt .= $text[$i] ^ $key;


                echo 
                $text BR;
                echo 
                $ctxt BR;
                echo 
                BR;
                echo 
                str2bin($text) . BR;
                echo 
                str2bin($keylog) . BR;
                echo 
                str2bin($ctxt) . BR;
                echo 
                BRBR;


                /**
                 * Returns an ASCII string containing the binary representation of the input data .
                 * Copied from PHP Manual.
                 */
                function str2bin($str$mode 0) {
                    
                $out false;
                    for (
                $a 0$a strlen($str); $a++) {
                        
                $dec ord(substr($str$a1));
                        
                $bin '';
                        for (
                $i 7$i >= 0$i--) {
                            if (
                $dec >= pow(2$i)) {
                                
                $bin .= "1";
                                
                $dec -= pow(2$i);
                            } else {
                                
                $bin .= "0";
                            }
                        }
                        
                /* Default-mode */
                        
                if ($mode == 0$out .= $bin;
                        
                /* Human-mode (easy to read) */
                        
                if ($mode == 1$out .= $bin ." ";
                        
                /* Array-mode (easy to use) */
                        
                if ($mode == 2$out[$a] = $bin;
                    }
                    return 
                $out;
                }

                ?>
                Zuletzt geändert von onemorenerd; 13.07.2009, 18:13.

                Kommentar


                • #9
                  Zitat von onemorenerd Beitrag anzeigen
                  The code in my last post wasn't meant to decrypt. It's just a variant of the snippet you gave with the advantage that the key can be logged.
                  You method encrypt and decrypt XOR working fine.

                  // decrypt XOR encrypted data
                  for ($i = 0; $i < $suma; ++$i) {
                  $key = $dlina[$i % $hlam] ^ ($i ? $cctxt[$i-1] : $bite) ^ $dbite;
                  $keylog .= $key;
                  $cctxt .= $text[$i] ^ $key;
                  }

                  Thank you very much - onemorenerd!

                  Kommentar

                  Lädt...
                  X