Is there a vulnerability in apache that allows to execute php directly?

Red Squirrel

No Lifer
May 24, 2003
69,736
13,351
126
www.betteroff.ca
I keep seeing query strings like this, some even more convoluted:

Code:
GET /?s=index/\\think\\template\\driver\\file/write&cacheFile=robots1.php&content=xbshell<?php%20@eval($_POST[admin]);?> HTTP/1.1" 302 687 "[my site]/?s=index/\\think\\template\\driver\\file/write&cacheFile=robots1.php&content=xbshell<?php @eval($_POST[admin]);?>

All I have is a static html page right now, so I don't know what they're trying to do, but is there maybe a way to execute php directly somehow? It almost looks like that's what they're trying to do or maybe even being successful. Whatever is in the POST might be the payload. Looks like they're using the user agent string as part of the attack as well.

My server got hacked a while back, twice - second time was a brand new install of Debian with nothing else on it just a basic landing page saying sites are coming back. Got hacked overnight as backups were being uploaded to it. Starting to wonder if there is a 0 day in Apache that is not discovered yet. Maybe somehow related to log4j? Ex: could some of that code be used in Apache too even though it's not Java?

Going to let this run for a while to see if it eventually gets hacked again, there's basically no attack surface at this point as I literally just have apache with a basic html page and ssh running. (key pair auth only) I want to try to self host again but it seems there is some kind of sophisticated attack being used against me, considering they were able to hack a brand new box with nothing setup yet. Not sure whether or not that query string is part of the attack or not.

Is there a way to intercept these queries before they end up going to apache? I guess some kind of reverse proxy maybe? I want to look for keywords and just ignore them and automatically ban the IPs that attempt this stuff.
 

mxnerd

Diamond Member
Jul 6, 2007
6,799
1,103
126
Googled the query string you posted.

Guess it's the hacking robots on the internet looking for vulnerabilities of any ThinkPHP installation.
Hacking robots can easily run the code 24/7 attacking thousands of websites at the same time.
Of course the robots won't know beforehand if you have the installation, but the robots will try anyway.
It does not make sense that the hacker is just targeting your website.


If you have any installation of Pi-Hole or AdminLTE, both also use ThinkPHP framework according to the net.

No idea regarding php / https servers/reverse proxy servers.
 

Red Squirrel

No Lifer
May 24, 2003
69,736
13,351
126
www.betteroff.ca
Oh so that's just targetting a specific applications in hopes it's installed in the default path? That's less concerning then. I just thought it was weird I was seeing that when I literally just have a text based index.htm file and my 404 error page set to it. So it's literally the only page on the entire web server at the moment so nothing to really crawl or look for.

I'm still not sure how they hacked my other server so kinda paranoid at this point. This time I decided to host DNS, email etc on a shared host and will focus only on web to minimize attack surface. Still unsure if they got in through Apache or another service.

Is there a way to block these types of attempts and block the IP? Like some kind of keyword based block? Someone trying to do that is up to no good anyway so I'd rather it just be blocked.
 

Red Squirrel

No Lifer
May 24, 2003
69,736
13,351
126
www.betteroff.ca
Yeah I know how to do all that, but would be nice to have a way to automate it by having something look at the logs and look for people trying to do questionable queries. Something like fail2ban I guess but more granular.

Suppose I can maybe code something though. I'd probably use iptables to block the IPs and not Apache itself though, I think it's faster to do it at the firewall level. Layer 3 (sorta) instead of layer 7.
 

mxnerd

Diamond Member
Jul 6, 2007
6,799
1,103
126