加密:http://example.com/3ISGSfzIiaAU+h2TwF0pNoKDKRenjKfRhehMMN3+OJw=
解密:http://example.com/opens.php?subid=66
此网址是某人打开电子邮件时触发的像素。
当我加载像素解密时,一切正常。我没有得到如何解密电子邮件中的链接以便加载的逻辑。
我的问题:我应该在哪里使用解密功能才能加载网址?
Ruby加密:
require 'openssl'
require 'base64'
class String
def self.encrypt(plain_text)
cipher = OpenSSL::Cipher.new('aes-256-cbc')
cipher.encrypt
iv = 'akjgkdladjgkadsw'
iv64 = [iv].pack("m").strip
key = 'o1diqwkadkfjg018jgkdja9194025123'
key64 = [key].pack("m").strip
cipher = OpenSSL::Cipher.new('aes-256-cbc')
cipher.encrypt
cipher.key = Base64.decode64(key64)
cipher.iv = Base64.decode64(iv64)
encrypted_data = cipher.update(plain_text)
encrypted_data << cipher.final
crypt64 = [encrypted_data].pack("m").strip
end
end
基本解密.php:
<?php
class String {
function decrypt($string) {
$ruby_crypt = $string;
$encrypted_data = base64_decode($ruby_crypt);
$key = base64_decode("bzFkaXF3a2Fka2ZqZzAxOGpna2RqYTkxOTQwMjUxMjM=");
$iv = base64_decode("YWtqZ2tkbGFkamdrYWRzdw==");
$result = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $key, $encrypted_data, MCRYPT_MODE_CBC, $iv);
$unencrypt = rtrim($result, "\x00..\x1F");
//print "\nUnencrypted token:\n'$unencrypt'\n";
}
}
?>
抓取参数并创建数据库条目(opens.php):
<?php
require_once("./db_connection.php");
include("./decryption.php");
// Create connection
$conn = new mysqli($servername, $username, $password, $db);
// Check connection
if($conn->connect_error) {
exit('Error connecting to database');
}
$conn->set_charset("utf8");
// echo "Connected successfully";
$id = intval($_REQUEST['subid']);
$stmt = $conn->prepare("UPDATE rcpt SET has_opens = has_opens + 1 WHERE id = ? ");
$stmt->bind_param('i', $id);
$stmt->execute();
$stmt->close();
header('Content-Type: image/gif');
$img = imagecreatefromgif("px.gif");
imagegif($img);
imagedestroy($img);
mysqli_close($conn);
?>