Nmap, Unicornscan ve Hping ile performans testleri

Zaman zaman ağ/güvenlik sistemlerine test yaparken üretici firmaların şu tip istekleri olabiliyor:” saniyede 1000, 10000, 100.000 paket gönderebilir misiniz?”

Böylece test edilen cihazın, sistemin hangi aşamada sıkıntı yaşadığı rahatlıkla bulunabiliyor. Çeşitli protokoller için paket üretiminde genellikle Hping’i kullaniyorum fakat hping’in pps(packet per second) ayarlaması tam manasıyla çalışmıyor, ya da benim sistemlerinde verim alamıyorum. Hping yerine zaman zaman kullandığım iki aracı da deneyerek sonuçlarını paylaşayım istedim. Evet aşağıdaki üç araç ile istediğiniz protokolde, istediğiniz oranda paket üreterek sistemlerinizi test edebilirsiniz.(Bu siteye doğru yapmayin testlerinizi:)

 

Nmap ile saniyede istenilen değerde paket üretimi

Nmap’in –min-rate ve –max-rate seçenekleri bu işe yarar. Port tarama yaparken eş zamanlı ne kadar paket gönderebileceğinizi bu seçenekleri ayarlayarak belirleyebilirsiniz.

Mesela eş zamanlı olarak 10.000 paket göndererek 65.535 portu taramak isteyelim, sonuç aşağıdaki gibi olacaktır.

# time nmap –min-rate 10000 –max-rate 10001 localhost  -vvv -PN -p1-65535

Starting Nmap 4.90RC2 ( http://nmap.org ) at 2009-12-26 11:53 EST
Warning: Hostname localhost resolves to 2 IPs. Using 127.0.0.1.
Initiating SYN Stealth Scan at 11:53
Scanning localhost (127.0.0.1) [65535 ports]
Completed SYN Stealth Scan at 11:53, 6.49s elapsed (65535 total ports)
Host localhost (127.0.0.1) is up (0.0000030s latency).
Scanned at 2009-12-26 11:53:15 EST for 7s
Interesting ports on localhost (127.0.0.1):
Not shown: 65525 closed ports
PORT     STATE SERVICE
21/tcp   open  ftp
22/tcp   open  ssh
25/tcp   open  smtp
53/tcp   open  domain
80/tcp   open  http
587/tcp  open  submission
953/tcp  open  rndc
5432/tcp open  postgresql
8118/tcp open  privoxy
9050/tcp open  tor-socks

Read data files from: /usr/local/share/nmap
Nmap done: 1 IP address (1 host up) scanned in 6.61 seconds
           Raw packets sent: 65535 (2.884MB) | Rcvd: 131084 (5.506MB)

real    0m6.614s
user    0m0.116s
sys     0m0.012s

görüleceği üzere saniyede 10.000 paketten 6~saniye sürüyor 60.000 portu taramak, yani Nmap ile pps üretecimiz düzgün çalışıyor.

Aynı testi saniyede 1000 paket gönderecek şekilde ayarlarsak zaman da değişsecektir.

[email protected]:~# time nmap –min-rate 1000 –max-rate 1001 localhost  -vvv -PN -p1-65535

Starting Nmap 4.90RC2 ( http://nmap.org ) at 2009-12-26 11:53 EST
Warning: Hostname localhost resolves to 2 IPs. Using 127.0.0.1.
Initiating SYN Stealth Scan at 11:53
Scanning localhost (127.0.0.1) [65535 ports]

Completed SYN Stealth Scan at 11:54, 65.47s elapsed (65535 total ports)
Host localhost (127.0.0.1) is up (0.0000040s latency).
Scanned at 2009-12-26 11:53:30 EST for 65s
Interesting ports on localhost (127.0.0.1):
Not shown: 65525 closed ports
PORT     STATE SERVICE
21/tcp   open  ftp
22/tcp   open  ssh
25/tcp   open  smtp
53/tcp   open  domain
80/tcp   open  http
587/tcp  open  submission
953/tcp  open  rndc
5432/tcp open  postgresql
8118/tcp open  privoxy
9050/tcp open  tor-socks

Read data files from: /usr/local/share/nmap
Nmap done: 1 IP address (1 host up) scanned in 65.59 seconds
           Raw packets sent: 65535 (2.884MB) | Rcvd: 131084 (5.506MB)

real    1m5.596s
user    0m0.120s
sys     0m0.000s

# time nmap –min-rate 30000 –max-rate 30000 localhost  -vvv -PN -p1-65535

Starting Nmap 4.90RC2 ( http://nmap.org ) at 2009-12-26 11:56 EST
Warning: Hostname localhost resolves to 2 IPs. Using 127.0.0.1.
Initiating SYN Stealth Scan at 11:56
Scanning localhost (127.0.0.1) [65535 ports]
Completed SYN Stealth Scan at 11:56, 2.59s elapsed (65535 total ports)
Host localhost (127.0.0.1) is up (0.0000080s latency).
Scanned at 2009-12-26 11:56:26 EST for 3s
Interesting ports on localhost (127.0.0.1):
Not shown: 65525 closed ports
PORT     STATE SERVICE
21/tcp   open  ftp
22/tcp   open  ssh
25/tcp   open  smtp
53/tcp   open  domain
80/tcp   open  http
587/tcp  open  submission
953/tcp  open  rndc
5432/tcp open  postgresql
8118/tcp open  privoxy
9050/tcp open  tor-socks

Read data files from: /usr/local/share/nmap
Nmap done: 1 IP address (1 host up) scanned in 2.71 seconds
           Raw packets sent: 65555 (2.884MB) | Rcvd: 131083 (5.506MB)

real    0m2.720s
user    0m0.476s
sys     0m0.948s

 

Unicornscan ile PPS belirtme

Unicornscan ile saniyede gönderilecek paket sayısını -r ya da –pps seçeneği kullanarak başarabiliriz.

Saniyede 1000 paket göndererek port tarama için(aynı zamanda hedef sisteme saniyede 1000 paket göndermeye yarar)

~# time unicornscan -vv –pps 1000 localhost:1-65535  -i lo
adding 127.0.0.1/32 mode `TCPscan’ ports `1-65535′ pps 1000
using interface(s) lo
scaning 1.00e+00 total hosts with 6.55e+04 total packets, should take a little longer than 1 Minutes, 12 Seconds
drone type Unknown on fd 4 is version 1.1
drone type Unknown on fd 3 is version 1.1
scan iteration 1 out of 1
using pcap filter: `dst 127.0.0.1 and ! src 127.0.0.1 and (tcp)’
using TSC delay

sender statistics 973.5 pps with 65535 packets sent total
listener statistics 0 packets recieved 0 packets droped and 0 interface drops

real    1m15.778s
user    1m6.452s
sys     0m0.764s

görüleceği üzere 1000 paket olmasa da pps değerimiz 973’e ayarlanmış durumda

 Hping ile isteğe göre PPS

Hping ile paket üretirken -i parametresini kullanarak gönderilecek paketler arasında ne kadarlık bekleme yapılacağı belirtilebilir. -i ‘den sonra -u kullanırsak mikrosaniye(saniyenin 100.000 de biri) değeri olur. Biz de saniy eile mikro saniye arasındaki farkı kullanarak Hping’e ne saniyede ne kadar paket oluşturması gerektiğini zöyleyebiliriz.

Saniyede 10 paket göndermek için

#hping -i u10000 -S -p 99 localhost

Saniyede 1000 paket göndermek istersek -i100 değerini kullanabiliriz.

#hping -S -p 0 192.168.2.23 -c 1000 -i u100
Sonuç: Düzgün değerde pps üretimi için en idel araç şimdilik Nmap gözüküyor ama Hping’in esnekliğini de unutmamak gerekir.

This entry was posted in Network Security and tagged , , . Bookmark the permalink.

2 Responses to Nmap, Unicornscan ve Hping ile performans testleri

  1. Emre Saglam says:

    Bunu konuşmamızdan sonra mı yazdın? 🙂

  2. Huzeyfe ONAL says:

    Evet iyi bahane oldu:). nmap’i detayli test etmemistim gormus oldum.

Leave a Reply

Your email address will not be published. Required fields are marked *

twenty + 3 =