Notes: April 2004 Archives

postfix relocated

| | Comments (2)

format
username new location Taichung

add this line to main.cf
relocated_maps = hash:/etc/postfix/relocated

to take effect
postmap /etc/postfix/relocated
postfix reload

then mail to username, system will sned a returned mail said

User has moved to new location Taichung

ClamAV

| | Comments (0)

http://www.clamav.netdownload http://prdownloads.sourceforge.net/clamav

command line scan tool
/usr/local/bin/clamdscan
command line scan tool, use with clamd, scan speed fast
/usr/local/bin/clamscan
virus pattern update tool
/usr/local/bin/freshclam
clamav daemon
/usr/local/sbin/clamd
lib
/usr/local/lib/libclamav.so.1 -> libclamav.so.1.0.4
/usr/local/lib/libclamav.so.1.0.4
config
/usr/local/etc/freshclam.conf
/usr/local/etc/clamav.conf
virus pattern
/usr/local/share/clamav/daily.cvd
/usr/local/share/clamav/main.cvd

use clamassassin for mail scan
http://drivel.com/clamassassin/

To pass your mail through clamassassin, add the following command to your
procmail rc file:

:0fw
| /usr/local/bin/clamassassin

If you installed the program elsewhere, change the path. The above will
scan the mesage for viruses and add the headers X-Virus-Status and
X-Virus-Report as appropriate. Procmail then continues processing the
message as normal. Nothing else will happen unless you add additional
rules to sort or discard detected viruses. To do this, you might do the
following:

:0:
* ^X-Virus-Status: Yes
IN.virus


ps. http://monkey.org/openbsd/archive/misc/0310/msg00002.html
The following are the open source antivirus solution:

(a) Open Antivirus
http://www.openantivirus.org

(b) Clam AV
http://clamav.elektrapro.com

(c) Trophie
http://www.vanja.com/tools/trophie/
(based on Trend Micro Virus scanning engine library)

(d) Sophie
http://www.vanja.com/tools/sophie/
(based on Sophos SAVI AV interface)

Google 改 UTF-8 編碼

| | Comments (0)

Google 最近改用 UTF-8 編碼
以前可以用
http://www.google.com/search?q=XXX 查詢
現在直接用這樣使用中文會有亂碼

現在要改成
http://google.com/search?hl=zh-TW&ie=Big5&q=%s
or (搜尋繁體中文)
http://google.com/search?hl=zh-TW&ie=Big5&lr=lang_zh-TW&q=%s
有用 MyIE2 的人可以到設定中心/快速搜尋裡面修改 * 的對應

DNS wildcard setting

| | Comments (0)

*.test IN A 140.117.53.147

就這麼簡單
試過 bind, maradns 都可以適用

MSN 6.2 fix

| | Comments (1)

Patch program for version 6.2.x download
Patch program for version 6.x all version download

// Multi-Open
Find 0F 85 9C 00 00 00 6A
Edit 90 E9 -- -- -- -- --

// No-Ad set 1/3
/*
Find E8 ?? FD FF FF 53 68
Edit 90 90 90 90 90 -- --
*/
Find FD FF FF 53 68
Edit 90 90 90 -- --
再往前推 2 bytes, change to 90

// No-Ad set 2/3
Find 3B CB 74 07 6A 01 E8 (3 found, but only change 1st one)
Edit -- -- EB -- -- -- --

// No-Ad set 3/3
Find 74 21 57 57
Edit EB -- -- --

dump, restore

| | Comments (0)

backup:
dump -0ua -f {dumpfile} {device}

restore:
restore -r -f {dumpfile}
restore -i -f {dumpfile}
(-i interactive)

mktemp, mkstemp

| | Comments (0)

template 最後要是 XXXXXX
mktemp 有安全性問題, 不要使用, man mktemp BUG 段, 需使用 mkstemp


char temp[]="/tmp/temp-XXXXXX";
mkstemp(temp);

poptop

| | Comments (0)

http://www.poptop.org/

tar zxvf pptpd-1.1.4-b4.tar.gz
cd pptpd-1.1.4-b4
./configure&&make&&make install

edit /etc/pptpd.conf
# localip 是 server 的內部 IP
localip 192.168.0.2
# remoteip 配給 vpn client 的 IP
remoteip 192.168.0.20-30
pidfile /var/run/pptpd.pid

if have firewall, add
iptables -A INPUT -p gre -j ACCEPT
iptables -A INPUT -p tcp --dport 1723 -j ACCEPT

/etc/ppp/chap-secrets
#帳號 servername 密碼 IP
test pank.org 1111 *

以上設定完成

windows 在新增 VPN 連線後
[內容]-[安全性]->要求資料加密 的選項不要打勾

Softether

| | Comments (2)

http://www.softether.com/

前幾個月有看到這個軟體, 當時沒有很注意, 剛剛翻了翻相關文件,
這真是劃時代的軟體, 經由虛擬 hub , 可以連到 firewall 下的電腦,
firewall 下的電腦, 連上虛擬 hub 後, 再也不受到任何現制.
令人振奮亦令人震驚!
衍生問題是系統安全性的問題, 舉個例子: 只要有人在公司內部裝這個軟體供外面連入,
外面的人就可以直接穿過 firewall 對公司內部電腦進行存取.

linux 版 virtual hub 安裝方法
ref. http://www.softether.com/jp/linux/
wget http://www.softether.com/jp/download/se_101_linux.zip
unzip se_101_linux.zip
gcc se_hub.a -lpthread -lssl -lcrypto -o se_hub
./se_hub &
(ca.crt, ca.key 需在 se_hub 同一個目錄)

管理
telnet localhost 8023
第一次會讓你設定密碼, 爾後請輸入密碼登入
------------------------------------------------------------
SoftEther Virtual HUB Administration Console 1.00

Copyright (C) 1997-2004 Daiyuu Nobori, All Rights Reserved.
------------------------------------------------------------

http://www.softether.com/

Note: Please use Microsoft Telnet Client (telnet.exe).

Please enter Administrator Password.

Password :


ref. http://shoppingguide.ithome.com.tw/special/special2004-05-25-002.html
利用弱點稽核軟體,檢查哪些主機有安裝SoftEther;防火牆可以從連結的主機那裡偵測到標示「SoftEther Protocol」的字串,了解哪些人正在使用SoftEther;SoftEther的作者表示,未來將開發檢查區域網路內是否有人在使用SoftEther的軟體。

FTP client file size limit

| | Comments (2)

現在動不動就是上 G 的檔案, 很多軟體都會出現這個問題
無法處理 size > 2147483647 的檔案(long integer)
剛剛用 ncftp 試圖要傳一個 2.8G 的檔, 就掛了

Solution:
1. 抓官方 binary distributions
2. 自行 make with -D_LARGEFILE_SOURCE

bind - delegate a sub domain

| | Comments (0)

sub IN NS ns.sub.pank.org.
ns.sub IN A 61.220.92.130

fetchyahoo & yahoopops

| | Comments (0)

http://fetchyahoo.sourceforge.net/
需安裝下列 RPM (以 mdk 9.2 為例)
perl-Crypt-SSLeay-0.49-1mdk.i586.rpm
perl-IO-stringy-2.108-4mdk.noarch.rpm
perl-MailTools-1.58-1mdk.noarch.rpm
perl-MIME-tools-5.411-4mdk.noarch.rpm

Usage:
fetchyahoo --username=username --password=password --spoolfile=/var/mail/username

http://yahoopops.sourceforge.net/
台灣 yahoo 不能收, 必須英文 YAHOO 的個人設定網頁登入,再編輯你的會員資料,將你的使用語言改成 English-US 後儲存設定
或用下面這個修正(for windows)
http://myweb.hinet.net/home5/daemon9/YahooPOPs-0.5-tw.htm

for windows
在 Mail Client 把 SMTP server 設成 localhost, pop

for linux
YAHOOPOPS_PORTNUMBER 5058
YAHOO_SMTP_PORT 5059
在 Mail Client 把 SMTP server 設成 localhost, port 為 5058

Postfix-SMTP-AUTH-TLS-Howto

| | Comments (0)

http://www.projektfarm.com/en/support/howto/postfix_smtp_auth_tls.html
大部分的分件都沒有提到 TLS 需要 patch, 這篇文章寫得滿仔細的

以下是整理過的步驟

取得檔案( 原文中有些 URL 已無效)
wget http://www.openssl.org/source/openssl-0.9.7c.tar.gz
wget ftp://ftp.andrew.cmu.edu/pub/cyrus-mail/cyrus-sasl-2.1.18.tar.gz
wget ftp://ftp.aet.tu-cottbus.de/pub/postfix_tls/related/postfix/postfix-2.0.18.tar.gz
wget ftp://ftp.aet.tu-cottbus.de/pub/postfix_tls/pfixtls-0.8.16-2.0.18-0.9.7c.tar.gz

解壓檔案
tar zxf openssl-0.9.7c.tar.gz
tar zxf cyrus-sasl-2.1.18.tar.gz
tar zxf postfix-2.0.18.tar.gz
tar zxf pfixtls-0.8.16-2.0.16-0.9.7b.tar.gz

編譯 openssl
cd openssl-0.9.7c
./config
make
make install

編譯 cyrus-sasl-2
cd ../cyrus-sasl-2.1.18
./configure --enable-anon --enable-plain --enable-login --with-saslauthd=/var/run/saslauthd --with-pam --with-openssl=/usr/local/ssl --with-plugindir=/usr/local/lib/sasl2 --enable-cram --enable-digest
make
make install

[ -d /usr/lib/sasl2 ] && mv /usr/lib/sasl2 /usr/lib/sasl2_orig
ln -s /usr/local/lib/sasl2 /usr/lib/sasl2
printf "pwcheck_method:saslauthd\nmech_list: plain login digest-md5\n" > /usr/local/lib/sasl2/smtpd.conf

編譯 postfix (含 tls patch)
cd ../postfix-2.0.18
useradd postfix
groupadd postdrop
patch -p1 < ../pfixtls-0.8.16-2.0.18-0.9.7c/pfixtls.diff
make makefiles CCARGS="-DHAS_SSL -DUSE_SASL_AUTH -I/usr/local/include/sasl -I/usr/local/ssl/include" AUXLIBS="-L/usr/local/ssl/lib -L/usr/local/lib -R/usr/local/lib -lsasl2 -lssl -lcrypto"
make
make install
cp /etc/postfix/aliases /etc/
newaliases
mkdir -p /var/spool/postfix/etc
cd /etc
cp localtime services hosts resolv.conf /var/spool/postfix/etc
mkdir -p /var/spool/postfix/var/run/saslauthd
chmod 755 /var/spool/postfix/var/run/saslauthd
ln -s /var/spool/postfix/var/run/saslauthd /var/run/saslauthd

產生 certificate files for TLS
cd /etc/postfix
openssl req -new -x509 -nodes -out smtpd.pem -keyout smtpd.pem -days 3650

編輯 /etc/postfix/main.cf 加入下列
# SASL
smtpd_sasl_auth_enable=yes
smtpd_recipient_restrictions=permit_sasl_authenticated, permit_mynetworks, reject_unauth_destination
smtpd_sasl_security_options=noanonymous
broken_sasl_auth_clients=yes
# TLS
smtp_use_tls = yes
smtpd_use_tls = yes
smtp_tls_note_starttls_offer = yes
smtpd_tls_key_file = /etc/postfix/smtpd.pem
smtpd_tls_cert_file = /etc/postfix/smtpd.pem
smtpd_tls_CAfile = /etc/postfix/smtpd.pem
smtpd_tls_loglevel = 1
smtpd_tls_received_header = yes
smtpd_tls_session_cache_timeout = 3600s
tls_random_source = dev:/dev/urandom

啟動 postfix 及 saslauthd
postfix start
saslauthd -a shadow

測試
telnet localhost 25

220 pank.idv.tw ESMTP Postfix
ehlo 0
250-pank.idv.tw
250-PIPELINING
250-SIZE 10485760
250-VRFY
250-ETRN
250-STARTTLS
250-AUTH LOGIN PLAIN DIGEST-MD5
250-AUTH=LOGIN PLAIN DIGEST-MD5
250-XVERP
250 8BITMIME

看起來正常, 再測試認證, 使用者名稱 pank, 密碼 test
取得編碼後字串 printf 'pank\0pank\0test' | mmencode
得到 cGFuawBwYW5rAHRlc3Q=
(使用這個方法測試時, 用數字 0-7 開頭的密碼會認證錯誤, 原因不明.
而事實上, 使用上述密碼在 smtp auth 上是沒問題的)

telnet localhost 25

220 pank.idv.tw ESMTP Postfix
ehlo 0
250-pank.idv.tw
250-PIPELINING
250-SIZE 10485760
250-VRFY
250-ETRN
250-STARTTLS
250-AUTH LOGIN PLAIN DIGEST-MD5
250-AUTH=LOGIN PLAIN DIGEST-MD5
250-XVERP
250 8BITMIME
auth plain cGFuawBwYW5rAHRlc3Q=
235 Authentication successful

已正常運作

若是 failed, 就看 log 查原因

ref. Postfix/TLS - A TLS extension for POSTFIX

Sticky bit

| | Comments (0)

http://www.study-area.net/linux/system/linux_fs.htm

1﹐則為檔案設上一個特殊標籤﹕sticky bit (黏著位元)﹐當這個標籤打開的時候﹐只有檔
案的擁有者才能刪除這個檔案(root 除外)﹐其它使用者就算具有 w 的權限﹐也只能修改檔
案的內容﹐而不能將檔案刪除。如果一個目錄具有這個位元﹐那麼其下所建立的檔案﹐也具
有這個屬性。

pure-ftpd --with-virtualchroot

| | Comments (0)

./configure --with-virtualchroot
此參數讓 link 不受 chroot 的限制, 好用
http://www.pureftpd.org/README

--with-virtualchroot: usually, when an user is chrooted (-A and -a
options), it's impossible to go out of his home directory. Enabling that
feature makes it possible: symbolic links are always followed, even if they
are pointing to directories not located in the user's home directory. This
is very useful for having shared directories (for instance, have a symbolic
link to /var/incoming in every home directory) .
This feature isn't enabled by default.

./configure --with-sysquotas
使用系統 quota

chattr

| | Comments (0)

i 屬性 Immutable, 無法刪除或改變
a 屬性 Append only

ex.
chattr -R +i /bin /boot /etc /lib /sbin
chattr -R +i /usr/bin /usr/include /usr/lib /usr/sbin
chattr +a /var/log/messages /var/log/secure

postfix transport

| | Comments (0)

例一
Server test.pank.org
MX 設到 tecoia.com.tw
Server tecoia.com.tw
mydestination 設上 test.pank.org
transport 檔設 test.pank.org smtp:[pank.org] ([] disable MX lookup)
postmap /etc/postfix/transport

信件就會先經過 tecoia.com.tw (可做過濾掃毒等動作), 再送到 test.pank.org

relay 的應用
bbs.fcu.edu.tw relay:[mail.nsysu.edu.tw]

要送到 someone@bbs.fcu.edu.tw 的信件, 會 relay 給 mail.nsysu.edu.tw

例二
所有的信送給上游 smtp, 除了本身及 server6.com.tw
server6.com.tw :
teco-ia.com.tw :
* :[ms1.hinet.net]

ps. 有異動需執行 postmap transport 及 postfix reload 動作

Pages

March 2008

Sun Mon Tue Wed Thu Fri Sat
            1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31          

About this Archive

This page is a archive of entries in the Notes category from April 2004.

Notes: March 2004 is the previous archive.

Notes: May 2004 is the next archive.

Find recent content on the main index or look in the archives to find all content.