I've built a system and have put a ton of work into making sure is super secure. But I have a (potentially irrational) fear that if someone were able to break into my server, they could just change the PHP code I've written and it'd be game over. No feature I could build could withstand someone with access to the server.

I do all the right things as far as picking good passwords for my server access, not saving them anywhere, etc... But I got to believe from the constant stream of news reports about mega-companies getting hacked that no matter what I do, there's still going to be some vulnerability somewhere that an experienced hacker can use to get into my system.

So what do you think of this plan?

  • Create a file titled something nondescript (we'll say secretFile.php for this example) and bury the file somewhere on the server.
  • Make that file simply return an md5 hash of the directory where all my code is.
  • Sign up for a second, completely separate host, and set up a cron job (cron.php) to call www.mySite.com/secretFile.php every X minutes
  • cron.php records the results of secretFile.php
  • If there's a change from the last time it checked in, send me a notification, trigger a kill switch, call 911, whatever...

I realize this plan could be foiled if someone were to also break into my secondary server, or if they knew about secretFile.php on my primary server. But in the name of "every bit of security helps", do you feel like this bit of security would actually help?

(Also, I know there are certain extensions that can be installed on my primary server that listen for file changes. But if someone has access to my primary server, I figure they could also just disable that extension too.)

  • 1
    Why write your own script? Why not just use Tripwire. The free, open source version should do the trick.
    – lzam
    Aug 31, 2014 at 14:34
  • 2
    Hire an information security professional. I don't want to sound condescending, but reading your suggestions you don't seem to know what you're doing. You can't patch system / transport level security by layers of obfuscation on the application level. All you're doing is complicating your own access, not the attacker's. It's that simple.
    – TildalWave
    Aug 31, 2014 at 15:18

1 Answer 1


As you mentioned if someone manages to get root access to your server its game over. The best practices to keep your server safe are:

  1. Strong password policy
  2. Keep it patched all the time
  3. Enforce additional safety mechanisms on the server such as SELinux, AppArmor etc... (assuming this is a linux server?) there is a good list of these on ubuntu's site
  4. Don't install untrusted software and keep the software on the server to the bare minimum
  5. Don't browse the web from the server
  6. Limit remote connections to bare minimum (RDP, VNC, SSH etc...) better allow only local access
  7. Have proper users and group permissions on your server and have everything run in the least privileged mode needed

The solution you suggested will not defend you server from being breached - it will just mitigate the risk after your security mechanisms have been breached already. This is already a bad enough situation which could lead to harm of losing data and lots of recovery efforts. The idea is to invest in protecting from being breached in the first place. (additionally as you mentioned - your solution is easily bypassed by a serious attacker which will alternate your php code)

Not the answer you're looking for? Browse other questions tagged .