Created
January 4, 2013 08:36
-
-
Save walkure/4450932 to your computer and use it in GitHub Desktop.
Irvine( http://hp.vector.co.jp/authors/VA024591/ )でオレオレSSL(証明書エラーが出る)なサーバからファイルを引っ張ってくるためのWinInet.dllハック http://www.chiyoclone.net/ からlistexp2.exe拾ってきて、Win32のWinInet.dllラッパを作り、HttpOpenRequestAとHttpSendRequestAの処理を上書きする。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <windows.h> | |
#include <WinInet.h> | |
#include "_ininet.h" | |
#define HINTERNET void* | |
EXTERN_C HINTERNET STDAPICALLTYPE d_HttpOpenRequestA( | |
__in HINTERNET hConnect, | |
__in_opt LPCSTR lpszVerb, | |
__in_opt LPCSTR lpszObjectName, | |
__in_opt LPCSTR lpszVersion, | |
__in_opt LPCSTR lpszReferrer, | |
__in_z_opt LPCSTR FAR * lplpszAcceptTypes, | |
__in DWORD dwFlags, | |
__in_opt DWORD_PTR dwContext | |
) | |
{ | |
if(dwFlags & INTERNET_FLAG_SECURE){ | |
dwFlags |= INTERNET_FLAG_IGNORE_CERT_DATE_INVALID | INTERNET_FLAG_IGNORE_CERT_CN_INVALID; | |
} | |
return HttpOpenRequestA(hConnect,lpszVerb,lpszObjectName,lpszVersion,lpszReferrer,lplpszAcceptTypes, | |
dwFlags,dwContext); | |
} | |
EXTERN_C BOOL STDAPICALLTYPE d_HttpSendRequestA( | |
_In_ HINTERNET hRequest, | |
_In_ LPCTSTR lpszHeaders, | |
_In_ DWORD dwHeadersLength, | |
_In_ LPVOID lpOptional, | |
_In_ DWORD dwOptionalLength | |
) | |
{ | |
DWORD dwError; | |
if(HttpSendRequest(hRequest,lpszHeaders,dwHeadersLength,lpOptional,dwOptionalLength)) | |
return TRUE; | |
dwError = GetLastError(); | |
if(dwError == ERROR_INTERNET_INVALID_CA){ | |
DWORD dwFlags; | |
DWORD dwBuffLen = sizeof(dwFlags); | |
InternetQueryOption (hRequest, INTERNET_OPTION_SECURITY_FLAGS,(LPVOID)&dwFlags, &dwBuffLen); | |
dwFlags |= SECURITY_FLAG_IGNORE_UNKNOWN_CA; | |
InternetSetOption (hRequest, INTERNET_OPTION_SECURITY_FLAGS,&dwFlags, sizeof (dwFlags) ); | |
return HttpSendRequest(hRequest,lpszHeaders,dwHeadersLength,lpOptional,dwOptionalLength); | |
} | |
return FALSE; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment