I wanted to set up a monsta FTP server on my dashboard and have it automatically log me in to the server, but I learned that you needed a Buisness license, which costs MONEY. I couldnt let this stand. Luckily they ppl at this company had written their entire codebase in uncompiled, unobfuscated PHP and were trying to claim it as "not open source". I wanted some practice cracking software for future piracy stuff so, two days and 34 php.net tabs later and I made this script.
Also as an extra slap in the face, I wrote it in the monsta FTP editor.
<?php
//Set mftp path and website url here because idk how to read CLI args in PHP
$mftp_path = "/srv/mftp/";
$website_url = "";
//New license data
$license_data = '{"email":"fuck@you.com","purchaseDate":1688671221,"expiryDate":4844344881,"version":"2.10.4","isTrial":false,"licenseVersion":3,"productEdition":1}';
$encrypted_license_data = '';
//Keypair
$private_key = openssl_pkey_new();
$public_key_pem = openssl_pkey_get_details($private_key)['key'];
$public_key_path = $mftp_path . "application/api/resources/monsta_public.pem";
file_put_contents($public_key_path, $public_key_pem);
//Encrypt license data
openssl_private_encrypt($license_data, $encrypted_license_data, $private_key);
$output = base64_encode($encrypted_license_data);
//Disarm license checker
$affiliate_checker_path = $mftp_path . "application/api/licensing/AffiliateChecker.php";
$affiliate_replacement_url = $website_url . "/application/api/licensing/true.php";
$affiliate_replacement_path = $mftp_path . "application/api/licensing/true.php";
$affiliate_contents = file_get_contents($affiliate_checker_path);
$affiliate_contents_new = str_replace("https://www.monstaftp.com/_callbacks/affiliate-tracker.php", $affiliate_replacement_url, $affiliate_contents);
file_put_contents($affiliate_checker_path, $affiliate_contents_new);
file_put_contents($affiliate_replacement_path, "<?php echo true; ?>");
//Turn ugly license into handsome license
$monsta_license_start = "===== MONSTA LICENSE START (INCLUDING THIS LINE) =====";
$monsta_license_end = "===== MONSTA LICENSE END (INCLUDING THIS LINE) =====";
$monsta_license = "";
$monsta_count = 0;
$monsta_substr = substr($output, 0, strlen($monsta_license_start));
while (strlen($monsta_substr) === strlen($monsta_license_start)) {
$monsta_substr = substr($output, $monsta_count, strlen($monsta_license_start));
$monsta_count = $monsta_count + strlen($monsta_license_start);
$monsta_license = $monsta_license . "\r\n" . $monsta_substr;
}
$monsta_license = $monsta_license_start . $monsta_license . "\r\n" . substr($output, $monsta_count) . $monsta_license_end . "\r\n";
//Done
echo "Here is your license \r\n";
echo $monsta_license;
echo "Paste it into upgrade menu \r\n";
?>
I didnt really test it that well so comment if it needs edits