Advertisement
Mysoft

Untitled

Apr 1st, 2017
719
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include "windows.bi"
  2. #include "win\combaseapi.bi"
  3. #include "win\winerror.bi"
  4.  
  5. #include "..\win\wincred.bi"
  6. #include "..\MyTDT\detour.bas"
  7.  
  8. #inclib "ole32"
  9.  
  10. extern "windows"
  11.   UndefAllParams()
  12.   #define P1 byval pUiInfo as PCREDUI_INFOA
  13.   #define P2 byval dwAuthError as DWORD
  14.   #define P3 byval pulAuthPackage as ULONG ptr
  15.   #define P4 byval pvInAuthBuffer as LPCVOID
  16.   #define P5 byval ulInAuthBufferSize as ULONG
  17.   #define P6 byval ppvOutAuthBuffer as LPVOID ptr
  18.   #define P7 byval pulOutAuthBufferSize as ULONG ptr
  19.   #define P8 byval pfSave as BOOL ptr
  20.   #define P9 byval dwFlags as DWORD
  21.   declare function CredUIPromptForWindowsCredentialsA(P1, P2, P3, P4, P5, P6, P7, P8, P9) as DWORD
  22.  
  23.   UndefAllParams()
  24.   #define P1 byval pUiInfo as PCREDUI_INFOW
  25.   #define P2 byval dwAuthError as DWORD
  26.   #define P3 byval pulAuthPackage as ULONG ptr
  27.   #define P4 byval pvInAuthBuffer as LPCVOID
  28.   #define P5 byval ulInAuthBufferSize as ULONG
  29.   #define P6 byval ppvOutAuthBuffer as LPVOID ptr
  30.   #define P7 byval pulOutAuthBufferSize as ULONG ptr
  31.   #define P8 byval pfSave as BOOL ptr
  32.   #define P9 byval dwFlags as DWORD
  33.   declare function CredUIPromptForWindowsCredentialsW(P1, P2, P3, P4, P5, P6, P7, P8, P9) as DWORD
  34.  
  35.   UndefAllParams()
  36.   #define P1 dwFlags as DWORD
  37.   #define P2 pAuthBuffer as PVOID
  38.   #define P3 cbAuthBuffer as DWORD
  39.   #define P4 pszUserName as LPSTR
  40.   #define P5 pcchMaxUserName as DWORD ptr
  41.   #define P6 pszDomainName as LPSTR
  42.   #define P7 pcchMaxDomainname as DWORD ptr
  43.   #define P8 pszPassword as LPSTR
  44.   #define P9 pcchMaxPassword as DWORD ptr
  45.   declare function CredUnPackAuthenticationBufferA(P1, P2, P3, P4, P5, P6, P7, P8, P9) as BOOL
  46.  
  47.   UndefAllParams()
  48.   #define P1 dwFlags as DWORD
  49.   #define P2 pAuthBuffer as PVOID
  50.   #define P3 cbAuthBuffer as DWORD
  51.   #define P4 pszUserName as LPWSTR
  52.   #define P5 pcchMaxUserName as DWORD ptr
  53.   #define P6 pszDomainName as LPWSTR
  54.   #define P7 pcchMaxDomainname as DWORD ptr
  55.   #define P8 pszPassword as LPWSTR
  56.   #define P9 pcchMaxPassword as DWORD ptr
  57.   declare function CredUnPackAuthenticationBufferW(P1, P2, P3, P4, P5, P6, P7, P8, P9) as BOOL
  58. end extern
  59.  
  60. dim as CREDUI_INFOW credui
  61. with credui
  62.   .cbSize         = sizeof(credui)
  63.   .hwndParent     = GetConsoleWindow()
  64.   .pszMessageText = @wstr("enter password to hack me")
  65.   .pszCaptionText = @wstr("enter me not")
  66.   .hbmBanner      = NULL '320x60
  67. end With
  68. dim as uint authPackage = 0
  69. dim as any ptr outCredBuffer
  70. dim as uint outCredSize
  71. dim as bool save = false
  72. dim as wstring*(CREDUI_MAX_USERNAME_LENGTH+1) usernameBuf
  73. dim as wstring*(CREDUI_MAX_PASSWORD_LENGTH+1) passwordBuf
  74. dim as wstring*(100+1) domainBuf
  75. var maxUserName = CREDUI_MAX_USERNAME_LENGTH
  76. var maxPassword = CREDUI_MAX_PASSWORD_LENGTH
  77. var maxDomain = 100
  78.  
  79. dim as DWORD promptresult
  80. dim as BOOL unpackresult
  81. promptresult = CredUIPromptForWindowsCredentialsW(@credui, 0, @authPackage, NULL, 0, @outCredBuffer, @outCredSize, @save, 1 /' Generic '/)
  82.  
  83. if promptresult = ERROR_SUCCESS then 'function didnt failed
  84.   unpackresult = CredUnPackAuthenticationBufferW(0, @outCredBuffer, outCredSize, @usernameBuf, @maxUserName, @domainBuf, @maxDomain, @passwordBuf, @maxPassword)
  85.   if unpackresult then
  86.     'clear the memory allocated by CredUIPromptForWindowsCredentials
  87.     CoTaskMemFree(outCredBuffer)
  88.     print "Username:" + usernameBuf
  89.     print "Password:" + passwordBuf
  90.     print "Domain:" + domainBuf
  91.   else
  92.     print "CredUnPackAuthenticationBuffer error: " & GetLastError()
  93.   endif
  94. elseif promptresult = ERROR_CANCELLED then
  95.   print "user canceled..."
  96. else
  97.   print "CredUIPromptForWindowsCredentials error: " & promptresult
  98. endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement