发布新日志

  • 琅山的经纬度

    2008-09-29 21:49:28

    东经29.16.7425

    北纬106.16.0853

    用软件计算出来的角度如下:

    地名不详
    经度:东经106.16度
    纬度:北纬29.16度

    卫星名称                            卫星经度  天线仰角  天线方位角    极化角 
    --------------------------------------------------------------------------------
    国际703  (InterSat-707)             57.0      27.10     南偏西67.16度 -53.59 
    国际604  (InterSat-604)             60.0      29.68     南偏西64.92度 -52.28 
    国际602  (InterSat-602)             62.0      31.38     南偏西63.35度 -51.31 
    国际804  (InterSat-804)             64.0      33.07     南偏西61.71度 -50.26 
    国际704  (InterSat-704)             66.0      34.73     南偏西60.00度 -49.13 
    泛美4/7  (PanamSat-4/7)             68.5      36.79     南偏西57.73度 -47.60 
    俄星LMI1 (LMI1)                     75.0      41.90     南偏西51.14度 -42.84 
    亚太2R   (ApStar-2R)                76.5      43.02     南偏西49.45度 -41.57 
    航向1号  (Luch-1)                   77.0      43.39     南偏西48.87度 -41.13 
    泰星2/3  (ThaiCom-2/3)              78.5      44.48     南偏西47.09度 -39.76 
    快车6号  (Express-6)                80.0      45.54     南偏西45.23度 -38.31 
    印度2E   (InSat-2E)                 83.0      47.55     南偏西41.28度 -35.18 
    中卫1号  (ChinaStar-1)              87.5      50.29     南偏西34.73度 -29.83 
    中新1号  (ST-1)                     88.0      50.57     南偏西33.95度 -29.19 
    马星1号  (MeaSat-1)                 91.5      52.36     南偏西28.23度 -24.40 
    印度2B/2 (CInSat 2B/2C)             93.5      53.25     南偏西24.75度 -21.44 
    国际K-TV (NSS K-TV)                 95.0      53.84     南偏西22.04度 -19.13 
    亚洲2号  (AsiaSat-2)                100.5     55.43     南偏西11.50度 -10.02 
    亚洲3号  (AsiaSat-3S)               105.5     55.99     南偏西1.35度  -1.18  
    百合花   (Bsat-1A/1B)               110.0     55.73     南偏东7.84度  6.84   
    鑫诺1号  (SinoSat-1)                110.5     55.66     南偏东8.85度  7.72   
    帕拉帕C2 (Palapa-C2)                113.0     55.17     南偏东13.83度 12.05  
    中星8号  (待发射)                   115.5     54.47     南偏东18.65度 16.22  
    韩星1/2  (KoreaSat-1/2)             116.0     54.31     南偏东19.59度 17.03  
    泰星1A   (ThaiCom-1A)               120.0     52.74     南偏东26.82度 23.21  
    亚洲1号  (AsiaSat-1)                122.0     51.79     南偏东30.21度 26.07  
    日本通信4号 (JcSat-4)               124.0     50.74     南偏东33.45度 28.77  
    中星6号  (ChinaSat-6)               125.0     50.19     南偏东35.00度 30.06  
    日本通信3号 (JcSat-3)               128.0     48.40     南偏东39.44度 33.69  
    亚太1A号 (ApStar-1A)                134.0     44.35     南偏东47.31度 39.93  
    亚太1号  (ApStar-1)                 138.0     41.38     南偏东51.88度 43.39  
    超鸟C    (SuperBird-C)              144.0     36.64     南偏东57.90度 47.71  
    马步海   (Agila-2)                  146.0     35.00     南偏东59.72度 48.95  
    超鸟B1   (SuperBird-B1)             162.0     21.27     南偏东71.70度 56.01  
    泛美8号  (PanamSat-8)               166.0     17.75     南偏东74.19度 57.16  
    泛美2号  (PanamSat-2)               169.0     15.11     南偏东75.96度 57.91  
    国际802  (InterSat-802)             174.0     10.69     南偏东78.78度 58.93  
    国际702  (InterSat-702)             177.0     8.05      南偏东80.39度 59.43  
    国际701  (InterSat-701)             180.0     5.42      南偏东81.96度 59.85  

  • 在内核中执行用户空间程序

    2008-09-11 22:11:59

    #include <linux/kernel.h>
    #include <linux/init.h>
    #include <linux/module.h>
    #include <linux/kmod.h>
    #include <asm/uaccess.h>

    MODULE_LICENSE("GPL");

    static int __init test_init(void)
    {
            char *argv[] = {
                    "/bin/sh",
                    "-c",
                    "mkdir test",
                    NULL};
            char *env[] = {
                    "ROOT=/",
                    "TERM=linux",
                    "PATH=/sbin:/usr/sbin:/bin:/usr/bin",
                    NULL};
            int ret;

            ret = call_usermodehelper(argv[0], argv, env, 1);

            return 0;
    }

    static void __exit test_exit(void)
    {
    }

    module_init(test_init);
    module_exit(test_exit);

     

     

     

    http://hi.baidu.com/wzt85/blog/item/8e17922e88ab7c554ec22604.html

  • 配置linux使之支持ipv6中继

    2008-08-30 14:54:54

  • 偶老家的经纬度

    2008-08-17 13:59:03

    因为外婆到家里来了,今天上午回了趟老家。

    于是用gps测了下老家的位置。

    北纬:28.54.7263

    东经:106.21.1357

    海拔:333.7米

  • 对于动态代码的情况,用来Dump出来处理过的代码(update)

    2008-08-14 17:15:55

    有些程序pack了一些代码,这些代码是在程序运行的时候重新组合出来的。为了更好的分析他们,最好是直接dump出来。下面就是IDC的代码,用来dump debug运行出来的代码。
    此时会弹出三个窗口,第一个询问目的文件名,第二个和第三个用来输入需要dump出来的线性地址范围。

    static DumpSegment(){
    auto xx;
    auto saddr,eaddr,dw;

    xx=fopen(AskFile(1, "e:\yjzg.txt", "Dump Segment to File:"), "wb+");

    saddr=AskAddr(0x401000, "Input Start Address");
    eaddr=AskAddr(0x466000, "Input  Stop Address");
    Message("StartAddr:%d\n", saddr);
    Message("Stop Addr:%d", eaddr);
    for (dw=saddr;dw<eaddr;dw=dw+4){
      writelong(xx, Dword(dw), 0);
    };
    fclose(xx);
    }

     

     

    http://reverseengineer.ycool.com/post.577483.html

  • 一段处理汇编的代码

    2008-08-14 08:30:40

    // asmkey.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include #include #include struct aa { char name[16]; char val[8]; struct aa *next; }; int main(int argc, char* argv[]) { FILE * fp ,*fp1; char buffer[128]; char temp[128]; struct aa *zhi; struct aa *head,*curren,*tmp; char *p1,*p2,*p3,*p4,*p5; int len; int biaoz=0; head =NULL; fp=fopen("vndioPart.asm","r"); if(fp == NULL) { printf("不能打开输入文件\n"); return 1; } fp1=fopen("out.asm","w"); if(fp == NULL) { printf("不能打开输出文件\n"); return 1; } fputs("//__declspec(naked) int unlimt(unsigned char * buff)\n",fp1); fputs("//{\n",fp1); fputs("// __asm\n",fp1); fputs("// {\n",fp1); fputs("// 汇编\n",fp1); fputs("// }\n",fp1); fputs("//}\n",fp1); fputs("\n",fp1); fputs("\n",fp1); while (fgets(buffer,128,fp) != NULL) { len = strlen(buffer); if (len <= 1) continue; if (memcmp(buffer,";",1) == NULL) continue; if (strstr(buffer,"near") != NULL) { p5 = strstr(buffer,"proc"); *(p5-1) = ':'; *p5 = '\0'; strcpy(temp,buffer); biaoz += 1; if (biaoz >= 2) { fputs("\n",fp1); fputs(temp,fp1); fputs("\n",fp1); fputs("\n",fp1); } continue; } if (strstr(buffer,"endp") != 0) { curren = head; while (curren != NULL) { tmp = curren; curren = curren->next; free(tmp); } head = NULL; continue; } p1= strstr(buffer,"="); if ( p1 != NULL) { if (head == NULL) { head = (struct aa *)malloc(sizeof(struct aa)); memcpy(head->name,buffer,(p1-buffer)); head->name[p1-buffer]='\0'; p2 = strrchr(buffer,' '); memcpy(head->val,p2+1,(buffer + len - p2)); head->val[buffer + len - p2 + 1]='\0'; head->next = NULL; }else { curren = head; while (curren->next != NULL) { curren = curren->next; } zhi = (struct aa *)malloc(sizeof(struct aa)); curren->next = zhi; zhi->next=NULL; memcpy(zhi->name,buffer,(p1-buffer)); zhi->name[p1-buffer]='\0'; p2 = strrchr(buffer,' '); memcpy(zhi->val,p2+1,(buffer + len - p2)); zhi->val[buffer + len - p2 + 1]='\0'; } continue; } curren = head; while (curren != NULL) { p3 = strstr(buffer,curren->name); if ( p3 != NULL) { memcpy(temp,buffer,p3-buffer); temp[p3-buffer] = ' '; temp[p3-buffer+1] = '\0'; strcat(temp,curren->val); temp[strlen(temp)-1] = '\0'; p4 = strrchr(buffer,']'); if (p4 != NULL) strcat(temp,p4); /*printf("%s\n",temp);*/ break; } else { memcpy(temp,buffer,len); temp[len] = '\0'; } curren = curren->next; }; fputs(temp,fp1); } fclose(fp); fclose(fp1); printf("转换完成!\n"); return 0; }
  • Config Linux as a gateway of 6to4 tunnel IPv6 network

    2008-07-25 16:24:05

    How to user 6to4 tunnel provided by Hurricane Electric to build up IPv6 network with a Linux gateway (Centos 5).
    Network TOP:Steps:
    1. Apply for a 6to4 tunnel, and we get the following information:
    Server IPv4 address: 72.52.104.74
    Server IPv6 address: 2001:470:1f04:571::1/64
    Client IPv4 address: 202.115.19.145
    Client IPv6 address: 2001:470:1f04:571::2/64
    Routed /64: 2001:470:1f05:571::/64
    2.Check /etc/sysconfig/network have the following line:
    NETWORKING_IPV6=yes
    3.Enable IPv6 on the Linux route, using the following commands and make sure they have written into /etc/rc.local so that it can work after reboot.
    /sbin/ifconfig sit0 up
    /sbin/ifconfig sit0 inet6 tunnel ::72.52.104.74
    /sbin/ifconfig sit1 up
    /sbin/ifconfig sit1 inet6 add 2001:470:1f04:571::2/64
    /sbin/ip route add 2000::/3 dev sit1
    4.Enable to IPv6 forwarding (routing)
    echo 1 >/proc/sys/net/ipv6/conf/all/forwarding
    5.Configure the local network using the following command and write it down into /etc/rc.local. ( eth0 is connected with other client on LAN),
    /sbin/ifconfig eth0 inet6 add 2001:470:1f05:571::1/64
    6.Install "radvd" for IPv6 Stateless Address Autoconfiguration.
    yum install radvd -y
    7.Edit the /etc/radvd.conf like this:
    interface eth0
    {
    AdvSendAdvert on;
    MinRtrAdvInterval 30;
    MaxRtrAdvInterval 100;
    prefix 2001:470:1f05:571::/64
    {
    AdvOnLink on;
    AdvAutonomous on;
    AdvRouterAddr off;
    };
    };
    8.The network is OK. visit ipv6.google.com or ipv6.org can check the new IPv6 network.
    9.You could install the DHCPv6 if you want use the IPv6 Stateful Autoconfiguration.( I still have the problem of LOSEING information of the default gateway when using DHCPv6, NEED YOUR HELP)
    yum install dhcpv6 -y
    edit /etc/dhcp6s.conf like this: (This config DON'T work well, the client will lack of the default gateway)
    interface eth0 {
    server-preference 255;
    renew-time 60;
    rebind-time 90;
    prefer-life-time 130;
    valid-life-time 200;
    allow rapid-commit;
    option dns_servers 2001:470:1f05:571::1 domain.org;
    link AAA {
    pool{
    range 2001:470:1f05:571::2 to 2001:470:1f05:571::FFF1/64;
    2001:470:1f05:571::/64;
    };
    };
    };
  • 没有头文件怎么用别人的dll

    2008-07-18 13:07:46

    最近搞个程序,用到md5加密,结果看了几个md5加密后,相同的数据结果不同,郁闷了!后面找到一个别人的加密程序算的结果一样,还好它里面算法是用dll实现的,呵呵!借来用了!
         先用od把它载入,然后查看可执行模块,选择我们的程序,右键查看名称,找到里面MD.dll导入的几个函数的地方,里面支持md2,md4,md5.我只要md5了,右键在每个参考上设置断点,运行,找到计算md5的地方,让它调用md5函数,od断下
     断到这里
    004520CF   .  68 6ED94500   push    0045D96E                         ;  ASCII "sfddfdsfsdf"
    004520D4   .  50            push    eax
    004520D5   .  68 6EF14500   push    0045F16E
    004520DA   .  E8 D34E0000   call    <jmp.&MD.MD5>

    从call 的地方看.前面3个push是参数了.
    函数的基本原型应该可以这样定义 int md5(参数1,参数2,参数3)  (一般dll的导出函数都遵循从右到左压参)
    现在就是来查清楚每个参数对应的是甚么了.
    004520CF   .  68 6ED94500   push    0045D96E                         ;  ASCII "sfddfdsfsdf"
    从od给的提示看,很明显参数3对应的是 原字符串的地址
    004520D4   .  50            push    eax
    我们看eax 寄存器存的是甚么?  其内容是 0000000B (正好是原字符串长度),基本确定参数2就是参数3的长度了
    004520D5   .  68 6EF14500   push    0045F16E
    这个是个内存地址,在od的数据窗口里面,选中这个地址段,看到的数据是乱码.(怀疑应该是返回值)
    0045F16E  C6 B9 90 85 27 A3 D3 74 45 8A 9C 3F 2B 07 B4 C1  乒悈'StE姕?+戳
    F8单步跟踪,同时查看 0045F16E  地址的内存数据变化
    0045F16E  4E BC CE 0B F5 73 0E E0 53 68 91 A3 47 3A A5 06  N嘉 鮯郤h懀G:?
    看内容变化,基本确定是返回值了!
    现在函数原型我们就基本确定了!
    int md5(char* reback,int len,char* input);
     基本来说这边的事情已经就完成了.
    现在可以搞程序了
    在程序里面先定义函数指针类型
    typedef int (_stdcall *MYMD5)(char* reback,int len,char* input);

    开始调用dll
    HMODULE hDll = NULL;
    MYMD5 md5 = NULL;
    hDll = ::LoadLibrary("md.dll"); //载入dll
    if (hDll)
    {
       md5 = (MYMD5)::GetProcAddress(hDll,(LPCSTR)4);//载入函数
                              //在md.dll里面md5函数的编号是4,用工具DEPENDS.EXE可以查看dll的导出函数名和编号
       if (md5 == NULL)
       {
           return FALSE;
       }
      }
    //................
    //这里中间就可以使用 函数md5了
    //....................
    if (hDll)
        ::FreeLibrary(hDll);//最后释放dll
  • 在Linux中实现虚桩式内核模块

    2008-07-18 13:06:00

    最近在把以前做的一个驱动程序在线加载技术移植到SuSE的AutoYaST安装系统中时遇到了一点小麻烦。AutoYaST采用SuSE自己编写的Linuxrc作为其初期引导部分,有别于大部分常规的initrd引导部分,Linuxrc是直接用C语言编写的,而且几乎没有提供什么扩充的灵活性。如此一来,就无法像以往移植到其它环境中那样单纯修改引导脚本就可以搞定。虽说直接修改Linuxrc的源码也可以达到这个目的,但这样就增加了后期维护的复杂度。唉,还真是个头疼的问题……

    仔细分析了一下AutoYaST的设计,发现它至少还是允许增补驱动程序的,但仅仅支持最简单的用配置文件写死的insmod方式…… 好吧,只要还给了这个勉强算得上可扩充的途径,我一样能把驱动在线加载模块集成进来。由于只能固定调用某个驱动,所以必须从内核模块下手。把现有程序改造成内核模块显然是不现实的,好在Linux内核中还提供了这样一个调用用户态程序的接口:call_usermodehelper(),你可以在kmod.h中找到它。功能很简单,调用一个用户态程序,并且可以选择是否阻塞直到它执行完成。

    顺着这个思路,只要写一个简单的虚桩式内核模块,在其初始化函数中调用我们真正想要执行的用户态程序即可达到目的了。但是,当我提出这个方案后,立即有同事质疑:在内核模块初始化阶段加载别的内核模块,搞不好会锁死内核吧?“搞不好”至少说明他也不肯定,为了找寻答案,我分析了一下内核中系统调用sys_init_module()的代码(以2.6.17为蓝本)。

    asmlinkage long
    sys_init_module(void __user *umod,
    		unsigned long len,
    		const char __user *uargs)
    {
    	......
    
    	/* Only one module load at a time, please */
    	if (mutex_lock_interruptible(&module_mutex) != 0)
    		return -EINTR;

    刚进入就加锁了,似乎有点不妙。紧接着开始加载内核模块:

    	/* Do all the hard work */
    	mod = load_module(umod, len, uargs);
    	if (IS_ERR(mod)) {
    		mutex_unlock(&module_mutex);
    		return PTR_ERR(mod);
    	}
    
    	/* Now sew it into the lists.  They won't access us, since
               strong_try_module_get() will fail. */
    	stop_machine_run(__link_module, mod, NR_CPUS);
    
    	/* Drop lock so they can recurse */
    	mutex_unlock(&module_mutex);
    
    	blocking_notifier_call_chain(&module_notify_list,
    			MODULE_STATE_COMING, mod);
    
    	/* Start the module */
    	if (mod->init != NULL)
    		ret = mod->init();

    看来这段代码的作者(或维护者)似乎早就预见到了我所面临的场景。内核模块的加载和初始化被清晰的分为两步,由于加载过程需要链接内核模块,因此必须加锁,而后续的初始化过程已经不会影响内核的完整性了,所以自然可以在解锁后进行。

    排除这个疑虑后,我写了一个简单的用于检验上述思路的内核模块:

    #include <linux/kernel.h>
    #include <linux/module.h>
    #include <linux/kmod.h>
    
    static int __init kmod_init(void)
    {
            int ret;
            char *envp[] = {
                    "PATH=/sbin:/bin",
                    NULL
            };
            char *argv[] = {
                    "/sbin/modprobe",
                    "--first-time",
                    "e1000",
                    NULL
            };
            if ((ret = call_usermodehelper(argv[0], argv, envp, 1)) != 0)
                    printk(KERN_ERR "Kmod test failed! (%d)\n", ret);
    
            return ret > 0 ? - ret : ret;
    }
    
    static void __exit kmod_exit(void)
    {
    }
    
    module_init(kmod_init);
    module_exit(kmod_exit);
    
    MODULE_LICENSE("GPL");

    用insmod插入它时实际上调用了用户态的modprobe插入另一个内核模块e1000。如果不希望将这个虚桩留在内核中,也可以通过在kmod_init中返回-1将自身从内核中移除。

    验证结果表明这个虚桩式内核模块的方案完全是可行的,而且与被加载的实际内核模块之间没有任何耦合及影响,它们可以各自独立的被卸载。

  • Kerio and Debian

    2008-06-02 13:59:00

    Wow! just wow!

    I've been looking for a decent groupware for a small start-up company. Therefore I've been trying out Scalix, Zimbra, OpenXchange (absolute nightmare to get running*) and others. While Scalix and Zimbra are indeed serious concurrence, Kerio just stunned me by it's ease of installation (Scalix took me 1 day, zimbra 1 week, Kerio 5 minutes.**) and administration. Everything seems to work right out of the box.

    Being a debian/ubuntu fan, I am missing a Kerio debian version though. It's a real pitty, because Kerio is indeed working (almost) out of the box in debian. As far as i can see the only thing that has to be rewritten is the start-stop script in /etc/init.d/.

    I hope this encourages you to release a debian version of Kerio Mailserver.

    Disclaimer: This is neither an official nor a supported way of installing. I am not responsible for any damage resulting from following this HowTo. Do it on your own responsibility!

    Here's how I did it:

    1. Get a clean Debian Etch Server System
    2. If postfix/sendmail is installed, remove it:
    apt-get remove postfix sendmail
    

    3. Install the needed packages:
    alien: Provides the RPM-to-DEB-Conversion
    libstdc++5: Required
    apt-get install alien libstdc++5
    

    4. Download the Kerio Linux RPM-Package
    5. Transform the RPM into a DEB
    alien --to-deb --keep-version --scripts kerio-kms-6.3.1-2402.linux.i386.rpm
    

    6. Install the Package
    dpkg -i kerio-kms_6.3.1-2402.linux_i386.deb
    

    7. Switch to the Kerio installation dir, and start config wizard
    cd /opt/kerio/mailserver
    ./cfgwizard
    

    8. As /etc/init.d/keriomailserver won't work, just stay in the dir. and start it manually: et voilà!
    ./mailserver
    


    The admin tool can be installed accordingly on a local computer. (Don't know what a gui's doing on a server ;))

    * The new version is still in alpha though...
    ** All of them running in "unsupported" debian etch environments, normally you probably could install all of them in less than an hour!


    I am running Kerio on a XEN domU Virtual Server under Debian Etch 4.0 with 2.6.18 kernel

    [Updated on: Wed, 25 April 2007 21:56]

     

     

    And /etc/init.d/keriomailserver:

    case "$1" in
        start)
            echo -n "Starting Kerio MailServer: "
            ulimit -c unlimited
            ulimit -s 2048
            ulimit -n 4096
            cd /opt/kerio/mailserver && ./mailserver
            echo "OK"
        ;;
        stop)
            echo -n "Stopping Kerio MailServer: "
            PID=`pidof mailserver`
            if [ "$PID" ] ; then
                kill $PID
                echo "killing...."
            else
                echo "not running?"
            fi
        ;;
    esac
    

    [Updated on: Fri, 09 November 2007 12:03]

  • Linux下修改SCSI硬盘序列号

    2008-05-31 11:09:24

    Linux下修改SCSI硬盘序列号

    IDE硬盘的序列号只需要调用一个ioctl就可以,google一下就出来了。但是我发现很多人说SCSI硬盘没有序列号,那么在我机器上scsiinfo -a /dev/sda打印出来的是什么。。。。?
    Vendor:                    ATA
    Product:                   HTS541080G9SA00
    Revision level:            MB4I
    Serial Number '      MPBDPAXNHPUY1M'
    于是apt-get source scsitools, 分析一下scsiinfo的源码就知道如何获取SCSI硬盘的序列号了,用了SG_IO这个ioctl, 参数是一个sg_io_hdr_t 结构体。想要修改它只需要欺骗应用程序就行了,写一个module,截获这个ioctl并将自己想要的值返回给应用程序。不过2.6内核sys_call_table好像不导出了,那么在/boot/System.map-`uname -r`这个文件中查找sys_call_table的入口地址直接写到程序里,代码如下,把SCSI硬盘序列号改成全A:
    #include <linux/init.h>
    #include <linux/kernel.h>
    #include <linux/module.h>
    #include <scsi/scsi.h>
    #include <scsi/sg.h>

    void **sys_call_table;
    #define __NR_ioctl 54
    typedef struct{
        int a[2];
    }id;

    asmlinkage long (*old_ioctl)(unsigned int fd, unsigned int cmd, unsigned long arg);
    asmlinkage long new_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
    {
        if(cmd == SG_IO) {
            int i;
            sg_io_hdr_t sgh = *(sg_io_hdr_t *)arg;
            unsigned char *cmdp = sgh.cmdp;
            unsigned char *buffer = sgh.dxferp;
            if(cmdp[0]==0x12 && cmdp[2]==0x80) {
                int ret = (*old_ioctl)(fd, cmd, arg);
                int leng = buffer[3];
                for(i = 0; i < leng; i++)
                    buffer[4 + i] = 'A';
                buffer[4 + i] = '\0';
            } else
                return (*old_ioctl)(fd, cmd, arg);
            return 0;
        } else
            return (*old_ioctl)(fd, cmd, arg);
    }

    int syscall_init(void)
    {  
        printk("syscall_init!\n");
        sys_call_table=(void *)0xc02824c0;
        old_ioctl=sys_call_table[__NR_ioctl];
        sys_call_table[__NR_ioctl]=&new_ioctl;

        return 0;
    }
    void syscall_exit(void)
    {
        sys_call_table[__NR_ioctl]=old_ioctl;
            printk("syscall_exit!\n");
    }
    module_init(syscall_init);
    module_exit(syscall_exit);
    MODULE_LICENSE("GPL");

    insmod这个模块后再scsiinfo -a /dev/sda看看?
    Vendor:                    ATA
    Product:                   HTS541080G9SA00
    Revision level:            MB4I
    Serial Number 'AAAAAAAAAAAAAAAAA'

    OK,可以用。

  • 用迅雷下fs2you...无需raysource

    2008-04-19 22:11:48

    用迅雷下fs2you...无需raysource

    “盗连王” - - 迅雷5必备

    不用raysource下fs2you网盘的文件 - -


    1:打开网盘地址

    2:在浏览器地址栏复制粘贴以下代码

    javascript:window.setTimeout=null;showDirectDownload()

    3:回车...强大的东西出现了 - -



    貌似很多人知道    为了方便还是发一下

    代码而已  跟qq空间一样
  • discuz和ss的rewrite规则

    2008-04-04 14:56:59

            RewriteRule ^(.*)/archiver/([a-z0-9\-]+\.html)\?*(.*)$ $1/archiver/index\.php\?$2&$3
            RewriteRule ^(.*)/forum-([0-9]+)-([0-9]+)\.html\?*(.*)$ $1/forumdisplay\.php\?fid=$2&page=$3&$4
            RewriteRule ^(.*)/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html\?*(.*)$ $1/viewthread\.php\?tid=$2&extra=page\%3D$4&page=$3&$4
            RewriteRule ^(.*)/profile-(username|uid)-(.+)\.html\?*(.*)$ $1/viewpro\.php\?$2=$3&$4
            RewriteRule ^(.*)/space-(username|uid)-(.+)\.html\?*(.*)$ $1/space\.php\?$2=$3&$4

     

    RewriteRule ^/([0-9]+)/spacelist(.+)$ /index.php?uid/$1/action/spacelist/type$2 [L]
    RewriteRule ^/([0-9]+)/viewspace(.+)$ /index.php?uid/$1/action/viewspace/itemid$2 [L]
    RewriteRule ^/([0-9]+)/viewbbs(.+)$ /index.php?uid/$1/action/viewbbs/tid$2 [L]
    RewriteRule ^/([0-9]+)/(.*)$ /index.php?uid/$1/$2 [L]
    RewriteRule ^/([0-9]+)$ /index.php?uid/$1 [L]

    RewriteRule ^/action(.+)$ /index.php?action$1 [L]
    RewriteRule ^/category(.+)$ /index.php?action/category/catid$1 [L]
    RewriteRule ^/viewnews(.+)$ /index.php?action/viewnews/itemid$1 [L]
    RewriteRule ^/viewthread(.+)$ /index.php?action/viewthread/tid$1 [L]
    RewriteRule ^/mygroup(.+)$ /index.php?action/mygroup/gid$1 [L]
    RewriteRule ^/index([\.a-zA-Z0-9]*)$ /index.php
    RewriteRule ^/thread-(.+)$ /index.php?action_viewthread_tid_$1
    RewriteRule ^/forum-(.+)$ /action_forumdisplay_fid_$1

     

     

    下面是litghttpd的规则:

    $HTTP["host"] =~ "^10\.96\.0\.30$" {
      url.rewrite-once = (
                    "^(.*)/archiver/([a-z0-9\-]+\.html)$" => "$1/archiver/index.php?$2",
                    "^(.*)/forum-([0-9]+)-([0-9]+)\.html$" => "$1/forumdisplay.php?fid=$2&page=$3",
                    "^(.*)/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$" => "$1/viewthread.php?tid=$2&extra=page\%3D$4&page=$3",
                    "^(.*)/profile-(username|uid)-(.+)\.html$" => "$1/viewpro.php?$2=$3"
      "^(.*)/space-(username|uid)-(.+)\.html$" => "$1/space\.php\?$2=$3"
            )
    }

  • 使htaccess 认证能退出登录

    2008-03-15 14:57:03

    Introduction::

    There is no way to log out of a .htaccess protected directory, unfortunately browsers have never implemented a "forget password" feature! So we need to be imaginative!

    Browsers only store one password per realm so we need to trick the browser into storing another "fakeusers" credentials.

    This guide will discuss a number of options, not all of these are proven but have been tested with mixed results.



    Method 1::

    The first method is not an actual logout and probably will not appeal to many but it works without fail. Very simply, your "logout" button is actually a "close-window" button. This ends the browser session, wiping the login details, forcing the user to re-enter their details next time they attempt to access the protected directory.

    You can close the browser window without a prompt with the following code:

    <head>
    <script language="JavaScript" type="text/javascript">
    <!--
    function closewindow() {
    self.opener = this;
    self.close()
    }
    //-->
    </script>
    </head>

    <body>
    <a href="JavaScript: closewindow()">Close Window</a>


    You can also try the following which may appeal to you better. When accessing the protected area, open it in a new window, you can then use a standard window closer as the logout button. This has the advantage of keeping the parent window open, which you may prefer. However, I find that this method doesn't always work as the parent window may also store the login credentials.


    Comments:

    1. It works in IE but in Mozilla the browser won't close a window it didn't open.
    2. It means you have to close the browser window which you may not want to do.
    3. You lose focus from your site.


    The following methods all have the same underlying method, to overwrite the logged in users credentials with a fake-users crenditials.



    Method 2::

    We assume you have already created a password protected directory with .htaccess and .htpasswd files. If you haven't then do so immediately! We'll call this directory "Restricted".

    Now, create a sub-directory outside of the "Restricted" directory called (for example) "logout". Password protect this directory allowing access to one fake-user. This fake-user can have a username "fakeuser" and password "fakepass". So directory logout should now contain it's own .htaccess and .htpasswd files allowing access only to user "fakeuser".

    Next we create the logout button.

    In order to replace the login information saved by the browser we overwrite it with the information needed to access directory "logout". As it is a 'logout link' we shouldn't have to enter any user information, this must be carried in the link.

    So our link is:

    <a href="http://fakeuser:fakepass@yourdomain.com/logout/">Logout</a>

    When the link is clicked the username and password allows access to the "logout" directory. You can create an index.htm in the "logout" directory which can display a good-bye message or links to other areas of your site etc.

    Also, since the browser now has saved the "new" user information your users will have to re-login if they want to access the "Restricted" directory, thus completing the appearance of having logged out!


    Comments:

    1. Can be difficult to set up but does work after some effort.
    2. You may run into the problem that the browsers is treating the "logout" directory as a new realm and storing the user credentials for this directory as well as "Restricted" directory.
    3. The following site uses almost the same method: http://www.columbia.edu/acis/webdev/password-logout.html


    Method 3::

    The third method is basically the same as method 2 but for the reasons highlighted above we make one important change.

    This time we place the "logout" directory inside the restricted directory. Again, the "logout" directory allows access only to "fakeuser". The link code must reflect this change:

    <a href="http://fakeuser:fakepass@yourdomain.com/Restricted/logout/">Logout</a>


    Comments:

    1. May get the problem that accessing "Restricted" will also allow you to access "logout" so the method will fail.


    Method 4::

    So far I have been unable to get this to work for me so if you see that i'm doing something wrong and can improve on the method then please let me know so we can share it with others!

    This method involves password protecting an individual file, not a sub-directory!

    Keeping with protected directory "Restricted" now create a file in this directory we can call "logout.htm". This file can contain your good-bye message etc.

    In order to protect this file, using the same "fakeuser" info as previously (fakeuser & fakepass), we need to add the following to the .htaccess:

    <Files logout.htm>
    <Limit ALL>
    AuthUserFile /www/Restricted/.htpasswd
    require user fakeuser
    </Limit>
    </File>

    The logout link is almost the same as in the previous example but we need to direct it to the .htm document rather than a directory:

    <a href="http://fakeuser:fakepass@yourdomain.com/Restricted/logout.htm">Logout</a>

    The result should be the same as previously.

    You may have trouble "merging" password protection for both the Restricted directory and the logout.htm file in the directory. This may take some tweaking to sort out!


    Comments:

    1. Protecting the individual file can be a problem. "Experts" have told me it can be done but I have not had success with this method.
    2. You may need to place the "logout.htm" in a sub-directory of restricted so you can place it's own .htaccess file in that directory.


    Final Comment:

    Don't just rely on the .htaccess to do all the work, there's a number of things you can do to help.
    Example: One application which I created for someone uses SSI extensively to not only redirect each logged in user to their individual directories but keeps users away from other users files and also forces all users to enter only through the login page.



    Your comments:

    Feedback on this guide is very important, it will help the many others who drop in here looking for a solution. So far we have received a number of comments which should help you.




    Quotation from "Apache HTTP Server Version 1.3 - Authentication, Authorization, and Access Control"

    How do I log out?

    Since browsers first started implementing basic authentication, web site administrators have wanted to know how to let the user log out. Since the browser caches the username and password with the authentication realm, as described earlier in this tutorial, this is not a function of the server configuration, but is a question of getting the browser to forget the credential information, so that the next time the resource is requested, the username and password must be supplied again. There are numerous situations in which this is desirable, such as when using a browser in a public location, and not wishing to leave the browser logged in, so that the next person can get into your bank account.

    However, although this is perhaps the most frequently asked question about basic authentication, thus far none of the major browser manufacturers have seen this as being a desirable feature to put into their products.

    Consequently, the answer to this question is, you can't. Sorry.

  • Excle中数字金额转换为人民币大写

    2008-03-04 10:17:31

    =IF(ROUND(E14,2)<0,"无效数值",IF(ROUND(E14,2)=0,"零元",IF(ROUND(E14,2)<1,"",TEXT(INT(ROUND(E14,2)),"[dbnum2]")&"元")&IF(INT(ROUND(E14,2)*10)-INT(ROUND(E14,2))*10=0,IF(INT(ROUND(E14,2))*(INT(ROUND(E14,2)*100)-INT(ROUND(E14,2)*10)*10)=0,"","零"),TEXT(INT(ROUND(E14,2)*10)-INT(ROUND(E14,2))*10,"[dbnum2]")&"角")&IF((INT(ROUND(E14,2)*100)-INT(ROUND(E14,2)*10)*10)=0,"整",TEXT((INT(ROUND(E14,2)*100)-INT(ROUND(E14,2)*10)*10),"[dbnum2]")&"分")))

  • DM500-s的固件修改方法

    2008-02-07 10:42:26

    如何将IMG解包及重新打包

    一、修改中文化菜单,以及修改开机画面都需要将IMG解包unpack,修改后重新打包repack。解包、打包都需要Dreambox的linux环境,当时你也可以自己配置一个支持squashFS的linux来搞。
    DM500S的存储空间十分有限,故需要mount一个NFS磁盘来操作。为什么一定要NFS磁盘?windows机器共享出来的CIFS磁盘不行吗?不行!只有NFS磁盘上才可以执行解包、打包工具,而且解包后的IMG里,有很多是符号连接文件,也只有NFS磁盘才能支持。mount NFS及swap的方法见satfan大侠的文章,已经写得很详细:
    http://www.dm7000s.com/thread-2070-1-2.html
    root@dreambox:/var/mnt/nfs> df -h
    Filesystem                Size      Used Available Use% Mounted on
    /dev/root                 3.8M      3.8M         0 100% /
    /dev/mtdblock/1           2.8M    444.0k      2.3M  16% /var
    192.168.1.8://home/nfs     9.2G    516.4M      8.2G   6% /var/mnt/nfs
    root@dreambox:/var/mnt/nfs> dd if=/dev/zero of=/var/mnt/nfs/ram bs=1M count=128
    128+0 records in
    128+0 records out
    root@dreambox:/var/mnt/nfs> mkswap -c /var/mnt/nfs/ram
    Setting up swapspace version 1, size = 134213632 bytes
    root@dreambox:/var/mnt/nfs> losetup /dev/loop/0 /var/mnt/nfs/ram
    root@dreambox:/var/mnt/nfs> free
                  total         used         free       shared      buffers
      Mem:        30116        29612          504            0          760
    Swap:       131064            0       131064
    Total:       161180        29612       131568
    root@dreambox:/var/mnt/nfs> cat /proc/meminfo
    MemTotal:        30116 kB
    MemFree:           504 kB
    Buffers:           760 kB
    Cached:          20012 kB
    SwapCached:          0 kB
    Active:           9408 kB
    Inactive:        16576 kB
    HighTotal:           0 kB
    HighFree:            0 kB
    LowTotal:        30116 kB
    LowFree:           504 kB
    SwapTotal:      131064 kB
    SwapFree:       131064 kB
    Dirty:               4 kB
    Writeback:           0 kB
    Mapped:           9220 kB
    Slab:             2176 kB
    Committed_AS:    44240 kB
    PageTables:        168 kB
    VmallocTotal:   475136 kB
    VmallocUsed:     28748 kB
    VmallocChunk:   443900 kB
    root@dreambox:/var/mnt/nfs>
    解包、打包工具见附件压缩包 http://blogimg.chinaunix.net/blog/upfile/070701130716.rar
    解压缩后,和原版IMG文件一起放到NFS磁盘下,一共有五个文件:
    - mkcramfs
    - mkdreamboxfs
    - mksquashfs
    - uncramfs
    - undreamboxfs
    为这几个文件增加执行权限:
    [Copy to clipboard] [ - ]CODE:
    root@dreambox:/var/mnt/nfs> chmod +x *
    OK,接下来就可以做解包及打包工夫了。
    将原版的pli IMG解包到img1这个目录下:
    [Copy to clipboard] [ - ]CODE:
    root@dreambox:/var/mnt/nfs> ./undreamboxfs pli-Helenite-dm500-20070417-2696.img ./img1
    9928+0 records in
    9928+0 records out
    Done!
    root@dreambox:/var/mnt/nfs>
    将完成修改的IMG重新打包,这个步骤挺费时间的:

    root@dreambox:/var/mnt/nfs> ./mkdreamboxfs img1 new.img
    Directory data: 164 bytes
    Everything: 1000 kilobytes
    Super block: 76 bytes
    CRC: 72538600
    155648+0 records in
    155648+0 records out
    Ready to make the squashFS part! This can take 1 or 2 minutes!
    Creating big endian 2.1 filesystem on tmp_mkdreambox_3, block size 65536.

    Big endian filesystem, data block size 65536, compressed data, compressed metadata, compressed fragments
    Filesystem size 4963.29 Kbytes (4.85 Mbytes)
            35.86% of uncompressed filesystem size (13840.55 Kbytes)
    Inode table size 6016 bytes (5.88 Kbytes)
            24.73% of uncompressed inode table size (24324 bytes)
    Directory table size 7914 bytes (7.73 Kbytes)
            50.69% of uncompressed directory table size (15614 bytes)
    Number of duplicate files found 49
    Number of inodes 1086
    Number of files 788
    Number of fragments 57
    Number of symbolic links  199
    Number of device nodes 0
    Number of fifo nodes 0
    Number of socket nodes 0
    Number of directories 99
    Number of uids 1
            root (0)
    Number of gids 0
    Done!
    root@dreambox:/var/mnt/nfs>
    为什么要mount上swap呢?因为dm500的内存容量很小,不增加swap的话,打包时就会因为内存不足而无法完成。
    root@dreambox /mnt # ./mkdreamboxfs img2 new.img
    Directory data: 164 bytes
    Everything: 1000 kilobytes
    Super block: 76 bytes
    CRC: cfc8e1f0
    155648+0 records in
    155648+0 records out
    Ready to make the squashFS part! This can take 1 or 2 minutes!
    Creating big endian 2.1 filesystem on tmp_mkdreambox_3, block size 65536.
    FATAL ERROR:zlib::compress failed, not enough memory
    cat: tmp_mkdreambox_3: No such file or directory
    Done!

    二、如何中文化菜单?

    中文化菜单需要修改如下文件:
    1、IMG解包后,修改share/locale/locale.alias 这个文件,增加一行内容:
    Chinese zh_CN
    2、汉化菜单文件,在share/locale/zh/LC_MESSAGES这个目录下有两个mo文件:
    plisetup.mo       tuxbox-enigma.mo
    用工具转换成po文件,再用po编辑器进行编辑,完成后转换回mo文件,替换原文件,重新打包IMG即可。
     
    三、如何修改启动画面?
    对于pli及gemini等img来说,启动画面是IMG里的文件bild,位于root/platform/kernel/下,
    root@dreambox:/var/mnt/nfs/img1/root/platform/kernel> ls -l
    -rwxr-xr-x    1 500      244         60193 Jul  1  2007 bild
    -rwxr-xr-x    1 500      244        976416 Jul  1  2007 os
    准备一幅720*576分辩率的图片,用TMPGenc压缩成MPEG2格式,只要视频部分,保存后的文件改为bild,替换root/platform/kernel/里的同名文件,再重新打包成IMG即可。
     
  • 我的 linux-vserver 之路

    2008-02-07 10:03:35

    想要保持系統的穩定又能有新奇的玩意兒可以測試,那麼 linux-vserver 似乎是最佳的選擇了。

    vserver 是一種強化的 chroot 環境,透過內容切換的方式實作出與 host OS 完全獨立的 Linux 環境。由於 Un*x 是一種檔案導向的作業系統,以 chroot 進行的檔案系統分離就已經具有相當程度的獨立性,而 linux-vserver 則進一步在 Linux 核心上動手腳,讓各個 vserver 環境能完全地獨立出來,就好像真的是不同的伺服器一樣。

    linux-vserver 計畫:「你可能會想,虛擬伺服器看起來很酷,但大概不是對所有人都有用吧。!」vserver 真的很有用,對一般 (Debian 的) 使用者來說,它至少可以讓系統更加強固穩定:安裝 host OS 作 container,再使用 vserver 進行日常工作。至於眾多亂搞系統的愛好者,更是容易理解 vserver 的好處。

    有了 vserver,我們就可以採取以下的系統管理模式:

    1. 安裝基本的 stable:用穩定版的 Debain,處理基本的磁碟、網路等等管理作業;避免系統因為上游套件的一點問題而無法使用 (或不方便使用)。
    2. 在 stable 上安裝 linux-vserver。
    3. 在 vserver 裡工作:
      • vserver 裡面安裝的軟體,不會影響 host OS。
      • 儘量測試新東西;怎麼玩,系統都不會壞。
      • 用 vserver 提供網路服務;即使被 hacked-in,也只是隨時可以清除重來的 vserver 出問題。

    非常好用。因此我寫了這篇文章,介紹如何在 Debian 下使用 vserver。大家都應該花點時間來了解一下這個棒技術,你不會後悔的。

    安裝使用 sarge (Debian 3.1r0a) 的 vserver

    在 Debian 裡面有三個相關的套件:kernel-patch-vserver, util-vserver, vserver-debiantoolslinux-vserver 本身以核心修補的形式發行,可以套用在 Debian 的 2.6.8, 2.6.11 和 2.6.12 (我測試過的) 核心上面 (也支援 2.4 的核心),所以 kernel-patch-vserver 這個套件是一定要安裝的。

    util-vserver 是一組用來管理 vserver 的工具程式集,也需要安裝;vserver-debiantools 則是 Debian 特定的工具程式集。一般來說三個套件我們都會安裝:

    $ apt-get -t sid kernel-patch-vserver util-vserver vserver-debiantools
    

    因為 sarge 裡的 vserver-debiantools 還有問題,所以得用 unstable 裡新的 vserver 相關套件。

    當然還需要取得核心原始碼:

    $ apt-get -t sid linux-source-2.6.12
    $ mkdir /usr/src/work; cd /usr/src/work
    $ tar xfj /usr/src/linux-source-2.6.12.tar.bz2
    $ mv linux-source-2.6.12 linux-source-2.6.12vserver
    

    2.6.12 核心可以用 gcc-4.0 編譯,舊 (<=2.6.11) 核心則要用 gcc-3.3。如果系統 gcc 的版本不一樣,那在 make-kpkg 之前加上 MAKEFLAGS="CC=gcc-3.3" 即可。我會在 make-kpkg 之前先組態一下:

    $ make menuconfig
    

    Note

    別忘了先裝 libncurses5-dev。也別忘了 kernel-package (提供 make-kpkg) 和 dpkg-dev

    然後用 (參考 [4]):

    $ make-kpkg --rootcmd fakeroot --revision custom01 --added-patches vserver --append-to-version +vserver --initrd --config menuconfig binary-arch
    

    --added-patches vserver 會在編譯之前把 vserver 修補上去 (修補檔放在 /usr/src/patches 裡面),然後再 menuconfig 以確認 vserver 相關的組態 (--config menuconfig)。最後編譯,完成之後會在上一層目錄裡 (/usr/src/work) 產生:

    kernel-headers-2.6.12+vserver_custom01_i386.deb
    kernel-image-2.6.12+vserver_custom01_i386.deb
    

    兩個檔案,用 dpkg -i 安裝後,修改 boot loader (lilo/grub) 即可使用。用 patched kernel 重新開機後,系統就具備 linux-vserver 的能力,可以用 util-vservervserver-debiantools 套件管理 vserver。

    調整 host OS

    vserver 還不完美;尤其它是配合 content-switching 的 chroot 環境,仍有許多程式需要調整配合。ssh 幾乎安裝在所有系統上,所以一定要調整它。

    ssh 預設會監聽系統上所有的通訊埠,這個行為與 vserver 的運作相衝突。如果不改變此行為,那麼所有連往 vserver 的 ssh 連線都會被 host OS 上的 sshd 攔下來,讓 vserver 的 sshd 失效。我們要把 host OS 的 /etc/ssh/sshd_config 的這一行:

    #ListenAddress 0.0.0.0
    

    改為

    ListenAddress 69.90.134.201 # host OS 的 IP,可多行
    

    然後重新啟動 ssh server。如果 host OS 上有其它伺服器的話,也需要作類似的修改。

    建立 vserver

    我們可以用 utils-vserver 提供的總管工具 vserver 來建立 vserver (請參考 [5]):

    $ REMOVE_PACKAGES="sparc-utils,dhcp-client,lilo,makedev,pcmcia-cs,ppp,\
    pppconfig,pppoe,pppoeconf,setserial,syslinux,fdutils,libpcap0,\
    iptables,pciutils"
    
    $ vserver cosmos build -m debootstrap --hostname cosmos \
    --interface eth0:192.168.200.1/24 -- \
    -d sarge -- --exclude=$REMOVE_PACKAGES
    

    Note

    這個動作會去抓取所需的套件,用 debootstrap 安裝 base system;如果 apt 來源慢的話,就會花點時間。

    cosmos 是 vserver 的名字,請隨便取你喜歡的。這樣建出來的 vserver 是採用 vserver2 的設定模式,與 legacy 設定模式不同。vserver-debiantools 裡的 newvserver 似乎會建立 legacy 設定模式的 vserver,但我並沒有確認。vserver2 設定模式的說明應該要參考大花頁 [3],我先警告,它很花。

    所有 vserver 的組態都放在 /etc/vservers 之下;各 vserver 預設的目錄結構位於 /var/lib/vserver

    為 vserver 作基本組態

    啟動與進入 vserver

    作到這裡,已經可以用:

    $ vserver cosmos start
    

    啟動 cosmos vserver,而

    $ vserver cosmos enter

    則會把我們帶進 cosmos。

    移掉不必要的 init 指令稿

    參考 Step-by-Step Guide [2],我也把以下的 init 指令稿 symbolic link 刪除了:

    cd /home/vservers/DebianSid/etc/rc0.d
    rm K20makedev K25hwclock.sh S30urandom S31umountnfs.sh  S35networking S36ifupdown S40umountfs S90halt K89klogd
    
    cd /home/vservers/DebianSid/etc/rc6.d
    rm K20makedev K25hwclock.sh S30urandom S31umountnfs.sh  S35networking S36ifupdown S40umountfs S90reboot K89klogd
    
    cd /home/vservers/DebianSid/etc/rcS.d
    rm S05keymap.sh S48console-screen.sh S50hwclock.sh S40networking  S45mountnfs.sh S10checkroot.sh S02mountvirtfs
    rm S30procps.sh S35mountall.sh S36mountvirtfs S39ifupdown S30checkfs.sh S18ifupdown-clean S18hwclockfirst.sh
    
    cd /home/vservers/DebianSid/etc/rc2.d
    rm S20makedev S11klogd
    

    在 host OS 裡就可以用 vserver cosmos stopvserver cosmos restart 了。

    base-config

    用以上程序安裝的 vserver 沒有作過 base-config,請進入 vserver 執行一次 base-config,再安裝/設定你的 vserver。

    X window in vserver

    在 vserver 裡面跑 X,就不會讓 host OS 的家目錄裡跑出一大堆 .[a-z]* 的檔案了!我們要先打開 vserver 的 CAP_SYS_RAWIO,請在 /etc/vservers/cosmos/bcapabilities 檔案 (預設並沒有這個檔案,請自己建一個新的) 裡寫入 CAP_SYS_RAWIO,並且為 vserver 建立 mem 裝置:

    $ mknod /var/lib/vservers/cosmos/dev/mem c 1 1
    $ chmod 640 /var/lib/vservers/cosmos/dev/mem
    $ chown root.kmem /var/lib/vservers/cosmos/dev/mem
    

    然後就可以在 vserver 裡安裝使用 X 了。

    Tip

    我是用 gdm 啟動 X 的。

    有人提供一些 vserver 的裝置,可以參考一下;randomurandom 對使用 TLS/SSL 的程式蠻重要的,缺少的話至少 Gaim 會有問題。

    希望大家 vserver 愉快!

  • dos2unix, unix2dos 对应的命令

    2007-12-17 14:39:10

    dos2unix, unix2dos 对应的命令

    dos2unix, unix2dos 用来实现 DOS <=> UNIX text file 转换
    aptitude install sysutils
    行末:
    DOS 格式 0d 0a
    UNIX 格式 0a

    可用功能相同的指令組合
    dos2unix:
    sed -i'' "s/\r//" file

    cat file | col -b > newfile

    cat file | tr -d "\r" > newfile

    cat file | tr -d "\015" > newfile

    unix2dos:
    sed -i'' "s/$/\r/" file

    sed -i'' "s/$/\x0d/" file

    -i后面的是单引号组成

    以上适用 GNU sed, FreeBSD 下的 sed 不适用
  • rsa_use_openssl

    2007-12-16 21:06:40

    #include <stdio.h>
    #include <openssl/err.h>
    #include <openssl/rsa.h>
    #include <openssl/pem.h>

    #define SECFILE "sec.pem"
    #define PUBFILE "pub.pem"

    int main(int argc, char *argv[])
    {
     int ret = -1, keylen = 0;
     RSA *key;
     FILE *fp;

     if (argc != 2) {
      fprintf(stderr, "Error: too many/few arguments.\n "
       "Usage: %s <numbits>\n", argv[0]);
      goto out;
     }
     keylen = atoi(argv[1]);
     if ((key = RSA_generate_key(keylen, 3, NULL, NULL)) == NULL) {
      fprintf(stderr, "%s\n",
       ERR_error_string(ERR_get_error(), NULL));
      goto out;
     }
     if (!RSA_check_key(key)) {
      fprintf(stderr,
       "Error: Problems while generating RSA Key.\nRetry.\n");
      goto out_free;
     }
     fp = fopen(SECFILE, "w");
     if (!fp) {
      goto out_free;
     }
     if (!PEM_write_RSAPrivateKey(fp, key, NULL, NULL, 0, 0, NULL)) {
      fprintf(stderr,
       "Error: problems while writing RSA Private Key.\n");
      goto out_close;
     }
     fclose(fp);
     fp = fopen(PUBFILE, "w");
     if (!fp) {
      goto out_free;
     }
     if (!PEM_write_RSAPublicKey(fp, key)) {
      fprintf(stderr,
       "Error: problems while writing RSA Public Key.\n");
      goto out_close;
     }
     printf("RSA key generated.\nLenght = %d bits.\n", keylen);
     ret = 0;
     out_close:
     fclose(fp);
     out_free:
     RSA_free(key);
     out:
     return ret;
    }

     

  • 访问任意进程数据

    2007-12-16 21:04:57

    http://bbs.chinaunix.net/viewthread.php?tid=701520&extra=&page=3


    #ifdef TEST_ACCESS_PROCESS_VM
    char buf[4096+8] = "TEST ACCESS_PROCESS_VM";
    test_user_copy()
    {
    struct task_struct *t;
    int len = 1024*4;
    long addr = 0x4014d008; //this is a fixed addr printed by tfile.c, never change.
    int found = 0;
    int i;

            for_each_process(t) {
                if(!strncmp("a.out", t->comm, 5)) {found++; break; }
                //printk("%p %s\n", t, t->comm);
            }
            if(!found) return;

            //so I can see kernel writing is done from user space. each time, the addr is not the
            //same
            sprintf(buf + 16, "        %p", &addr);

            for(i = 0; i < 6*256; i++) { //256 pages = 1M
                access_process_vm(t, addr+i*4096, buf, len, 1);  //addr USER, buf is KERNEL
            }
            printk("i = %d addr max = %p \n", i, addr + i*4096);
    }
    #endif


    [Copy to clipboard] [ - ]CODE:
    char *cp;

    main()
    {
        cp = malloc(1024*1024*4); //4M
        printf("cp = %p size = 4M\n", cp);  //change addr value in module according to this printed value.


        for(;;) {
          getchar();
          printf("%s, \n", cp);
        }
    }

371/212>
Open Toolbar