Showing posts with label Intrusion Detection System. Show all posts
Showing posts with label Intrusion Detection System. Show all posts

Friday, June 9, 2017

What is BroIDS?

 
A short introduction of what is BroIDS (or shortly with general use Bro):
 
Bro Intrusion Detection System
 
BroIDS is an open-source, Unix-based,  network-based IDS. It was developed by Vern Paxson at Lawrence Berkeley National Lab and the International Computer Science Institute. As all NIDS, BroIDS monitors the network traffic to look for any suspicious activity. It parses the network traffic to dig out its application-level semantics and then executes event-oriented analyzers to compare the activities with patterns (whenever a suspicious activity is found on the network, IDS logs them, and those activities are used as patterns to check for similar activities). (1)
 
BroIDS is an open-source network security monitor which inspects network traffic looking for suspicious activity. The BroIDS framework provides an extensible scripting language that allows an analysis of application to protocol level traffic. All built-in and user added BroIDS scripts output data to log files which can be further analyzed to detect malicious activities. (2)
 
Features of BroIDS
 
  • network-based IDS
  • custom scripting language,
  • pre-defined policy scripts,
  • snort signature compatibility support,
  • powerful signature matching facility,
  • different approach of network analysis,
  • detection follows an immediate action. (1)
BroIDS detects definite and abnormal activities, such as certain hosts connecting to certain services, using signatures and patterns of failed connection attempts. As BroIDS logs all activities in detail, it is most useful in network forensic investigations. BroIDS is popular, as it targets high speed, high volume intrusion, and detects using powerful packet filtering techniques to accomplish the essential performance. (1)
 
Bro is not:
  • an IDS,
  • an IPS,
  • an alerting system,
  • a SIEM,
  • an awesome frontend,
  • a silver bullet, (3)
 
Analyzing the Traffic
 
First, BroIDS filters the network traffic and then the remaining information is sent to its event engine, where BroIDS interprets the structure of the network packets and abstracts them into higher-level  events  describing  the  activity. Lastly,  BroIDS  implements  policy  scripts against the events, looking for possible intrusions. (1) 
 
Policy scripts
 
BroIDS is an open-source network security monitor that has been in development since 1995. The power of BroIDS is in the extensible scripting engine that analyzes the packet data. There are a wide array of out-of-the-box, pre-written scripts that ship with BroIDS that analyze network traffic. These local scripts write to six different categories of logs; network protocols, files, detection, network observations, miscellaneous, and diagnostics. (2)
 
"Bro uses a specialized policy language that allows a site to tailor Bro's operation, both as site policies evolve and as new attacks are discovered.” These scripts are program written in BroIDS language and have all the rules describing the types of events which are potential intrusions and these policy scripts analyze the activities then initiate actions based on the analysis. It records the activities seen on the network as files and also generates alerts. It is a good idea to consider “Why Bro needs a special language?”, because this is a language which understands specific notions such as ports, IP addresses, connections  etc. and has a different approach to analyze the network to make the task easy. Users of BroIDS need not to learn the BroIDS language to run it. (1)

These scripts take action such as follows:ƒ
  • generating output files which have recorded events on the monitored network,
  • generating alerts if it sees a problem,
  • terminating the existing connections,
  • blocking traffic by placing blocks in to router ACL,
  • sends e-mail messages to the user to report events. (1)
BroIDS can analyze the network with deep levels of abstraction and stores all the past activities and integrate with new ones. (1)
 
BroIDS can inspect network traffic in real-time or look into a packet capture file that was previously recorded. As part of the analysis, BroIDS looks for known attacks in the same way a typical intrusion detection system would. The benefit of BroIDS is that all connections, sessions, and application level data are written to an extensive set of log files for later review. (2)
 
References:
 

Wednesday, September 7, 2016

Suricata "Content" Parametresi

Suricata saldırı tespit/engelleme sistemi -beklendiği üzere- şifrelenmemiş paketlerin "veri" (payload) kısmına da bakarak saldırı örüntülerini (pattern) tespit edebilmektedir.
 
Bu tespitleri yapabilmek için Suricata imzalarında bir "content" alanı bulunmaktadır. Bu yazımızda Suricata imzalarındaki "content" alanıyla ilgili bilgi vermeye çalışacağız.
 
Öncelikle içeriğinde "content" geçen rastgele bir örnek imza aşağıda verilmiştir:
alert http $HOME_NET any -> $EXTERNAL_NET any (msg:"ET USER_AGENTS Lowercase User-Agent header purporting to be MSIE"; flow:established,to_server; content:"user-agent|3a 20|Mozilla/4.0|20|(compatible|3b 20|MSIE|20|"; http_header; content:!"|0d 0a|VIA|3a 20|"; http_header; classtype:trojan-activity; sid:2012607; rev:4;)

Örnekten de görülebileceği gibi bir Suricata imzasının içerisinde birden fazla "content" alanı da olabilmektedir.
 
"content" parametresiyle, gelen paketin veri (payload) kısmında aranacak harf-rakam kombinasyonunun tırnak içerisine yazılması gerekiyor. Örneğin Suricata imzasında content:"SALDIRIYORUM ULEYYNNN!!" yazmış olduğunuz takdirde Suricata, gelen paketlerin veri kısımlarında "SALDIRIYORUM ULEYYNNN!!" içeriği olan paketleri tespit edecektir.
 
alert tcp $HOME_NET any -> $EXTERNAL_NET any (msg:"YABAN SALDIRISI!!!"; flow:established,to_server; content:"SALDIRIYORUM ULEYYNNN!!"; classtype:yaban-activity; sid:2222220; rev:3;)
 
"content" parametresinin içerisine harflerin, rakamların ya da özel karakterlerin hexadecimal karşılıkları da yazılabilmektedir.

Suricata imzasının içerisine yazacağımız; content: "|53 41 4c 44 49 52 49 59 4f 52 55 4d 20 55 4c 45 59 59 4e 4e 4e 21 21|" ile content:"SALDIRIYORUM ULEYYNNN!!" aynı anlama gelmektedir. Harflere karşılık gelen hexadecimal değerler aşağıda verilmiştir.
S = 53, A =41, L = 4c, D = 44, I = 49, R = 52,I = 49, Y = 59, O = 4f, R = 52, U = 55, M = 4d, = 20, U = 55, L = 4c, E = 45, Y = 59, Y = 59, N = 4e, N = 4e, N = 4e, ! = 21, ! = 21
Normal karakterler iki adet "<örnek>" (tırnak) arasına yazılırken, hexadecimal karakterler iki tane |<örnek>| (pipe) arasına yazılmaktadır.

Bazı karakterler imzanın okunmasında karışıklığa yol açtıklarından dolayı bu karakterleri Suricata imzasının içerisine iki tırnak arasına yazmak mümkün olmamaktadır. Bu karakterleri imzanın içerisine mutlaka hexadecimal olarak yazmak gerekmektedir. Bu karakterler ve hexadecimal karşılıkları aşağıda verilmiştir:
" = |22|
; = |3B|
: = |3A|
| = |7C|
Buna bir örnek vermek gerekirse; Suricata imzasının içerisine content:"http://" yazılamamaktadır. Bunun yerine content:"http|3A|//" yazılabilmektedir. 
"content" parametresinin içeriği büyük-küçük harf duyarlıdır. Yani content:"SALDIRIYORUM ULEYYNNN!!" ile content:"saldiriyorum uleyynnn!!" aynı anlama gelmemektedir. Büyük-küçük harf duyarlılığımı iptal etmek için imzanın içerisinde "nocase" parametresinin kullanılması gerekmektedir.
 
Örneğin; content:"SALDIRIYORUM ULEYYNNN!!"; nocase; ile content:"saldiriyorum uleyynnn!!"; nocase; aynı anlama gelmektedir.
Peki bir Suricata imzası içinde iki adet "content" parametresi olması durumunda Suricata nasıl davranmaktadır? Öncelikle bu, anlaması biraz zor bir algoritmaya dayanmaktadır. Bu algoritmanın ayrıntılarına girmeyeceğiz. Genel olarak; "content" parametresi içerisindeki "daha uzun" (longer) ve "en çok değişen" (varied) harf/rakam kombinasyonları tercih edilmektedir.
 
Örneğin: Suricata imzası içerisinde content:"SALDIRIYORUM ULEYYNNN!!" ve content:"YAKALA oni!" parametrelerinin bulunduğunu kabul edelim. Birinci "content"in içerisinde 23 karakter bulunmakta, ikinci "content"in içerisinde de 11 karakter bulunmaktadır. Bu durumda Suricata content:"SALDIRIYORUM ULEYYNNN!!" parametresine öncelik verecektir.
 
"En çok değişen" kavramına da bir örnek vermeye çalışalım: content:"SALDIRIYORUM ULEYYNNN!!" ile content:"S|41|LD|49|R|49|YORUM ULEYY|4E||4E||4E|!!" arasında bir karar verilmek istenmesi durumunda Suricata content:"S|41|LD|49|R|49|YORUM ULEYY|4E||4E||4E|!!" parametresini tercih edecektir. Çünkü ikinci "content"in bizim tabirimizle "değişen parçaları" daha fazladır. (|41|, |49| vb...)

Suricata imzalarında "daha az değişen" veya "daha kısa" olan değişkenlere öncelik vermek istediğimiz takdirde de "fast_pattern" adlı parametreyi kullanmamız gerekmektedir. Örneğin, Suricata'ya daha uzun ve değişeni daha çok olan content:"SALD|49|R|49|YORUM ULEYY|4E||4E||4E|!!" yerine daha kısa ve değişeni olmayan content:"az bi dakka!" parametresini tercih ettirmek istiyorsak bunların imzanın içerisine aşadaki gibi yazılması gerekmektedir:
content:"SALD|49|R|49|YORUM ULEYY|4E||4E||4E|!!"; content:"az bi dakka!"; fast_pattern;
 
(İki adet "en çok değişen" ve iki adet "daha uzun" parametrelerine sahip olan "content" için bkz. https://redmine.openinfosecfoundation.org/projects/suricata/wiki/Suricata_Fast_Pattern_Determination_Explained)
 
Suricata imzasındaki "content" parametresi http trafiği için de özelleştirilmiştir. "content" parametresinin http trafiğinde nasıl kullanıldığını da başka bir yazıya bırakalım.

Friday, August 5, 2016

Suricata Rule Thresholding


Three types of threshold values can be defined in Suricata rules: limit, threshold and both. I want to make some further explanations about them because this concept may be a bit confusing.

The notation of rule thresholding in Suricata is shown below:

threshold: type <threshold|limit|both> track , count <M>, seconds <T>

type threshold
Type threshold alerts every M times we see this event during the time interval.

threshold: type threshold track by_src, count 4, seconds 360;

In the above example the rule generates "1" alarm everytime the event is met "4" times in "360" seconds.

The figure below depicts "type threshold":

type limit
Type limit alerts on the 1st M events during the time interval, then ignores events for the rest of the time interval. 

threshold:type limit, track by_src, count 4 , seconds 360;

In the above example the rule generates "4" alarms if the event is met first "4" times in "360" seconds. After the detections it doesn't generate any alarms in the rest of the 360 seconds.

The figure below depicts "type limit":
 
type both
Type both alerts once per time interval after seeing M occurrences of the event, then ignores any additional events during the time interval.

threshold:type both, track by_src, count 4 , seconds 360;

In the above example the rule generates "1" alarm if the event is met "4" times in "360" seconds. After the detection it doesn't generate an alarm in the rest of the 360 seconds.

The figure below depicts "type both":







Thursday, January 7, 2016

Suricata'nın Saldırı Trafiği Haricindeki Kayıtları Tutma(ma)sı

Suricata, beta sürümü ilk defa 2009 yılının Aralık ayında ve ilk kararlı sürümünün de 2010 yılının Temmuz ayında piyasaya sürülmüş olan açık kayaklı bir saldırı tespit/engelleme sistemi yazılımıdır. (http://suricata-ids.org) Suricata, OISF (Open Information Security Foundation) adlı bir sivil toplum kuruluşu tarafından geliştirilmiştir. (http://oisf.net)

Bu yazımızda Suricata'nın özelliklerine değinmeyeceğiz. Bu yazımızda değineceğimiz hususu aşağıya yazmaya çalıştım.

Suricata, -diğer tüm saldırı tespit sistemleri gibi- ağa gelip giden tüm trafiği dinleyecek şekilde ağ topolojisi üzerinde konumlandırılır. Saldırı tespit sistemleri, dinledikleri ağ trafiği içerisinde kendi saldırı imza veri tabanlarına (signatures) karşılık gelen trafikleri alarm (alert) oluşturacak şekilde bir kayıt (log) dosyasına yazarlar. Yani saldırıları kayıt (log) altına alırlar.
Suricata, dinlediği ağ trafiği içerisinde saldırı veri tabanıyla eşleşmeyen trafiği -yani saldırı haricindeki trafiği- de bir kayt (log) dosyasına yazabilir. Yani ağa gelip giden tüm trafiği dinliyor ve sizin seçmiş olduğunuz protokole göre bu trafiği de kayıt (log) altına alabiliyor. Örneğin herhangi bir saldırı örüntüsü içermeyen; SSH (TCP 22), HTTP (TCP 80), NTP (UDP 123), SMTP (TCP 25),... gibi trafikleri de kayıt altına alabilmektedir. Suricata bu kayıtları "json" kayıt formatında tutabilmektedir. Bu kayıt dosyasının varsayılan (default) ismi “eve.log”dur. (/var/log/suricata/eve.log)
Saldırı olmayan trafiğin kayıtlarını (log) tutmak istemiyorsak Suricata'nın yapılandırma (konfigürasyon) dosyası olan suricata.yaml dosyasının içeriğinde değişiklik yapmamız gerekmektedir. suricata.yaml dosyası içerisinde "app-layer" başlığı altındaki parametreler, saldırı örüntüsü içermeyen ağ trafiğinin dinlenmesini sağlamaktadır.
Aşağıda örnek bir suricata.yaml dosyasının "app-layer" başlığı altındaki bazı parametre değerleri gösterilmektedir. Aşağıdaki örnekte Suricata saldırı tespit sisteminin sadece SMB trafiğini eve.json isimli kayıt (log) dosyasına kaydetmesi sağlanmıştır. Bunun haricinde kalan hiçbir trafik kayıt (log) dosyasına kaydedilmemektedir. Sadece imza veri tabaındaki saldırılara karşılık gelen saldırı kayıtları (log) ve SMB trafiği kayıt (log) altına alınmaktadır.
**********
app-layer altında yapılan değişiklikler aşağıda açıklanmıştır:
  
-app-layer:
--protocols:
---tls:
----enabled: no (HTTPS trafiğinin kaydı engellenmiştir.)
----detection-ports:
-----dp: 443
---dcerpc:
----enabled: no (DCE/RPC trafiğinin kaydı engellenmiştir.)
---ftp:
----enabled: no (FTP trafiğinin kaydı engellenmiştir.)
---ssh:
----enabled: no (SSH trafiğinin kaydı engellenmiştir.)
---smtp:
----enabled: no (SMTP trafiğinin kaydı engellenmiştir.)
---imap:
----enabled: no (IMAP trafiğinin kaydı engellenmiştir.)
---msn:
----enabled: no (MSN trafiğinin kaydı engellenmiştir.)
---smb:
----enabled: yes (SMB trafiğinin kaydına izin verilmiştir.)
----detection-ports:
-----dp: 139
**********
Suricata ile ilgili olarak şimdilik bu kadar. Yukarıda yazdığım özelliği bulmak biraz vaktimi aldığı için çözümü paylaşmak istedim.