| Server IP : 3.111.61.48 / Your IP : 216.73.216.67 Web Server : Apache System : Linux ip-10-0-5-176 6.8.0-1057-aws #60~22.04.1-Ubuntu SMP Wed May 27 08:16:59 UTC 2026 x86_64 User : ubuntu ( 1000) PHP Version : 8.2.31 Disable Function : exec,passthru,shell_exec,system MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /proc/self/root/etc/script/ |
Upload File : |
import smtplib
import os
from datetime import datetime
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
# Email Configuration
sender_email = "uptime@arukustech.com"
receiver_email = "hosting@arukustech.com"
aws_smtp_server = "email-smtp.ap-south-1.amazonaws.com"
aws_smtp_port = 587
aws_smtp_username = "AKIAYOTEITKZPI26TMDM"
aws_smtp_password = "BLFjkzAixZKQPoRz3owT9eVITObkYtODYxE7z/sU/M5K"
# Directory to monitor
MONITOR_DIR = '/var/www/vhost/'
# File extensions to monitor
FILE_EXTENSIONS = ('.php', '.exe', '.sh', '.js', '.htaccess', '.html', '.ini', '.bash', '.webp', '.xml')
# Log file to track previously detected files
LOG_FILE = '/etc/script/monitored_default_Store-files.log'
# Separate file for newly detected files
NEW_FILES_LOG = '/etc/script/monitored_newly_added-files.log'
# Function to scan for files in the monitored directory
def scan_for_files():
detected_files = []
for root, dirs, files in os.walk(MONITOR_DIR):
for file in files:
if file.endswith(FILE_EXTENSIONS):
detected_files.append(os.path.join(root, file))
return detected_files
# Function to read previously detected files from the monitored log file
def read_logged_files():
if os.path.exists(LOG_FILE):
with open(LOG_FILE, 'r') as log_file:
logged_files = log_file.readlines()
return [file.strip() for file in logged_files]
return []
# Function to log new detected files to the new files log
def log_new_files(new_files):
with open(NEW_FILES_LOG, 'w') as new_files_file:
for file in new_files:
new_files_file.write(f"{file}\n")
with open(LOG_FILE, 'a') as log_file:
for file in new_files:
log_file.write(f"{file}\n")
# Function to send email using AWS SES SMTP
def send_email(subject, body):
msg = MIMEMultipart()
msg['From'] = sender_email
msg['To'] = receiver_email
msg['Subject'] = subject
msg['X-Priority'] = '1' # Mark the email as important
# Attach the HTML content
msg.attach(MIMEText(body, 'html'))
try:
server = smtplib.SMTP(aws_smtp_server, aws_smtp_port)
server.starttls()
server.login(aws_smtp_username, aws_smtp_password)
server.sendmail(sender_email, receiver_email, msg.as_string())
server.quit()
print(f"Email sent successfully to {receiver_email}")
except Exception as e:
print(f"Failed to send email: {e}")
# Main function
def main():
detected_files = scan_for_files()
logged_files = read_logged_files()
# Initial run: only update the LOG_FILE and exit
if not logged_files:
with open(LOG_FILE, 'w') as log_file:
for file in detected_files:
log_file.write(f"{file}\n")
print("Initial files have been logged.")
return
# Filter out the files that have already been logged
new_files = [file for file in detected_files if file not in logged_files]
if new_files:
# Log the newly detected files
log_new_files(new_files)
# Prepare HTML email content
subject = 'Alert: Arukus WP Suspicious Files Detected'
body = f"""
<html>
<body>
<h2 style="color: red; font-weight: bold;">URGENT: New Suspicious Files Detected</h2>
<p><strong>Date:</strong> {datetime.now().strftime("%Y-%m-%d %H:%M:%S")}</p>
<p><strong>New suspicious files detected in the monitored directories:</strong></p>
<ul>
"""
for file in new_files:
body += f"<li>{file}</li>"
body += """
</ul>
<p><strong>Action Required:</strong> Please review the files and take necessary action to secure your server.</p>
<p><strong>Best regards,</strong><br>Arukus Tech Support</p>
</body>
</html>
"""
# Send email for new detected files
send_email(subject, body)
else:
print("No new files detected.")
if __name__ == '__main__':
main()