diff --git a/basicauth.c b/basicauth.c index 6e037ee..8ab54b8 100644 --- a/basicauth.c +++ b/basicauth.c @@ -31,24 +31,28 @@ * Create the HTTP basic authentication cookie for use by the proxy. Result * is stored in basicauth. */ -void make_basicauth() { - int len = strlen( args_info.user_arg ) + strlen( args_info.pass_arg ) + 2; +char *basicauth(char *user, char *pass) { + char b64str[80]; /* Buffer to hold the proxies basic authentication data */ + + int len = strlen( user ) + strlen( pass ) + 2; char *p = (char *) malloc( len ); /* Set up the cookie in clear text */ - sprintf( p, "%s:%s", args_info.user_arg, args_info.pass_arg ); + sprintf( p, "%s:%s", user, pass ); /* * Base64 encode the clear text cookie to create the HTTP base64 * authentication cookie */ - base64( (unsigned char *)basicauth, (unsigned char *)p, strlen(p) ); + base64( (unsigned char *)b64str, (unsigned char *)p, strlen(p) ); // if( args_info.verbose_flag ) { // message( "Proxy basic auth of %s is %s\n", p, basicauth ); // } free( p ); + + return b64str; } // vim:noexpandtab:ts=4 diff --git a/basicauth.h b/basicauth.h index 5ba0239..ce72c13 100644 --- a/basicauth.h +++ b/basicauth.h @@ -18,9 +18,8 @@ */ /* basicauth.h */ -char basicauth[80]; /* Buffer to hold the proxies basic authentication data */ /* Functions */ -void make_basicauth(); +char *basicauth(char *user, char *pass); // vim:noexpandtab:ts=4 diff --git a/http.c b/http.c index a274d46..44574f3 100644 --- a/http.c +++ b/http.c @@ -122,7 +122,7 @@ void proxy_protocol(PTSTREAM *pts) { strzcat( buf, "Proxy-Authorization: NTLM %s\r\n", ntlm_type1_buf ); } } else { - strzcat( buf, "Proxy-Authorization: Basic %s\r\n", basicauth ); + strzcat( buf, "Proxy-Authorization: Basic %s\r\n", basicauth(args_info.user_arg, args_info.pass_arg ) ); } } @@ -161,8 +161,8 @@ void proxy_protocol(PTSTREAM *pts) { message( "\nTunneling to %s (destination)\n", args_info.dest_arg ); sprintf( buf, "CONNECT %s HTTP/1.0\r\n", args_info.dest_arg); - if ( args_info.user_given && args_info.pass_given ) - strzcat( buf, "Proxy-Authorization: Basic %s\r\n", basicauth ); + if ( args_info.remuser_given && args_info.rempass_given ) + strzcat( buf, "Proxy-Authorization: Basic %s\r\n", basicauth(args_info.remuser_arg, args_info.rempass_arg )); strzcat( buf, "Proxy-Connection: Keep-Alive\r\n"); diff --git a/proxytunnel.c b/proxytunnel.c index 6234176..6268bcd 100644 --- a/proxytunnel.c +++ b/proxytunnel.c @@ -346,8 +346,6 @@ int main( int argc, char *argv[] ) { build_type1(); if ( args_info.verbose_flag ) message("Build Type 1 NTLM Message : %s\n", ntlm_type1_buf); - } else { - make_basicauth(); } }