Notes: December 2004 Archives

PPPoE 原來可以這樣

user-pic
Vote 0 Votes

IP 跟 Gateway 完全是不同網段

ppp0 Link encap:Point-Point Protocol
inet addr:218.166.248.109 P-t-P:61.228.96.254 Mask:255.255.255.255
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1492 Metric:1
RX packets:14794 errors:0 dropped:0 overruns:0 frame:0
TX packets:14745 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:3
RX bytes:1544763 (1.4 MiB) TX bytes:740369 (723.0 KiB)

# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
61.228.96.254 0.0.0.0 255.255.255.255 UH 0 0 0 ppp0
192.168.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
10.18.43.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
127.0.0.0 0.0.0.0 255.0.0.0 U 0 0 0 lo
0.0.0.0 61.228.96.254 0.0.0.0 UG 0 0 0 ppp0

BASH [ expr ] -a -o

user-pic
Vote 0 Votes

expr1 -a expr2
True if both expr1 and expr2 are true.
expr1 -o expr2
True if either expr1 or expr2 is true.

-a (AND) operation first, then -o (OR) operation

e.g.
there're 3 files, a, c, d
#!/bin/sh
[ -f a -o -f b -o -f c -o -f d ] && echo 0
[ -f a -o -f b -o -f c -a -f d ] && echo 1
[ -f a -o -f b -a -f c -o -f d ] && echo 2
[ -f a -o -f b -a -f c -a -f d ] && echo 3
[ -f a -a -f b -o -f c -o -f d ] && echo 4
[ -f a -a -f b -o -f c -a -f d ] && echo 5
[ -f a -a -f b -a -f c -o -f d ] && echo 6
[ -f a -a -f b -a -f c -a -f d ] && echo 7
result is...

Allow auth in Windows XP SP2

user-pic
Vote 0 Votes

連某些服務會頓一下嗎? 可能該服務需要用到 auth (ident)
例如 ProFTPD
有這種狀況的話, 把 auth 加到防火牆例外可以加快連線速度
控制台/防火牆/例外/新增連接埠
名稱: auth
連接埠編號: 113
TCP

昨天嘗試要使用 GRUB 來 load Windows CE, 結果失敗

一般 Windows CE 的檔案如下
-r-xr--r-- 1 root root 16384 4月 29 2004 bldr*
drwxr--r-- 2 root root 2048 6月 1 2001 bmp/
drwxr--r-- 3 root root 2048 3月 30 2005 Documents and Settings/
-rwxr--r-- 1 root root 72491 3月 9 2004 eboot.bin*
-r-xr--r-- 1 root root 18805259 10月 28 20:51 nk.bin*
-r-xr--r-- 1 root root 308316 10月 28 20:55 splash.bin*

一張可開機的 Windows CE CF 卡使用 dd 的方式 copy 到另一張不同的 CF 卡, 是無法開機的.
Windows CE 的 boot loader 似乎是讀固定的位置
改用 GRUB 的話
使用 load DOS 的方法, 失敗
使用 load 整個 image 的方法, 失敗

ref.
http://www.gnu.org/software/grub/manual/grub.html
http://syslinux.zytor.com/memdisk.php

Hosts Disable Movable Type as Comment Spam Slows Servers
This article give me a hint.
MT comment spam bot target mt-comments.cgi to post comment spam,
Why not rename it!
1. mv mt-comments.cgi mt-comments_something.cgi
2. edit mt.cfg, uncomment CommentScript, and fill with mt-comments_something.cgi
3. rebuild all pages

After few days test, it works! (see 404 log)
This way get rid of most comment spam.
Some bot reference form action=filename, This trick will fail.

Show DirectX Info

user-pic
Vote 0 Votes

run dxdiag

由於微軟的細明體有字型碎裂及字距的問題
可以改用螢火飛所釋出內嵌點陣字的文鼎新宋字型

wget http://firefly.idv.tw/apt/firefly-font/fireflysung-1.3.0.tar.gz
or
wget http://www.study-area.org/apt/firefly-font/fireflysung-1.3.0.tar.gz
#下載內嵌點陣字的文鼎新宋字型

tar zxf fireflysung-1.3.0.tar.gz
#解壓縮

ttfm.sh --add fireflysung-1.3.0/fireflysung.ttf
# 用 ttfm 工具安裝
fc-cache -f -v (Build font information cache)

裝完重新啟動 X, 把字型設為 AR PL New Sung

ref. 螢火飛相關套件安裝

77 IP Info

user-pic
Vote 0 Votes

http://77bbs.com/ip/

I wrote a small program to show your IP info and location with IP to Country mapping database and my bbs domain_name_query file.

Bash Parameter Expansion

user-pic
Vote 0 Votes

${parameter:-word} Use Default Values.
e.g.
echo ${A:-1}
A=2
echo ${A:-1}
result is
1
2

${parameter:=word} Assign Default Values.
e.g.
echo ${A:=1}
echo $A
A=2
echo ${A:=1}
result is
1
1
2

${parameter:?word} Display Error if Null or Unset.
equals [ -z $parameter ] && echo word && exit 1

${parameter:+word} Use Alternate Value.
equals [ -z $parameter ] || parameter=word
e.g.
echo ${A:+1}
A=2
echo ${A:+1}
result is

1

${parameter:offset}
${parameter:offset:length}
e.g.
A=string
echo ${A:1}
echo ${A:2:3}
result is
tring
rin

${!prefix*} Expands to the names of variables whose names begin with prefix
e.g.
A=test1
A1=test2
A2=test3
B=test4
echo ${!A*}
result is
A A1 A2

${#parameter} The length in characters of the value of parameter
e.g.
A=string
echo ${#A}
result is
6

${parameter#word} Head cut
${parameter##word}
e.g.
A=file.tar.gz
echo ${A#*.}
echo ${A##*.}
result is
tar.gz
gz

${parameter%word} Tail cut
${parameter%%word}
e.g.
A=file.tar.gz
echo ${A%.*}
echo ${A%%.*}
result is
file.tar
file

${parameter/pattern/string} Pattern replacing
${parameter//pattern/string}
e.g.
A=linux_linux
echo ${A/linux/freebsd}
echo ${A//linux/freebsd}
result is
freebsd_linux
freebsd_freebsd

ref. man bash, / Parameter Expansion

Get Windows computer name by IP

user-pic
Vote 0 Votes

Linux: nmblookup -A IP
e.g.
# nmblookup -A 192.168.1.238
Looking up status of 192.168.1.238
WIN2003 <00> - B
WIN2003 <20> - B
WORKGROUP <00> - B
WORKGROUP <1e> - B

Windows: ping -a IP

the ip before proxy

user-pic
Vote 0 Votes

echo $HTTP_X_FORWARDED_FOR

GRANT ALL PRIVILEGES ON *.* TO YourUserName@YourPublicIP IDENTIFIED BY "YourPassword";

YourUserName is the username that you would like to create.
YourPublicIP is the public IP address of your PC (can be IP range or use % to allow any host).
("211.72.20.%" = 211.72.20.0/24, quote IP range if with %)
YourPassword - You can setup a password for your account.

Don't forget flush privileges;

e.g.
mysql> grant all privileges on *.* to pank@"211.72.20.%" identified by "1111";
Query OK, 0 rows affected (0.01 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)

Gallary and gettex

user-pic
Vote 0 Votes

只要在 make php 時, enable gettex support
./configure --with-mysql --with-apxs=/usr/local/apache/bin/apxs \
--enable-module=so --with-config-file-path=/usr/local/etc \
--libexecdir=/usr/local/apache/libexec --with-gd --with-zlib --with-jpeg-dir --with-freetype-dir --with-gettext
使用 IE 看 Gallery, 相簿的 counter 都變成 1, 怪怪
用 Firefox 倒是正常

"ERROR: recv: Connection reset by peer"
(return value 141)

This error occured because license problem, maybe expired.

workaround: change another hostname by -n parameter

PS. If server is windows 2003, return value 0, no such error message

iptables DNAT port mapping test

user-pic
Vote 0 Votes

環境: 內部的一台機器 listen tcp port 135,139 供測試
測試工具: nmap, 設好 rule 後作多次 port scan 動作, 觀查 open port

135-139 對 135-139 (一對一 mapping)
結果: port 135,139 open

235-239 對 135-139 (一對一 shift mapping)
結果: 動態 port 對應
(在 235-239 中動態分配 2 個 port 分別 mapping 到 135,139)

100-150 對 135-139 (多對少 mapping, --dport 在 listen port 範圍內)
結果: 動態 port 對應, 135 對 135, 139 對 139 的機率很高

150-200 對 135-139 (多對少 mapping, --dport 不在 listen port 範圍內)
結果: 動態 port 對應

130-140 對 120-150 (少對多 mapping, --dport 在 listen port 範圍內)
結果: 固定 135,139 open

140-150 對 120-140 (少對多 mapping, --dport 不在 listen port 範圍內)
結果: 動態 port 對應
有掃到 0 個 port, 1 個 port , 2 個 port 均有出現
因為 10 個 port 無法一一 mapping 到 20 個 port

結論: 當 port 無法直接 mapping 時, 會動態 mapping

MSN's Ad Server

user-pic
Vote 0 Votes

rad.msn.com 是 MSN 的存放廣告的 Server

由 Ethereal 觀察, MSN Messenger 會送出像如下的 URL
http://rad.msn.com/ADSAdClient31.dll?GetAd?PG=IMSTWN?SC=HF?ID=000201000251651a

77BBS URL

user-pic
Vote 0 Votes

寫了一個轉址服務 http://url.77bbs.com/
此服務類似 http://tinyurl.com/
不同點在於 77BBS URL 使用 sub domain 的方式做處理

  • 注意事項
    77BBS URL 使用兩碼的英數字排列組合循環使用(約有1200組), 此網址有時效性,
    網址的時效為一個循環, 直到下次有使用者佔用同一個名稱為止
    舉個例子, 假設平均每天有 40 個人使用 77BBS URL, 網址的時效性約為一個月

  • rbash - RESTRICTED SHELL

    user-pic
    Vote 0 Votes

    If you want to restrict someone's shell access, use rbash.

    chsh -s /bin/rbash username

    ref. man bash

    About this Archive

    This page is an archive of entries in the Notes category from December 2004.

    Notes: November 2004 is the previous archive.

    Notes: January 2005 is the next archive.

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

    Monthly Archives