So i recently hooked PR_Write in Mozilla and was able to log results( all of the connection literally ) to a log file, there's however one problem, i was assuming that after hooking PR_Write, i would be able to capture HTTPS data but when i log in to an HTTPS server, it doesn't capture the unencrypted POST data, i tried using localhost and making a fake POST and it captures the localhost post considering it's not encrypted. Is the point of hooking PR_Write not to capture all kinds of data?
This is the prototype of the PR_Write that i'm using and the variable:
typedef int (*Custom_Write)(PVOID, LPVOID, INT);
Custom_Write c_write=NULL;
PR_Write definition by Mozilla
and in the detour function, i call the original PR_Write by getting the address which is stored in c_write
using GetProcAddress. Below is how it's called:
// detour function
int detour_pr_write(int fd, LPVOID buf, int bytes)
{
// ... code for virtual protect
int retaddr=c_write(fd, buf, bytes);
// file functions
fwrite(buf, sizeof(char), strlen(buf), fileHandle);
// ... code for virtual protect
return retaddr; // go to original function
}
The logging and other stuff works fine but when it comes down to writing encrypted POST data, it fails. It ends up writing gibberish.