vbscript之通過(guò)對(duì)比注冊(cè)表查找隱藏的服務(wù)
來(lái)源:易賢網(wǎng) 閱讀:900 次 日期:2016-06-29 09:25:15
溫馨提示:易賢網(wǎng)小編為您整理了“vbscript之通過(guò)對(duì)比注冊(cè)表查找隱藏的服務(wù)”,方便廣大網(wǎng)友查閱!

系統(tǒng)服務(wù)有可能被 rootkit 隱藏,但有些時(shí)候我們?nèi)钥梢詮淖?cè)表中找到相關(guān)的信息。建議以管理員權(quán)限運(yùn)行,否則有些服務(wù)列舉不出來(lái)或出現(xiàn)錯(cuò)誤的提示

效果圖:

代碼(checksvr.vbs):

代碼如下:

'on error resume next

const hkey_local_machine = &h80000002

set oreg=getobject(winmgmts:{impersonationlevel=impersonate}!\\.\root\default:stdregprov)

strkeypath = system\currentcontrolset\services

oreg.enumkey hkey_local_machine, strkeypath, arrsubkeys

wscript.echo checking, please wait ...

wscript.echo

for each subkey in arrsubkeys

oreg.getstringvalue hkey_local_machine, strkeypath & \\ & subkey, objectname, strvalue

if not (strvalue = ) then

'判斷服務(wù), 利用數(shù)組來(lái)比較不知道會(huì)不會(huì)快些?

if not (checksvr(subkey)) then

wscript.echo subkey & formatouttab(subkey) & strvalue & formatouttab(strvalue) & [ hidden ]

else

wscript.echo subkey & formatouttab(subkey) & strvalue & formatouttab(strvalue) & [ ok ]

end if

end if

next

wscript.echo

wscript.echo all done.

wscript.quit (0)

function checksvr(strname)

set owmi = getobject(winmgmts: & {impersonationlevel=impersonate}!\\.\root\cimv2)

set cservice = owmi.execquery(select * from win32_service where name=' & strname & ')

if (cservice.count <> 0) then

checksvr = true

else

checksvr = false

end if

end function

function formatouttab(strname)

strlen = len(strname)

select case true

case strlen < 8

formatouttab = vbtab & vbtab & vbtab & vbtab & vbtab

case strlen < 16

formatouttab = vbtab & vbtab & vbtab & vbtab

case strlen < 24

formatouttab = vbtab & vbtab & vbtab

case strlen < 32

formatouttab = vbtab & vbtab

case strlen < 40

formatouttab = vbtab

case else

formatouttab = vbtab

end select

end function

利用字典,速度要快很多:

復(fù)制代碼 代碼如下:

dim odic, oreg, owmi, arrservices

const hkey_local_machine = &h80000002

wscript.echo [*] checking, please wait ...

wscript.echo

set odic = createobject(scripting.dictionary)

set owmi = getobject(winmgmts: & {impersonationlevel=impersonate}!\\.\root\cimv2)

set arrservices = owmi.execquery(select * from win32_service)

for each strservice in arrservices

odic.add strservice.name, strservice.name

next

set oreg = getobject(winmgmts:{impersonationlevel=impersonate}!\\.\root\default:stdregprov)

strkeypath = system\currentcontrolset\services

oreg.enumkey hkey_local_machine, strkeypath, arrsubkeys

for each subkey in arrsubkeys

oreg.getstringvalue hkey_local_machine, strkeypath & \\ & subkey, objectname, strvalue

if not (strvalue = ) then

if odic.exists(subkey) then

wscript.echo subkey & formatouttab(subkey) & strvalue & formatouttab(strvalue) & [ ok ]

else

wscript.echo subkey & formatouttab(subkey) & strvalue & formatouttab(strvalue) & [ hidden ]

end if

end if

next

odic.removeall

wscript.echo

wscript.echo [*] all done.

wscript.quit (0)

function formatouttab(strname)

strlen = len(strname)

select case true

case strlen < 8

formatouttab = vbtab & vbtab & vbtab & vbtab

case strlen < 16

formatouttab = vbtab & vbtab & vbtab

case strlen < 24

formatouttab = vbtab & vbtab

case strlen < 32

formatouttab = vbtab

case else

formatouttab = vbtab

end select

end function

更多信息請(qǐng)查看腳本欄目
由于各方面情況的不斷調(diào)整與變化,易賢網(wǎng)提供的所有考試信息和咨詢回復(fù)僅供參考,敬請(qǐng)考生以權(quán)威部門公布的正式信息和咨詢?yōu)闇?zhǔn)!

2025國(guó)考·省考課程試聽報(bào)名

  • 報(bào)班類型
  • 姓名
  • 手機(jī)號(hào)
  • 驗(yàn)證碼
關(guān)于我們 | 聯(lián)系我們 | 人才招聘 | 網(wǎng)站聲明 | 網(wǎng)站幫助 | 非正式的簡(jiǎn)要咨詢 | 簡(jiǎn)要咨詢須知 | 加入群交流 | 手機(jī)站點(diǎn) | 投訴建議
工業(yè)和信息化部備案號(hào):滇ICP備2023014141號(hào)-1 云南省教育廳備案號(hào):云教ICP備0901021 滇公網(wǎng)安備53010202001879號(hào) 人力資源服務(wù)許可證:(云)人服證字(2023)第0102001523號(hào)
云南網(wǎng)警備案專用圖標(biāo)
聯(lián)系電話:0871-65099533/13759567129 獲取招聘考試信息及咨詢關(guān)注公眾號(hào):hfpxwx
咨詢QQ:526150442(9:00—18:00)版權(quán)所有:易賢網(wǎng)
云南網(wǎng)警報(bào)警專用圖標(biāo)