Hack
2007年07月21日
packit
Network Injection and Capture
ethernetのパケットを作成してキャプチャできる
ARP poisoningの実験をしたかった。
packit -m inject -t arp -x 192.168.0.2 -X 1:2:3:4:5:6 -E 6:5:4:3:2:1
とかやってみる。-Eが送信先。
2007年07月19日
Emacs22のdesktop
Emacs22になってからdesktopが保存されなくなった。
これもまたちょっと.emacsに書く必要がある。
(desktop-save-mode 1)
2007年04月16日
valgrind
A memory debugger and profiler
適当にメモリリークを起こすコードを書く。
#include <stdlib.h>
int
main(void)
{
malloc(100);
return 0;
}
次に -g 付きでコンパイルしてからvalgrindを通して実行する。
$ valgrind --leak-check=full ./a.out
==28368== Memcheck, a memory error detector.
==28368== Copyright (C) 2002-2007, and GNU GPL'd, by Julian Seward et al.
==28368== Using LibVEX rev 1732, a library for dynamic binary translation.
==28368== Copyright (C) 2004-2007, and GNU GPL'd, by OpenWorks LLP.
==28368== Using valgrind-3.2.3-Debian, a dynamic binary instrumentation framework.
==28368== Copyright (C) 2000-2007, and GNU GPL'd, by Julian Seward et al.
==28368== For more details, rerun with: -v
==28368==
==28368==
==28368== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 13 from 1)
==28368== malloc/free: in use at exit: 100 bytes in 1 blocks.
==28368== malloc/free: 1 allocs, 0 frees, 100 bytes allocated.
==28368== For counts of detected errors, rerun with: -v
==28368== searching for pointers to 1 not-freed blocks.
==28368== checked 59,080 bytes.
==28368==
==28368== 100 bytes in 1 blocks are definitely lost in loss record 1 of 1
==28368== at 0x40244B0: malloc (vg_replace_malloc.c:149)
==28368== by 0x8048370: main (leak.c:6)
==28368==
==28368== LEAK SUMMARY:
==28368== definitely lost: 100 bytes in 1 blocks.
==28368== possibly lost: 0 bytes in 0 blocks.
==28368== still reachable: 0 bytes in 0 blocks.
==28368== suppressed: 0 bytes in 0 blocks.
てな具合です。
- Accesses memory it shouldn't (areas not yet allocated, areas that have
been freed, areas past the end of heap blocks, inaccessible areas of
the stack).
- Uses uninitialised values in dangerous ways.
- Leaks memory.
- Does bad frees of heap blocks (double frees, mismatched frees).
- Passes overlapping source and destination memory blocks to memcpy() and
related functions.
などができるとのこと。
2007年04月08日
mmm-mode
Emacsで複数のメジャーモードを一つのバッファで使うモード。つまりHTMLの中でPHPを書いたりするときに便利。
;; (require 'mmm-mode)
(setq mmm-global-mode 'maybe)
(mmm-add-mode-ext-class nil "\\.php?\\'" 'html-php)
(mmm-add-classes
'((html-php
:submode php-mode
:front "<\\?\\(php\\)?"
:back "\\?>")))
(add-to-list 'auto-mode-alist '("\\.php?\\'" . xml-mode))
インストールの後.emacsに書く。これで<php? ?>で囲まれた部分だけphp-mode、外はxml-modeで動く。
いままでPHPとかrhtmlなどのHTML埋め込み方式のテンプレートが嫌いで、ZPT・amritaなどのXMLの範囲内でできるテンプレートが好きなのはEmacsでの編集が仕辛いのが大きな理由でした。mmm-modeができるようになったことで変わるかな?とにかくRailsでrhtmlになるので頑張ってみようと思っているのですが。
2007年04月07日
Mercurial
分散型SCMの一つ。Pythonで書かれています。
rpm.orgが使っていると書いてある。
GINA
GINA (Graphical Identification and Authentication)はMS Windowsの認証部分を変更するためのインターフェイス、とおおざっぱに言うとそういう話。
2007年03月15日
bootable CDを作る
mkisofsを使ってbootable CDを作る方法。
おまじないで悪いけどいきなり書きます。
mkisofs -l -r -J -V "My CDROM" -b boot/isolinux/isolinux.bin \
-c boot/isolinux/boot.catalog \
-o /tmp/myknopp.iso -no-emul-boot -boot-load-size 4 \
/var/tmp/mnt
- -l 長いファイル名
- -r Rock Ridge拡張をもうちょっと便利にしたものらしい
- -J Joliet拡張
- -V ボリュームID
- -b bootイメージ。ルートからの相対パス
- -c カタログを生成するパス。-bと同じく相対パス
- -o 生成するイメージのパス
- -no-emul-boot おまじない
- -boot-load-size 4 おまじないだからわかんないって
- /var/tmp/mnt CDにするファイルのパス
参考
最短距離を進んでばかりではつまらない
最短距離を進んでばかりではつまらない。
でも、素直にハードウェアが認識されたほうが楽なんだけど。うがー。
2007年03月06日
sshで内部へのトンネル
sshを使って外から内側へのトンネルを作る
2007年02月27日
tcptrace
tcpdumpの出力を解析してレポートに出してくれる。
# tcpdump -w dumpfile
# tcptrace dumpfie
あと、tcpdump以外も読めますと書いてあったが試してないのでよくわからない。
2007年02月02日
Hyper Estraierでメール検索
先延ばしにしていたけどやってみることに。
# find ~/Maildir -type f | grep /cur/ | estcmd gather -cl -fm -cm casket -
としてインデックを作成。estseek.cgiやestseek.conf等をコピーしてきてCGIとして動かす。Wanderlustに組込みたいが2年前にパッチが出て以来進行してない模様。
http://qdbm.sourceforge.net/mikio/osmftsspecial/2007年01月24日
gmailfs
今さらですがgmailfsを実験。
# aptitude install gmailfs
# aptitude install fuse-source
# m-a a-i fuse
ここでinsmod fuseがあるかもないかも
# mount mount -t gmailfs none /mount/point/gmailfs -o username=gmailuser,password=gmailpass,fsname=secret
てな具合です。
カーネルモジュールのインストールがいつのまにか便利になっていて、module-assistantパッケージのおかげかな、なーんにも考えなくてもモジュールが入ってしまう。fsnameのパラメータは他人に推測されない文字列にしましょう。なぜこんなものがいるかというと、gmailはメールボックスなので他人からメールを送られることがあるわけです。そのときgmailfsが使っているものと区別するために使います。

