iT邦幫忙

2021 iThome 鐵人賽

DAY 13
1
Security

Kali Linux 工具筆記系列 第 13

Day 13 漏洞分析 - Vulnerability Analysis (unix-privesc-check)

  • 分享至 

  • twitterImage
  •  

工具介紹

今天要介紹的是unix-privesc-check,它是一個在 Unix 系統上運行的腳本,會檢查程式、資料夾、各種設定,嘗試找到錯誤的配置,來將一般使用者的權限提升,而提升權限意味使用者不再受限,甚至可以掌控整個主機。而且不像之前介紹的那些工具,是在Kali上遠端對目標機器執行一些工作,而是直接在本機上執行。本機端執行這點可能會讓人疑惑:「本機上要如何去安裝程式?」,因為本身是個shell腳本,所以其實不需要經過安裝的步驟,只要能夠上傳或是複製、編輯檔案等方式,將腳本放到受測機器上就可以來運行了,因此必要條件其實是要擁有受測機器上的一般使用者登入權限。

使用方式

unix-privesc-check位於Kali的Vulnerability Analysis分類,直接執行的話可以看到介紹跟使用方式

unix-privesc-check v1.4 ( http://pentestmonkey.net/tools/unix-privesc-check )

Usage: unix-privesc-check { standard | detailed }

"standard" mode: Speed-optimised check of lots of security settings.

"detailed" mode: Same as standard mode, but also checks perms of open file
                 handles and called files (e.g. parsed from shell scripts,
                 linked .so files).  This mode is slow and prone to false 
                 positives but might help you find more subtle flaws in 3rd
                 party programs.

This script checks file permissions and other settings that could allow
local users to escalate privileges.

Use of this script is only permitted on systems which you have been granted
legal permission to perform a security assessment of.  Apart from this 
condition the GPL v2 applies.

Search the output for the word 'WARNING'.  If you don't see it then this
script didn't find any problems.

看來使用方式只有分standarddetailed,另外也有提到如果找到問題會有關鍵字WARNING,所以執行的時候可以直接過濾出關鍵字

/usr/bin/unix-privesc-check standard | grep WARNING

但我自己在執行過程中看到許多腳本語法問題造成無法正常執行的狀況

/usr/bin/unix-privesc-check: 1076: [: standard: unexpected operator

本來以為是腳本太久,但後來打開腳本實際去看,第一行是#!/bin/sh,代表直接執行是會用sh去執行,然後ls -al /bin/sh去檢查是否有軟連結,會發現Kali是使用dash來執行,所以接下來改用bash來執行腳本

bash /usr/bin/unix-privesc-check standard | grep WARNING

在Kali上的掃瞄結果

Search the output below for the word 'WARNING'.  If you don't see it then
WARNING: There are SSH agents running on this system:
WARNING: There are GPG agents running on this system:

接下來可以把腳本複製到靶機上去試試看,可以利用scp將腳本傳到靶機上

scp /usr/bin/unix-privesc-check msfadmin@192.168.1.86: 

然後到靶機的家目錄上執行上面的指令

bash unix-privesc-check standard | grep WARNING

偵測結果跟Kali上就有些不同,真不愧是靶機...

Search the output below for the word 'WARNING'.  If you don't see it then
WARNING: Unencrypted Private SSH Key Found in /home/msfadmin/.ssh/id_rsa
WARNING: Public SSH Key Found in /root/.ssh/authorized_keys
WARNING: Public SSH Key Found in /home/msfadmin/.ssh/authorized_keys

結語

今天介紹了unix-privesc-check這個古老的腳本,但其實還不是很了解它是如何判斷設定是有問題,什麼是可利用的,但好在它是腳本,行數也大概一千多行左右,所以之後還是需要投資一些時間來了解它實際上是如何運作的。


上一篇
Day 12 漏洞分析 - Vulnerability Analysis (legion)
下一篇
Day 14 網頁分析 - Web Application Analysis (wpscan - WordPress vulnerability scanner)
系列文
Kali Linux 工具筆記31
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言