Thursday, April 23, 2009

wget useful parameters

遇到了所以在此做個紀錄,雜記一下:

# wget -r -np -A img,txt,gz,pcap,cap http://xxx.xxx.xxx
-r --recursive
-np --no-parent
-A --accept=LIST
-> 如此一來就會對xxx.xxx.xxx的網站以遞迴的方式,抓取以img,txt,gz,pcap與cap類型的檔案,其它的都會忽視。

更多的參數可透過wget --help或是man wget獲得更進一步的資訊。

Monday, April 13, 2009

忽視記錄指定的指令於history中

上次介紹可用HISTCONTROL="ignorespace"來忽視開頭為"空白"的指令記錄於history中,今天再提供另一種可行的方法,當看到特定的指令時,也將不記錄於history中,實作的方法如下:

Usage: HISTIGNORE="cmd1:cmd2"

Example1: 忽視記錄pwd,useradd,userdel,passwd等指令:
# export HISTIGNORE="pwd:useradd:userdel:passwd"

Example2: 開機即套用:
Redhat/SUSE: echo 'export HISTIGNORE="pwd:useradd:userdel:passwd"' >> /etc/profile
Note: 如果系統不允許重開機,可以透過source /etc/profile來生效。

Friday, April 10, 2009

不紀錄開頭為space的指令於history中

直接來看如何實作吧!
舉個常會碰到的例子, 如果在console下需輸入敏感的資料時, 不要讓它記錄到history中:
#HISTCONTROL=ignorespace
# echo "redhat" | passwd --stdin lawrence (注意開頭必需為空白)
#history

如此一來echo "redhat" | passwd --stdin lawrence 就不會記錄到history中.

Wednesday, April 08, 2009

Modify Linux prompt

改變一下原本CentOS5.x黑底白字的prompt為黑底綠字如下, 有小學時用DOS的fu ~ XD



加入以下的設定於 /etc/profile讓每個使用者都有這種fu ~
PS1="\e[0;32m[\u@\h \W]$ \e[m"

Cocoa Packet Analyzer in OSX

以前帽客要在OSX下抓網路封包, 有兩種方法:
1. 開啟終端機, 執行tcpdump -> 只有文字模式
2. 安裝X11-> 透過某個在OSX下能安裝Linux apps的工具(Fink)安裝wireshark -> 有圖形可看了, 但是挺麻煩.

現在不用囉! 直接給它安裝Cocoa Packet Analyzer就可以在OSX下抓網路封包啦!
About Cocoa Packet Analyzer
A native Mac OS X implementation of a network protocol analyzer and packet sniffer. It is able to do basic network capturing (incl. packet filtering), analyze and display packet trace files. CPA supports the industry-standard PCAP packet capture format for reading, capturing and writing packet trace files. Further more the libPCAP/ tcpdump filter expressions may be used during capturing network traffic. It supports a variety of network protocols and can be enhanced using the Cocoa bundle plugin technology. Features a quicklook plugin so you can get an overview of you trace file even in finder.

Support libpcap format, 太棒了正是我需要的, 因為我 慣用的packet playback tools只支援libpcap format.

Download: http://www.apple.com/downloads/macosx/networking_security/cocoapacketanalyzer.html

Friday, April 03, 2009

透過ac command 顯示所有使用者登入的時間

今天看書,學習到利用ac指令來獲取系統上所有使用者上線的總時間,帽客覺得這是非常實用的指令,故於此分享給大家,以下是ac的簡單說明: (man page description)
ac prints out a report of connect time (in hours) based on the logins/logouts in the current wtmp file. A total is also printed out.

ok, 再來以上線跑不久的OpenSUSE11.1來做個例子:

Example1: 顯示每天所有使用者上線的時間總和:
linux-xgby:~ # ac -d
Mar 7 total 28.81
Mar 9 total 0.14
Mar 13 total 17.35
Mar 15 total 32.28
Mar 20 total 8.09
Mar 21 total 3.00
Mar 22 total 44.08
Mar 23 total 10.44
Mar 24 total 33.19
Mar 25 total 29.43
Mar 31 total 0.03
Apr 1 total 15.17
Apr 2 total 4.47
Apr 2 total 14.60
Apr 3 total 21.09
Today total 1.67

Example2: 顯示個別使用者上線的時間總和:
linux-xgby:~ # ac -p
lawrence 258.67
root 5.31
total 263.98

如何,夠簡單又實用吧!

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!