diff --git a/ChangeLog b/ChangeLog index 9981edd..c05dcc4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,90 +1,7 @@ To email a contributor remove "DELETE" from the email address. (The DELETEs are necessary as this list is published online.) -2023/09/2023 Hennik Hunsaker https://github.com/danhunsaker - * src/setup.h to change the size - * src/main.c to check the size rather than use a hard coded value - * src/init.c to check the size and offer half to the config; - * src/version.c Version increment: 4.1.7-b6 - -2023/06/20 Jeroen Derks https://github.com/Magentron - * src/cookie.c Solves #223 - * src/page.c Solves #223 - * src/version.c Version increment: 4.1.7-b5 - -2023/06/20 Jeroen Derks https://github.com/Magentron - * src/cookie.c Fixed integrity checks - * src/version.c Version increment: 4.1.7-b4 - -2023/04/10 Jeffrey Fulmer https://www.joedog.org/support/ - * src/cookie.c Added siege attribute persistent - * src/cookie.h Added public prototypes - * src/cookies.c Added persistence for -g/--get cookies - * src/init.c Added auth-urls for 403 challenges - * src/setup.h Added auth-url array - * src/version.c Version increment: 4.1.7-b3 - -2023/04/04 Jeffrey Fulmer https://www.joedog.org/support/ - * src/browser.c Don't accept auth challenge if we have no creds - * src/auth.c Return "" if we can't build a header - * src/auth.h Added BOOLEAN auth_has_credentials - * src/version.c Version increment: 4.1.7-b2 - -2023/02/21 Kirit Sælensminde https://github.com/KayEss - * .gitignore Added generated files - * src/main.c Added precision to output metrics - * src/version.c Version increment: 4.1.7-b1 - -2023/01/05 Jeffrey Fulmer https://www.joedog.org/support/ - * src/version.c Version increment: 4.1.6 - -2022/12/27 Jeffrey Fulmer https://www.joedog.org/support/ - * src/cookies.c Retrieve cookies in -p/--print mode (bug fix) - * src/sock.c More verbose message on resolution failures - * src/version.c Version increment: 4.1.6-b2 - -2022/10/03 Jeffrey Fulmer https://www.joedog.org/support/ - * src/log.c Print warning to stderr to elude > capture - * src/version.c Version increment: 4.1.6-b1 - -2022/08/02 Jeffrey Fulmer https://www.joedog.org/support/ - * src/browser.c Corrected deferred - * src/version. Version increment 4.1.5 - * utils/Makefile.am Added manifier to the distro - -2022/07/31 Jeffrey Fulmer https://www.joedog.org/support/ - * src/browser.c Made all threads cancel deferred - * src/ftp.c Catch 421: server accepts but doesn't handle - * src/timer.c Added a second to account for spool up - * src/version.c Version increment: 4.1.4 - -2022/04/18 Jeffrey Fulmer https://www.joedog.org/support/ - * src/memory.c Added xstrncpy, xstrncat - * src/memory.h Added xstrncpy, xstrncat - * src/cookies.c Implemented new x* functions - * src/ssl.c Silenced compiler warning - * src/main.c Added xstrncpy to silence warnings - * src/version.c Version increment: 4.1.3 - -2022/04/18 Frank Ledo via https://github.com/FrankLedo - * doc/siege.pod Fixed a typo in the man page - -2022/04/08 barryhunter via https://github.com/barryhunter - * src/parser.c Refined match for META redirect - -2022/03/21 cui fliter https://github.com/cuishuang - * src/browser.c Fixed typos - * src/date.c Fixed typos - * src/url.c Fixed typos - * utils/siege2csv.in Fixed typos - -2022/03/17 Jeffrey Fulmer https://www.joedog.org/support/ - * src/main.c Silenced statistics output on -g/--get - * src/cookies.c Improved domain matching, added my.get - * src/ssl.c Silenced a compiler warning - * src/version.c Version increment: 4.1.2 - -2021/07/14 Jeffrey Fulmer https://www.joedog.org/support/ + * src/browser.c Added HTTP response 201 handler * src/response.c Added Content-Location handler * src/response.h Added CONTENT_LOCATION value diff --git a/doc/siegerc.in b/doc/siegerc.in index 07e9346..f0c6d5f 100644 --- a/doc/siegerc.in +++ b/doc/siegerc.in @@ -614,6 +614,14 @@ unique = true # proxy-host = # proxy-port = +# +# Proxy Socks5: By default siege will attempt to connect to HTTP proxy +# (which is the most common way), however, you can enable socks5 proxy +# with the setting proxy-socks5 +# +# ex: proxy-socks5 = true +# proxy-socks5 = + # # Proxy-Authenticate: When siege hits a proxy server which requires # username and password authentication, it will this username and diff --git a/src/Makefile.am b/src/Makefile.am index 0672547..1666b29 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -62,6 +62,7 @@ parser.c parser.h \ perl.c perl.h \ response.c response.h \ sock.c sock.h \ +socks5.c socks5.h \ ssl.c ssl.h \ stralloc.c stralloc.h \ timer.c timer.h \ diff --git a/src/auth.c b/src/auth.c index c27aa4f..b9cec41 100644 --- a/src/auth.c +++ b/src/auth.c @@ -78,10 +78,11 @@ struct AUTH_T { unsigned char nonce[8]; } ntlm; struct { - BOOLEAN required; /* boolean, TRUE == use a proxy server. */ - char *hostname; /* hostname for the proxy server. */ - int port; /* port number for proxysrv */ - char *encode; /* base64 encoded username and password */ + BOOLEAN required; /* boolean, TRUE == use a proxy server. */ + BOOLEAN socks5; /* boolean, TRUE == socks5, FALSE == http proxy */ + char *hostname; /* hostname for the proxy server. */ + int port; /* port number for proxysrv */ + char *encode; /* base64 encoded username and password */ } proxy; pthread_mutex_t lock; }; @@ -405,6 +406,14 @@ auth_get_proxy_required(AUTH this) return this->proxy.required; } +BOOLEAN +auth_get_proxy_socks5(AUTH this) +{ + if (this == NULL) + return FALSE; + return this->proxy.socks5; +} + char * auth_get_proxy_host(AUTH this) { @@ -423,6 +432,12 @@ auth_set_proxy_required(AUTH this, BOOLEAN required) this->proxy.required = required; } +void +auth_set_proxy_socks5(AUTH this, BOOLEAN socks5) +{ + this->proxy.socks5 = socks5; +} + void auth_set_proxy_host(AUTH this, char *host) { diff --git a/src/auth.h b/src/auth.h index 3993dfb..920c695 100644 --- a/src/auth.h +++ b/src/auth.h @@ -46,7 +46,9 @@ BOOLEAN auth_set_ntlm_header(AUTH this, SCHEME scheme, char *header, char *realm char * auth_get_digest_header(AUTH this, SCHEME scheme, DCHLG *chlg, DCRED *cred, const char *meth, const char *uri); BOOLEAN auth_set_digest_header(AUTH this, DCHLG **ch, DCRED **cr, unsigned int *rand, char *realm, char *str); BOOLEAN auth_get_proxy_required(AUTH this); +BOOLEAN auth_get_proxy_socks5(AUTH this); void auth_set_proxy_required(AUTH this, BOOLEAN required); +void auth_set_proxy_socks5(AUTH this, BOOLEAN socks5); char * auth_get_proxy_host(AUTH this); void auth_set_proxy_host(AUTH this, char *host); int auth_get_proxy_port(AUTH this); diff --git a/src/browser.c b/src/browser.c index 85815ad..7ce431e 100644 --- a/src/browser.c +++ b/src/browser.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -951,8 +952,14 @@ __init_connection(BROWSER this, URL U) (auth_get_proxy_required(my.auth))?auth_get_proxy_port(my.auth):url_get_port(U) ); + if (auth_get_proxy_required(my.auth) && auth_get_proxy_socks5(my.auth)) { + if ( !socks5_tunnel_mount(this->conn, url_get_hostname(U), url_get_port(U)) ) { + return FALSE; + } + } if (url_get_scheme(U) == HTTPS) { - if (auth_get_proxy_required(my.auth)) { + // if (auth_get_proxy_required(my.auth)) { + if (auth_get_proxy_required(my.auth) && !auth_get_proxy_socks5(my.auth) ) { https_tunnel_request(this->conn, url_get_hostname(U), url_get_port(U)); https_tunnel_response(this->conn); } diff --git a/src/http.c b/src/http.c index ef9be88..5dde105 100644 --- a/src/http.c +++ b/src/http.c @@ -58,7 +58,7 @@ https_tunnel_request(CONN *C, char *host, int port) size_t rlen, n; char request[256]; - if (C->encrypt == TRUE && auth_get_proxy_required(my.auth)) { + if (C->encrypt == TRUE && auth_get_proxy_required(my.auth) && !auth_get_proxy_socks5(my.auth)) { snprintf( request, sizeof(request), "CONNECT %s:%d HTTP/1.0\015\012" @@ -133,7 +133,7 @@ http_get(CONN *C, URL U) ifmod = cache_get_header(C->cache, C_LAST, U); /* Request path based on proxy settings */ - if(auth_get_proxy_required(my.auth)){ + if(auth_get_proxy_required(my.auth) && !auth_get_proxy_socks5(my.auth) ){ sprintf( fullpath, "%s://%s:%d%s", C->encrypt == FALSE?"http":"https", url_get_hostname(U), url_get_port(U), url_get_request(U) @@ -291,7 +291,7 @@ http_post(CONN *C, URL U) memset(protocol, '\0', sizeof(protocol)); memset(keepalive,'\0', sizeof(keepalive)); - if (auth_get_proxy_required(my.auth)) { + if (auth_get_proxy_required(my.auth) && !auth_get_proxy_socks5(my.auth)) { sprintf( fullpath, "%s://%s:%d%s", diff --git a/src/init.c b/src/init.c index 3ba6d08..fde2e16 100644 --- a/src/init.c +++ b/src/init.c @@ -115,6 +115,7 @@ init_config( void ) my.auth = new_auth(); auth_set_proxy_required(my.auth, FALSE); auth_set_proxy_port(my.auth, 3128); + auth_set_proxy_socks5(my.auth, FALSE); my.timeout = 30; my.timestamp = FALSE; my.chunked = FALSE; @@ -209,6 +210,7 @@ show_config(int EXIT) if (auth_get_proxy_required(my.auth)){ printf("proxy-host: %s\n", auth_get_proxy_host(my.auth)); printf("proxy-port: %d\n", auth_get_proxy_port(my.auth)); + printf("proxy-socks5: %s\n", auth_get_proxy_socks5(my.auth) ? "true" : "false"); } printf("connection: %s\n", my.keepalive?"keep-alive":"close"); printf("concurrent users: %d\n", my.cusers); @@ -573,6 +575,12 @@ load_conf(char *filename) else if (strmatch(option, "proxy-host")) { auth_set_proxy_host(my.auth, trim(value)); } + else if (strmatch(option, "proxy-socks5")) { + if (!strncasecmp(value, "true", 4)) + auth_set_proxy_socks5(my.auth, TRUE); + else + auth_set_proxy_socks5(my.auth, FALSE); + } else if (strmatch(option, "proxy-port")) { if (value != NULL) { auth_set_proxy_port(my.auth, atoi(value));