Archive for the ‘ Güvenlik ’ Category

Passive Asset Detection System (PADS)

PADS (Passive Asset Detection System) networkü dinleyip hangi host’ların ve servislerin çalıştığını imza tabanlı olarak pasif modda tespit eder.Bu uygulama pasif modda sniffer olarak çalışmasından dolayı network’de görünmez ve aktif olarak ağa bir paket göndermez. IDS ve Firewall tarafından tespit edilmesi imkansızdır (promiscuos moda geçmediği sürece)

root@ubuntucuk:~# pads -h
pads – Passive Asset Detection System
v1.2 – 06/17/05
Matt Shelton

Usage:
-c : Read configuration from .
-d
: Dump banner packets to a libpcap formatted file.
-D : Run PADS in the background (daemon mode).
-g : Drop privileges to this group.
-h : Help
-i : Listen on . The lowest number interface
will be used if an interface isn’t specified.
-n : Reads in a comma seperated list of networks
to be monitored.
ex. -n “192.168.0.0/24,10.0.0.0/16″
-p : PID file used with daemon mode.
-r
: Read packets from a libpcap formatted file.
-u : Drop privileges to this user.
-v : Verbose
-V : Version
-w : Dump data into file other than assets.csv.

Additional arguments will be processed as a libpcap filter. For example,
the following command will not only use interface hme1 but will also only
search for assets on port 22:

pads -i hme1 port 22

Bir kaç örnek uygulama;
WEB Servislerinin tespiti
root@ubuntucuk:~# pads -i eth0 port 80
pads – Passive Asset Detection System
v1.2 – 06/17/05
Matt Shelton

[-] Filter: port 80
[-] Listening on interface eth0
[*] Asset Found: Port – 80 / Host – 78.186.248.166 / Service – www / Application –
Devamını okuyun

Etiketler: , , , , , ,

p0f (Passive OS fingerprinting)

İşletim sistemini tespit etmenin sık kullanılan iki yöntemi vardır.

Aktif İşletim Sistemi Tespiti (Active OS fingerprinting) : Hedef sistem aktif ve ulaşılabilir olmalıdır.Hedef sisteme anormal paketler gönderip dönen cevaplara göre işletim sistemi tespit edilmeye çalışılır.
Uzak bir ağdaki aktif sistemi tespit etmek için ideal, fakat güvenlik duvarı , saldırı tespit ve engelleme sistemlerine takılmanız kuvvetle muhtemel

Pasif İşletim Sistemi Tespiti (Passive OS fingerprinting) : Kaydedilmiş trafikten veya pasif modda trafiği dinleyip işetim sistemi tespit etmeyi sağlayan etkili bir yöntem.

Pasif işletim sistemi tespiti sağlayan gelişmiş araçlardan p0f ile farklı senaryolar üzerinden bu methodu inceleyelim ;
root@ubuntucuk:/home/coslat/pcap# p0f -h
p0f: invalid option — ‘h’


Usage: p0f [ -f file ] [ -i device ] [ -s file ] [ -o file ]
[ -w file ] [ -Q sock [ -0 ] ] [ -u user ] [ -FXVNDUKASCMROqtpvdlrx ]
[ -c size ] [ -T nn ] [ -e nn ] [ 'filter rule' ]
-f file   – read fingerprints from file
-i device – listen on this device
-s file   – read packets from tcpdump snapshot
-o file   – write to this logfile (implies -t)
-w file   – save packets to tcpdump snapshot
-u user   – chroot and setuid to this user
-Q sock   – listen on local socket for queries
-0        – make src port 0 a wildcard (in query mode)
-e ms     – pcap capture timeout in milliseconds (default: 1)
-c size   – cache size for -Q and -M options
-M        – run masquerade detection
-T nn     – set masquerade detection threshold (1-200)
-V        – verbose masquerade flags reporting
-F        – use fuzzy matching (do not combine with -R)
-N        – do not report distances and link media
-D        – do not report OS details (just genre)
-U        – do not display unknown signatures
-K        – do not display known signatures (for tests)
-S        – report signatures even for known systems
-A        – go into SYN+ACK mode (semi-supported)
-R        – go into RST/RST+ACK mode (semi-supported)
-O        – go into stray ACK mode (barely supported)
-r        – resolve host names (not recommended)
-q        – be quiet – no banner
-v        – enable support for 802.1Q VLAN frames
-p        – switch card to promiscuous mode
-d        – daemon mode (fork into background)
-l        – use single-line output (easier to grep)
-x        – include full packet dump (for debugging)
-X        – display payload string (useful in RST mode)
-C        – run signature collision check
-t        – add timestamps to every entry


‘Filter rule’ is an optional pcap-style BPF expression (man tcpdump).

Ağ arabirimini üzerinden geçen trafiği dinleyip anlık olarak sonuç verebilir.
-S : Bilinen sistemler için imzaları raporla
-v : 802.1q Vlan frame desteğini aktif eder.
-l : Çıktıyı satır satır ver.

root@ubuntucuk:/home/coslat/pcap# p0f -S -v -l
p0f – passive os fingerprinting utility, version 2.0.8
(C) M. Zalewski <lcamtuf@dione.cc>, W. Stearns <wstearns@pobox.com>
p0f: listening (SYN) on ‘eth0′, 262 sigs (14 generic, cksum 0F1F5CA2), rule: ‘all’.
192.168.5.205:50969 – Linux 2.6 (newer, 2) (up: 15 hrs) Signature: [S4:64:1:60:M1460,S,T,N,W6:.] -> 209.85.227.106:80 (distance 0, link: ethernet/modem)
192.168.5.205:50970 – Linux 2.6 (newer, 2) (up: 15 hrs) Signature: [S4:64:1:60:M1460,S,T,N,W6:.] -> 209.85.227.106:80 (distance 0, link: ethernet/modem)
192.168.5.205:54475 – Linux 2.6 (newer, 2) (up: 15 hrs) Signature: [S4:64:1:60:M1460,S,T,N,W6:.] -> 209.85.227.138:80 (distance 0, link: ethernet/modem)
^C+++ Exiting on signal 2 +++
[+] Average packet ratio: 60.00 per minute.


Dinlediği ağ arabirimi üzerinden “192.168.5.205” ip adresine ait sistemin “Linux 2.6” çekirdeğine sahip olduğunu ve bu tespiti [S4:64:1:60:M1460,S,T,N,W6:.] imzasına göre yaptığını söyledi.

Promiscuous modda dinleme yapmak için  ;
-p : Promiscuous moda geç.

root@ubuntucuk:/home/coslat/pcap# p0f -S -v -l -p
p0f – passive os fingerprinting utility, version 2.0.8
(C) M. Zalewski <lcamtuf@dione.cc>, W. Stearns <wstearns@pobox.com>
p0f: listening (SYN) on ‘eth0′, 262 sigs (14 generic, cksum 0F1F5CA2), rule: ‘all’.
192.168.5.61:1522 – Windows XP/2000 (RFC1323+, w+, tstamp-) [GENERIC] Signature: [65535:128:1:52:M1460,N,W1,N,N,S:.:Windows:?] -> 91.103.140.2:80 (distance 0, link: ethernet/modem)
192.168.5.61:1522 – Windows XP/2000 (RFC1323+, w+, tstamp-) [GENERIC] Signature: [65535:127:1:52:M1460,N,W1,N,N,S:.:Windows:?] -> 91.103.140.2:80 (distance 1, link: ethernet/modem)
192.168.5.61:1523 – Windows XP/2000 (RFC1323+, w+, tstamp-) [GENERIC] Signature: [65535:128:1:52:M1460,N,W1,N,N,S:.:Windows:?] -> 91.103.140.2:80 (distance 0, link: ethernet/modem)
^C+++ Exiting on signal 2 +++
[+] Average packet ratio: 720.00 per minute
.

Kaydedilmiş trafiği analiz etmek
-S : Bilinen sistemler için imzaları raporla.
-v : 802.1q Vlan frame desteğini aktif eder.
-o : Çıktıyı dosyaya yaz.
-l : Çıktıyı satır satır ver.

root@ubuntucuk:/home/coslat/pcap# p0f -v -s p0f.pcap -o analiz.log -l
p0f – passive os fingerprinting utility, version 2.0.8
(C) M. Zalewski <lcamtuf@dione.cc>, W. Stearns <wstearns@pobox.com>
p0f: listening (SYN) on ‘p0f.pcap’, 262 sigs (14 generic, cksum 0F1F5CA2), rule: ‘all’.
[+] End of input file.
root@ubuntucuk:/home/coslat/pcap# cat analiz.log
<Wed May 26 17:11:09 2010> 192.168.2.13:1134 – Windows 2000 SP4, XP SP1+ -> 83.66.162.3:80 (distance 1, link: ethernet/modem)
<Wed May 26 17:11:15 2010> 192.168.2.7:1055 – Windows 2000 SP4, XP SP1+ -> 178.18.193.27:80 (distance 0, link: ethernet/modem)
<Wed May 26 17:11:15 2010> 192.168.2.7:1055 – Windows 2000 SP4, XP SP1+ -> 178.18.193.27:80 (distance 1, link: ethernet/modem)
<Wed May 26 17:11:20 2010> 192.168.5.144:3244 – Windows 2000 SP4, XP SP1+ -> 208.78.70.70:8245 (distance 0, link: ethernet/modem)


Farklı bir p0f imza veritabanınız varsa,  -f parametresi ile p0f imza veritabanını kullanabilirsiniz
root@ubuntucuk:/home/coslat/pcap# p0f -v -l -f /etc/p0f/p0f.fp -s p0f.pcap -o analiz.log

Etiketler: , , , ,

Bridge FreeBSD PF ve Transparent Squid

Bridge FreeBSD PF ve Transparent Squid

FreeBSD  işletim sistemini bridge modda yapılandırıp üzerinde PF (packet filter) ile transparent squid kullanımı anlatılmıştır.

Nasıl Çalışır
FreeBSD PF fiziksel olarak gateway ile istemciler arasına yerleştirilir, mevcut network yapısı ve istemcilerin ağ ayarları değiştirilmeden  (proxy, gateway vs.) layer 2 seviyesinde filtreleme yapılır.İstemciler bilinmeyenlerin çıkış noktası olarak yine gateway’lerini görürler ve internete çıkmak için tüm paketleri gateway’lerine iletirler fakat gateway’lerine paketler ulaşmadan bridge modda çalışan PF ve Squid bunları işlenen kural listesine göre süzüp ardından trafiği olduğu gibi (nat vs. yapmadan) gateway’e iletir.Bridge modda FreeBSD tıpkı bir switch gibi çalışır …

Böylelikle görünmez modda PF ve Squid çalıştırmış oluyoruz.

İstenilen Network Yapısı

FreeBSD  bridge yapılandırması

Ağ kartlarının “fxp0” ve “fxp1” olduğu düşünülmüştür.

# ifconfig bridge create
bridge0
#
ifconfig bridge0
bridge0: flags=8802<BROADCAST,SIMPLEX,MULTICAST> metric 0 mtu 1500
ether 96:3d:4b:f1:79:7a
id 00:00:00:00:00:00 priority 32768 hellotime 2 fwddelay 15
maxage 20 holdcnt 6 proto rstp maxaddr 100 timeout 1200
root id 00:00:00:00:00:00 priority 0 ifcost 0 port 0

# ifconfig bridge0 addm fxp0 addm fxp1 up
# ifconfig fxp0 up
# ifconfig fxp1 up

Ayarların açılışta geçerli olması için /etc/rc.conf dosyasına aşağıdaki satırlar eklenir;

cloned_interfaces="bridge0"
ifconfig_bridge0="addm fxp0 addm fxp1 up"
ifconfig_fxp0="up"
ifconfig_fxp1="up"

Bridge interface için ip ataması yapılmak isteniliyorsa;
ifconfig bridge0 inet 192.168.0.1/24

PF (Packet Filter) ile istemcilerden gelen ve hedef port 80 olan isteklerin squid’e yönlendirilmesi

PF aktif edilmesi ;

kldload pf.ko
/etc/rc.conf;
pf_enable="YES"
pf_rules="/etc/pf.conf"
pf_flags=""
pflog_enable="YES"
pflog_logfile="/var/log/pflog"
pflog_flags=""

Servisin başlatılması
#/etc/rc.d/pf start 

Kural dosyası
# touch /etc/pf.conf
İstemcilerden gelen herhangi bir hedefin 80. Portuna giden istekler squid e yönlendirilir
pf.conf ;
int_if=”vr0″
ext_if=”fxp0″
rdr on $int_if inet proto tcp from $lan to any port { 80 443 } -> 127.0.0.1 port 3128
pass in quick on $int_if route-to lo0 inet proto tcp from $lan to 127.0.0.1 port 3128 keep state

Not:  $lan = yerel network aralığınız. Örnek : 192.168.5.0/24

Squid Kurulumu;
-Port ağacından kurulumu ;
# cd /usr/ports/www/squid && make install clean

Not: squid port ağacından kurarken PF desteğini aktif etmenizde fayda var.

- Depodan kurulumu
# pkg_add  –rv ftp://ftp.freebsd.org/pub/FreeBSD/ports/i386/packages-7-stable/Latest/squid.tbz

Transparent olarak çalışması için squid.conf dosyasına eklenecek satır ;
http_port 127.0.0.1:3128 transparent

Eğer herşey yolunda gittiyse squid.conf dosyasına aşağıdaki gibi bir kural tanımlayıp test edebilirsiniz ;

acl yasakli dstdomain .yahoo.com
http_access deny yasakli

Daha fazla bilgi;
Bridge: http://www.freebsd.org/doc/handbook/network-bridging.html
Pf ve Squid : http://www.benzedrine.cx/transquid.html

Etiketler: , , , , , ,

Honeysnap – Pcap Paket Ayrıştırma Aracı

Honeysnap, pcap formatında kaydedilmiş network trafiğini analiz eden bir komut satırı aracıdır.
Pratik kullanımı ve yüksek öneme sahip bir çok protokolü desteklemektedir.Birden çok pcap dosyasını aynı anda analiz edebilmekte.
Unix/linux ve BSD sistemlerde komut satırından çalışan bu araç, Sebek, HoneyD gibi tuzak sistemler hazırlayan HoneyNet.org ekibinin bir projesi.
Şu an desteklediği protokoller;

  • DNS
  • FTP
  • HTTP
  • IRC
  • Socks
  • Sebek

Örnek bazı fonksiyonları ;

  • Paket ve bağlantı özeti
  • Binary dosya ayrıştırma
  • ASCII tabanlı ayrıştırma
  • Gelen ve giden bağlantıların akış özeti
  • IRC trafiğini yorumlama ve ayrıştırma
  • Bir çok internet protokolünü ayrıştırma
  • Socks decode

Kurulum

Gerekli yazılım ve kütüphanelerin kurulumu ;

$ apt-get install python2.4-dev
$ apt-get install libpcap0.8 libpcap0.8-dev
$ wget https://projects.honeynet.org/honeysnap/attachment/wiki/WikiStart/pypcap-1.1.tar.gz
$ tar xvzf pypcap-1.1.tar.gz
$ cd pcap-1.1
$ python setup.py install


Honeysnap download adresi = https://projects.honeynet.org/honeysnap/attachment/wiki/WikiStart/honeysnap-1.0.6.14.tar.gz


$ tar xvzf honeysnap-1.0.6
$ cd honeysnap-1.0.6
$ python setup.py install

Yukarıdaki adımları sorunsuz uyguladıysanız honeysnap sisteminize kurulmuş olucaktır.

Kullanımı

Honeysnap,  tüm ayarlarını honeynet.cfg dosyasında tutar.

Yapacağınız analiz şekline göre .cfg dosyasını düzenlemeniz gerekmektedir.

root@pentester:~/honeysnap-1.0.6.14#honeysnap -h
Usage: honeysnap [options]

Options:
–version             show program’s version number and exit
-h, –help            show this help message and exit
-c CONFIG, –config=CONFIG
Config file
-f FILE, –file=FILE  Write report to FILE
-o DIR, –output=DIR  Write output to DIR, defaults to ‘output’
-H HONEYPOTS, –honeypots=HONEYPOTS
……………………

Örnek uygulamalar ;

Pcap dosyasından network aktiviteleri hakkında istatiksel veri almak için ;
root@pentester:~/honeysnap-1.0.6.14# honeysnap -c honeynet.cfg zararziyan.pcap

Birden çok pcap dosyasını analiz etmek için ;

honeysnap -c honeysnap.cfg zararziyan.pcap zararziyan2.pcap zararziyan3.pcap

Bir host’a ait trafik bilgilerini almak için ;

root@pentester:~/honeysnap-1.0.6.14# honeysnap -H192.168.5.202 zararziyan.pcap

Analysing file: zararziyan.pcap

Pcap file information:
File name: zararziyan.pcap
Number of packets: 2768
File size: 505559 bytes
Data size: 461247 bytes
Capture duration: 38.024023056 seconds
Start time: Tue Jan 19 10:52:25 2010
End time: Tue Jan 19 10:53:03 2010
Data rate: 12130.4102756 bytes/s
Data rate: 97043.2822051 bits/s
Average packet size: 166.635476879 bytes

Not:birden fazla host için trafiği analiz edicekseniz -HIP,IP2,IP3 şeklinde kullanabilirsiniz.

Bir host’a ait HTTP trafiğini ayrıştırmak ;

root@pentester:~/honeysnap-1.0.6.14# honeysnap -H192.168.5.202 –do-http zararziyan.pcap

HTTP summary for 192.168.5.202

requested_files:

74.125.77.118 -> 192.168.5.202, i2.ytimg.com/vi/1JC1N0bGMtg/default.jpg (Mozilla/5.0 (Windows; U; Windows NT 6.1; tr; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7) at Tue Jan 19 10:52:30 2010
file: /root/honeysnap-1.0.6.14/output/192.168.5.202/http/outgoing/default.jpg.3, filetype: image/jpeg, md5 sum: 2b94c9bf5b1717db5b31fdcbd3a31036
74.125.77.118 -> 192.168.5.202, i2.ytimg.com/vi/1JC1N0bGMtg/default.jpg (Mozilla/5.0 (Windows; U; Windows NT 6.1; tr; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7) at Tue Jan 19 10:52:30 2010

Bir Host’a ait FTP trafiğini ayrıştırmak ;

root@pentester:~/honeysnap-1.0.6.14# honeysnap -H192.168.5.202 –do-ftp zararziyan2.pcap

Analysing file: zararziyan2.pcap

Pcap file information:
File name: zararziyan2.pcap
Number of packets: 11620
File size: 10981775 bytes
Data size: 10795831 bytes
Capture duration: 98.1785218716 seconds
Start time: Tue Jan 19 12:11:01 2010
End time: Tue Jan 19 12:12:40 2010
Data rate: 109961.22975 bytes/s
Data rate: 879689.837997 bits/s
Average packet size: 929.0732358 bytes

Extracting from FTP
FTP summary for 192.168.5.202

requested_files:
192.168.5.202 requested perl5-Curl.tar.gz from 89.19.25.155 (Unknown, Unknown) at Tue Jan 19 12:11:16 2010
file: /root/honeysnap-1.0.6.14/output/192.168.5.202/ftp/outgoing/perl5-Curl.tar.gz.1, filetype: application/x-gzip, md5 sum: 965958197b3fa0b768d0d1d6853c6934
0 requests served by honeypot

Desteklenen protokoller ve kullanılabilir diğer seçenekler ile analiz yapmak için ;

root@pentester:~/honeysnap-1.0.6.14# honeysnap -H192.168.5.202,192.168.5.180 –do-outgoing –do-irc –do-ftp –do-sebek –do-htp –do-outgoing -o /home/ozanus/analysis -f /home/ozanus/analysis/sonucbuiste.txt

Binary dosyayı ayıklamak ;

root@pentester:~/honeysnap-1.0.6.14# honeysnap -H192.168.5.202 –all-flows zararziyan2.pcap -o /root/analysis -f /root/sonucistebu.txt

root@pentester:~/honeysnap-1.0.6.14# ls /root/analysis/192.168.5.202/flows/
incoming  outgoing

Bu yazı güncellenecektir.

Etiketler: , , , , , , ,