Click here to Skip to main content
15,890,375 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi brother,

How to clean variable from WinHttp api?

I use codecave to call winhttp api but I want to hide the url. I have called RtlZeroMemory but the url is still visible...

Can Variables be cleared with kernel32.RtlZeroMemory? Can kernel32.RtlZeroMemory be called from user mode?

I have no idea to clean up memory from codecave.

thanks in advance,

What I have tried:

if (hConnect)
        hRequest = WinHttpOpenRequest( hConnect, L"PUT", 
                                       L"/writetst.txt", 
                                       NULL, WINHTTP_NO_REFERER, 
                                       WINHTTP_DEFAULT_ACCEPT_TYPES,
                                       0);
Posted
Updated 7-Jul-17 3:11am

1 solution

You must only search, read and understand the in HttpOpenRequest documentation which says:

"After the calling application finishes using the HINTERNET handle returned by WinHttpOpenRequest, it must be closed using the WinHttpCloseHandle function."

C++
WinHttpCloseHandle(hRequest);
hRequest = 0;//to make it clear


I leave it to you to find the closing of the connection handle yourself. ;-)
 
Share this answer
 
Comments
royal grandong 7-Jul-17 9:26am    
In my case I just call WinHttpOpenRequest one time but after I dump memory there are many memory address which store my url both ansi dan unicode string version.

I've called WinHttpCloseHandle.

thanks @

here is my PowerBASIC code :

CALL DWORD @p.fnWinHttpOpen USING WinHttpOpen( _
@p.fnUserAgent, _
%WINHTTP_ACCESS_TYPE_DEFAULT_PROXY, _
BYVAL %WINHTTP_NO_PROXY_NAME, _
BYVAL %WINHTTP_NO_PROXY_BYPASS, _
0) TO hSession

IF hSession THEN CALL DWORD @p.fnWinHttpConnect USING WinHttpConnect( _
hSession, _
wzServer, _ '--> here is my decrypted server string
%INTERNET_DEFAULT_HTTP_PORT, _
0) TO hConnect

CALL DWORD @p.fnRtlZeroMemory USING RtlZeroMemoryDummy(VARPTR(wzServer),%MAX_PATH)

IF hConnect THEN CALL DWORD @p.fnWinHttpOpenRequest USING WinHttpOpenRequest( _
hConnect, _
@p.fnReqMethod, _
wzUrl, _ '--> here is my decrypted url string
BYVAL %NULL, _
BYVAL %WINHTTP_NO_REFERER, _
BYVAL %WINHTTP_DEFAULT_ACCEPT_TYPES, _
0) TO hRequest

CALL DWORD @p.fnRtlZeroMemory USING RtlZeroMemoryDummy(VARPTR(wzUrl),%MAX_PATH)

IF hRequest THEN CALL DWORD @p.fnWinHttpSendRequest USING WinHttpSendRequest( _
hRequest, _
BYVAL %WINHTTP_NO_ADDITIONAL_HEADERS, _
0, _
%WINHTTP_NO_REQUEST_DATA, _
0, _
0, _
0) TO bResults

IF bResults THEN CALL DWORD @p.fnWinHttpCloseHandle USING WinHttpCloseHandle(bResults)
IF hRequest THEN CALL DWORD @p.fnWinHttpCloseHandle USING WinHttpCloseHandle(hRequest)
IF hConnect THEN CALL DWORD @p.fnWinHttpCloseHandle USING WinHttpCloseHandle(hConnect)
IF hSession THEN CALL DWORD @p.fnWinHttpCloseHandle USING WinHttpCloseHandle(hSession)

CALL DWORD @p.fnRtlZeroMemory USING RtlZeroMemoryDummy(VARPTR(wzServer),%MAX_PATH)
CALL DWORD @p.fnRtlZeroMemory USING RtlZeroMemoryDummy(VARPTR(wzUrl),%MAX_PATH)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900