[ 永遠的UNIX::UNIX技術資料的寶庫 ]   GB | BIG5

首頁 > 安全技術 > 工具 > 正文
TIS防火牆詳述
本文出自:不詳 作者: quack(quack@antionline.org) (2002-08-01 06:02:00)
什是防火牆不知道;) 

什是TIS?這是一組由(Trusted Information Systems)寫的一組構造防火牆的工具 
包,又叫firewall toolkit,這個工具箱裡的軟件適當的安裝並配置以一定的安全策略 
就可以構成基本的防火牆了,而且它是免費的;)花點心思看一看,說不定可以省下一筆不 
菲的防火牆購置資金哦…… 

一、編譯運行 

1、下載 

可以到TIS的web站點下載http://www.tis.com,但它有一些很麻煩的認証過程,建議 
直接到國內的安全站點轉轉,或者到http://packetstorm.securify.com/去下載,我 
得到的版本是fwtk2.1.tar.Z的版本,此的說明均以此版本為例,且在solaris7 x86 
上通過,gcc版本為2.95.2。 

2、編譯 

# gunzip fwtk2.1.tar.Z 
# tar vfx fwtk2.1.tar 
# cd fwtk 

將fwtk2.1.tar.Z解壓,可以在./fwtk目錄下發現有很多Makefile.config.*文件, 
比如你使用的操作系統是solaris2.7,那就直接將Makefile.config更名,把 
Makefile.config.solaris更名為Makefile.config就行了。 

# mv Makefile.config Makefile.config.old 
# mv Makefile.config.solaris Makefile.config 

在solaris下的編譯相當容易至少solaris7與solaris8下面不用修改任何東西就 
可以編譯通過了。 

# make && make install 

如果你使用的是linux,僅僅把Makefile.config.linux當成當前Makefile.config還 
不夠,因為如果你要使用X的gw.那你必須有 Athena Widget的設置。否則編譯會 
出問題。因此,可以修改Makefile讓系統不編譯x-gw。 

所以可以 

# vi Makefile 

查找下面這行: 

# directories to build executables in 
DIRS= smap smapd netacl plug-gw ftp-gw tn-gw rlogin-gw http-gw x-gw 

把面的x-gw去掉就可以了。 

如果是在bsd下,特別要注意,bsd的make 不認識象:.include "Makefile.config" 
這種格式,因此,在bsd下要用TIS提供的fixmake來處理。或者用指定 

CC= gcc 
COPT= -g -traditional -DBSDI 

來適應bsd系統比如我的FreeBSD3.4。 

如果在編譯過程中有出現sys_errlist的定義聲明出錯,那要修改原程序,比如: 
exter char *sys_errlist[]; 
把該行注釋掉。 

如果出現"Undefined symbol `_crypt' referenced from text segment"錯誤,則 
看在你的Makefile.config中AUXLIB設置是否有"-lcrypt"。 

如果還有問題……我懶得翻譯那多東西了,你可以到下面的URL看看: 

http://fwtk.netimages.com/fwtk/faq/ 

這裡列出了人們在編譯及使用tis時遇到的一些常見問題。 


二、配置前的準備工作 

1、理解一些概念 

a、wrapper 

我的理解,wrapper應該是一個包裝程序,說白了和那些login什的門沒本質區別;) 
比如說tcpd吧,我們用它來守護一些網絡服務守護進程,比如,在超級服務守護進程 
inetd的配置文件中,我們可以將 

finger stream tcp nowait nobody /usr/etc/in.finger in.fingerd 

這一句替換掉,用tcpd來包裝 

finger stream tcp nowait nobody /usr/etc/tcpd in.fingerd 

發送一個HUP信號給inetd讓它重啟,tcpd就發生作用了,如果此時收到一個對主機的 
finger請求,tcpd便啟動,先檢查訪問控制的配置文件,也就是/etc/hosts.allow和 
/etc/hosts.deny,如果允許訪問,再啟動真正的finger守護進程去處理該請求。 

怎樣,和login的門相比原理是不是相同的?比如ulogin.c吧,是將真正的login改 
名備份到另一個地方,用假的login包裝起來,收到login請求時,先判斷訪問者是不是 
有設置DISPLAY的環境變量,如果該變量和password相同的話,則啟動/bin/sh,如果沒 
有,則以正常的login來響應該請求……哎,這是題外話,不說了…… 

b、gateway 

應用級網關(Application Level Gateways)是在網絡應用層上建立協議過濾和轉發功能。 
它針對特定的網絡應用服務協議使用指定的數據過濾邏輯,並在過濾的同時,對數據包 
進行必要的分析、登記和統計,形成報告。 

呵,這種教材似的東西看著是不是覺得難理解,看了半天不知所雲?其實在TIS下面,它 
的各種gw比如tn-gw,是控制telnet的,當你連接到tn-gw運行的端口時,它會出現一個 
自己的提示符……如下: 

C:\>telnet 192.168.0.2 
然telnet窗口將出現 
hi,i'm quack,welcome to my 3cr19TkI7's website! <------------這是我的tn-welcome.txt 
tn-gw-> 它會在在連接時顯示…… 
當我鍵入問號尋求幫助時,會有如下的提示信息…… 
tn-gw->? 
Valid commands are: (unique abbreviations may be used) 
connect hostname [serv/port] 
telnet hostname [serv/port] 
x-gw [hostname/display] 
help/? 
password 
timeout seconds 
quit/exit 
tn-gw-> 
看明白了嗎,唔,沒錯,它提供的是穿越這台防火牆主機對其它機器的telnet訪問;) 
tn-gw-> telnet 192.168.0.2 55555 
Trying 192.168.0.2 port -9981... 
Connected to 192.168.0.2. 

SunOS 5.7 

login: quack 
Password: 
Last login: Fri Jun 9 00:27:48 from 192.168.0.1 
Sun Microsystems Inc. SunOS 5.7 Generic October 1998 
Cracker% 

這下清楚了吧……稍安勿燥,面我將說明這是如何配置的。 

c、proxy 

代理服務(Proxy Service)也稱鏈路級網關或TCP通道(Circuit Level Gateways or TCP 
Tunnels),也有人將它歸應用級網關一類。它是針對數據包過濾和應用網關技術存在 
的缺點而引入的防火牆技術,其特點是將所有跨越防火牆的網絡通信鏈路分為兩段。防 
火牆內外計算機系統間應用層的"鏈接",由兩個終止代理服務器上的"鏈接"來實現,外 
部計算機的網絡鏈路只能到達代理服務器,從而起到了隔離防火牆內外計算機系統的作 
用。此外,代理服務也對過往的數據包進行分析、注冊登記,形成報告,同時當發現被 
攻擊跡象時會向網絡管理員發出警報,並保留攻擊痕跡。 

2、文件介紹 

默認的安裝,TIS是安裝在/usr/local/etc目錄下的,現在我們來看看裡面都有些什吧 

# cd /usr/local/etc 
# ls -la 
總數1092 
drwxr-xr-x 2 root other 512 6月 6 17:05 . 
drwxr-xr-x 11 root other 512 6月 6 17:02 .. 
-rwxr-xr-x 1 root other 17012 6月 6 17:05 authdump 
-rwxr-xr-x 1 root other 18752 6月 6 17:05 authload 
-rwxr-xr-x 1 root other 23132 6月 6 17:05 authmgr 
-rwxr-xr-x 1 root other 47500 6月 6 17:05 authsrv 
-rwxr-xr-x 1 root other 50952 6月 6 17:05 ftp-gw 
-rwxr-xr-x 1 root other 117712 6月 6 17:05 http-gw 
-rwxr-x--- 1 root other 362 6月 6 17:05 mqueue 
-rwxr-xr-x 1 root other 26820 6月 6 17:05 netacl 
-rw-r--r-- 1 root other 3101 6月 6 17:05 netperm-table 
-rwxr-xr-x 1 root other 30308 6月 6 17:05 plug-gw 
-rwxr-xr-x 1 root other 45892 6月 6 17:05 rlogin-gw 
-rwxr-xr-x 1 root other 31436 6月 6 17:05 smap 
-rwxr-xr-x 1 root other 28772 6月 6 17:05 smapd 
-rwxr-xr-x 1 root other 49940 6月 6 17:05 tn-gw 
-rwxr-xr-x 1 root other 44792 6月 6 17:05 x-gw 

一個一個來解釋吧…… 

a.authdump:這是對TIS認証數據庫進行管理的工具,它可以在數據庫中建立信息的 
ASCII文本形式的備份。其中的密碼是加密輸出的。 

b.authload:也是認証數據庫管理工具,它對數據庫中的單個記錄進行處理,這個命 
令在你需要向數據庫中添加一組條目或者需要在兩個站點之間共享數據庫時特別有 
用。 

c.authmgr:網絡認証的客戶程序,它是與認証方authsrv的接口。是用來訪問網絡上 
的認証服務器或者加密連接時用的。 

d.authsrv:第三方網絡認証守護程序,它提供了多種誰形式的綜合接口,比如口令、一 
次性口令或者令牌認証系統,它裡面有一個包含用戶和組記錄的數據庫,並且還有一個 
管理接口,允許一個獲得認証的管理員管理本地或網絡上的用戶記錄。面會說它的 
配置的。 

e.ftp-gw: 
它是帶有日志記錄和訪問控制的可以穿越的FTP代理服務。 

f.http-gw: 
帶有日志記錄和訪問控制的gopher和http代理服務。 

g.mqueue: 
不知是不是message queue?不太懂……:( 

h.netacl: 
TCP網絡訪問控制,由inetd調用,對各種服務提供包裝。 

i.netperm-table: 
所有各種服務的配置文件。 

j.plug-gw: 
通用的一個tcp連接代理服務程序。 

k.rlogin-gw: 
這是提供穿過rlogin的代理服務r系統服務的危險大家是都知道的了,如果非要不 
可,用它來提供包裝吧 

l.smap: 
sendmail包裝程序客戶端,它實現了smtp的最小版本,接受來自網絡的消息,並 
發給smapd由它作進一步傳送,它一般是運行在chroot下的。 

m.smapd: 
sendmail包裝程序守護程序,它通過定期掃描由smap維護的郵件緩沖池區域並轉 
發搜集和保存在那裡的任意消息。 

n.tn-gw: 
telnet的代理服務器。 

o.x-gw: 
X網關服務器。 


3、系統準備 

a.去除IP轉發 

你的機器有兩塊網卡? 
如果你不想你的防火牆輕易被人穿越,就得老老實實把IP轉發功能幹掉,因為IP轉發 
會導致從一個接口接收到的報文重新轉發到所有其它適用的接口一般去除IP轉發 
可能要重新配置內核。 
默認情況下,如果Solaris機器有超過一塊的網卡的話,它將會在不同網卡間轉發數 
據包,這一行為可以在/etc/init.d/inetinit中得到控制。要在Solaris 2.4或者更 
低版本機器下關閉它,可以將ndd -set /dev/ip ip_forwarding 0添加 
/etc/init.d/inetinit的未尾。在Solaris 2.5中,只要touch /etc/notrouter. 
如果是SunOS4.1x,則在內核運行adb,在核心配置文件中加入 
options "IPFORWARDING=-1"並重新編譯生成新的內核。 
至linux,你試著make menuconfig,找到IP:forwarding/gatewaying,將 
CONFIG_IP_FORWARD關掉,重新編譯即可。其它的類似吧,自己琢磨琢磨,我也不會;) 

b.移除/etc/inetd.conf及/etc/rc2.d/內不必要的服務 

首先可以用 
# ps -elf 
看看系統啟動時啟動的服務 
你可以暫時先把/etc/inetd.conf內的所有服務都屏蔽掉在每一項前面加上#號使其 
失效因為稍我們將用netacl或者各種*-gw來包裝這些服務啟動的inetd.conf 
總是要改的;) 
並非所有的進程都是由inetd這一超級服務器守護進程來啟動的,有一些直接在rc2.d裡 
定義,直接在系統啟動時就運行,如果你有運行下列服務的話,最好也關掉: 
pcnfsd 
rwhod 
mountd 
protmap 
sendmail 
named 
printer 
timed 
nfsd 
rstatd 
xntpd 
nfsiod 
有些服務的關閉可能會影響系統服務,需要你自行分析了……。 

三、配置 

1、netperm-table 

這是防火牆工具箱裡所有東西netacl,smap,ftp-gw,tn-gw,plug-gw等的配置文件, 
當一個應用被啟動時,它就會從netperm-table中讀取出自己相關的配置和許可信息的 
策略文件。下面把默認安裝的netperm-table貼出來它有許多注解的 


# netperm配置表的示例文件 

# 要更好地利用地這個netperm-table,最好把你的主機名用IP地址來替代 
# (e.g.; 666.777.888),這樣比較不容易受到DNS欺騙的侵害。 


# netacl示例規則: 
# --------------------- 
# 下面兩行的注釋如果去掉,將啟動telnet 
#netacl-telnetd: permit-hosts 127.0.0.1 -exec /usr/libexec/telnetd 
#netacl-telnetd: permit-hosts YOURADDRESS 198.6.73.2 -exec /usr/libexec/telnetd 

# 下面這行是tn-gw的 
#netacl-telnetd: permit-hosts * -exec /usr/local/etc/tn-gw 

# 下面是rlogin 
#netacl-rlogind: permit-hosts 127.0.0.1 -exec /usr/libexec/rlogind -a 
#netacl-rlogind: permit-hosts YOURADDRESS 198.6.73.2 -exec /usr/libexec/rlogind -a 

# rlogin-gw的配置 
#netacl-rlogind: permit-hosts * -exec /usr/local/etc/rlogin-gw 


# 要將finger使能,把下面兩行的注釋去掉 
#netacl-fingerd: permit-hosts YOURNET.* -exec /usr/libexec/fingerd 
#netacl-fingerd: permit-hosts * -exec /bin/cat /usr/local/etc/finger.txt 

# smap規則示例: 
# ------------------- 
smap, smapd: userid 6 
smap, smapd: directory /var/spool/smap 
smapd: executable /usr/local/etc/smapd 
smapd: sendmail /usr/sbin/sendmail 
smap: timeout 3600 

# ftp gateway 規則示例: 
# -------------------------- 
#ftp-gw: denial-msg /usr/local/etc/ftp-deny.txt 
#ftp-gw: welcome-msg /usr/local/etc/ftp-welcome.txt 
#ftp-gw: help-msg /usr/local/etc/ftp-help.txt 
ftp-gw: timeout 3600 
# uncomment the following line if you want internal users to be 
# able to do FTP with the internet 
#ftp-gw: permit-hosts YOURNET.* 
# uncomment the following line if you want external users to be 
# able to do FTP with the internal network using authentication 
#ftp-gw: permit-hosts * -authall -log { retr stor } 

# telnet gateway規則示例: 
# ----------------------------- 
#tn-gw: denial-msg /usr/local/etc/tn-deny.txt 
#tn-gw: welcome-msg /usr/local/etc/tn-welcome.txt 
#tn-gw: help-msg /usr/local/etc/tn-help.txt 
tn-gw: timeout 3600 
tn-gw: permit-hosts YOURNET.* -passok -xok 
# if this line is uncommented incoming traffic is permitted WITH 
# authentication required 
#tn-gw: permit-hosts * -auth 

# rlogin gateway規則: 
# ----------------------------- 
#rlogin-gw: denial-msg /usr/local/etc/rlogin-deny.txt 
#rlogin-gw: welcome-msg /usr/local/etc/rlogin-welcome.txt 
#rlogin-gw: help-msg /usr/local/etc/rlogin-help.txt 
rlogin-gw: timeout 3600 
rlogin-gw: permit-hosts YOURNET.* -passok -xok 
# if this line is uncommented incoming traffic is permitted WITH 
# authentication required 
#rlogin-gw: permit-hosts * -auth -xok 


# auth server and client的規則示例 
# ------------------------------------ 
authsrv: hosts 127.0.0.1 
authsrv: database /usr/local/etc/fw-authdb 
authsrv: badsleep 1200 
authsrv: nobogus true 

# clients using the auth server 
*: authserver 127.0.0.1 7777 

# X代理的規則: 
tn-gw, rlogin-gw: xforwarder /usr/local/etc/x-gw 

一頭霧水是吧……我來歸結一下…… 
a.每一條規則都是按照要使用該規則的程序的名字開頭,跟一個冒號,當程序讀 
取時也只讀取其相關的規則。 
b.多個應用可以共用一條規則,各應用名字用逗號隔開或者用星號來通配當然 
我不建議你這做,這樣簡單是簡單了,但維護或者閱讀起來會比較煩。 

不多說了,在各種服務中再慢慢談配置吧。 

2、netacl 

這裡我示例配置用netacl包裝telnet以及ftp守護程序 
首先我們在/etc/inetd.conf裡添上下面兩行記得嗎,前邊我們disable了它們了;) 

ftp stream tcp nowait root /usr/local/etc/netacl in.ftpd 
telnet stream tcp nowait root /usr/local/etc/netacl in.telnetd 

這根據你自己的不同來決定,比如你的守護進程是ftpd和telnetd,把in.ftpd及in.telnetd改 
成它們好了。然ps -ef|grep inetd找出進程號發送HUP信號重啟。 

修改/usr/local/etc/netperm-table中相關條目如下: 

# telnet rules: 

netacl-in.telnetd: permit-hosts 192.168.0.1 -exec /usr/sbin/in.telnetd 

#這裡我只允許從192.168.0.1這台機器telnet上來,所以連localhost都不行:) 

netacl-in.telnetd: deny-hosts unknow 

#要注意這條信息哦,這是防止網絡中惡意用戶的IP spoof 的辦法 
#這樣,你就可以讓地址192.168.0.2 telnet到你機器上 ,而除了它之外的所有地址 
#會被顯示一條警告信息。最一條保証了如果你主機的IN.APPR.ARPA反向DNS查詢主機 
#名錯誤的時候,該不知名的遠程機器無法telnet進來。(DNS spoof) 

netacl-in.telnetd: permit-hosts * -exec /bin/cat /usr/local/etc/notelnet.txt 

#這條會在不允許登陸時顯示一條信息你可以自己編輯內容。 

# Ftp Rules: 

netacl-in.ftpd: permit-hosts 127.0.0.1 -exec /usr/sbin/in.ftpd 

#這條只允許本地機器localhost的ftp其它都被拒絕 

netacl-in.ftpd: permit-hosts * -exec /bin/cat /usr/local/etc/noftp.txt 

#對被拒絕的機器顯示這一信息 

OK,現在我們來測試一下我們的配置是否正常工作…… 
我從192.168.0.1上telnet目標機器192.168.0.2 
SunOS 5.7 

login: ronin 
Password: 
Last login: Sat Jun 10 18:00:34 from 192.168.0.1 
Sun Microsystems Inc. SunOS 5.7 Generic October 1998 
Cracker% 

唔,正常得很,看看阻塞的規則是否工作吧,我們就從localhost telnet本地吧…… 

Cracker% telnet localhost 
Trying 127.0.0.1... 
Connected to localhost. 
Escape character is '^]'. 
here is notelnet.txt file,means you can't access this host. <---我的notelnet.txt內容 
Connection closed by foreign host. 
Cracker% 

FTP的測試也是類似的,就不再多說了…… 

總結netacl的規則有如下表達: 

permit-host ip/hostname 指定允許主機 
deny-host ip/hostname 指定拒絕主機,被拒絕的主機會被syslogd記錄 
-exec executable[args] 為處理服務而激活的程序 
-user userid 程序啟動時的身份以root或者nobody等等 
-chroot rootdir 標識在調用服務程序前的chroot目錄 

3、認証系統: 

對這個認証系統,也同樣要編輯/etc/services,添加 

authsrv 3333/tcp 

然在/etc/inetd.conf中加入一行 

authsrv stream tcp nowait root /usr/local/etc/authsrv authsrv 

# ./authsrv <-----------------運行authsrv 
authsrv# ? <-----------------它就跳出來authsrv#字樣,我要看幫助, 
鍵?,得到下面的輸出 

Command List: 
(Commands may be invoked with unique leading abbreviation) 
authorize username [comment] 
authenticate username 
response 
quit 
exit 
display username 
adduser username [fullname] <----------添加用戶 
deluser username 
enable username [onetime] <----------給用戶使能 
disable username 
password [username] passwordtext <----------設密碼 
passwd [username] passwordtext 
proto username protoname <----------標志用戶使用的認証協議 
group username groupname <----------設組別 
rename username newname [fullname] 
wiz username 
unwiz username 
superwiz username 
operation group/user username command dest [tokens] 
list [group] 
ls [group] 

help 

authsrv# adduser wlj <--------------我在加用戶了 
ok - user added initially disabled 
authsrv# password wlj wlj <-------------設密碼,xixi,passwd=username,so easy to crack 
Password for wlj changed. 
authsrv# group wlj other <-------------設組別 
set group 
authsrv# enable wlj <-------------使能 
enabled 
authsrv# wiz wlj 
set group-wizard 
authsrv# superwiz wlj 
set wizard 
authsrv# ls <-------------現在看看…… 
Report for users in database 
user group longname status proto last 
---- ----- -------- ------ ----- ---- 
user n passw never 
wlj other y G passw never 

搞定了這個就可以試試authmgr的情況了…… 

前面提到的authmgr這個客戶程序則是用法如下: 

Cracker# ./authmgr 
Connected to server 
authmgr-> login 
Username: wlj 
Password: 
Logged in 
authmgr-> list 
Report for users in database 
user group longname status proto last 
---- ----- -------- ------ ----- ---- 
admin root y W passw never 
wlj other y G passw Sat Jun 10 11:26:18 2000 
authmgr-> 

至認証服務器也有它的規則,比如我的機器上的是這樣的: 

# Example auth server and client rules 
# ------------------------------------ 
authsrv: hosts 127.0.0.1 
authsrv: database /usr/local/etc/fw-authdb 
authsrv: badsleep 1200 
authsrv: nobogus true 

# clients using the auth server 
*: authserver 127.0.0.1 3333 

說說它的規則吧……關authsrv可以有下面的規則項: 

database pathname 指定authsrv數據庫的數徑 
nobogus true 當用戶認証失敗返回一個友好的錯誤消息 
badsleep seconds 對嘗試口令的登陸的限制 
userid name 指定authsrv運行的PID 
hosts host-pattern[key] 跟加密有關的了 
operation user id telnet-gw host + 
+>存儲在netperm-table中的操作規則 

operation user id ftp-gw host put + 

怎樣,看得明白?我寫得太亂,但實在表達不好;(不明白的話自己查幫助吧…… 


4、ftp-gw 

現在要來配置ftp代理了,一般情況下,你可能希望既運行ftp代理又運行正常的ftp服務, 
這樣要對幾個文件進行處理,首先編輯/etc/services,加入以下行: 

ronin 4444/tcp 

然在文件/etc/inetd.conf中把與FTP相關的行改為如下: 

ftp stream tcp nowait root /usr/local/etc/ftp-gw ftp-gw 
ronin stream tcp nowait root /usr/local/etc/netacl in.ftpd 

其中第二行的意思是配合/etc/services文件,將普通ftp端口移至4444,並以netacl包裝。 
而第一行就是我們的ftp-gw了。 

重啟進程,用端口掃描可以看到4444端口是打開的,可以直接連通。 
我們現在應該來配置ftp-gw的規則了打開文件/usr/local/etc/netperm-table: 

# Example ftp gateway rules: 
# -------------------------- 
ftp-gw: denial-msg /usr/local/etc/ftp-deny.txt 
# 對拒絕訪問者的信息 
ftp-gw: welcome-msg /usr/local/etc/ftp-welcome.txt 
# 歡迎信息 
#ftp-gw: help-msg /usr/local/etc/ftp-help.txt 
ftp-gw: timeout 3600 
# 這裡設定超時的時間 
# uncomment the following line if you want internal users to be 
# able to do FTP with the internet 
#ftp-gw: permit-hosts YOURNET.* 
ftp-gw: hosts 192.168.0.* 
# 允許192.168.0.*的這些機器登陸 
ftp-gw: authserver localhost 3333 
# 認証服務器是本地機器,端口為3333 <---------剛才在認証服務中定義的 

它的程序規則如下: 

userid user 指定了用戶ID 
directory pathname ftp-gw之前的chroot目錄 
denial-msg filename 訪問拒絕時顯示的文件 
welcome-msg filename 歡迎信息文件 
help-msg filename 幫助信息文件 
denydest-msg filename 受限制的訪問顯示文件 
timeout secondvalue 超時設置 

主機訪問選項如下: 

-dest pattern 標志一個有效目標 
-dest {pattern1 pattern2……} 標志一組有效目標 
-auth 說明代理要求用戶出示有效ID証明才允許使用 
-passok 如果來自受托主機,則允許修改口令 

下面我們來驗証一下,先ftp到4444的netacl控制端口…… 

C:\>ftp 
ftp> o 192.168.0.2 4444 
Connected to 192.168.0.2. 
sorry, you can't allow to access the ftp site! <-------定義的noftp.txt…… 
Connection closed by remote host. 
ftp> 

阻塞規則起作用了…… 

然來試試代理吧: 

C:\>ftp 192.168.0.2 
Connected to 192.168.0.2. 
220 i am quack, welcome ^&^ 
User (192.168.0.2:(none)): wlj@localhost <---------記得我剛才輸入的認証用戶? 
331-(----GATEWAY CONNECTED TO localhost----) 
331-(220 i am quack, welcome ^&^) 
331 Enter authentication password for wlj 
Password: 
230 User authenticated to proxy 
ftp> 

成功連接了……至允許及阻塞的規則自己制訂去吧。 

5、tn-gw 

和配置FTP沒有什兩樣,編輯/etc/services、/etc/inetd.conf、 
/usr/local/etc/netperm-table等文件,定義好端口、規則……就不多說了。 

6、plug-gw\rlogin-gw\http-gw\x-gw:這些代理的配置也大同小異,讀者可以自行研究。 

7、smap\smapd:至這個,我沒有配sendmail,也懶得弄了沒有嘗試不敢胡說…… 

四、附加工具包 

在tis的./tools/目錄有一些管理工具,利用它們可以完成一些系統管理功能, 
但是,可能是下載的版本的原因吧,我在packetstorm下載到的版本無法直接編譯安 
裝通過,問題有二,一是./tools/server/下有個syslog,得改成syslogd,還有就 
是make install時工具沒法裝到正確的目錄,你可以修改一下Makefile或者幹脆自 
已動手拷貝還要快些:) 

這些工具如下: 

./tools/admin/ 

1、flog 

這個東西是監視某一log文件的實時變化的工具,作者自述在控制台工作時經常運行 
tail -f /usr/adm/syslog來實時察看log文件的變化,以確定系統的運行情況,而 
flog是一個更加聰明的工具你可以簡單地鍵入flog&來運行它,默認情況下它察 
看的是/var/log/messages你可以在編譯的時候自己定義它。 

或者你可以用flog /var/log/auth.log&來察看其它的文件。 

2、portscan 

這東東似乎沒必要多說任誰看portscan也知道是個端口掃描工具了…… 

usage: portscan [-l low port] [-h high port] [-v] host 

最簡單直接的就是:./portscan localhost了……確定現在有哪些端口在提供服務。 
如果用-v host參數也會得到一個冗余的輸出每個端口打印一個小圓點……通過 
這個輸出你可以判斷它是不是還在跑…… 

3、netscan 

這是一個網絡ping程序,它將網絡地址做為參數接受,並且ping該網絡中的每個地址。 
它的缺省輸出是一組響應ping的地址列表及對應的主機名字。比如你可以用下面方式 
運行: 
# ./netscan 202.101.103 

它會依次ping每個地址,並將有響應就是存活的主機返回。 

它還可以以冗余方式運行。在這種方式下,響應ping的地址與其名字放在一起或者左對 
齊,沒有響應的地址則會縮排,以tab方式縮進一個制表空格。可以用 

# ./netscan -v 202.101.103 

得到冗余方式的輸出。 

4、progmail 

這是一個簡單的發送郵件的程序,要安裝它,你可以將它拷貝到/usr/local/etc/中, 
然修改sendmail.cf中的行: 

Mprog, P=/bin/sh, F=lsDFMeuP, S=10, R=20, A=sh -c $u 

將其改為: 

Mprog, P=/usr/local/etc/progmail, F=lsDFMeuP, S=10, R=20, A=sh -c $u 

5、reporting 

# ls -la 
-rw-r----- 1 ronin other 2126 1994 11月 5 authsrv-summ.sh 
-rw-r----- 1 ronin other 962 1994 11月 5 daily-report.sh 
-rw-r----- 1 ronin other 4799 1996 11月 27 deny-summ.sh 
-rw-r----- 1 ronin other 2757 1994 11月 5 ftp-summ.sh 
-rw-r----- 1 ronin other 2796 1994 11月 5 http-summ.sh 
-rw-r----- 1 ronin other 247 1994 11月 5 login-summ.sh 
-rw-r----- 1 ronin other 2048 1994 11月 5 netacl-summ.sh 
-rw-r----- 1 ronin other 2017 1994 11月 5 smap-summ.sh 
-rw-r----- 1 ronin other 2256 1994 11月 5 tn-gw-summ.sh 
-rw-r----- 1 ronin other 960 1994 11月 5 today-report.sh 
-rw-r----- 1 ronin other 962 1994 11月 5 weekly-report.sh 

這些東西不言而明是shell script寫成的日志統計工具了,自己看看代碼吧…… 

然在client及server目錄下還有以下工具作個簡略介紹吧: 

ftpd - a version of ftpd that uses the auth server 
login-sh - a login shell wrapper that uses the auth server 
(see the man pages) 
syslog - a version of the 4.3bsd syslog that uses regexps 
gate-ftp - If invoked as "gate-ftp", the environment variable FTPSERVER is 
searched for, and is contacted as a proxy ftp gateway. Autologin in done 
through the proxy. If FTPSERVERPORT is set, that is used as the port 
number for the gateway server. 
tn - a simple "expect" script that handles telnetting out through 
the proxy automatically 


好了,很久沒打過這多的字了……手酸死了…… 

結論:上面說了這多,其實只是說明一些基本的配置,至你自己的網絡如何用這一防火 
牆來將入侵者阻擋大門之外,這需要你自行分析你的安全策略、網絡結構等等再靈活地運 
用這些防火牆工具及規則來確保安全。 


附1、一些tip 譯自fwtk faq 一文 

1、我如何在toolkit裡使用S/KEYS? 

First, you must obtain the SecureID library from Axent Technologies (Security Dynamics) 
or the Skey library. In order to compile the SecureID with the toolkit, change the 
"tis_sd_init" reference in securid.c to "sd_init". The "tis_" variant is a TIS fix that 
ships with Gauntlet since the SecurID software won't work well with multi-homed hosts. 
For both, you need to edit the Makefile in the auth directory for the proper modules to be 
compiled and linked. Remove the "#" from the "SKEYDIR=" (etc..) lines and re-make. 

#if you are using the SKEY modules, define SKEYDIR to be the source 
#directory where the SKEY libraries and include files are. 
#SKEYDIR=../../skey 
#SKEYINC= -I$(SKEYDIR) 
#SKEYLIB= $(SKEYDIR)/libskey.a 
#SKEYOBJ= skey.o 
#if you are using the SecurID module, define SECURDIR to be the source 
#directory where the SecurID libraries and include files are. 
#SECURDIR= /var/ace/client 
#SECURLIB= $(SECURDIR)/sdclient.a $(FWLIB) #SECURINC= -I$(SECURDIR) 
#SECUROBJ= securid.o 

2、 我如何在netperm-table指定一個子網掩碼? 

使用如"network-number:netmask"之類的格式,下面是示例: 

111.222.0.0:255.255.0.0 

這一特性在FWTK 2.x以上的版本才有效哦。 

3、為什當我要打開proxy時得到"inetd: xxx-gw/tcp: unknown service"的錯誤提示? 

這表示在你/etc/inetd.conf中要打開的服務與/etc/services中定義的有沖突。 

舉例來說,你的inetd.conf文件中有如下行: 

ftp-gw stream tcp nowait root /usr/local/etc/ftp-gw ftp-gw 
最就是指服務service的名樂,把它改為ftp就OK了。 

如果你運行的是Solaris 2.x,可能還要參考/etc/nsswitch.conf文件。 


4、我如何將FWTK的log文件與其它標準syslog文件隔開? 

可以編輯firewall.h: 

找到下面的行: 
#define LFAC LOG_DAEMON 
替換為 
#define LFAC LOG_LOCAL6 

然將: 
local6.* /var/log/fwtk 
扔到syslog.conf裡面去,然把類似下面這行的東東幹掉 

*.info;local6,mail.none /var/log/messages 

當然,在你的netperm-table裡面要用-log的選項打開記錄功能哦。 

5、我如何為不同的服務建立分開的log文件? 

按照如下形式來編輯你的/etc/syslog.conf文件吧具體內容可以參看syslog.conf的 
man page。 

# patterns to match for 
"authsrv" /home/log/auth 
"netacl.*fingerd" /home/log/in-fingerd 
"netacl.*telnetd" /home/log/in-telnetd 
"smap" /home/log/smap 
"ftp-gw" /home/log/ftp-gw 
"plug-gw" /home/log/plug-gw 
"rlogin-gw" /home/log/rlogin-gw 
"tn-gw" /home/log/tn-gw 
# Standard system logs 
*.emerg;*.alert;*.crit;*.err;*.warning;*.notice;*.info;*.debug /var/adm/messages 
*.emerg * 
*.emerg;*.crit /dev/console 

最,發送HUP信號給syslogd來重啟進程就OK了。 

附2、一些相關術語(摘自防火牆的選型、配置、安裝和維護一書) 

1、防火牆(firewall):在被保護網絡和因特網之間,或在其它網絡之間限制訪問的一種 
或一系列部件。 
2、主機(host):連接到網絡上的計算機系統,它可以是各種類型的機器,如SUN工作站, 
PC或者IBM主機等等,也可以運行不同的操作系統。 
3、堡壘主機(bastion host):它是一種被強化的可以防御進攻的計算機,被暴露因特 
網之上,作為進入內部主機的一個檢查點。通常情況下,堡壘主機上運行一些通用的操作 
系統。 
4、雙宿主主機dual homed host):有兩個網絡接口的主機。 
5、屏蔽路由器(screened router):可以根據過濾原則對數據包進行阻塞和轉發的機器。 
6、屏蔽主機(screened host):被放置到屏蔽路由器面的網絡上的主機,主機能被訪 
問和程度取決路由器的屏蔽規則。 
7、屏蔽子網(screen subnet):位屏蔽路由器面的子網,子網能被訪問的程度取決 
屏蔽規則。 
8、代理服務器(proxy server):一種代表客戶和真正服務器通信的程序。典型的代理接受 
用戶的客戶請求,然決定用戶或用戶的IP地址是否有權使用代理服務器(也可能支持其它 
的認証手段),然代表客戶與真正服務器之間建立連接。 
9、IP欺騙(ip spoofing):這是一種黑客的攻擊形式,黑客使用一台機器,而用另一台機 
器的IP地址,從而裝扮成另一台機器與服務器打交道。例如,一個防火牆不允許某一競爭 
站點訪問該站點,但競爭站點可以使用其它站點的IP和服務器通信,而服務器則不知道與 
它通信的機器是競爭站點的主機。 
10、DNS欺騙(DNS spoofing):通過破壞被攻擊機上的名字服務器緩存,或破壞一個域名 
服務器來偽造IP地址和主機名的映射,從而冒充其它機器。 
11、隧道路由器(trnneling router):它是一種特殊的路由器,可以對數據包進行加密, 
讓數據能通過非信任網,如因特網,然在另一端用同樣的路由器進行解密。 
12、虛擬私用網(Virtual Private Network,VPN):一種連接兩個遠程局域網的方式, 
連接要通過非信任網,如因特網,所以一般通過隧道路由器來實現互聯。 
13、差錯與控制報文(ICMP):這是TCP/IP協議中的一種,建立在IP層上,用主機之間或 
主機在路由器之間傳輸錯誤報文以及路由建議。 
14、縱深防御(Defense in Depth):一種確保網絡盡可能安全的安全措施,一般與防火牆 
聯用。 
15、最小特權(Least Privilege):在運行和維護系統中,盡可能地減少用戶的特權,但同 
時也要使用戶有足夠的權限來做事,這樣就會減少特權被濫用的機會。內部人員濫用特權 
很可能在防火牆上打開一個安全缺口,這很危險,很多的入侵是由此引起的。 
16、數據包過濾(package filtering):一些設備,如路由器、網橋或單獨的主機,可以有 
選擇地控制網絡上來往的數據流。當數據包要經過這些設備時,這些設備可以檢查數據包 
的相應位,根據既定的原則來決定是否允許數據包通過。有時這也被稱作屏蔽。 


==================== 
錯漏難免,請高手賜教  (http://www.fanqiang.com)
    進入【UNIX論壇

相關文章
Cisco PIX防火牆的安裝流程 (2001-10-18 07:00:00)
解讀防火牆記錄 (2001-09-11 10:00:02)
如何在防火牆上設置Sendmail (2001-07-25 07:00:00)
路由設定---8.學校端路由器遇到防火牆時 (2001-06-05 11:00:00)
如何在防火牆面設置門(V1.5) (2001-05-31 21:04:01)
怎樣用ipchains構建防火牆 (2001-04-21 19:38:25)
如何設置一個可靠的防火牆系統保護公司內部網絡? (2001-04-20 16:17:58)
如何設定防火牆IP Firewall (2001-04-16 14:19:47)
 

★  樊強制作 歡迎分享  ★