Skip to content

Commit

Permalink
Adds URL rewriting in WebBrowser and WinInet GET, POST and POST with …
Browse files Browse the repository at this point in the history
…file (#39)

* Update dynamic_patch.c

Adiciona GG Patch:
TH S2 312b
TH S2 321a

* Update common.c

fix type parameter

* Update config.h

Option BypassSelfSignedCertificate

ignora os certificados inválidos

* Update config.c

Option BypassSelfSignedCertificate

ignora certificados inválidos

* add ole32 web_browser

Adiciona os Hooks do WebBrowser.
O básico do MFC(usado no update.exe) e o IWebBrowser(usado no ProjectG.exe)

* Update common-fnptr.h

Add new types to Wininet and WebBrowser

* Update hooks.c

add InitWebBrowserHook

* Update inject.c

fix CreateProccessAHook

* Update Makefile

add ole32/web_browser.o

* Update rugburn.vcxproj

add ole32\web_browser.c

* Update rugburn.vcxproj.filters

add ole32\web_browser.c

* Update rugburn_test.vcxproj

add ole32\web_browser.c

* Update rugburn_test.vcxproj.filters

add ole32\web_browser.c

* Update netredir.c

adiciona os hooks para o WinInet.

Versões GET, POST e POST com arquivo.

Já que não consegui fazer o InternetErrorDlg funcionar,
para pedir a permissão do usuário para certificados inválidos e redirecionamento de POST.
(mesmo com HWND e Flags ele não cria o DLG e retorna ERROR_CANCELED).

Então criei uma opção no .json para ignora os erros de certificados:
"BypassSelfSignedCertificate": "TRUE"

POST que precisa de permissão para ele ignora direto e faz o redirecionamento.

* Update common-fnptr.h

adiciona o IWebBrowser type, por que o MinGW do github não tem o arquivo ExDisp.h, mas o cygwin64 -> MinGW tem ele.

* Update common-fnptr.h

melhorias

* add exdisport.h

definição da struct IWebBrowser

* Update netredir.c

Ajeitei para quando criar uma nova handle do OpenRequest todas as outras funções ganchos usar a nova handle.

* Update common-fnptr.h

fix

* Update web_browser.c

fix SysFreeString
  • Loading branch information
Acrisio-Filho authored Sep 14, 2024
1 parent 7a09cf6 commit 027f59d
Show file tree
Hide file tree
Showing 16 changed files with 2,044 additions and 13 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ OBJS := \
obj/hooks/ws2_32/redir.o \
obj/hooks/wininet/netredir.o \
obj/hooks/comctl32/dynamic_patch.o \
obj/hooks/ole32/web_browser.o \
obj/hooks/hooks.o \
obj/ld.o \
obj/common.o \
Expand Down
1 change: 1 addition & 0 deletions rugburn.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
<ClCompile Include="src\config.c" />
<ClCompile Include="src\dll\rugburn\main.c" />
<ClCompile Include="src\hex.c" />
<ClCompile Include="src\hooks\ole32\web_browser.c" />
<ClCompile Include="src\ijl15.c" />
<ClCompile Include="src\hooks\comctl32\dynamic_patch.c" />
<ClCompile Include="src\hooks\hooks.c" />
Expand Down
1 change: 1 addition & 0 deletions rugburn.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<ClCompile Include="src\hooks\wininet\netredir.c" />
<ClCompile Include="src\hooks\ws2_32\redir.c" />
<ClCompile Include="src\dll\rugburn\main.c" />
<ClCompile Include="src\hooks\ole32\web_browser.c" />
</ItemGroup>
<ItemGroup>
<None Include="LICENSE.md" />
Expand Down
1 change: 1 addition & 0 deletions rugburn_test.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@
<ClCompile Include="src\hooks\hooks.c" />
<ClCompile Include="src\hooks\kernel32\inject.c" />
<ClCompile Include="src\hooks\msvcr100\msvcr100.c" />
<ClCompile Include="src\hooks\ole32\web_browser.c" />
<ClCompile Include="src\hooks\projectg\us852\ranking.c" />
<ClCompile Include="src\hooks\user32\window.c" />
<ClCompile Include="src\hooks\wininet\netredir.c" />
Expand Down
1 change: 1 addition & 0 deletions rugburn_test.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<ClCompile Include="src\hooks\wininet\netredir.c" />
<ClCompile Include="src\hooks\ws2_32\redir.c" />
<ClCompile Include="src\exe\test\main.c" />
<ClCompile Include="src\hooks\ole32\web_browser.c" />
</ItemGroup>
<ItemGroup>
<None Include="LICENSE.md" />
Expand Down
60 changes: 58 additions & 2 deletions src/common-fnptr.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
#include <windows.h>
#include <ws2tcpip.h>

// IWebBrowser 1 and 2
#include "exdispport.h"

#ifdef __MINGW32__

typedef struct _DNS_QUERY_REQUEST {
Expand Down Expand Up @@ -53,6 +56,24 @@ typedef struct tagINITCOMMONCONTROLSEX {
// comctl32.dll
typedef BOOL(STDCALL *PFNINITCOMMONCONTROLSEXPROC)(const INITCOMMONCONTROLSEX *picce);

// ole32.dll
typedef HRESULT(STDCALL *PFNCOGETCLASSOBJECTPROC)(REFCLSID rclsid, DWORD dwClsContext,
LPVOID pvReserved, REFIID riid, LPVOID *ppv);
typedef HRESULT(STDCALL *PFNCOCREATEINSTANCEPROC)(REFCLSID rclsid, LPUNKNOWN pUnkOuter,
DWORD dwClsContext, REFIID riid, LPVOID *ppv);

// oleaut32.dll
typedef BSTR(STDCALL *PFNSYSALLOCSTRINGLENPROC)(const OLECHAR *strIn, UINT ui);
typedef void(STDCALL *PFNSYSFREESTRINGPROC)(BSTR bstrString);

// ieframe.dll
typedef HRESULT(STDCALL *PFNINVOKEPROC)(IDispatch *This, DISPID dispIdMember, REFIID riid,
LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr);
typedef HRESULT(STDCALL *PFNNAVIGATEPROC)(IWebBrowser2 *This, BSTR URL, VARIANT *Flags,
VARIANT *TargetFrameName, VARIANT *PostData,
VARIANT *Headers);

// general
typedef BOOL(WINAPI *PFNDLLMAINPROC)(HANDLE, DWORD, LPVOID);

Expand Down Expand Up @@ -141,10 +162,45 @@ typedef VOID(STDCALL *PFNGETSTARTUPINFOAPROC)(LPSTARTUPINFOA lpStartupInfo);
typedef VOID(STDCALL *PFNGETSTARTUPINFOWPROC)(LPSTARTUPINFOW lpStartupInfo);

// wininet.dll
typedef void(STDCALL *PFNINTERNETCONNECTAPROC)(HINTERNET, LPCSTR, INTERNET_PORT, LPCSTR, LPCSTR,
DWORD, DWORD, DWORD_PTR);
typedef HINTERNET(STDCALL *PFNINTERNETOPENURLAPROC)(HINTERNET, LPCSTR, LPCSTR, DWORD, DWORD,
DWORD_PTR);
typedef HINTERNET(STDCALL *PFNINTERNETCONNECTAPROC)(HINTERNET hInternet, LPCSTR lpszServerName,
INTERNET_PORT nServerPort, LPCSTR lpszUserName,
LPCSTR lpszPassword, DWORD dwService,
DWORD dwFlags, DWORD_PTR dwContext);
typedef HINTERNET(STDCALL *PFNHTTPOPENREQUESTAPROC)(HINTERNET hConnect, LPCSTR lpszVerb,
LPCSTR lpszObjectName, LPCSTR lpszVersion,
LPCSTR lpszReferrer, LPCSTR *lplpszAcceptTypes,
DWORD dwFlags, DWORD_PTR dwContext);
typedef BOOL(STDCALL *PFNHTTPSENDREQUESTAPROC)(HINTERNET hRequest, LPCSTR lpszHeaders,
DWORD dwHeadersLength, LPVOID lpOptional,
DWORD dwOptionalLength);
typedef BOOL(STDCALL *PFNHTTPSENDREQUESTEXAPROC)(HINTERNET hRequest,
LPINTERNET_BUFFERSA lpBuffersIn,
LPINTERNET_BUFFERSA lpBuffersOut, DWORD dwFlags,
DWORD_PTR dwContext);
typedef BOOL(STDCALL *PFNHTTPENDREQUESTAPROC)(HINTERNET hRequest, LPINTERNET_BUFFERSA lpBuffersOut,
DWORD dwFlags, DWORD_PTR dwContext);
typedef BOOL(STDCALL *PFNHTTPADDREQUESTHEADERSAPROC)(HINTERNET hRequest, LPCSTR lpszHeaders,
DWORD dwHeadersLength, DWORD dwModifiers);
typedef BOOL(STDCALL *PFNHTTPQUERYINFOAPROC)(HINTERNET hRequest, DWORD dwInfoLevel, LPVOID lpBuffer,
LPDWORD lpdwBufferLength, LPDWORD lpdwIndex);
typedef BOOL(STDCALL *PFNINTERNETCLOSEHANDLEPROC)(HINTERNET hInternet);
typedef BOOL(STDCALL *PFNINTERNETQUERYDATAAVAILABLEPROC)(HINTERNET hFile,
LPDWORD lpdwNumberOfBytesAvailable,
DWORD dwFlags, DWORD_PTR dwContext);
typedef BOOL(STDCALL *PFNINTERNETWRITEFILEPROC)(HINTERNET hFile, LPCVOID lpBuffer,
DWORD dwNumberOfBytesToWrite,
LPDWORD lpdwNumberOfBytesWritten);
typedef BOOL(STDCALL *PFNINTERNETREADFILEPROC)(HINTERNET hFile, LPVOID lpBuffer,
DWORD dwNumberOfBytesToRead,
LPDWORD lpdwNumberOfBytesRead);
typedef BOOL(STDCALL *PFNINTERNETQUERYOPTIONAPROC)(HINTERNET hInternet, DWORD dwOption,
LPVOID lpBuffer, LPDWORD lpdwBufferLength);
typedef BOOL(STDCALL *PFNINTERNETSETOPTIONAPROC)(HINTERNET hInternet, DWORD dwOption,
LPVOID lpBuffer, DWORD dwBufferLength);
typedef BOOL(STDCALL *PFNINTERNETCRACKURLAPROC)(LPCSTR lpszUrl, DWORD dwUrlLength, DWORD dwFlags,
LPURL_COMPONENTSA lpUrlComponents);

// winmm.dll
typedef DWORD(STDCALL *PFNTIMEGETTIMEPROC)();
Expand Down
2 changes: 1 addition & 1 deletion src/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ PSTR GetSelfPath() {
return pszSelfPath;
}

BOOL FileExists(LPCTSTR szPath) { return GetFileAttributesA(szPath) != INVALID_FILE_ATTRIBUTES; }
BOOL FileExists(LPCSTR szPath) { return GetFileAttributesA(szPath) != INVALID_FILE_ATTRIBUTES; }

LPSTR ReadEntireFile(LPCSTR szPath, LPDWORD dwFileSize) {
HANDLE hFile = NULL;
Expand Down
14 changes: 14 additions & 0 deletions src/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,27 @@ void ReadJsonPatchAddressMap(LPSTR *json, LPCSTR key) {
Config.NumPatchAddress++;
}

void ReadJsonBypassSelfSignedCertificate(LPSTR *json, LPCSTR key) {
LPCSTR value = JsonReadString(json);

Config.bBypassSelfSignedCertificate = FALSE;

if (value == NULL || value == "")
return;

if (_stricmp(value, "TRUE") == 0)
Config.bBypassSelfSignedCertificate = TRUE;
}

void ReadJsonConfigMap(LPSTR *json, LPCSTR key) {
if (!strcmp(key, "UrlRewrites")) {
JsonReadMap(json, ReadJsonUrlRewriteRuleMap);
} else if (!strcmp(key, "PortRewrites")) {
JsonReadArray(json, ReadJsonPortRewriteRuleArray);
} else if (!strcmp(key, "PatchAddress")) {
JsonReadMap(json, ReadJsonPatchAddressMap);
} else if (!strcmp(key, "BypassSelfSignedCertificate")) {
ReadJsonBypassSelfSignedCertificate(json, key);
} else {
FatalError("Unexpected JSON config key '%s'", key);
}
Expand Down
2 changes: 2 additions & 0 deletions src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ typedef struct _RUGBURNCONFIG {

PATCHADDRESS PatchAddress[MAXPATCHADDRESS];
int NumPatchAddress;

BOOL bBypassSelfSignedCertificate;
} RUGBURNCONFIG, *LPRUGBURNCONFIG;

extern RUGBURNCONFIG Config;
Expand Down
Loading

0 comments on commit 027f59d

Please sign in to comment.