TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Hacked: Investigating an Intrusion on My Server

100 pointsby frantzmiccoliover 8 years ago

14 comments

viraptorover 8 years ago
This article was absolutely painful to read. Let me try a different ending:<p>&gt; Conclusion:<p>1. Ensure the files that php is running are not writable by the same process. Different app -&gt; different user.<p>2. Unless you&#x27;re planning to send emails from the server, firewall output on those ports. If you do plan to, firewall everything apart from that server (you can setup alerts when DNS changes, it&#x27;s not going to happen often for email hosts)<p>3. Disable most unnecessary functions and modules. Anything touching eval, str_rot13, exec, and many others should be killed right away.<p>4. Enable basedir.<p>5. If you can&#x27;t handle regular system updates, don&#x27;t run your own server. If you can&#x27;t handle wordpress updates, host it with someone else.<p>6. Wherever you host, make sure your app can be easily redeployed. You can&#x27;t rely on dates to see when anything changed.<p>7. If you can&#x27;t handle system upgrades, don&#x27;t think that docker or any software is going to solve any of your problems.
评论 #12387827 未加载
评论 #12386687 未加载
评论 #12387566 未加载
评论 #12393366 未加载
efotoover 8 years ago
In short: an old server running un-updated software was broken into not once but at least four times since the start of the year.<p>The post describes some steps the author took to investigate and block the attack. It&#x27;s an entertaining reading, but I&#x27;d strongly advise against trying this at home: it is not worth the risk. Reinstalling the system from scratch instead would have been much more prudent.
评论 #12386431 未加载
rmdossover 8 years ago
Fun read. If you ever get hacked, I recommend just destroying the server and starting from scratch and a clean backup.<p>If you try to find all backdoors and left over rootkits, you will end up forgetting one and being re-compromised.
评论 #12388141 未加载
评论 #12387219 未加载
0xmohitover 8 years ago
One may find the following resources useful for measures on how to secure one&#x27;s infrastructure:<p>- Security Guide: How to Protect Your Infrastructure Against the Basic Attacker [0]<p>- 7 Security Measures to Protect Your Servers [1]<p>[0] <a href="http:&#x2F;&#x2F;blog.mailgun.com&#x2F;security-guide-basic-infrastructure-security&#x2F;" rel="nofollow">http:&#x2F;&#x2F;blog.mailgun.com&#x2F;security-guide-basic-infrastructure-...</a><p>[1] <a href="https:&#x2F;&#x2F;www.digitalocean.com&#x2F;community&#x2F;tutorials&#x2F;7-security-measures-to-protect-your-servers" rel="nofollow">https:&#x2F;&#x2F;www.digitalocean.com&#x2F;community&#x2F;tutorials&#x2F;7-security-...</a>
AReallyGoodNameover 8 years ago
Question about this:<p>It&#x27;s not possible for me to track all the 0 days for every piece of software and library that my servers run. One of my long running servers could have been backdoor-ed by a 0 day 6 months ago and i probably wouldn&#x27;t know it. The servers are kept updated but 0 days don&#x27;t care about that by definition.<p>What&#x27;s the best practice here? Should we pre-emptively have our servers rebuild daily just in case a 0-day backdoored them?
评论 #12387288 未加载
schwedeover 8 years ago
You should consider running this malware detection script[0]. That script is designed to catch malware php scripts. I&#x27;ve used it before with lots of success. You will also want to check the access logs for all php scripts hit in the last few months. Your hacker&#x27;s spam script is likely being activated&#x2F;ran by a GET or a POST to that script. That&#x27;s a pretty cheap way to screen for other compromised files.<p>[0] - <a href="https:&#x2F;&#x2F;www.rfxn.com&#x2F;projects&#x2F;linux-malware-detect&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.rfxn.com&#x2F;projects&#x2F;linux-malware-detect&#x2F;</a>
cm2187over 8 years ago
I did get one of these OVH spam warning emails too once. It was for a failover mail server. It turned out that the software I was using (smartermail) wasn&#x27;t using TLS by default so the link between the failover and the primary server was unencrypted. Spammers often target failover over primary servers. And OVH was interpreting the failover passing on the spam back to the primary server as me sending spam.
Neil44over 8 years ago
Don&#x27;t delete the outbound mail queue as they have a header in them which tells you which php script sent them.<p>Also in the httpd logs look for POST 200&#x27;s to scripts that shouldn&#x27;t be getting them, and look for long query strings esp with base64 in them. Check those scripts and also scripts messed with by the same user-agent and ip&#x27;s.<p>Never just delete anything, always check the contents and write a script that can search and nuke it en masse. e.g. Find | xargs | sed etc.<p>When I had issues earlier this year I had postfix outbound throttled right down, and a script to shut it down completely if the queue got big. So if I got the monitoring email about smtp going down I&#x27;d know I&#x27;d missed something ;)<p>Ps, wp-cli, you need it in your life :)
mboelenover 8 years ago
Thanks for sharing your intrusion story. Although it is always painful for the person to experience, it gives good insights on what happens in the wild. As the author of security tools rkhunter and Lynis, it is still a sign that basic (and advanced) system hardening remains needed for a long time.<p>The other comments show that there are so many things you could do. But some are more relevant than others. That is something we want to test for in Lynis with upcoming updates. One focus area will be detecting Drupal&#x2F;Joomla&#x2F;WordPress installations. If anyone wants to help out the open source project and make the web a safer place, this is your chance to help: <a href="https:&#x2F;&#x2F;github.com&#x2F;CISOfy&#x2F;lynis" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;CISOfy&#x2F;lynis</a><p>Thanks again for sharing!
fake-nameover 8 years ago
Ahhh PHP, where `assert()` `eval()`s strings passed to it.
hwhover 8 years ago
I wish it was easier to convert &quot;standard&quot; dynamic web pages into static HTML easier. There&#x27;s one or two Wordpress sites I&#x27;d really like to get rid of updating over and over again (which is still less work than actually reading mostly meaningless Changelogs and making a decision if there are security issues that actually apply to me). Probably, my solution to this problem will be &quot;wget -r&quot;, plus a bit of sanitizing.
评论 #12388518 未加载
Hoggover 8 years ago
Does }__ appear in your logs? All versions of all branches of Joomla prior to I think 3.4.6 had a problem with serialization that allowed arbitrary PHP execution.
chmikeover 8 years ago
Here are my advice:<p>1. once compromized, start with a fresh copy. Use ansible to define automatic installation scripts so that the server can be fully reinstalled in a &quot;snap&quot;. Use backups of the user data to restore.<p>2. Automate upgrades. It&#x27;s a piece of cake with ansible.<p>3. Stay away from php. There are too many potential loopholes. I now start using go to implement my web servers. Especially if the web site is static. Check Hugo or tools like that. I implement dynamic servers with go and Iris that uses fasthttp.
评论 #12388344 未加载
waltwaltherover 8 years ago
There is always something to be learned. Thank you for sharing.