也談隱藏盤符等windows 的管理員的策略實現

來源:互聯網
上載者:User

標籤:item   調試   roo   ros   不同的   als   date   xca   cal   

網上的文章都知道在HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer 檔案夾下有控制隱藏磁碟機隱藏控制台的索引值,通過改動這些索引值來控制能否夠改變windows的配置或者許可權。或者掩藏或者顯示什麼。

(必需要又一次啟動)那麼誰來控制這個開關呢?

     通過自己的調試追蹤到例如以下的棧

 # ChildEBP RetAddr Args to Child00 0235f134 7602ed30 00000528 765aebe0 00000000 Sandboxdll!Mine_RegQueryValueExW+0xca [e:\ronggf\work\branches\minsheng\client_windows\src\hooklib\hook_advapi32.cpp @ 365]WARNING: Stack unwind information not available. Following frames may be wrong.01 0235f178 7602e977 00000528 765aebe0 0000ffff SHLWAPI!PathIsRelativeW+0xdf02 0235f1bc 7602aed2 80000002 0235f210 765aebe0 SHLWAPI!SHRegGetValueW+0xe303 0235f1e0 7602b97e 80000002 0235f210 765aebe0 SHLWAPI!SHGetValueW+0x2104 0235f41c 76024a79 00000000 765af510 765aebe0 SHLWAPI!Ordinal271+0x69*** ERROR: Symbol file could not be found. Defaulted to export symbols for C:\Windows\system32\SHELL32.dll -05 0235f43c 765aedb7 00000100 00000000 765aedc0 SHLWAPI!StrCmpNIW+0x4006 0235f45c 766b1026 00000100 0235f4b8 00000004 SHELL32!SHRestricted+0x2407 0235f474 766b07b3 00000000 02d80e68 00000000 SHELL32!Ordinal744+0x32a108 0235f494 766b0476 0235f4b8 02d36040 02d36010 SHELL32!Ordinal744+0x2a2e09 0235f4e8 765685e5 02d80e68 00000001 0235f574 SHELL32!Ordinal744+0x26f1*** ERROR: Symbol file could not be found. Defaulted to export symbols for C:\Windows\system32\explorerframe.dll -0a 0235f538 7198d77d 02d36010 00000001 0235f574 SHELL32!OpenRegStream+0x16520b 0235f5b0 7198041e 02a5c2e0 01000000 80000000 explorerframe!Ordinal110+0xe3800c 0235f5d0 765d619e 02a5c2f4 7fffffff 02a63668 explorerframe!Ordinal110+0x10210d 0235f5ec 765d6109 0235f628 00000000 02ac0fb8 SHELL32!SHCreateItemFromIDList+0x1660e 0235f634 765caaa8 0235f64c 7602b6cf 02a63668 SHELL32!SHCreateItemFromIDList+0xd10f 0235f63c 7602b6cf 02a63668 0030e150 0235f6c0 SHELL32!Ordinal95+0x227410 0235f64c 771ab5e9 02ac0fb8 752c3f68 00294448 SHLWAPI!PathBuildRootW+0x4c11 0235f6c0 771ae8d1 02ac0fb8 0030e150 752c3188 ntdll!RtlTestBit+0x21c12 0235f820 75f81194 00294440 0235f86c 771db3f5 ntdll!RtlIsCriticalSectionLockedByThread+0x47413 0235f82c 771db3f5 00294440 752c31c4 00000000 kernel32!BaseThreadInitThunk+0x1214 0235f86c 771db3c8 771ad63e 00294440 00000000 ntdll!RtlInitializeExceptionChain+0x6315 0235f884 00000000 771ad63e 00294440 00000000 ntdll!RtlInitializeExceptionChain+0x36 從 SHELL32.dll 的 函數 SHRestricted開始,轉到讀取策略注冊表索引值上去的,我們來看看 SHRestricted 的逆向

.text:7387F02B [email protected] proc near ; CODE XREF: CMenuItemsCache::RefreshCachedDarwinShortcuts(int)+Dp
.text:7387F02B                                         ; CDesktopBrowser::_ActivateView(void)+3Dp ...
.text:7387F02B
.text:7387F02B rest            = dword ptr  8
.text:7387F02B
.text:7387F02B                 mov     edi, edi
.text:7387F02D                 push    ebp
.text:7387F02E                 mov     ebp, esp
.text:7387F030                 push    offset [email protected]@3JA ; long g_lRestrictionsVersionNumber
.text:7387F035                 push    9Ch
.text:7387F03A                 push    offset [email protected]@3PAKA ; ulong * g_rgRestrictionItemValues
.text:7387F03F                 push    offset unk_7387F058
.text:7387F044                 push    0
.text:7387F046                 push    [ebp+rest]
.text:7387F049                 call    ds:[email protected] ; SHRestrictionLookup(x,x,x,x,x,x)
.text:7387F04F                 pop     ebp
.text:7387F050                 retn    4
.text:7387F050 [email protected] endp

在當中調用了 SHLAPI.DLL 中的 SHRestrictionLookup

SHRestrictionLookup

函數例如以下:

int __stdcall SHRestrictionLookup(int a1, LPCWSTR pszDir, int a3, void *Dst, int a5, int a6){  char *v6; // [email protected]  int v7; // [email protected]  unsigned int v8; // [email protected]  int v9; // [email protected]   v7 = 0;  if ( !g_bDllTerminating )  {    _ValidateRestrictionTable(Dst, a5, a6);    v8 = 0;    if ( (unsigned int)a5 > 0 )    {      v9 = a3;      while ( a1 != *(_DWORD *)v9 )      {        ++v8;        v9 += 12;        if ( v8 >= a5 )          return v7;      }      v6 = (char *)Dst + 4 * v8;      v7 = *(_DWORD *)v6;      if ( *(_DWORD *)v6 == -1 )      {        v7 = SHGetRestriction(pszDir, *(LPCWSTR *)(a3 + 12 * v8 + 4), *(LPCWSTR *)(a3 + 12 * v8 + 8));        AcquireSRWLockExclusive(&g_csrwlockRestrictions);        if ( *(_DWORD *)a6 == SHGlobalCounterGetValue(GLOBALCOUNTER_RESTRICTIONS) )          *(_DWORD *)v6 = v7;        ReleaseSRWLockExclusive(&g_csrwlockRestrictions);      }    }  }  return v7;}

會從注冊表中擷取值然後返回(假設沒有擷取 -1 沒有擷取)。否則直接讀取出來

在MSDN 中:

Determines whether a specified administrator policy is in effect. In many cases, applications need to modify certain behaviors in order to comply with the policies enacted by system administrators.

檢測指定的管理員策略是否有效。在非常多情況下。應用程式須要遵照系統管理員指定的策略依序改動某些行為。

系統行為是這個樣子,假設我們的程式須要某些和系統行為不同,那麼hook這個函數。而且返回和系統不同的值就能起到效果。

也談隱藏盤符等windows 的管理員的策略實現

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.