LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Security (https://www.linuxquestions.org/questions/linux-security-4/)
-   -   404 error attack (https://www.linuxquestions.org/questions/linux-security-4/404-error-attack-4175484522/)

newbie14 11-14-2013 02:18 AM

404 error attack
 
Dear All,
I found these logs entries. The intruder actually knows the exact path and file name and also the get value which the programme suppose to accept. I have secured it where at the very top I check if the session value are isset and not empty. Is there any thing else can be harden here on linux? I guess possibly they have sniff the link maybe from some attacked pc could that be the reason they got the exact links.

Code:

207.182.143.146 - - [13/Nov/2013:18:11:11 +0800] "GET /folder2/v....php?ui=8090 HTTP/1.1" 404 224 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.72 Safari/537.36"
207.182.143.146 - - [13/Nov/2013:18:11:12 +0800] "GET /folder1/a........php HTTP/1.1" 404 224 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.72 Safari/537.36"
207.182.143.146 - - [13/Nov/2013:18:11:14 +0800] "GET /folder1/g.......php HTTP/1.1" 404 220 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.72 Safari/537.36"
207.182.143.146 - - [13/Nov/2013:18:11:15 +0800] "GET /folder1/vi.........php?tid=5213 HTTP/1.1" 404 236 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.72 Safari/537.36"
207.182.143.146 - - [13/Nov/2013:18:11:19 +0800] "GET /folder2/v.......php?id=200&e=5eid=1 HTTP/1.1" 404 226 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.72 Safari/537.36"
207.182.143.146 - - [13/Nov/2013:18:11:20 +0800] "GET /folder1/v.........php HTTP/1.1" 404 222 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.72 Safari/537.36"


Pearlseattle 11-14-2013 12:49 PM

Hi

Install & configure "iptables" (firewall) and then install "fail2ban" and configure it to 1) recognize the faulty attempts in your apache (or whatever you're using) logfile and to block access from that IP-number after more than X attempts.

Habitual 11-14-2013 02:17 PM

http://www.htaccess-guide.com/deny-v...by-ip-address/

Funny, are you hiding the software they are GET'ing for a reason?
If they know it's there, they wouldn't need to GET
folder2/...
folder1/...

So I think it's a scan for vulnerable software.

ericson007 11-14-2013 05:03 PM

As stated above, it is just a scan. I get tons of those as well. You can also use iptables in the newer kernels to drop packets complying to strings. For example, my biggest issue is w00tw00t and zmEu scans, but really not to much of an issue since they never find what they are after. You can then use iptables to check strings like zmeu and make it drop those packets

Habitual 11-14-2013 06:30 PM

Quote:

Originally Posted by ericson007 (Post 5064563)
my biggest issue is w00tw00t and zmEu scans, but really not to much of an issue since they never find what they are after. You can then use iptables to check strings like zmeu and make it drop those packets

you using something like
Code:

iptables -I INPUT -p tcp --dport 80 -m string --algo bm --string "w00tw00t" --to 1000 -j DROP
iptables -I INPUT -p tcp --dport 80 -m string --algo bm --string "ZmEu" --to 1000 -j DROP

?
Any performance hits the system doing so?

I saw an example without the "--to 1000" and to be honest, I'm not sure what that does.

Thanks.

newbie14 11-14-2013 07:59 PM

Dear Pearl,
I have both iptables and fail2ban running. Unfortunately my hosting guy off the iptables saying is not required as we have the hardware based firewall. Anyway I am gonna on it so what extra line can I put in it so that it recognize this sort of activity and same goes for fail2ban?

newbie14 11-14-2013 08:02 PM

Dear Habitual,
You suggested the .htacess method but some articles are saying dont use .htacess as it can create vulnerabilities too. Yes I hide my software but its very funny how do they know the exact get variable I dont think so its a scanner can do so exact matching right? Could it be they have hacked into some pc who have used this exact links with the get variables so they re-running it ?

ericson007 11-15-2013 01:01 AM

@Habitual

I don't really see there is much of a performance hit. The system is not so busy, i am running a small online training site for my business but most students don't bother using it. So the greatest amount of traffic i see are those types of hits.

I would think theoretically it should use less resources than apache starting a worker thread and writing a 404.

Since packets are dropped before reaching the server.

The virtual processor seems to be sitting around mostly at 0 - 0.46 at max utilization. That is pretty much what it was before and hits that peak when scanned and cron starts to run.

The 1000 just makes it lighter on resources by inspecting the first 1000 bits. Generally the engine details would be found in that part of the packet.

@newbie14
I would suggest getting that iptables up and going. Fits right in with a multi layered security approach. Your i.t. guy is gonna get bitten one day.

The .htaccess might be the onlything you have available depending on your hoting provider. If you can it is better to define variables in your config file for the host. It will be better protected and as benefit will have a slight performance benefit by not having to read the .htaccess every time an operation is performed.

And no they don't get exact matches if you get 404 errors. If it was an exact match, it would be a 200 code.

If you serve folders publically and left the default http config then your folders can be indexed. Scanners can traverse directories and just try tons of things.

You won't believe how many variations i saw last month with a scanner checking for phpmyadmin. There was one day with almost 400 variations of directories they tried.

newbie14 11-15-2013 07:08 AM

Dear Ericson,
Part of iptables is as below. Anything extra I should I add to this?

Quote:

# TCP only accept HTTP and HTTPS
-A INPUT -m state --state ESTABLISHED -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp -m multiport --dports 80,443 -m limit --limit 1/min --limit-burst 3 -j LOG --log-prefix "IN_HTTP "
# ...and limit the amount of new requests:
-A INPUT -m state --state NEW -m tcp -p tcp -m multiport --dports 80,443 -m limit --limit 16/sec --limit-burst 4 -j ACCEPT
#
What do you mean by this "If you can it is better to define variables in your config file for the host." Which config you mean here is the httpd.conf? Yes I know why they didnt get exact match is because of my names have few upper case where as theirs was all small case but trust me it was exact match with even the get variable. This is what worries me what and how do you think they would got those links?

I have remove the indexes from day one where it will give this
Quote:

error Forbidden

You don't have permission to access /folder1/ on this server.
. So I dont know how they can traverse my folder it the indexes is off from day one. Yes I get those tons of phmyadmin and even cgi-bin variation lucky all failed and I stop using phpmyadmin on this machine as I got attacked before this. I use only on lan access machine .

Habitual 11-15-2013 08:41 AM

Quote:

Originally Posted by newbie14 (Post 5064666)
Dear Habitual,
You suggested the .htacess method but some articles are saying dont use .htacess as it can create vulnerabilities too.

Code:

<Files .htaccess>
order allow,deny
deny from all
</Files>

in .htaccess. ;)
Code:

chmod 444 /path/to/.htaccess
and I'd like to know where you are reading that nonsense.

Quote:

Originally Posted by newbie14 (Post 5064666)
Yes I hide my software but its very funny how do they know the exact get variable I dont think so its a scanner can do so exact matching right? Could it be they have hacked into some pc who have used this exact links with the get variables so they re-running it ?

Hard to tell without a complete couple of lines from the log.
Standard installs of standardized programs creates standardized attack vectors.

Habitual 11-15-2013 08:44 AM

Quote:

Originally Posted by ericson007 (Post 5064785)
@Habitual

I don't really see there is much of a performance hit.

Thanks!

newbie14 11-15-2013 08:52 AM

Dear Habitual,
I read sometime ago article sorry for misinformation.Actually my application is a login based. That is why on every page I check for the session values. So do you think .htacess will incur extra login rite? As I mentioned to eriscon I know why they didnt get exact match is because of my names have few upper case where as theirs was all small case but trust me it was exact match with even the get variable. This is what worries me what and how do you think they would got those links? How to stop scanner will the indexing itself help ?

Habitual 11-15-2013 10:52 AM

Quote:

Originally Posted by newbie14 (Post 5064997)
Dear Habitual,
I read sometime ago article sorry for misinformation.Actually my application is a login based. That is why on every page I check for the session values. So do you think .htacess will incur extra login rite? As I mentioned to eriscon I know why they didnt get exact match is because of my names have few upper case where as theirs was all small case but trust me it was exact match with even the get variable. This is what worries me what and how do you think they would got those links? How to stop scanner will the indexing itself help ?

No worries.
If you don't care to post a "complete couple of lines from the log", then PM me a few of them and we can see what the pattern may be to the scan.
If this is a Public-facing site, then perhaps you can allow me to know it via PM and I can use some detective skills.fu to see what's up there?


Code:

deny from xxx.xx.xxx.xxx
allow from all

and if there is a pattern to the scan, we could perhaps deny all except for a 'valid' host/IPs such as this wordpress .htaccess configuration that prevent unauthorized logins/access to wp-login.php

Code:

# END WordPress
<Files wp-login.php>
order deny,allow
deny from all
allow from xx.xxx.xxx.xxx      # M's Office
Allow from xxx.xx.xx.xx                # J's house
</Files>

Do you have root access to the server?
As I have said, the intruder does NOT know "exactly" anything, else those 404s would be 200s.

newbie14 11-15-2013 11:11 AM

Dear Habitual,
No its not a public facing site. So can I email you will best. Yes I do have a root access to it but i dont use it. I use key based login.

Habitual 11-15-2013 11:14 AM

Quote:

Originally Posted by newbie14 (Post 5065080)
Dear Habitual,
No its not a public facing site. So can I email you will best. Yes I do have a root access to it but i dont use it. I use key based login.

That's mostly good news.
But how does 207.182.143.146 reach it if it's not public-facing then?

Subscribed with interest...


All times are GMT -5. The time now is 01:32 AM.