| PHP Developer Forum Hier habt ihr die Möglichkeit, eure Skriptprobleme mit anderen Anwendern zu diskutieren. Seid so fair und beantwortet auch Fragen von anderen Anwendern. Dieses Forum ist sowohl für ANFÄNGER als auch für PHP-Profis! Post your PHP questions here! |
 |

13-07-2009, 02:01
|
|
Nirvana77
Registrierter Benutzer
|
|
Registriert seit: Jul 2009
Beiträge: 6
|
|
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
|

13-07-2009, 02:11
|
|
Nirvana77
Registrierter Benutzer
|
|
Registriert seit: Jul 2009
Beiträge: 6
|
|
$text -> XOR encryption -> $ctext
How create back loop?
$ctext -> XOR decryption -> $text
Pleaseeee, heeeeeelllppppp
|

13-07-2009, 02:44
|
 |
onemorenerd
 Moderator
|
|
Registriert seit: Mar 2005
Ort: Berlin
Beiträge: 9.481
|
|
Geändert von onemorenerd (13-07-2009 um 04:59 Uhr)
|

13-07-2009, 02:58
|
|
Nirvana77
Registrierter Benutzer
|
|
Registriert seit: Jul 2009
Beiträge: 6
|
|
Zitat:
Zitat von onemorenerd
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.
|

13-07-2009, 04:47
|
 |
onemorenerd
 Moderator
|
|
Registriert seit: Mar 2005
Ort: Berlin
Beiträge: 9.481
|
|
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?
|

13-07-2009, 16:08
|
|
Nirvana77
Registrierter Benutzer
|
|
Registriert seit: Jul 2009
Beiträge: 6
|
|
Zitat:
Zitat von onemorenerd
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.
|

13-07-2009, 16:27
|
|
Nirvana77
Registrierter Benutzer
|
|
Registriert seit: Jul 2009
Beiträge: 6
|
|
Zitat:
Zitat von onemorenerd
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;
?>
Geändert von Nirvana77 (13-07-2009 um 16:35 Uhr)
|

13-07-2009, 18:10
|
 |
onemorenerd
 Moderator
|
|
Registriert seit: Mar 2005
Ort: Berlin
Beiträge: 9.481
|
|
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 BR, BR;
/* * 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 BR, BR;
/* * 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 BR, BR;
/** * 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, $a, 1)); $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; }
?>
Geändert von onemorenerd (13-07-2009 um 18:13 Uhr)
|

13-07-2009, 19:02
|
|
Nirvana77
Registrierter Benutzer
|
|
Registriert seit: Jul 2009
Beiträge: 6
|
|
Zitat:
Zitat von onemorenerd
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!
|
|
Aktive Benutzer in diesem Thema: 1 (Registrierte Benutzer: 0, Gäste: 1)
|
|
|
| Themen-Optionen |
|
|
| Thema bewerten |
|
|
Forumregeln
|
Es ist Ihnen nicht erlaubt, neue Themen zu verfassen.
Es ist Ihnen nicht erlaubt, auf Beiträge zu antworten.
Es ist Ihnen nicht erlaubt, Anhänge hochzuladen.
Es ist Ihnen nicht erlaubt, Ihre Beiträge zu bearbeiten.
HTML-Code ist aus.
|
|
|
|
PHP News
|