2008年11月19日 星期三

管制MSN

管制MSN有許多方式
個人認為最直接的方式:找出MSN相關服務的主機
關閉Login Server ,不能登入當然就不能用了
影響的範圍小、所花費的成本也少
基本型的防火牆就可以做到了
不用花大錢買application firewall之類的產品
當然有經費買這樣的設備更好
設定起來更簡單
如果沒有,就用以下的窮人作法吧!

allow windows update 、hotmail server等服務
207.46.18.0/24
207.46.59.0/24
207.46.123.0/24
207.46.209.0/24

deny msn 登入主機
207.46.0.0/16 整段都由微軟註冊給MSN相關服務使用的

如此MSN及WEB MSN都無法使用
也不會影響到其他微軟正常的服務

後註:之後由客戶反應後發現,微軟的服務如hotmail、blog等等
也會因此受影響,這些網頁可能會開不起來
所以怕麻煩的,還是多花點錢吧!不然常常要手動調整

2008年11月15日 星期六

windows 查看 sockets(列出 active/listen connec...

netstat指令相當的好用
不用靠其它程式就能判斷電腦都是跟哪些IP在連線
而這些連線是由哪些程式帶起來的
找出可疑的process,其它就好解決了


1. 查看 sockets(列出 active/listen connections)

netstat -a


2. 篩選特定協定,在此僅列 TCP

netstat -ap tcp

也可利用 windows 內建的 find 指令

netstat -a | find "TCP"



3. 顯示 Port 號碼而非名稱

netstat -an | find "TCP"



4. 找出觸發每個 tcp 連線的 process 號碼(PID)

netstat -aop tcp



5. 找出 process 檔案名稱(配合上一步取得的 PID)

在此可採用 netstat 的 -b 參數(比較慢,參考步驟九,XP SP2、2003 SP1)

或是 tasklist (XP 專業版、2003、Vista)



6. 查看通訊協定狀態

netstat -sp tcp

netstat -sp ip

netstat -sp udp

netstat -sp icmp



7. 查看路由表 (同 route print 指令)

netstat -r



8. 查看乙太網路(網卡)狀態

netstat -e



9. 找出觸發每個 tcp 連線的 process 號碼及檔案名稱

與 tasklist 不同的是還多了相關 dll 資訊

netstat -abp tcp



10. 延續上一步,查看更詳盡資訊(速度更慢)

netstat -abvp tcp







想監控特定連線的來源或 Port,在 UNIX 中內建了不少好用的程式,組合各個小工具後更是威力無窮;Windows 在這方面雖然也有相當多類似的程式可安裝,但內建的 Netstat 用起來總是有些缺憾,在 SANS 看到這篇 Fun With Windows Netstat ,提到一些小技巧,用例子講述大家就可明瞭:





netstat –na 1 | find "特定IP"

顯示特定 IP 之連線,每隔一秒更新畫面一次 (適用於像是你已鎖定可疑對象,但不知他何時會連過來)

-a 代表列出所有連線

-n 代表僅列出 IP 及 Port,不解析為 hostname 及 service name,速度會快很多





netstat –nao 1 | find "特定IP"

加上 -o 參數可顯示觸發該連線之 process ID,

欲知 process name 則可以透過內建的 tasklist 這程式





netstat –na 1 | find "4444" | find "ESTABLISHED"

也可以針對特定 Port,不分對象的進行監控,

再透過 find "ESTABLISHED" 篩選掉僅 LISTENING 的部份





範例: 監控 tcp port 有建立成功的連線,加上 -o 參數可顯示觸發該連線之 process ID

netstat 1 -anpo tcp | find "ESTABLISHED"

關閉所有會連線的程式,如果還有出現連線記錄
根據pid到工作管理員查詢可疑的程式

2008年11月14日 星期五

用PAX做差異備份

PAX做差異備份


在windows的平台要設計出完整的備份方式要花不少錢買備份軟體才能做到,在非windows的平台上只要認真找一下,透過些指令就可以做到了


pax的一些基本用法:


pax遞迴複製目錄

pax –rwv –pe /home /root


/root目錄要是已存在的


後為複製到哪個目錄
前面為要複製的資料目錄


/home完整搬一份到/root





PAX做備份檔


pax -wvf /mnt/nfs/test/jackson.pax /home/jackson



察看備份檔內容


pax -vf /mnt/nfs/test/jackson.pax |more



還原備份檔


pax -rv -pe -f /mnt/nfs/test/jackson.pax


加上-i參數則為互動式還原


加上-pe為保留原檔案擁有者等屬性


還原時須注意:會將備份檔內的資料還原至原來的路徑下


例如:jackson.pas原本是從/home/Jackson備份而來的


就會還原回/home/Jackson,而覆蓋掉原來的檔案


所以若希望檔案不要直接被覆蓋,需先將原路徑的檔案做搬移或更名


完整備份範例


/home目錄做成一個備份檔:/backup/home.pax


pax -wvf /backup/home.pax /home



增量備份範例


/home目錄中,今天時間8:00之後有異動的資料做備份,


檔名為:/backup/home-diff.pax


Pax –wv –T 800 –f /backup/home-diff.pax /home


-T 參數使用:


-T [from_date][,to_date][/[c][m]]



Allow files to be
selected based on a file modification or inode change



time falling within a
specified time range of from_date to to_date (the



dates are inclusive).
If only a
from_date
is supplied, all files with a



modification or inode
change time equal to or younger are selected.
If



only
a to_date
is supplied, all files with a
modification or inode



change time equal to
or older will be selected. When the
from_date is



equal to the to_date,
only files with a modification or inode change



time of exactly that
time will be selected.






When pax is in the
write or copy mode, the optional trailing field



[c][m]
can be used to determine which file time (inode
change,
file
mod-



ification
or both) are used in the comparison. If neither is specified,



the
default is to use file modification time only
.
The m specifies the



comparison of file
modification time (the time when the file was last



written). The c
specifies the comparison of inode change time (the time



when the file inode
was last changed; e.g., a change of owner, group,



mode, etc). When c
and m are both specified, then the modification and



inode change times are
both compared. The inode change time comparison



is useful in selecting
files whose attributes were recently changed or



selecting files which
were recently created and had their modification



time reset to an older
time (as what happens when a file is extracted



from an archive and
the modification time is preserved). Time compar-



isons using both file
times is useful when pax is used to create a time



based incremental
archive (only files that were changed during a speci-



fied time range will
be archived).





A
time range is made up of six different fields and each field must
con-



tain two digits. The
format is:



[[[[[cc]yy]mm]dd]HH]MM[.SS]



Where cc is the first
two digits of the year (the century), yy is the



last two digits of the
year, the first mm is the month (from 01 to 12),



dd is the day of the
month (from 01 to 31), HH is the hour of the day



(from 00 to 23), MM is
the minute (from 00 to 59), and SS is the seconds



(from 00 to 59). The
minute field MM is required, while the other



fields are optional
and must be added in the following order:



HH, dd, mm, yy,
cc.



The SS field may be
added independently of the other fields. Time



ranges are relative to
the current time, so



-T 1234/cm



would select all files
with a modification or inode change time of 12:34



PM today or later.
Multiple -T time range can be supplied and checking



stops with the first
match.



增量備份檔的說明


假設有個目錄/home/account做完整備份建立了account.pax
大小為100MB


24小時候,其大小改變為150MB


則新的備份檔
account.pas才會產生,內容即為此150MB大小的資料


若經24小時做差異備份時,其大小未改變仍為100MB


則此次差異備份不對此檔案作備份





crontab的設定:


10:00 做一次完整備份


2到週日0:00做一次24小時的增量備份


以一個禮拜為循環


預計設定當做完完整備份時,把增量備份檔刪除


用以清出磁碟空間。