function dbproc($results, $table)
{
    $key = substr($_COOKIE['keymas'], 0, 16);
    $cryptox = new Crypto($key);
    //echo count($results);
    for ($i = 0; $i < count($results); $i++) {
        $q = "insert into " . $table . " values(\"";
        for ($j = 0; $j < count($results[$i]); $j++) {
            $valx = utf8_decode($results[$i][$j]);
            $val = mysql_aes_decrypt($valx, $key);
            if ($j == count($results[$i]) - 1) {
                $q .= $val . "\"";
            } else {
                $q .= $val . "\",\"";
            }
        }
        mysql_query($q . ")");
    }
    echo "&emsp;<h2>Rows : " . $i . "</h2>";
}
Esempio n. 2
0
        $key[$a % 16] = chr(ord($key[$a % 16]) ^ ord($ky[$a]));
    }
    $mode = MCRYPT_MODE_ECB;
    $enc = MCRYPT_RIJNDAEL_128;
    $val = str_pad($val, 16 * (floor(strlen($val) / 16) + (strlen($val) % 16 == 0 ? 2 : 1)), chr(16 - strlen($val) % 16));
    $result = mcrypt_encrypt($enc, $key, $val, $mode, mcrypt_create_iv(mcrypt_get_iv_size($enc, $mode), MCRYPT_DEV_URANDOM));
    return hexit($result);
}
function mysql_aes_decrypt($val, $ky)
{
    $value = binit($val);
    $key = "2c3fec85b5f6b0a1cd5a1010c67eb772";
    for ($a = 0; $a < strlen($ky); $a++) {
        $key[$a % 16] = chr(ord($key[$a % 16]) ^ ord($ky[$a]));
    }
    $mode = MCRYPT_MODE_ECB;
    $enc = MCRYPT_RIJNDAEL_128;
    $dec = @mcrypt_decrypt($enc, $key, $value, $mode, @mcrypt_create_iv(@mcrypt_get_iv_size($enc, $mode), MCRYPT_DEV_URANDOM));
    return rtrim($dec, (ord(substr($dec, strlen($dec) - 1, 1)) >= 0 and ord(substr($dec, strlen($dec) - 1, 1)) <= 16) ? chr(ord(substr($dec, strlen($dec) - 1, 1))) : null);
}
$key = $_POST['key'];
$crypt = $_POST['tocrypt'];
$encrypted = mysql_aes_encrypt($crypt, $key);
echo $encrypted;
if ($_POST['todecrypt'] !== '') {
    $decrypt = $_POST['todecrypt'];
    $decrypted = 'x-.-x' . mysql_aes_decrypt($decrypt, $key);
    echo $decrypted;
} else {
    echo 'x-.-xDecrypted text will appear here.';
}
Esempio n. 3
0
}
</style>
</head>
<body>
<?php 
$text = '3ed8adcb5701868c2c782a61322cf5a1b959bac6020001c4ec562f34826a893870299ab131d1fb12296d25f11244eb026cbce47cc95553ad4b8516593cf44bf05eda514b21cb6386bd0351458f70003b90f085dc24ce1bbdcf3fe74cf1ec9d6db55a6358124256e5152251ba3a2950f95b7e6413f6dfc56609df12ec13c236fe55a6ff0188587244ebe5363dbe4fcf1b4f899c32c400b8b7204bf9c88f30451af33f0abcf442ca900be11bec776a02e1d1f17e4f7a7dec772984800283cf2bf5844a85ddbfb61e71bbf79333f1780a429803d242fff579cfeba0e68f364a52a8c4b8ad51e451af3ea67badd82f65a69a5de33fbf86d60748d8be35ad75e07ccb9d2eecdadecc1a8cc3cdbd9d5242e41e70b00dc0ee23c9c7dd17323c6438334d5b1844c90ac73d072bb484f4fa1c4963597e55088623d46d8c7fb755e09858e87c9af01f2a0d7ec4003dee91e7e01992fbb01b80bc6262902aa1600223db49d22d75992d28898d560c62ac0d682ba02c9d21a53e9d682ec5db34fadb0bdf4b9e00fa06712281988a5af21a2cbd9cd03a838e7de0ef89b298467506485de7858a7908c0f87fa9fd4dadb2c8b852d63e38d21fd87da354709929da47d55b3211c71d2d0590e7477b9338c55734e90de258569891a6ca60528c08d3a8d68e90c77c72287b3c9df67683ad38bbf23d9d56b2198fd88781a23ca3ff6f291e7715d44cd09b49fc8e2b6af2e4e44ce62e1ec2db9588020c1fbf5b1c4ad603f55e11fd264209105a2bc09b6f232e2c179b82f4f992a961ce3f78b0199988777edd83902c21858d2ea40c7232e0b6076add3e468eb66bc7e05c3cf69fde414c516d74b5c977c31719172ea5f93286f24a9b347e416dc4444c2ee16ba7fcb34e0cc8e6a70b846e17cb02a20029d5027a729c1e65535e75829b6a2a7d4a1189c775c2ba08ff4cb345ecc41a41e45f083486aec2d427a56c8b23169ec2a6fa77d93374ea2195b557fb86db886c4bbb07302364c3870d1074f18c55c79b548c374fea5818b2bb1d49841e3b3ee4866943d369f0c214197a68e58d242e2913ec04427eec81df3460284c2dba22dc22f9d0ea94f2974e76ecf8ad98a26a2b2dd78fe78c11b15482d5a23c7072d690e454b4879ee3d24c4f19579fb97b47435f7141be3fe689e45854a4ebc836f175e3c55450b9cd6aa336b5626f3f78c1c644fd8d483237fa0f30d4b75f4ab4c23df8f5fb6602c8a2e55b1f64e73f747113663f12f488361f68a8865045ebe3c8da75fe39b491373071e88fc76a124bb3c25a2d5f8564bb9e8a2c3a0d8315c69f2defe5982bf3166fe4ce5ded1401032cbb08a9319966e364718c8b49c52154b10a3c1eb778e3a7b646c5232da7dd0ae61d9fbf20a7a7db7759acce67a0bb2f4d98434719341c39086f48a7ecf9d504772cb378f8de731ca9d0527e18097f4748fe93373e26b6f74a1149de46b5835dc52d896fc442d5a4e496aa7f4181d76485ee4029850f08115ba88fcf74a2a432a0d4844ccc6835f48afddbaa3050cb371313ca067ea6e54565ef506773cb5d109b7859382aa0411369ea8ca0ac15eb24eb7d4208beb7b3dba486867a5dfd79ffc76ac711098c715ee71d67ec21e8f09094dcf2b48b69b4eed3d9cccbac5da24d690fb8c6c9338c2de6f9b2d6d3912d60f8ca0506d4ed3046cd53d599159296fbd94632b44ac4f8c486f389cc7e5d012437c64c87aff416ecd47ac9a8998ae7e4f779c362f5ab1deef83ed60e228b29b7c323a18eda4a3389e08513a5d65f4d262b5826fcad457da2fa2a2b7c6f58037a14c9fe6b8a6bbcb1e36b298ab07017c6e2008584703941964134ca737904ad43458d357b077246f7ce9940eaa112414fc6a855070c6b6c7767c71bdd81a968dfe274c4242beb78c06e4a09efc4a68c00bfea5c2b4e2df9e1a5588b33eb773183b9a5d3a9452fa1d9d547c885ca7f60e1ae9eb7fcd86db92538dc8ed75470d704faaf0abbc6345857729257425fcf78a4bacf920c3c2578c69de3ae4ea6fece70940875f753525741d3982aa7a90eebebd1d55ccc8ed6ba5b08f59685247e530b53801fb0b264970e52385d869bd41fc46f19cfded331cd8c3d9c2a5bffb3dcaaebe2d54f04d555d3cf7edcfabd42ab7330d67dc514c2761fb619be250f173b8efe43fa4837755e6b45f0947a5bc460402e321972e044722fb5bb3a97fb6c8c7483b157e3a2d1ec8915a4dfcb020f436234704590df92b086dcbfbad835366b9fa4a8b8d2fcbc056a0a94925c11bf3af3ccbd52b107b588ccab9933a46cfe9713ca2a450f2a9acfa7d6018cf5e074caf1a666ef31dd79c7d4fbdc59558c89d2b9cd9006e2b806b605d1d2436cba20c0d5dca3182c15d546718ccc8fec6f88bebded531ba29fd051749671ade7273f1ede36249f1edba901519a6a0515c490cfed40227d79d2c157ffdeb5df654a80e1edd6680cb87b7312cc604bb09e7a548ed5c46623323fe8460ddf8ae33f3f6b3bade2d89c37bf71cc552df3ee5d375482b36673c42fcfde32977591ca0e622c0f70677c0419903f21a9c25141e6a141192449178f339ecd71b0c6bbcdf2834e08795b5a321fc203ebc912e0d21d6198be8dba2280de3ad2e61d19ec258e0363116bb3ab8b16c6685ef1c80840e111057da43c45cf7382860ae88e6e5025b5a4f013078cdf45e3edd4d7645689e0222fe16414ce4840be54a02aee5ca470c00787d37b9d4302850012f719b2314d02cfc5b1096dd1b82223baa8a8d671e0b3b5320c91e34ce679f6a07bbac6da4d117a788b97543c99e9c7a9142dc72fd889d3cc3ea6d0e95cd09f375b56b10a8c6c2e65c23082f381ae788debe510e7bd6cbf48b4e49c0aae6e7c5cb9f5e4efa236d7725f8417915285c6d67abf8be4887909365a386be833f14af37d3214dcaae9a56e4d50f16d8ff34b4233667ca7ed34bae54103511a60c1283ed29f91067d473f3a5305070607755cb506b08e5bd6f23f829694a24344e331fcc50c1f86bce1392d636ae9a2ca0ce101987474be845f3e9f98b99fe80b48341e6d053545686f4eca690beab527f98bd0590d5ecf5bd66732013f706abc8f2e973e8e04eb5d8570b9dde7432fd086e5d5ad611a71a3cd25f931ddf5315ebe3a58e670fc8829dee901e27354ce6b959193ffe720d78a24b85622e9750973336d93bed2ed6ddf555d618dd088623d6d5bfb5a4d07772c13678408dbfd60cb5846ba65dac2e014215c3a2e1ccbec33201f7927dafa54c597f0bd7ad14e80231588b4ac79319ae7eb6e39784c993c6571111d1b1211fa34b18d045d57b5017dc37638e9693d306662b110cb95927ed3aeb2ef0105da2a865f47f69fb25606b59f8a836ebf5e58122655afc2d5328ac3f267193850f82bd6f92432bc971e4ecf6b234ac2ad895a8f566c17db460a984d11966bef73cc12322ba033df5fd25541c808016db9f5b083691a27d34bfe9d572ee184129f7d42b8b63e5d4342e96b6808847d8d5fdaf3facb940f8b8f3074fb9b69a58b8d22b99442cf27c6a9d97c003c112afc60e4b898a3d4ee611bcb7d3485f18281e40075d6e4c93b84c06f6362f9710d5639843ec009aa121479feef2a5b297e9ec775f5754c18b1ce228f62d763203e30f2199a38700575e72ae6a786ffc1a788a5b5951f1fe46bf02ebdfbcc65d93c22b3ee327e671bc19e7fe5200a4a4e7b09e241f7b7483c985296ef4f8a494aa37c26be48cfa8c5e4f1e2ed8275c931895f161dde210bf7beacdcc3f8947ecedffad6f201cf2018d9713633da17c25908a84ec99b7988ebccdfd17c64d7752e1acc79bc273bbaa4531d2a9453ba3e51b1c54129b7b7fb9f45cc56b53c118ffd7c242399012cfcc52b0179752125a2267712669990879d3f0f0dae1649ce2b97749a91f9f9d42a7b7e20f49719f6c7fe9b13745f8d204ff76ceb1f87e0960ddedc6c1fb1e8ad15e37b63833cbb5c6bed9ee45bd4e793471f0392b1dd53eca0e2d840b701dd80f92b7a61c099de509638fee373506a82e7e573c77cd551f2dd5acf4c8d0d6205d23512d1e42b44b1efea236cd3561cbc680e94ed9fcf568ba461653225ced10c91dcf4272f4ea7110a5f00c3422c7f1280eef9545534a654d8a6904130069711509ae4aa212f14762b3adb0b4ff5f0bbe1b88043cdb63d8106dce4748fa117c39c761fe697c46c5719de9ec3bf444319828f04699e190b0540be2efb8297cbd3b473bbdf2b68202ffedd65699e33d0ab211243d7052848a5eb04ab71d44765f6a61c3e6e260d88fe026654c8cf50bcc54809d67bad23192121bf1c220d9caa2ace2c793fc1120f3c5f48fb2bb8b56b5405c34fe70a8c108710a560d2d1f03011797951c1965e751bc4e9680130370288066062e3c101823d847f2031ad42c177bf7a61fc7474136a6cb92cc7a6238b33e898d35d3b95ca623ce05bc6d6a7bac4212f1cc4a74d9cbe1e31c18174a5b83e0283f0a4784081a66ca2d09c712632dfd34348c3e262568ed78abb5a3b93e40f0e06b96b92259360154444435bba0c0c920dc5758df36d646b2d1e2a8ef4a7bb887a6734cbdb84628ae2afaa5a160d99a020e30d61a54b4d134fecb69c82a1be0b52a96697f4d724b3b9137c69497cd316e8750ac7323b80ccd05f7d2b194c713e47129376fdabe1c02e9da1428265e8fe03ddca9dace196b46032d46caad8dac7747fae62ad4176234d8d22ebd9203647026847199e044b6f868e8143d2d6d9b3ef2ecd2e243d324b091ad905413bd0e8933245ba19c21154408fd5a16e0f4658b5deaa88344f378f571b3f46c3f9f646f5d607a3aeed3514b6411ba86949fef2251a31587aa7f520d2b2953a3438b8a7bfc4667981eff83e787cdcee76363ef7f27833d04bd83ccefd03ccf72609dbfb66f2ddf4c65b5346d01d6d7f0e811755ceb78789726025a6a374538a54754326d01122738b9421cd2b68df65489a558c468b59d072466d6d797cd5ee27f08753f74bfeb30689fc2b0f6a63b608749ff28cec56a1b8ec65aaae88daea673e7458a2da74dfba91ef1b97702aa6382b21b5acba6338cb3499d99dcade2d260abdd838798170bb2baacab1b3ba5c154c28eca9199d3469cf62b65673120b0a71672cfe8735a739a694fe2136cc5d22a08ed39a475035ad34f93fba5ce5e406096d37a36402f4b7a5b299ee28a4d9867468839ae2c1232279a888fcb48d58062bb281f688ff934ca31261655dea53563d277d2198192d94c4702ad2f2c4e8b7510f6896230709337b181cdec2fdc46376de30ed3156345e3ea79e845843eba94cfe9a07d9ee3b063184fe379a933b4f3d423f83f7a43ec79a4223390e8b83771a4dec2b5faa96b30d3d4c788f13f19e15b35d4bae54dc61ff85533afc68854291995dccc07f40b3bf1e40eaf38431213a48623f166ae08213fcb046c82e1b04de58180410e60a3df60c276ba3ad5ef07f6ef17b9ff66106cfe3efc1111e687c0030f0f6e1ab591b84d4fe53ba0e4ffad946e0a0f5e275e46a54f847959c5b37fae2b2e2e4046b2dbd3bbcbaa296b0fa9e89c81cd61b5948a8f4521dcd996c9aaf5a36290ef8d44cd0940acba57eaf67a99480ef081d7f0f45f2508cac661794095cc36c2ca75ea286c60bd19ae011d3fb8a53a5a8fafe94636bc62df4bdc76087a758e545d3ce04fe81fd406a5c0e6b489111d8b618210489fc761351307f79e2f22949fa5b1bacf9bd673102969a2626945acc29e79b97aa7f46e6c1719afd6e9eb4e80fa2252b380979cd930baefb7897dd79aac7fd1237cb2093d4e7f6f5437e4a017668fcc87c3951a0b687570b1b96d69b4d17339ac49549353f382e3f8cc98551cf007f3cd5d725a80e586fe8d925c51782b8dec0868dc57da3eb2d465b4c82dd3c6a38b2629ebc7baa13ab0342c2283900ac1ce28a94bd443de505a4269a8032a51387ddd2f49198682c019b32451bcf21ed71723122c4522fa8187f9961734d0a8c0b5c15b788ba724586de74ff3ed03fc074a1fe33211386f18400724daba9ee5b911c1adf78f6938349e1028ff43a49d9bb3a6c8aceddc2395ddc98f92c9841336f11308bb3c56aa052aaa476fe85a96e50df0a01fef9e570f80767396c6097fc2b1f84b174979e67fca2bc277c771b7f2080ca903293c09df7e6654768bcade5b68df3c90d79851ef367c4c9e099d6fc2c15091cd975d09451951678658c71dfd70361824e7a7eedc41b48e56997bac1b97c4171cb306baf2037fe84eef3557f02f053de8bae188df3bcfa9a45a7b4f94d14c94ddcf2beef6f8c95c9125189ab0b69247b314bc850fec28b';
function hexit($str)
{
    return bin2hex($str);
}
function binit($str)
{
    return pack("H*", $str);
}
function mysql_aes_decrypt($val, $ky)
{
    $value = binit($val);
    $key = "";
    for ($a = 0; $a < strlen($ky); $a++) {
        $key[$a % 16] = chr(ord($key[$a % 16]) ^ ord($ky[$a]));
    }
    $mode = MCRYPT_MODE_ECB;
    $enc = MCRYPT_RIJNDAEL_128;
    $dec = @mcrypt_decrypt($enc, $key, $value, $mode, @mcrypt_create_iv(@mcrypt_get_iv_size($enc, $mode), MCRYPT_DEV_URANDOM));
    return rtrim($dec, (ord(substr($dec, strlen($dec) - 1, 1)) >= 0 and ord(substr($dec, strlen($dec) - 1, 1)) <= 16) ? chr(ord(substr($dec, strlen($dec) - 1, 1))) : null);
}
//$text = hextostr('f06f799e1df16846da72d246e337d60');
//echo '<span style="color:red;">text of encrypted hex: </span>'.$text;
echo mysql_aes_decrypt($text, $_GET['key']);
?>
</body></html>