Last active
August 27, 2015 11:54
-
-
Save maxired/e8e96ace9ea9b263f674 to your computer and use it in GitHub Desktop.
SSL Hack
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
ALL: | |
gcc -fPIC -shared -o sslhack.so sslhack.c -lc -ldl |
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
ALL: | |
gcc -fPIC -shared -o sslhack.so sslhack.c -lc -ldl |
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 <stdlib.h> | |
#include <sys/types.h> | |
#include <string.h> | |
#include <dlfcn.h> | |
#include <openssl/ssl.h> | |
#include <stdio.h> | |
#define LIBC_NAME "libssl.so.1.0.0" | |
int SSL_read(SSL *ssl, void *buf, int num){ | |
void *libc; | |
libc = dlopen(LIBC_NAME, RTLD_LAZY); | |
if(!libc){ | |
printf("Unable to open the lib \n"); | |
return -1;} | |
int (*bind_ptr)(void * , void *, int); | |
*(void **) (&bind_ptr) = dlsym(libc, "SSL_read"); | |
if(!bind_ptr){ | |
return -1;} | |
int ret = (int)(*bind_ptr)(ssl, | |
buf, | |
num); | |
if(ret>0){ | |
printf("RECV : %d bytes %.*s \n" ,ret, ret ,(char*)buf); | |
} | |
return ret; | |
} | |
int SSL_write(SSL *ssl, const void *buf, int num){ | |
void *libc; | |
libc = dlopen(LIBC_NAME, RTLD_LAZY); | |
if(!libc){ | |
printf("Unable to open the lib \n"); | |
return -1;} | |
int (*bind_ptr)(void * , void *, int); | |
*(void **) (&bind_ptr) = dlsym(libc, "SSL_write"); | |
if(!bind_ptr){ | |
return -1;} | |
int ret = (int)(*bind_ptr)(ssl, | |
buf, | |
num); | |
if(ret>0){ | |
printf("SEND : %d bytes , %.*s \n" , ret, ret, (char*)buf); | |
} | |
return ret; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment