fusefs

fusefs 是一個 userland filesystem, 可以讓你使用在 operator 群組內的 user (不一定要是 root) 來 mount 某些奇怪的 fs, 像是 sshfs, gmailfs, flickrfs, smbnetfs, blogfs, wikipediafs, bittorrentfs

另外有 ftpfs, 但是看到是 perl based 的就不太想用了 :Q  也許找套好一點的 ftp library 來生 C 版本的 ftpfs
BTW, 不知道能不能作一個 encoding translation fs,  實際存 unicode, 根據 shell 的 LC_CTYPE 來轉成正確的 encoding…XD

IPSec 設定筆記

參考

http://taosecurity.blogspot.com/2005/01/ipsec-tunnels-with-freebsd-although.html

  1. 修改 Kernel,加上

    options FAST_IPSEC
    device crypto

    並且重開機。

  2. 安裝 security/ipsec-tools
  3. 設定 /usr/local/etc/racoon/racoon.conf:

    path pre_shared_key "/usr/local/etc/racoon/psk.txt";
    padding
    {
    maximum_length 20; # maximum padding length.
    randomize off; # enable randomize length.
    strict_check off; # enable strict check.
    exclusive_tail off; # extract last one octet.
    }

    listen
    {
    isakmp (MY_IP) [500];
    }
    timer
    {
    # These value can be changed per remote node.
    counter 5; # maximum trying count to send.
    interval 20 sec; # maximum interval to resend.
    persend 1; # the number of packets per send.

    # maximum time to wait for completing each phase.
    phase1 30 sec;
    phase2 15 sec;
    }
    remote
    [500]
    {
    #exchange_mode main,aggressive;
    exchange_mode aggressive,main;
    doi ipsec_doi;
    situation identity_only;

    my_identifier user_fqdn “sakane@kame.net”;
    peers_identifier user_fqdn “sakane@kame.net”;
    #certificate_type x509 “mycert” “mypriv”;

    nonce_size 16;
    lifetime time 1 min; # sec,min,hour

    proposal {
    encryption_algorithm 3des;
    hash_algorithm sha1;
    authentication_method pre_shared_key;
    dh_group 2;
    }
    }

  4. 設定 /usr/local/share/psk.txt:
  5. 設定 /etc/ipsec.conf:
    flush;
    spdflush;spdadd any -P out ipsec
    esp/tunnel/-/require;
    spdadd any -P in ipsec
    esp/tunnel/-/require;

    spdadd / any -P out ipsec
    esp/tunnel/-/require;

    spdadd / any -P in ipsec
    esp/tunnel/-/require;

  6. /usr/local/etc/rc.d/racoon.sh start; /etc/rc.d/ipsec start;

P.S.
racoon 的範例設定檔在 /usr/local/share/examples/ipsec-tools 裡面。

自動擋暴力 try ssh 的 script (with pf)

從 http://anp.ath.cx/sshit/sshit.pl 改進的,現在不會 fork 一堆出來了。
這個版本是用 tail -F 讀 /var/log/auth.log,跟 sshit.pl 的作法不同。

Link: http://www.csie.nctu.edu.tw/~jnlin/script/chkfw_select_pf.txt

你必須要在 /etc/pf.conf 加上:

table <$PF_TABLE> persist
block on $extdev from <$PF_TABLE> to any

才會真正 block 有惡意者的 IP。

ng_netflow 的使用方法

# /usr/sbin/ngctl -f- <<-SEQ
mkpeer fxp0: tee lower right
connect fxp0: fxp0:lower upper left
mkpeer fxp0:lower netflow right2left iface0
name fxp0:lower.right2left netflow
msg netflow: setifindex { iface=0 index=5 }
connect fxp0:lower netflow: left2right iface1
msg netflow: setifindex { iface=1 index=6 }
mkpeer netflow: ksocket export inet/dgram/udp
msg netflow:export connect inet/127.0.0.1:9991
SEQ