Skip to content

Instantly share code, notes, and snippets.

@maxired
Last active August 27, 2015 11:54
Show Gist options
  • Save maxired/e8e96ace9ea9b263f674 to your computer and use it in GitHub Desktop.
Save maxired/e8e96ace9ea9b263f674 to your computer and use it in GitHub Desktop.
SSL Hack
ALL:
gcc -fPIC -shared -o sslhack.so sslhack.c -lc -ldl
ALL:
gcc -fPIC -shared -o sslhack.so sslhack.c -lc -ldl
#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