发新话题
打印

[讨论]请有IIS 5的朋友帮忙测试以下代码

[讨论]请有IIS 5的朋友帮忙测试以下代码

议题提交:代码罐头
信息来源:邪恶八进制信息安全团队(www.eviloctal.com

代码如下.修改自WIN2K3 DDK EXAMPLES
请有win2000的朋友(已安装IIS)
麻烦运行后帖给我一下结果.
我在IIS 6下.enumdata失败.
从错误号看来是LDAP分配内存失败.很底层的一个错误.搞得我不清楚具体什么问题了.
有经验的朋友请忙帮.
为了节省大家时间.同时放上DSW以及EXE文件.

运行方法:
.\EnumerateKeys.exe localhost /lm/w3svc
第一个参数是localhost
第二个参数可以是/lm键值以下任何一个.
推荐使用/LM/W3SVC
复制内容到剪贴板
代码:
/*******************************************
*
* EnumerateKeys.CPP
*
* This is a simple program to enumerate the
* IIS metabase keys using the IMSAdminBase
* interface.
*
********************************************/


#define STRICT
#define INITGUID
#define WINVER 0x0400
#define _WIN32_DCOM

#include <WINDOWS.H>
#include <OLE2.H>
//#include <coguid.h>

#include <stdio.h>
#include <stdlib.h>

#include "iadmw.h"
#include "iiscnfg.h"

int __cdecl wmain(
   int            argc,
   wchar_t         *argv[])
{
     HRESULT         hr = S_OK;
     DWORD          dwEnumIndex;
     WCHAR          wszChildKeyName[METADATA_MAX_NAME_LEN];
     WCHAR          wszEnumPath[METADATA_MAX_NAME_LEN];
   COSERVERINFO      csiMachineName;
     OLECHAR         wszMachineName[MAX_PATH];
     IClassFactory     *pClassFactory = NULL;
     IMSAdminBase      *pAdminBase = NULL;  //interface pointer

     METADATA_RECORD wszChildData;
     DWORD dwDataLen;
     DWORD dwEnumDataIndex;

     if ( (argc < 2) || (argc > 3 ) )
     {
          _putws( L"ERROR! Wrong number of parameters" );
          _putws( L"   You must supply at least the machine name\n" );

          hr = E_INVALIDARG;
      goto exit;
     }

   if ( wcslen( argv[1] ) >= MAX_PATH )
   {
          _putws( L"ERROR! bad" );

          hr = E_INVALIDARG;
      goto exit;
   }

     if ( ( argc == 3 ) && ( wcslen( argv[2] ) > METADATA_MAX_NAME_LEN ) )
     {
          _putws( L"ERROR! bad" );

          hr = E_INVALIDARG;
      goto exit;
     }

     //fill the structure for CoGetClassObject
     wcsncpy (wszMachineName, argv[1], MAX_PATH-1 );
     wszMachineName[MAX_PATH-1] = L&#39;\0&#39;;

     csiMachineName.pAuthInfo = NULL;
     csiMachineName.dwReserved1 = 0;
     csiMachineName.dwReserved2 = 0;
     csiMachineName.pwszName = wszMachineName;

     // Initialize COM
   hr = CoInitializeEx( NULL, COINIT_MULTITHREADED );
   if (FAILED(hr))
     {
          wprintf( L"ERROR: CoInitialize Failed! Error: 0x%08x\n", hr );
      goto exit;
     }

     hr = CoGetClassObject( CLSID_MSAdminBase, CLSCTX_SERVER, &csiMachineName,
                  IID_IClassFactory, (void**) &pClassFactory);
     if (FAILED(hr))
     {
          wprintf( L"ERROR: CoGetClassObject Failed! Error: 0x%08x\n", hr );
      goto exit;
     }

     hr = pClassFactory->CreateInstance(NULL, IID_IMSAdminBase, (void **) &pAdminBase);
     if (FAILED(hr))
     {
          wprintf( L"ERROR: CreateInstance Failed! Error: 0x%08x\n", hr );
      goto exit;
     }

     if (argc != 3)
     {
          // Set up a default path.
          wszEnumPath[0] = L&#39;/&#39;;
          wszEnumPath[1] = L&#39;\0&#39;;
     }
     else
     {
        wcsncpy( wszEnumPath, argv[2], METADATA_MAX_NAME_LEN-1 );
        wszMachineName[METADATA_MAX_NAME_LEN-1]=L&#39;\0&#39;;
     }

     wprintf( L"Enumerating Path: %s\n", wszEnumPath );

     // Enumerate the data
     for ( dwEnumIndex = 0; SUCCEEDED(hr); dwEnumIndex++ )
     {
          hr = pAdminBase -> EnumKeys( METADATA_MASTER_ROOT_HANDLE,
                        wszEnumPath,
                        wszChildKeyName,
                        dwEnumIndex);
          if ( SUCCEEDED(hr) )
          {
            wprintf( L"[%s]\n", wszChildKeyName );

          }
     }
     wprintf( L"EnumIndex: %d \n", dwEnumIndex );
     wprintf( L"EnumKeys return code: 0x%08x\n", hr );
     hr = S_OK;
     for ( dwEnumDataIndex = 0; SUCCEEDED(hr); dwEnumDataIndex++ ){
          hr = pAdminBase->EnumData(METADATA_MASTER_ROOT_HANDLE,
                                                                       wszEnumPath,
                                                                       &wszChildData,
                                                                       dwEnumDataIndex,
                                                                       &dwDataLen);
          if ( SUCCEEDED(hr) )
          {
              wprintf( L"[%s]\n", wszChildData.dwMDAttributes );
          }
     }
     if ( hr != HRESULT_FROM_WIN32(ERROR_NO_MORE_ITEMS) )
     {
          wprintf( L"EnumDataIndex: %d \n", dwEnumDataIndex );
          wprintf( L"EnumData return code: 0x%08x\n", hr );

          goto exit;
     }

     hr = S_OK;

exit:
     if ( pClassFactory != NULL )
     {
        pClassFactory->Release();
        pClassFactory = NULL;
     }
     if ( pAdminBase != NULL )
     {
        pAdminBase->Release();
        pAdminBase = NULL;
     }

     if ( FAILED(hr) )
     {
        wprintf( L"the example failed with 0x%08x\n", hr );
     }

     return hr;
}

附件

EnumerateKeys.rar (1.56 MB)

2005-7-20 14:55, 下载次数: 28

连入侵者都敢说自己在做网络安全。关键大家是真正为安全作过什么?

TOP

手上偏偏没有2000 Server + IIS5
但是有2000 pro 可以还要装IIS 稍微有点麻烦 这几日是没戏了 过几日看看的....
qq310926是我唯一用号,除此之外有其他号码号自称邪八冰血封情,则非本人。

TOP

........
我是XP PRO.
装了IIS
可惜你要求是2000

TOP

为什么用这个?用iis自带的adsutil.vbs不是更好?
http://www.phpweblog.net/GaRY/

TOP

VBS创建ADSI对象.
我碰到有次无法创建.导致我做的那个工具根本不能用.
ADSUTIL也一样.
所以想用ABO来作.
还有.我这个人变态的.总是想用最底层的东西.能有ABO就不想用ADSI...呵呵...
连入侵者都敢说自己在做网络安全。关键大家是真正为安全作过什么?

TOP

winxp iis
可以吗?
如果可以
偶马上帮测试

TOP

谢谢.你可以试试看.
不过XP的IIS基本和IIS 6差不多
连入侵者都敢说自己在做网络安全。关键大家是真正为安全作过什么?

TOP

测试结果:
Microsoft Windows XP [版本 5.1.2600]
(C) 版权所有 1985-2001 Microsoft Corp.

G:\Documents and Settings\Andyower>E:\实验\URL\EnumerateKeys\EnumerateKeys\Debug\Enu
merateKeys.exe /LM/W3SVC
ERROR: CoGetClassObject Failed! Error: 0x800706ba
the example failed with 0x800706ba

TOP

郁闷
忘记加参数了
再次测试结果:
Microsoft Windows XP [版本 5.1.2600]
(C) 版权所有 1985-2001 Microsoft Corp.

G:\Documents and Settings\Andyower>E:\实验\URL\EnumerateKeys\EnumerateKeys\Debug\Enu
merateKeys.exe localhost /LM/W3SVC
Enumerating Path: /LM/W3SVC
[Info]
[Filters]
[1]
EnumIndex: 4
EnumKeys return code: 0x80070103
EnumDataIndex: 1
EnumData return code: 0x80070008
the example failed with 0x80070008

TOP

谢谢.果然结果和II6下面一样.呵呵.不出所料
连入侵者都敢说自己在做网络安全。关键大家是真正为安全作过什么?

TOP

发新话题