5月 13th, 2015






postcommit_pl.tar.gz BugFreeforSVN.tar.gz


使iphone ssh可以输入中文

3月 8th, 2013

set input-meta on
set meta-flag on
set output-meta on
set convert-meta off




11月 2nd, 2012

iphone 4s, ios5.
表现: ssh一直不能使用,不能连接到iphone的sshd. 用sbsettings开,关无效。
怀疑 sbsettings,启用ssh后卸载,重启,无效。
发现文件系统上 /usr/sbin/sshd 在能连上时存在,不能连时,此文件被删除。

经过排查和google,找到了可疑进程poc-bbot,原来这个竟然是 iphone ikee worm。
删除办法 http://www.iphonefaq.org/archives/97723
此毒是通过扫描网段里的22端口,用root帐号alpine密码登录传染jailbroken iphone的。


build arm toolchain

3月 4th, 2012
#this is not a bash script file, just log of commands.
export ARCH=arm
export TARGET=arm-pc-linux-gnueabi
export PREFIX=/usr/arm
export SYSROOT=$PREFIX/sysroot
export PATH=$PREFIX/bin:$PATH
sudo mkdir $PREFIX
#chown to allow make install happy at user level so that we won't crash system files on error.
sudo chown $USER $PREFIX
mkdir -p $SYSROOT/usr/include
#build binutils
mkdir binutils-2.22/build ; cd binutils-2.22/build
../binutils-2.22/configure --target=$TARGET --prefix=$PREFIX --with-sysroot=$SYSROOT  --disable-nls
make install
#build gcc stage1
../gcc-4.6.3/configure --target=$TARGET --prefix=$PREFIX --enable-interwork --enable-languages=c --without-headers --disable-shared --disable-threads --with-gnu-as --with-gnu-ld
make all-gcc all-target-libgcc
#cd arm-* ; make libgcc_eh.a
make install-gcc install-target-libgcc
#linux headers
make at91rm9200dk_defconfig
make include/linux/version.h
cp -a include/linux          $SYSROOT/usr/include/
cp -a include/asm-generic    $SYSROOT/usr/include/
cp -a ./arch/arm/include/asm $SYSROOT/usr/include/
cp -a ./arch/x86/include/asm/ioctl.h  $SYSROOT/usr/include/asm/
cp -a ./arch/x86/include/asm/errno.h  $SYSROOT/usr/include/asm/
cp -a ./arch/avr32/include/asm/bitsperlong.h $SYSROOT/usr/include/asm/
#build eglibc
cd eglibc-2.14/libc ; ln -s ../linuxthreads . ; ln -s ../ports .
mkdir ../../build
cd ../../build
../eglibc-2.14/libc/configure --prefix=/usr --host=$TARGET --enable-add-ons --with-headers=$SYSROOT/usr/include
vim config.make
#add -march=armv6 -mfpu=vfp to CFLAGS
make install_root=$SYSROOT install
#build gcc stage2
../gcc-4.6.3/configure --target=$TARGET --prefix=$PREFIX --enable-languages=c,c++ --with-sysroot=$SYSROOT

fix openwrt network script bug

1月 23rd, 2012

On my router there are some interfaces in /etc/config/network. The wan interface is configured as a PPPOE netowrk to connect my ISP. There is also a pptp-vpn connected named zvpn. I found it is very slow to run “/etc/init.d/network reload”, taking about 2 miniutes. If I comment out the zvpn interface, it runs fast.

Obviously, the vpn connection depends on my main connection — the wan interface which works in PPPOE mode. So this should be the key point. I spent many hours before to find how to config the dependency, including asking this question in the openwrt forum, but with no luck.  Today I wrote some debug statements in the network scripts and almost brick my router to find what is wrong, finaly I got it.

I thought it is because the vpn interface is inited before wan, so I named my vpn interface as zvpn to make it as the last one,  but I’m wrong.  I don’t need to care its name.  The network scripts load each interface in the order of what it is in the configration file — /etc/config/network. However, there is a problem: the network scripts also unload each interface in this order.

We know, the unload order should be the reverse of the load order. This can be changed by patch /sbin/ifdown.

This is the patch:

--- /rom/sbin/ifdown        2012-01-21 22:21:29.000000000 +0800
+++ ifdown      2012-01-23 17:23:46.000000000 +0800
@@ -7,10 +7,17 @@
 case "$1" in
                [ -e "/tmp/resolv.conf.auto" ] && rm /tmp/resolv.conf.auto
+               TODO=
                config_cb() {
-                       [ interface != "$1" -o -z "$2" ] || eval "$0 -w $2"
+                       [ interface != "$1" -o -z "$2" ] || TODO="$2 $TODO"
                config_load network
+               for i in $TODO ; do
+                       $0 -w $i
+               done
                exit 0
        "-w") shift ;;

Openwrt has a recovery mode that helps me to unbrick my router after I made some bad modifications to the config files. To enter this mode, power off the router, hold reset button, power on, keep holding reset button until replying ping requests. Then just telnet, mount -t jffs2 /dev/mtdblock3 /overlay/, and fix problems there.


install vmware tools on debian (guest) for newest kernel (3.1.0)

1月 19th, 2012

vmware version: vmware workstation 8.0.1 build-528992
debian kernel: 3.1.0-1-486
vmware tools fails to install or run.

1. apt-get install libglib2.0-0
2. patch /usr/lib/vmware-tools/modules/source/vmhgfs.tar
unpack vmhgfs.tar, patch, repack.
the patch:

diff -ur vmhgfs-only-old/file.c vmhgfs-only/file.c
--- vmhgfs-only-old/file.c      2011-11-14 11:41:31.000000000 +0800
+++ vmhgfs-only/file.c  2012-01-19 17:59:47.899616529 +0800
@@ -84,6 +84,8 @@
 #if defined VMW_FSYNC_OLD
                      struct dentry *dentry,
+                                        loff_t start,
+                                        loff_t end,
                      int datasync);
 static int HgfsMmap(struct file *file,
                     struct vm_area_struct *vma);
@@ -990,6 +992,8 @@
 #if defined VMW_FSYNC_OLD
           struct dentry *dentry,        // IN: Dentry for this file
+                 loff_t start,
+                 loff_t end,
           int datasync)                        // IN: fdatasync or fsync
    LOG(6, (KERN_DEBUG "VMware hgfs: HgfsFsync: was called\n"));
diff -ur vmhgfs-only-old/filesystem.c vmhgfs-only/filesystem.c
--- vmhgfs-only-old/filesystem.c        2011-11-14 11:41:31.000000000 +0800
+++ vmhgfs-only/filesystem.c    2012-01-19 16:41:00.303867660 +0800
@@ -358,6 +358,8 @@
    HgfsSuperInfo *si;
    HgfsMountInfo *mountInfo;
    struct dentry *rootDentry;
+   struct dentry *tmpDentry;
+   struct inode *inode;
@@ -408,15 +410,15 @@
     * and superblock. Then HgfsInstantiate will do the rest, issuing a getattr,
     * getting the inode, and instantiating the dentry with it.
-   rootDentry = compat_d_alloc_name(NULL, "/");
+   inode = new_inode(sb);
+   tmpDentry = d_alloc_root(inode);
+   rootDentry = compat_d_alloc_name(tmpDentry, "/");
    if (rootDentry == NULL) {
       LOG(4, (KERN_WARNING "VMware hgfs: HgfsReadSuper: Could not allocate "
               "root dentry\n"));
       result = -ENOMEM;
       goto exit;
-   rootDentry->d_parent = rootDentry;
-   rootDentry->d_sb = sb;
    result = HgfsInstantiate(rootDentry, HGFS_ROOT_INO, NULL);
    if (result) {
       LOG(4, (KERN_WARNING "VMware hgfs: HgfsReadSuper: Could not instantiate "

some notes for mac osx dev.

1月 8th, 2012

set install_name for dylib
g++ -install_name xxx.o -o xxx.dylib

view install_name:
method1: otool -L xxx.dylib see the first row.

change install_name
install_name_tool -change old.dylib new.dylib xxx.dylib

pack libs
lipo -create a_32.dylib a_64.dylib -output a.dylib


patch mindmanager to avoid fuzzy text.

12月 28th, 2011

mindmanager is a great tool, but it has a bug (or they the devlopers may think it’s a feature) not fixed for years. That is, the fuzzy text problem. Just search mindmanager fuzzy text , there are many results about this bug and some patches for the old versions of mindmanager. Just as what is said from http://forum.us.mindjet.com/viewtopic.php?f=16&t=3060 ,disabling the call to GdipSetTextRenderingHint fixes this bug.

steps to make a patch
1. open a debugger, ex: ollydbg, load mindmanager.
2. break at GdipSetTextRenderingHint (gdiplus.dll!_GdipSetTextRenderingHint@8)
3. when it break down, track the call to it. It’s something like:

00688A2D  call        00CC8792

goto 00CC8792 , it is something like:

00CC8792  jmp         dword ptr ds:[0E5A758h]

change it to :
retn 8
code bytes: c2 08 00 90 90 90
4. save the modification to mindmanager.exe
5. done, enjoy clear text.


patch openwrt to avoid “bad substitution”

11月 13th, 2011

when editing some configration of openwrt , this error maybe occured:
/sbin/ifup: eval: line 1: syntax error: bad substitution

I found at least one reason of this error code, and fixed it.

--- /rom/lib/network/config.sh
+++ config.sh
@@ -15,7 +15,7 @@
        local fam
        for fam in ipv4 ipv6; do
-               if [ -d /proc/sys/net/$fam ]; then
+               if ls /proc/sys/net/$fam/*/$ifn 2>/dev/null ; then
                        local key
                        for key in /proc/sys/net/$fam/*/$ifn/*; do
                                local val

If there is no such file , $key is “/proc/sys/net/ipv4/*/eth1:1/*” before this modification, statements in then case are not executed after modification. so this code resolved the problem of reporting:
/sbin/ifup: eval: line 1: syntax error: bad substitution


Google’s IP Range

8月 30th, 2011

the following ip addresses belong to google. – – – – – – –