Güvenlik » Güvenlik Soru ve Cevaplar

mod_security kural zinciri hakkında

http://forum.whmdestek.com/

Go Back   WHM/cPanel Support Platform » Türkçe » Site, Sunucu Sorunlarınız ve Çözümleri » Güvenlik » Güvenlik Soru ve Cevaplar
 


Reply
 
LinkBack Thread Tools Display Modes
  #11  
Old 26.03.08, 00:19
Onursal's Avatar
fshbcr
 
Join Date: Jun 2007
Location: Çorlu
Age: 28
Posts: 638
Rep Power: 1092
Onursal has a reputation beyond reputeOnursal has a reputation beyond reputeOnursal has a reputation beyond reputeOnursal has a reputation beyond reputeOnursal has a reputation beyond reputeOnursal has a reputation beyond reputeOnursal has a reputation beyond reputeOnursal has a reputation beyond reputeOnursal has a reputation beyond reputeOnursal has a reputation beyond reputeOnursal has a reputation beyond repute
Send a message via MSN to Onursal
aynı cümleler senin içinde geçerli ilyas ya yalnış yapmışındır. veyahut versiyonun uyuşmuyordur versiyonun aynı değilse 2x versiyonu için ruleler yukarıdaki ekte
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #12  
Old 26.03.08, 00:25
byilyas's Avatar
Athlon
 
Join Date: Mar 2008
Location: istanbul
Posts: 136
Rep Power: 11
byilyas has much to be proud ofbyilyas has much to be proud ofbyilyas has much to be proud ofbyilyas has much to be proud ofbyilyas has much to be proud ofbyilyas has much to be proud ofbyilyas has much to be proud ofbyilyas has much to be proud of
Quote:
Originally Posted by Fesih BICER View Post
aynı cümleler senin içinde geçerli ilyas ya yalnış yapmışındır. veyahut versiyonun uyuşmuyordur versiyonun aynı değilse 2x versiyonu için ruleler yukarıdaki ekte

Demek sitelerin yayını senin kuralların apache 1.x için olmasından kaynaklandı bende apache 2.x kullanıyorum abiciğim belirttin şu versiyonları bakın hata bende apachim 2.x yazsaydım gece gece kriz yaşamıyacaktım neyseki bir dostum el attı temizledi ruleleri

Edit: mod securitynin versiyonuda 2 küsür
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #13  
Old 26.03.08, 00:29
ALEXIS's Avatar
phpBB Türkiye
 
Join Date: Aug 2007
Location: istanbul
Posts: 112
Rep Power: 2
ALEXIS is on a distinguished road
Burada sürüyle kural var, bana sadece mod_security test edebileceğim basit bir kural yazabilir misiniz?

Mesela, şu çalışmasın, error 403 versin:

site.com/index.php?cmd=
__________________
Profesyonel phpBB3 hizmetleri
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #14  
Old 29.03.08, 00:30
byilyas's Avatar
Athlon
 
Join Date: Mar 2008
Location: istanbul
Posts: 136
Rep Power: 11
byilyas has much to be proud ofbyilyas has much to be proud ofbyilyas has much to be proud ofbyilyas has much to be proud ofbyilyas has much to be proud ofbyilyas has much to be proud ofbyilyas has much to be proud ofbyilyas has much to be proud of
Bu konu gerçekten önemli bir konu fakat kimse güvenliği önemsemyor veya açıklar ile yaşamaktan mutlu
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #15  
Old 29.03.08, 01:32
Ni-Osman's Avatar
Linux HelpDesk
 
Join Date: Feb 2008
Location: Denizli
Posts: 271
Rep Power: 7012
Ni-Osman has a reputation beyond reputeNi-Osman has a reputation beyond reputeNi-Osman has a reputation beyond reputeNi-Osman has a reputation beyond reputeNi-Osman has a reputation beyond reputeNi-Osman has a reputation beyond reputeNi-Osman has a reputation beyond reputeNi-Osman has a reputation beyond reputeNi-Osman has a reputation beyond reputeNi-Osman has a reputation beyond reputeNi-Osman has a reputation beyond repute
Send a message via MSN to Ni-Osman Send a message via Yahoo to Ni-Osman Send a message via Skype™ to Ni-Osman
Quote:
Originally Posted by ALEXIS View Post
Burada sürüyle kural var, bana sadece mod_security test edebileceğim basit bir kural yazabilir misiniz?

Mesela, şu çalışmasın, error 403 versin:

site.com/index.php?cmd=
http://www.ni.net.tr/dosyalar/modsec.conf.txt

bunu eskiden her ay güncellerdim otomatik cron yapmıştık herkesin makinasına buradan çekerdi apache restart olurdu ama artık bu tür bash script işleri ile uğraşacak zamanım olmuyor bunu incelemeni tavsiye ederim misal bak demişsinki

index.php?cmd=

bunu engellemek istiyorum benim kural dosyamda

SecFilterSelective THE_REQUEST "act=chmod"

bunları görmüşsündür bunlar ya c99 için ya r57 için bunların tamamı değişkenler şimdi sen gider bunu

SecFilterSelective THE_REQUEST "php?cmd="

yaparsan işini görecektir yada


SecFilterSelective THE_REQUEST "cmd="

ama sandığın gibi değil bu R57 c99 gibi şeyleri yapan elemanlar bazı hazır scriptlerin değişkenlerini kullanarak yapmış (modsec ile bunu önlerlerse hazır scriptlerin çalışmaması için)

bu nedenle kural dosyasında şunları göreceksin

SecFilterSelective THE_REQUEST "act=tools"
SecFilterSelective THE_REQUEST "act=gof"
SecFilterSelective THE_REQUEST "act=ls"
SecFilterSelective THE_REQUEST "act=mk"
SecFilterSelective THE_REQUEST "act=f&"
SecFilterSelective THE_REQUEST "act=sql"
SecFilterSelective THE_REQUEST "act=gofile"
SecFilterSelective THE_REQUEST "act=mkdir"
SecFilterSelective THE_REQUEST "act=ftpquickbrute"
SecFilterSelective THE_REQUEST "act=d"
SecFilterSelective THE_REQUEST "act=phpinfo"
SecFilterSelective THE_REQUEST "act=security"
SecFilterSelective THE_REQUEST "act=makefile"
SecFilterSelective THE_REQUEST "act=encoder"
SecFilterSelective THE_REQUEST "act=fsbuff"
SecFilterSelective THE_REQUEST "act=selfremove"
SecFilterSelective THE_REQUEST "act=update"
SecFilterSelective THE_REQUEST "act=feedback"
SecFilterSelective THE_REQUEST "act=search"
SecFilterSelective THE_REQUEST "act=chmod"
SecFilterSelective THE_REQUEST "act=upload "
SecFilterSelective THE_REQUEST "act=delete"
SecFilterSelective THE_REQUEST "act=paste"
SecFilterSelective THE_REQUEST "act=copy"
SecFilterSelective THE_REQUEST "act=cut"
etc. etc..

bu şekilde devam ediyor tüm bunları değişken ve eşitlikleri tek tek yazmamızdaki sebep act yi bir başka hazır scriptin kullanıyor olması

bu kural dosyasına bakarak tamamen kendi özel kural dosyalarınızı yazabilirsiniz


Unutmadan yaptıklarınızı paylaşmayı unutmayın!

Kolay gelsin.
__________________
Netinternet Telekom
Artık daha çok zamanınız var!


Üyelik ve Partnerlikler :cPanel INC. , Parallels , DirectAdmin , Netenberg , RIPE , Redhat , Microsoft(Bitmedi) ,GeoTurst
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #16  
Old 30.03.08, 00:46
byilyas's Avatar
Athlon
 
Join Date: Mar 2008
Location: istanbul
Posts: 136
Rep Power: 11
byilyas has much to be proud ofbyilyas has much to be proud ofbyilyas has much to be proud ofbyilyas has much to be proud ofbyilyas has much to be proud ofbyilyas has much to be proud ofbyilyas has much to be proud ofbyilyas has much to be proud of
Osman hocam verdiğiniz adresteki dosyayı biraz inceledim sanırım dosyadaki kural zincirleri mod_security 1.x için 2.x versiyonu için olanı yokmudur?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #17  
Old 30.08.08, 14:47
Atari
 
Join Date: Nov 2007
Posts: 3
Rep Power: 0
cd42 is on a distinguished road
ayni durumdan bende magdur oldum mod_security1 den 2 ye yukseldim diger versionlar ile birlikte default olarak gelen kurallar her seyin calismasini engelliyor uygun sartlarda kati olmayan yada bu surekli 501 ve 406 gibi hatalari verip durmayan bir rule set olusturlursa cok iyi olur version henuz yeni olmasi nedeniyle fazla kaynak yok umarim yakin zamanda seslerimizi duyanlar cikar
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #18  
Old 03.09.08, 01:32
rm -rf
 
Join Date: Jan 2008
Location: Istanbul
Age: 22
Posts: 119
Rep Power: 1001
GODAttach has a reputation beyond reputeGODAttach has a reputation beyond reputeGODAttach has a reputation beyond reputeGODAttach has a reputation beyond reputeGODAttach has a reputation beyond reputeGODAttach has a reputation beyond reputeGODAttach has a reputation beyond reputeGODAttach has a reputation beyond reputeGODAttach has a reputation beyond reputeGODAttach has a reputation beyond reputeGODAttach has a reputation beyond repute
Send a message via ICQ to GODAttach
Code:
Today I had time for another shot at my new .htaccess, and I can tell you that it got better. I think it's pretty much done now, and I am really happy with it. I also got a couple of questions about how it exactly works. So I post my latest .htaccess here, plus a walkthrough on the various mod_rewrite rules I use.

First off, here is my latest beauty:



RewriteEngine On

Options +FollowSymLinks

ServerSignature Off



RewriteCond %{REQUEST_METHOD}  ^(HEAD|TRACE|DELETE|TRACK) [NC,OR]

RewriteCond %{THE_REQUEST}     ^.*(\\r|\\n|%0A|%0D).* [NC,OR]



RewriteCond %{HTTP_REFERER}    ^(.*)(<|>|'|%0A|%0D|%27|%3C|%3E|%00).* [NC,OR]

RewriteCond %{HTTP_COOKIE}     ^.*(<|>|'|%0A|%0D|%27|%3C|%3E|%00).* [NC,OR]

RewriteCond %{REQUEST_URI}     ^/(,|;|:|<|>|">|"<|/|\\\.\.\\).{0,9999}.* [NC,OR]



RewriteCond %{HTTP_USER_AGENT} ^$ [OR]

RewriteCond %{HTTP_USER_AGENT} ^(java|curl|wget).* [NC,OR]

RewriteCond %{HTTP_USER_AGENT} ^.*(winhttp|HTTrack|clshttp|archiver|loader|email|harvest|extract|grab|miner).* [NC,OR]

RewriteCond %{HTTP_USER_AGENT} ^.*(libwww-perl|curl|wget|python|nikto|scan).* [NC,OR]

RewriteCond %{HTTP_USER_AGENT} ^.*(<|>|'|%0A|%0D|%27|%3C|%3E|%00).* [NC,OR]



RewriteCond %{QUERY_STRING}    ^.*(;|<|>|'|"|\)|%0A|%0D|%22|%27|%3C|%3E|%00).*(/\*|union|select|insert|cast|set|declare|drop|update|md5|benchmark).* [NC,OR]

RewriteCond %{QUERY_STRING}    ^.*(localhost|loopback|127\.0\.0\.1).* [NC,OR]

RewriteCond %{QUERY_STRING}    ^.*\.[A-Za-z0-9].* [NC,OR]

RewriteCond %{QUERY_STRING}    ^.*(<|>|'|%0A|%0D|%27|%3C|%3E|%00).* [NC]



RewriteRule ^(.*)$ access_log.php 



First we set the basic configuration in order to utilize the Apache mod_rewrite module.

RewriteEngine On

Options +FollowSymLinks



Then our first basic rule is to turn off the server signature, which can be helpful in order to stop banner grabbing:

ServerSignature Off



I use 2 different flags, namely:

NC - Not Case sensitive

OR - Or the next rule



The first rule is based upon the REQUEST_METHOD. The request method is the method on which a client wishes to connect to our server. I only want GET or POST requests, so I limit methods which I think should not request my server at all. TRACE and TRACK should be blocked in any case, because of the violation of the browsers same origin policy rules. DELETE is optional, but since I won't use it I block it anyway. I also block HEAD request methods, a HEAD request is usually made by law abiding scanners that usually perform banner grabbing and do not want to fetch the whole page. While that might sound reasonable to allow, I block it.

RewriteCond %{REQUEST_METHOD}  ^(HEAD|TRACE|DELETE|TRACK) [NC,OR]



THE_REQUEST is the full request that is being made by a client and consist of a long string. This is usefull to sanitize, because I do not want a client sending me dual headers, or dual requests that can lead to http response splitting, or CRLF injection as it was called in the old days.

RewriteCond %{THE_REQUEST}     ^.*(\\r|\\n|%0A|%0D).* [NC,OR]



HTTP_REFERER can contain characters that could be used to pentest a webapplication, or it can carry a worm payload vector. Blocking characters that will likely never happen in a legitimate request, we make sure that it cannot do something malicious.

RewriteCond %{HTTP_REFERER}    ^(.*)(<|>|'|%0A|%0D|%27|%3C|%3E|%00).* [NC,OR]



The HTTP_COOKIE is equal important, and often a place to store pentest characters or payload.

RewriteCond %{HTTP_COOKIE}     ^.*(<|>|'|%0A|%0D|%27|%3C|%3E|%00).* [NC,OR]



The REQUEST_URI is important in server protection. Mostly overflow protection, or canonicalization issues like happened with Apache Tomcat for example. With a max of 9999 duplicate characters. Please notice that the REQUEST_URI always contains unencoded (verbatim) characters.

RewriteCond %{REQUEST_URI}     ^/(,|;|:|<|>|">|"<|/|\\\.\.\\).{0,9999}.* [NC,OR]



This rule set checks the USER_AGENT. Of course, it can be forged. But that is not the point. Wget and cURL are somewhat harder to forge on a platform, and many penetration software packages have a hard coded user-agent which sometimes cannot be changed, when it is proprietary software for example. This is only to thwart the less experienced hackers and massive generic bots, which will also save us bandwidth and log annoyances! The first rule checks for an empty user-agent. The lynx browser -for crontabs for example- is allowed because it has libwww-FM as a user agent, whereas I block the libwww-perl user-agent, since scripts can use the Perl libraries to attack.

RewriteCond %{HTTP_USER_AGENT} ^$ [OR]

RewriteCond %{HTTP_USER_AGENT} ^(java|curl|wget).* [NC,OR]

RewriteCond %{HTTP_USER_AGENT} ^.*(winhttp|HTTrack|clshttp|archiver|loader|email|harvest|extract|grab|miner).* [NC,OR]

RewriteCond %{HTTP_USER_AGENT} ^.*(libwww-perl|curl|wget|python|nikto|scan).* [NC,OR]

RewriteCond %{HTTP_USER_AGENT} ^.*(<|>|'|%0A|%0D|%27|%3C|%3E|%00).* [NC,OR]



The QUERY_STRING is probably the most important of all, because that is where most of the actual action is happening. In the rules below I check for a common SQL injection pattern, pentest characters for XSS, and also for remote shell injection in the 3rd rule because periods should actually not be present in the QueryString in my opinion.

RewriteCond %{QUERY_STRING}    ^.*(;|<|>|'|"|\)|%0A|%0D|%22|%27|%3C|%3E|%00).*(/\*|union|select|insert|cast|set|declare|drop|update|md5|benchmark).* [NC,OR]

RewriteCond %{QUERY_STRING}    ^.*(localhost|loopback|127\.0\.0\.1).* [NC,OR]

RewriteCond %{QUERY_STRING}    ^.*\.[A-Za-z0-9].* [NC,OR]

RewriteCond %{QUERY_STRING}    ^.*(<|>|'|%0A|%0D|%27|%3C|%3E|%00).* [NC]



Finally, we rewrite the request to a fail-safe page. This can be a script that logs all the information -which I do not recommend- If possible send it to a forbidden page. Anything you wish.

RewriteRule ^(.*)$ access_log.php 



Considerations.

Working with Apache modules always takes caution from your side. This tiny Apache firewall is meant to block requests that are malformed and usually never happen on a legitimate request. It is advised to take notice that it can break some poorly coded applications on your server. In such a way, that when it blocks an application it is advised to modify this application, because it is likely doing something that is almost certainly dangerous. It depends whether you have access to your httpd.conf, but if you consider to use these rules it is recommended to place them in your httpd.conf instead of a .htaccess for better performance. Please also remember that it does not protect you from data that comes through POST. I hope that explains it some more and that you can use it, because it really can be another layer of defense. Not only can it protect holes you are not aware of, it also blocks generic abuse of webapplications.
bi yerlerden bulmusum nerden oldugunuda hatirlamiyorum. Kaynak belirtemiyorum bu yuzden.
__________________
Fabrikadan yeni cikmis bir makineden, bir
akademisyen ile rekabet etmesini beklemek hic de
adil degildir - Alan Turing
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #19  
Old 03.09.08, 01:41
rm -rf
 
Join Date: Jan 2008
Location: Istanbul
Age: 22
Posts: 119
Rep Power: 1001
GODAttach has a reputation beyond reputeGODAttach has a reputation beyond reputeGODAttach has a reputation beyond reputeGODAttach has a reputation beyond reputeGODAttach has a reputation beyond reputeGODAttach has a reputation beyond reputeGODAttach has a reputation beyond reputeGODAttach has a reputation beyond reputeGODAttach has a reputation beyond reputeGODAttach has a reputation beyond reputeGODAttach has a reputation beyond repute
Send a message via ICQ to GODAttach
Quote:
Originally Posted by Fesih BICER View Post
dene tabi ayıpsın.

işlevi şöyle türkiyede kendi hacker sananlar sitelerin sonuna index.php?id=http:///exploit.linki/hnn.txt? gibi link getirip açık kapı ararlar. bizim kural sondaki txt? kısmını önler zaten sonda soru işareti ? kalmadımı exploit dışardan çalışmaz.

ama sunucunuza php olarak upload ederse çalıştırır. bunun içinde artı güvenlik önlemleri var. php fonksiyonlarını kapama, open basedir, safe mod v.s

@alexix

çalışır. sorun çıkarmaz yani.
Remote File Inclusion deniyor bu aciklara ve acik kaynak / kapali kaynak bir cok sistemde bir donem oldukca yogun sekilde karsilasiyorduk, sanirim bunlar icinde en utanc vericisi odtu, itu, aibu gibi universiteler ve honda gibi bir teknoloji devinde dahi bulunmus olmasi. Bir CMSde karsiniza cikmis cok mu. Bir guvenlik acigini kimin ne sekilde kullandigi onemli degil (lamer, hijacker, newbie). Onemli olan o acigin sistemde bulunuyor olmasi eh onun icinde o guvenlik dunyasinin nese kaynagi gencleri degilde sistemde acigi bulunduran uygulamayi suclamayi deneyin boylece uygulamanin daha guvenli gelistirilmesi icin baski yapmis olursunuz.

REGISTER_GLOBALS'in ayibi. Super Globals kullanilabilir!?
__________________
Fabrikadan yeni cikmis bir makineden, bir
akademisyen ile rekabet etmesini beklemek hic de
adil degildir - Alan Turing

Last edited by GODAttach; 03.09.08 at 01:46.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
mod_security kurulumu CaLViN Güvenlik Makaleler 50 20.11.08 08:41
Örnek Mod Security Kural Zinciri McLee Güvenlik Makaleler 3 20.07.08 13:45
Mod_security 2.5.0 Kurulumu hamzam WHM Soru ve Cevaplar 2 19.03.08 22:44
Mod_Security Installation CaLViN Security 0 08.11.07 21:14
veri tabanı hakkında hakkında prozac WHM Soru ve Cevaplar 12 15.10.07 18:43


Sign up for PayPal and start accepting credit card payments instantly.

Navigasyon
Menü