bfek-18
19th October 2009 09:07 UTC
system::call crypt32::CertNameToStr
Hi,
I want a function from the field crypt32 benefit.
From these links i have the suggestions.
http://nsis.sourceforge.net/Import_Root_Certificate
http://forums.winamp.com/showthread....ht=certificate
I would like to use this function: crypt32::CertNameToStr
here is this function in c :
//-----------------------------------------------------------
// Convert the subject name to an ASN.1 encoded
// string and print the octets in that string.
// First : Get the number of bytes that must
// be allocated for the string.
cbSize = CertNameToStr(
pCertContext->dwCertEncodingType,
&(pCertContext->pCertInfo->Subject),
MY_STRING_TYPE,
NULL,
0);
Here's my attempt with system::call functions
; $2 pointer to the next certificate
;
; extracted from struct # http://msdn.microsoft.com/en-us/libr...8VS.85%29.aspx
;
System::Call "*$2(i .r5,,,i .r6,)"
; extracted from struct # http://msdn.microsoft.com/en-us/libr...8VS.85%29.aspx
;
System::Call "*$6(,,,,,,i .r7,,,,,,)"
System::Call "crypt32::CertNameToStr(i r5,i r7, i 3,i 0,i 0) i.r3"
unfortunately without success.
Any hints are very wellcome.
(sorry for my poor english)
Uwe
Zinthose
19th October 2009 15:36 UTC
/sigh...
I doubt many people will help you since your request very suspicious.
Your forum account is brand new and your asking to perform a task that exploits a known security vulnerability in Windows.
http://www.microsoft.com/technet/sec.../ms09-056.mspx
http://www.microsoft.com/technet/security/bulletin/ms09-056.mspx
bfek-18
19th October 2009 20:15 UTC
Re: system::call crypt32::CertNameToStr
Hallo Zinthose,
Thank you for your notice.My question is, in this respect quite harmless.
I want my current NSIS script easier.
This is my current way, to read the issuer from the certificate store.
; snip
!define RegCertKey "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\SystemCertificates\My\Certificates"
GetTempFileName $9
ExecDos::exec 'regedit /e $9 ${RegCertKey}' "" ""
; snip
Then search with "BinStrSearch" in this file to find the issuer name.
This whole to simplify is my goal.
Uwe
f0rt
20th October 2009 22:14 UTC
This could be done like shown in the following script (based on the script referred by you in your first post of this thread):
OutFile "cert.exe"
>!include "LogicLib.nsh"
>!define CERT_STORE_CERTIFICATE_CONTEXT 1
>!define CERT_NAME_ISSUER_FLAG 1
>!define CERT_NAME_SIMPLE_DISPLAY_TYPE 4
>Function display_certs
; Save registers
Push$0
Push$1
Push$2
Push$3
Push$4
; Open system certificate store of certification authorities
System
::Call "crypt32::CertOpenSystemStore(i 0, t 'MY') i.r1"
${If} $1 != 0
StrCpy$2 0
; Loop through certificate store
${Do}
System::Call "crypt32::CertEnumCertificatesInStore(i r1, i r2) i.r2"
${If} $2 != 0
; Get subject of certificate
System::Call "crypt32::CertGetNameString(i r2, \\
i ${CERT_NAME_SIMPLE_DISPLAY_TYPE}, i 0, i 0, \\
t .r4, i ${NSIS_MAX_STRLEN}) i.r3"
${If} $3 != 0
StrCpy$0 "Subject: $4$\\r$\\n"
; Get issuer of certificate
System::Call "crypt32::CertGetNameString(i r2, \\
i ${CERT_NAME_SIMPLE_DISPLAY_TYPE}, \\
i ${CERT_NAME_ISSUER_FLAG}, i 0, \\
t .r4, i ${NSIS_MAX_STRLEN}) i.r3"
${If} $3 != 0
StrCpy$0 "$0Issuer: $4"
${EndIf}
MessageBox MB_OK "$0"
${EndIf}
${Else}
${ExitDo}
${EndIf}
${Loop}
System::Call "crypt32::CertCloseStore(i r1, i 0)"
${EndIf}
; Restore registers
Pop$4
Pop$3
Pop$2
Pop$1
Pop$0
FunctionEnd
>Function .onInit
InitPluginsDir
Call display_certs
Quit
FunctionEnd
Section
SectionEnd
>