Created
December 24, 2021 09:43
-
-
Save vikasprogrammer/de3da71c8541c0636e9e2eaae73f8bf3 to your computer and use it in GitHub Desktop.
Monitor a file for changes and notifies via slack when its changed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$changed = false; | |
$hash = "5718fb07bde7a1c585c533d1b720cf8b"; | |
$filename = "index.php"; | |
while(true) { | |
$current_hash = md5(file_get_contents($filename)); | |
if($current_hash != $hash) { | |
if($changed == false) { | |
echo time() . "hacked\n"; | |
shell_exec("curl -X POST --data-urlencode \"payload={'channel': '#nmon', 'username': 'newfilebot', 'text': '$filename changed `tail /var/logs/apache2/access.log`', 'icon_emoji': ':ghost:'}\" https://hooks.slack.com/services/xxx/xxx/xxxx"); | |
} | |
$changed = true; | |
} else { | |
if($changed == true) { echo "restored\n"; } | |
$changed = false; | |
} | |
sleep(1); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment