Remove MSProxy support

It's not enabled anywhere, certainly not maintained
This commit is contained in:
TingPing 2014-12-28 13:28:19 -05:00
parent 330e31c70f
commit 9cb73f839f
12 changed files with 8 additions and 938 deletions

View File

@ -39,7 +39,6 @@ AH_VERBATIM([PREFIX],[#undef PREFIX])
AH_VERBATIM([HEXCHATLIBDIR],[#undef HEXCHATLIBDIR])
AH_VERBATIM([HEXCHATSHAREDIR],[#undef HEXCHATSHAREDIR])
AH_VERBATIM([SOCKS],[#undef SOCKS])
AH_VERBATIM([USE_MSPROXY],[#undef USE_MSPROXY])
AH_VERBATIM([USE_LIBPROXY],[#undef USE_LIBPROXY])
AH_VERBATIM([HAVE_ISO_CODES],[#undef HAVE_ISO_CODES])
AH_VERBATIM([HAVE_GTK_MAC],[#undef HAVE_GTK_MAC])
@ -150,10 +149,6 @@ AC_ARG_ENABLE(libcanberra,
[AS_HELP_STRING([--disable-libcanberra],[disable libcanberra support])],
libcanberra=$enableval, libcanberra=yes)
AC_ARG_ENABLE(ntlm,
[AS_HELP_STRING([--enable-ntlm],[enable Microsoft\'s NTLM auth (libntlm) library support (default: no)])],
ntlm=$enableval, ntlm=no)
AC_ARG_ENABLE(libproxy,
[AS_HELP_STRING([--disable-libproxy],[disable libproxy support (default: auto)])],
libproxy=$enableval, libproxy=auto)
@ -603,7 +598,6 @@ dnl *********************************************************************
AM_CONDITIONAL(USE_OPENSSL, test "x$openssl" = "xyes")
AM_CONDITIONAL(USE_LIBNOTIFY, test "x$libnotify" = "xyes")
AM_CONDITIONAL(USE_LIBCANBERRA, test "x$libcanberra" = "xyes")
AM_CONDITIONAL(USE_MSPROXY, test "x$ntlm" = "xyes")
AM_CONDITIONAL(DO_TEXT, test "x$textfe" = "xyes")
AM_CONDITIONAL(DO_GTK, test "x$gtkfe" = "xyes")
AM_CONDITIONAL(DO_PERL, test "x$perl" = "xyes")
@ -635,20 +629,6 @@ if test "$socks" = yes; then
fi
fi
dnl *********************************************************************
dnl ** MS PROXY *********************************************************
dnl *********************************************************************
have_ntlm="no"
if test "x$ntlm" = "xyes" ; then
have_ntlm="no"
AC_CHECK_LIB(ntlm, ntlm_smb_encrypt, have_ntlm=yes)
if test "$have_ntlm" = yes; then
LIBS="$LIBS -lntlm"
AC_DEFINE(USE_MSPROXY)
fi
fi
dnl *********************************************************************
dnl ** GCC FLAGS ********************************************************
dnl *********************************************************************
@ -868,7 +848,6 @@ echo libnotify support ..... : $libnotify
echo libcanberra support ... : $libcanberra
echo Plugin interface ...... : $plugin
echo IPv6 support .......... : $ipv6
echo MS Proxy NTLM \(ISA\) ... : $have_ntlm
echo libproxy support ...... : $libproxy
echo
echo Perl .................. : $perl

View File

@ -22,7 +22,6 @@ EXTRA_DIST = \
inet.h \
make-te.c \
modes.h \
msproxy.h \
network.h \
notify.h \
outbound.h \
@ -46,10 +45,6 @@ if USE_OPENSSL
ssl_c = ssl.c
endif
if USE_MSPROXY
msproxy_c = msproxy.c
endif
if USE_DBUS
dbusdir = dbus
libhexchatcommon_a_LIBADD = \
@ -64,7 +59,7 @@ endif
noinst_PROGRAMS = make-te
libhexchatcommon_a_SOURCES = cfgfiles.c chanopt.c ctcp.c dcc.c hexchat.c \
history.c ignore.c inbound.c marshal.c modes.c $(msproxy_c) network.c notify.c \
history.c ignore.c inbound.c marshal.c modes.c network.c notify.c \
outbound.c plugin.c plugin-timer.c proto-irc.c server.c servlist.c \
$(ssl_c) text.c tree.c url.c userlist.c util.c
libhexchatcommon_a_CFLAGS = $(LIBPROXY_CFLAGS)

View File

@ -26,7 +26,6 @@
<ClInclude Include="inet.h" />
<ClInclude Include="marshal.h" />
<ClInclude Include="modes.h" />
<ClInclude Include="msproxy.h" />
<ClInclude Include="network.h" />
<ClInclude Include="notify.h" />
<ClInclude Include="outbound.h" />
@ -59,7 +58,6 @@
<ClCompile Include="inbound.c" />
<ClCompile Include="marshal.c" />
<ClCompile Include="modes.c" />
<ClCompile Include="msproxy.c" />
<ClCompile Include="network.c" />
<ClCompile Include="notify.c" />
<ClCompile Include="outbound.c" />
@ -167,4 +165,4 @@ powershell -File "$(SolutionDir)..\win32\version-template.ps1" "$(SolutionDir)..
]]></Command>
</PreBuildEvent>
</ItemDefinitionGroup>
</Project>
</Project>

View File

@ -44,9 +44,6 @@
<ClInclude Include="modes.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="msproxy.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="network.h">
<Filter>Header Files</Filter>
</ClInclude>
@ -142,9 +139,6 @@
<ClCompile Include="modes.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="msproxy.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="network.c">
<Filter>Source Files</Filter>
</ClCompile>
@ -197,4 +191,4 @@
<ItemGroup>
<None Include="..\..\win32\config.h.tt" />
</ItemGroup>
</Project>
</Project>

View File

@ -55,10 +55,6 @@
#include <glib-object.h> /* for g_type_init() */
#endif
#ifdef USE_MSPROXY
#include "msproxy.h"
#endif
#ifdef USE_LIBPROXY
#include <proxy.h>
#endif
@ -360,9 +356,6 @@ static int
hexchat_misc_checks (void) /* this gets called every 1/2 second */
{
static int count = 0;
#ifdef USE_MSPROXY
static int count2 = 0;
#endif
count++;
@ -378,15 +371,6 @@ hexchat_misc_checks (void) /* this gets called every 1/2 second */
count = 0;
}
#ifdef USE_MSPROXY
count2++;
if (count2 >= 720) /* 720 every 6 minutes */
{
msproxy_keepalive ();
count2 = 0;
}
#endif
return 1;
}

View File

@ -429,14 +429,6 @@ typedef struct session
void (*scrollback_replay_marklast) (struct session *sess);
} session;
struct msproxy_state_t
{
gint32 clientid;
gint32 serverid;
unsigned char seq_recv; /* seq number of last packet recv. */
unsigned char seq_sent; /* seq number of last packet sent. */
};
/* SASL Mechanisms */
#define MECH_PLAIN 0
#define MECH_BLOWFISH 1
@ -494,7 +486,6 @@ typedef struct server
int proxy_sok; /* Additional information for MS Proxy beast */
int proxy_sok4;
int proxy_sok6;
struct msproxy_state_t msp_state;
int id; /* unique ID number (for plugin API) */
#ifdef USE_OPENSSL
SSL_CTX *ctx;

View File

@ -1,470 +0,0 @@
/* X-Chat
* Copyright (C) 1998 Peter Zelezny.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*
* MS Proxy (ISA server) support is (c) 2006 Pavel Fedin <sonic_amiga@rambler.ru>
* based on Dante source code
* Copyright (c) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
* Inferno Nettverk A/S, Norway. All rights reserved.
*/
/*#define DEBUG_MSPROXY*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <fcntl.h>
#ifndef WIN32
#include <unistd.h>
#endif
#define WANTSOCKET
#define WANTARPA
#include "inet.h"
#include "hexchat.h"
#include "network.h"
#include "hexchatc.h"
#include "server.h"
#include "msproxy.h"
#ifdef USE_MSPROXY
#include <ntlm.h>
static int
send_msprequest(s, state, request, end)
int s;
struct msproxy_state_t *state;
struct msproxy_request_t *request;
char *end;
{
ssize_t w;
size_t l;
request->magic25 = htonl(MSPROXY_VERSION);
request->serverack = state->seq_recv;
/* don't start incrementing sequence until we are acking packet #2. */
request->sequence = (unsigned char)(request->serverack >= 2 ? state->seq_sent + 1 : 0);
memcpy(request->RWSP, "RWSP", sizeof(request->RWSP));
l = end - (char *)request;
/* all requests must be atleast MSPROXY_MINLENGTH it seems. */
if (l < MSPROXY_MINLENGTH) {
bzero(end, (size_t)(MSPROXY_MINLENGTH - l));
l = MSPROXY_MINLENGTH;
}
if ((w = send(s, request, l, 0)) != l) {
#ifdef DEBUG_MSPROXY
printf ("send_msprequest(): send() failed (%ld bytes sent instead of %Iu\n", w, l);
perror ("Error is");
#endif
return -1;
}
state->seq_sent = request->sequence;
return w;
}
static int
recv_mspresponse(s, state, response)
int s;
struct msproxy_state_t *state;
struct msproxy_response_t *response;
{
ssize_t r;
do {
if ((r = recv (s, response, sizeof (*response), 0)) < MSPROXY_MINLENGTH) {
#ifdef DEBUG_MSPROXY
printf ("recv_mspresponse(): expected to read atleast %d, read %ld\n", MSPROXY_MINLENGTH, r);
#endif
return -1;
}
if (state->seq_recv == 0)
break; /* not started incrementing yet. */
#ifdef DEBUG_MSPROXY
if (response->sequence == state->seq_recv)
printf ("seq_recv: %d, dup response, seqnumber: 0x%x\n", state->seq_recv, response->sequence);
#endif
} while (response->sequence == state->seq_recv);
state->seq_recv = response->sequence;
return r;
}
int
traverse_msproxy (int sok, char *serverAddr, int port, struct msproxy_state_t *state, netstore *ns_proxy, int csok4, int csok6, int *csok, char bound)
{
struct msproxy_request_t req;
struct msproxy_response_t res;
char *data, *p;
char hostname[NT_MAXNAMELEN];
char ntdomain[NT_MAXNAMELEN];
char challenge[8];
netstore *ns_client;
int clientport;
guint32 destaddr;
guint32 flags;
if (!prefs.hex_net_proxy_auth || !prefs.hex_net_proxy_user[0] || !prefs.hex_net_proxy_pass[0] )
return 1;
/* MS proxy protocol implementation currently doesn't support IPv6 */
destaddr = net_getsockaddr_v4 (ns_proxy);
if (!destaddr)
return 1;
state->seq_recv = 0;
state->seq_sent = 0;
#ifdef DEBUG_MSPROXY
printf ("Connecting to %s:%d via MS proxy\n", serverAddr, port);
#endif
gethostname (hostname, NT_MAXNAMELEN);
p = strchr (hostname, '.');
if (p)
*p = '\0';
bzero (&req, sizeof(req));
req.clientid = htonl(0x0a000000); /* Initial client ID is always 0x0a */
req.command = htons(MSPROXY_HELLO); /* HELLO command */
req.packet.hello.magic5 = htons(0x4b00); /* Fill in magic values */
req.packet.hello.magic10 = htons(0x1400);
req.packet.hello.magic15 = htons(0x0400);
req.packet.hello.magic20 = htons(0x5704);
req.packet.hello.magic25 = htons(0x0004);
req.packet.hello.magic30 = htons(0x0100);
req.packet.hello.magic35 = htons(0x4a02);
req.packet.hello.magic40 = htons(0x3000);
req.packet.hello.magic45 = htons(0x4400);
req.packet.hello.magic50 = htons(0x3900);
data = req.packet.hello.data;
strcpy (data, prefs.hex_net_proxy_user); /* Append a username */
data += strlen (prefs.hex_net_proxy_user)+2; /* +2 automatically creates second empty string */
strcpy (data, MSPROXY_EXECUTABLE); /* Append an application name */
data += strlen (MSPROXY_EXECUTABLE)+1;
strcpy (data, hostname); /* Append a hostname */
data += strlen (hostname)+1;
if (send_msprequest(sok, state, &req, data) == -1)
return 1;
if (recv_mspresponse(sok, state, &res) == -1)
return 1;
if (strcmp(res.RWSP, "RWSP") != 0) {
#ifdef DEBUG_MSPROXY
printf ("Received mailformed packet (no RWSP signature)\n");
#endif
return 1;
}
if (ntohs(res.command) >> 8 != 0x10) {
#ifdef DEBUG_MSPROXY
printf ("expected res.command = 10??, is %x", ntohs(res.command));
#endif
return 1;
}
state->clientid = htonl(rand());
state->serverid = res.serverid;
#ifdef DEBUG_MSPROXY
printf ("clientid: 0x%x, serverid: 0x%0x\n", state->clientid, state->serverid);
printf ("packet #2\n");
#endif
/* almost identical. */
req.clientid = state->clientid;
req.serverid = state->serverid;
if (send_msprequest(sok, state, &req, data) == -1)
return 1;
if (recv_mspresponse(sok, state, &res) == -1)
return 1;
if (res.serverid != state->serverid) {
#ifdef DEBUG_MSPROXY
printf ("expected serverid = 0x%x, is 0x%x\n",state->serverid, res.serverid);
#endif
return 1;
}
if (res.sequence != 0x01) {
#ifdef DEBUG_MSPROXY
printf ("expected res.sequence = 0x01, is 0x%x\n", res.sequence);
#endif
return 1;
}
if (ntohs(res.command) != MSPROXY_USERINFO_ACK) {
#ifdef DEBUG_MSPROXY
printf ("expected res.command = 0x%x, is 0x%x\n", MSPROXY_USERINFO_ACK, ntohs(res.command));
#endif
return 1;
}
#ifdef DEBUG_MSPROXY
printf ("packet #3\n");
#endif
bzero(&req, sizeof(req));
req.clientid = state->clientid;
req.serverid = state->serverid;
req.command = htons(MSPROXY_AUTHENTICATE);
memcpy(req.packet.auth.NTLMSSP, "NTLMSSP", sizeof("NTLMSSP"));
req.packet.auth.bindaddr = htonl(0x02000000);
req.packet.auth.msgtype = htonl(0x01000000);
/* NTLM flags: 0x80000000 Negotiate LAN Manager key
0x10000000 Negotiate sign
0x04000000 Request target
0x02000000 Negotiate OEM
0x00800000 Always sign
0x00020000 Negotiate NTLM
*/
req.packet.auth.flags = htonl(0x06020000);
if (send_msprequest(sok, state, &req, &req.packet.auth.data) == -1)
return 1;
if (recv_mspresponse(sok, state, &res) == -1)
return 1;
if (res.serverid != state->serverid) {
#ifdef DEBUG_MSPROXY
printf ("expected serverid = 0x%x, is 0x%x\n", state->serverid, res.serverid);
#endif
return 1;
}
if (ntohs(res.command) != MSPROXY_AUTHENTICATE_ACK) {
#ifdef DEBUG_MSPROXY
printf ("expected res.command = 0x%x, is 0x%x\n", MSPROXY_AUTHENTICATE_ACK, ntohs(res.command));
#endif
return 1;
}
flags = res.packet.auth.flags & htonl(0x00020000); /* Remember if the server supports NTLM */
memcpy(challenge, &res.packet.auth.challenge, sizeof(challenge));
memcpy(ntdomain, &res.packet.auth.NTLMSSP[res.packet.auth.target.offset], res.packet.auth.target.len);
ntdomain[res.packet.auth.target.len] = 0;
#ifdef DEBUG_MSPROXY
printf ("ntdomain: \"%s\"\n", ntdomain);
printf ("packet #4\n");
#endif
bzero(&req, sizeof(req));
req.clientid = state->clientid;
req.serverid = state->serverid;
req.command = htons(MSPROXY_AUTHENTICATE_2); /* Authentication response */
req.packet.auth2.magic3 = htons(0x0200); /* Something */
memcpy(req.packet.auth2.NTLMSSP, "NTLMSSP", sizeof("NTLMSSP")); /* Start of NTLM message */
req.packet.auth2.msgtype = htonl(0x03000000); /* Message type 2 */
req.packet.auth2.flags = flags | htonl(0x02000000); /* Choose authentication method */
data = req.packet.auth2.data;
if (flags) {
req.packet.auth2.lm_resp.len = 0; /* We are here if NTLM is supported, */
req.packet.auth2.lm_resp.alloc = 0; /* Do not fill in insecure LM response */
req.packet.auth2.lm_resp.offset = data - req.packet.auth2.NTLMSSP;
req.packet.auth2.ntlm_resp.len = 24; /* Fill in NTLM response security buffer */
req.packet.auth2.ntlm_resp.alloc = 24;
req.packet.auth2.ntlm_resp.offset = data - req.packet.auth2.NTLMSSP;
ntlm_smb_nt_encrypt(prefs.hex_net_proxy_pass, challenge, data); /* Append an NTLM response */
data += 24;
} else {
req.packet.auth2.lm_resp.len = 24; /* Fill in LM response security buffer */
req.packet.auth2.lm_resp.alloc = 24;
req.packet.auth2.lm_resp.offset = data - req.packet.auth2.NTLMSSP;
ntlm_smb_encrypt(prefs.hex_net_proxy_pass, challenge, data); /* Append an LM response */
data += 24;
req.packet.auth2.ntlm_resp.len = 0; /* NTLM response is empty */
req.packet.auth2.ntlm_resp.alloc = 0;
req.packet.auth2.ntlm_resp.offset = data - req.packet.auth2.NTLMSSP;
}
req.packet.auth2.ntdomain_buf.len = strlen(ntdomain); /* Domain name */
req.packet.auth2.ntdomain_buf.alloc = req.packet.auth2.ntdomain_buf.len;
req.packet.auth2.ntdomain_buf.offset = data - req.packet.auth2.NTLMSSP;
strcpy(data, ntdomain);
data += req.packet.auth2.ntdomain_buf.len;
req.packet.auth2.username_buf.len = strlen(prefs.hex_net_proxy_user); /* Username */
req.packet.auth2.username_buf.alloc = req.packet.auth2.username_buf.len;
req.packet.auth2.username_buf.offset = data - req.packet.auth2.NTLMSSP;
strcpy(data, prefs.hex_net_proxy_user);
data += req.packet.auth2.username_buf.len;
req.packet.auth2.clienthost_buf.len = strlen(hostname); /* Hostname */
req.packet.auth2.clienthost_buf.alloc = req.packet.auth2.clienthost_buf.len;
req.packet.auth2.clienthost_buf.offset = data - req.packet.auth2.NTLMSSP;
strcpy(data, hostname);
data += req.packet.auth2.clienthost_buf.len;
req.packet.auth2.sessionkey_buf.len = 0; /* Session key (we don't use it) */
req.packet.auth2.sessionkey_buf.alloc = 0;
req.packet.auth2.sessionkey_buf.offset = data - req.packet.auth2.NTLMSSP;
if (send_msprequest(sok, state, &req, data) == -1)
return 1;
if (recv_mspresponse(sok, state, &res) == -1)
return 1;
if (res.serverid != state->serverid) {
#ifdef DEBUG_MSPROXY
printf ("expected res.serverid = 0x%x, is 0x%x\n", state->serverid, res.serverid);
#endif
return 1;
}
if (res.clientack != 0x01) {
#ifdef DEBUG_MSPROXY
printf ("expected res.clientack = 0x01, is 0x%x\n", res.clientack);
#endif
return 1;
}
if (ntohs(res.command) >> 8 != 0x47) {
#ifdef DEBUG_MSPROXY
printf ("expected res.command = 47??, is 0x%x\n", ntohs(res.command));
#endif
return 1;
}
if (ntohs(res.command) == MSPROXY_AUTHENTICATE_2_NAK) {
#ifdef DEBUG_MSPROXY
printf ("Authentication failed\n");
#endif
return -1;
}
#ifdef DEBUG_MSPROXY
printf ("packet #5\n");
#endif
bzero(&req, sizeof(req));
req.clientid = state->clientid;
req.serverid = state->serverid;
req.command = htons(MSPROXY_CONNECT);
req.packet.connect.magic2 = htons(0x0200);
req.packet.connect.magic6 = htons(0x0200);
req.packet.connect.destport = htons(port);
req.packet.connect.destaddr = destaddr;
data = req.packet.connect.executable;
strcpy(data, MSPROXY_EXECUTABLE);
data += strlen(MSPROXY_EXECUTABLE) + 1;
/*
* need to tell server what port we will connect from, so we bind our sockets.
*/
ns_client = net_store_new ();
if (!bound) {
net_store_fill_any (ns_client);
net_bind(ns_client, csok4, csok6);
#ifdef DEBUG_MSPROXY
perror ("bind() result");
#endif
}
clientport = net_getsockport(csok4, csok6);
if (clientport == -1) {
#ifdef DEBUG_MSPROXY
printf ("Unable to obtain source port\n");
#endif
return 1;
}
req.packet.connect.srcport = clientport;
if (send_msprequest(sok, state, &req, data) == -1)
return 1;
if (recv_mspresponse(sok, state, &res) == -1)
return 1;
if (ntohs(res.command) != MSPROXY_CONNECT_ACK) {
#ifdef DEBUG_MSPROXY
printf ("expected res.command = 0x%x, is 0x%x\n",MSPROXY_CONNECT_ACK, ntohs(res.command));
#endif
return 1;
}
net_store_fill_v4 (ns_client, res.packet.connect.clientaddr, res.packet.connect.clientport);
#ifdef DEBUG_MSPROXY
printf ("Connecting...\n");
#endif
if (net_connect (ns_client, csok4, csok6, csok) != 0) {
#ifdef DEBUG_MSPROXY
printf ("Failed to connect to port %d\n", htons(res.packet.connect.clientport));
#endif
net_store_destroy (ns_client);
return 1;
}
net_store_destroy (ns_client);
#ifdef DEBUG_MSPROXY
printf ("packet #6\n");
#endif
req.clientid = state->clientid;
req.serverid = state->serverid;
req.command = htons(MSPROXY_USERINFO_ACK);
if (send_msprequest(sok, state, &req, req.packet.connack.data) == -1)
return 1;
return 0;
}
void
msproxy_keepalive (void)
{
server *serv;
GSList *list = serv_list;
struct msproxy_request_t req;
struct msproxy_response_t res;
while (list)
{
serv = list->data;
if (serv->connected && (serv->proxy_sok != -1))
{
#ifdef DEBUG_MSPROXY
printf ("sending MS proxy keepalive packet\n");
#endif
bzero(&req, sizeof(req));
req.clientid = serv->msp_state.clientid;
req.serverid = serv->msp_state.serverid;
req.command = htons(MSPROXY_HELLO);
if (send_msprequest(serv->proxy_sok, &serv->msp_state, &req, req.packet.hello.data) == -1)
continue;
recv_mspresponse(serv->proxy_sok, &serv->msp_state, &res);
#ifdef DEBUG_MSPROXY
if (ntohs(res.command) != MSPROXY_USERINFO_ACK)
printf ("expected res.command = 0x%x, is 0x%x\n", MSPROXY_USERINFO_ACK, ntohs(res.command));
#endif
}
list = list->next;
}
}
#endif

View File

@ -1,262 +0,0 @@
/* X-Chat
* Copyright (C) 1998 Peter Zelezny.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*
* MS Proxy (ISA server) support is (c) 2006 Pavel Fedin <sonic_amiga@rambler.ru>
* based on Dante source code
* Copyright (c) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
* Inferno Nettverk A/S, Norway. All rights reserved.
*/
#ifndef HEXCHAT_MSPROXY_H
#define HEXCHAT_MSPROXY_H
#include "network.h"
#define MSPROXY_EXECUTABLE "hexchat.exe" /* This probably can be used for access control on the server side */
#define MSPROXY_MINLENGTH 172 /* minimum length of packet. */
#define NT_MAXNAMELEN 17 /* maximum name length (domain etc), comes from NetBIOS */
#define MSPROXY_VERSION 0x00010200 /* MS Proxy v2 ? */
/* Commands / responses */
#define MSPROXY_HELLO 0x0500 /* packet 1 from client. */
#define MSPROXY_HELLO_ACK 0x1000 /* packet 1 from server. */
#define MSPROXY_USERINFO_ACK 0x0400 /* packet 2 from server. */
#define MSPROXY_AUTHENTICATE 0x4700 /* authentication request */
#define MSPROXY_AUTHENTICATE_ACK 0x4714 /* authentication challenge */
#define MSPROXY_AUTHENTICATE_2 0x4701 /* authentication response */
#define MSPROXY_AUTHENTICATE_2_ACK 0x4715 /* authentication passed */
#define MSPROXY_AUTHENTICATE_2_NAK 0x4716 /* authentication failure */
#define MSPROXY_CONNECT 0x071e /* connect request. */
#define MSPROXY_CONNECT_ACK 0x0703 /* connect request accepted. */
#pragma pack(1)
struct ntlm_buffer {
guint16 len;
guint16 alloc;
guint32 offset;
};
struct msproxy_request_t {
guint32 clientid; /* 1-4 */
guint32 magic25; /* 5-8 */
guint32 serverid; /* 9-12 */
unsigned char serverack; /* 13: ack of last server packet */
char pad10[3]; /* 14-16 */
unsigned char sequence; /* 17: sequence # of this packet. */
char pad11[7]; /* 18-24 */
char RWSP[4]; /* 25-28: 0x52,0x57,0x53,0x50 */
char pad15[8]; /* 29-36 */
guint16 command; /* 37-38 */
/* packet specifics start at 39. */
union {
struct {
char pad1[18]; /* 39-56 */
guint16 magic3; /* 57-58 */
char pad3[114]; /* 59-172 */
guint16 magic5; /* 173-174: 0x4b, 0x00 */
char pad5[2]; /* 175-176 */
guint16 magic10; /* 177-178: 0x14, 0x00 */
char pad6[2]; /* 179-180 */
guint16 magic15; /* 181-182: 0x04, 0x00 */
char pad10[2]; /* 183-184 */
guint16 magic16; /* 185-186 */
char pad11[2]; /* 187-188 */
guint16 magic20; /* 189-190: 0x57, 0x04 */
guint16 magic25; /* 191-192: 0x00, 0x04 */
guint16 magic30; /* 193-194: 0x01, 0x00 */
char pad20[2]; /* 195-196: 0x4a, 0x02 */
guint16 magic35; /* 197-198: 0x4a, 0x02 */
char pad30[10]; /* 199-208 */
guint16 magic40; /* 209-210: 0x30, 0x00 */
char pad40[2]; /* 211-212 */
guint16 magic45; /* 213-214: 0x44, 0x00 */
char pad45[2]; /* 215-216 */
guint16 magic50; /* 217-218: 0x39, 0x00 */
char pad50[2]; /* 219-220 */
char data[256]; /* 221-EOP: a sequence of NULL-terminated strings:
- username;
- empty string (just a NULL);
- application name;
- hostname */
} hello;
struct {
char pad1[4]; /* 39-42 */
guint16 magic2; /* 43-44 */
char pad10[12]; /* 45-56 */
guint32 bindaddr; /* 57-60: address to bind. */
guint16 bindport; /* 61-62: port to bind. */
char pad15[2]; /* 63-64 */
guint16 magic3; /* 65-66 */
guint16 boundport; /* 67-68 */
char pad20[104]; /* 69-172 */
char NTLMSSP[sizeof("NTLMSSP")]; /* 173-180: "NTLMSSP" */
guint32 msgtype; /* 181-184: NTLM message type = 1 */
guint32 flags; /* 185-188: NTLM message flags */
guint16 magic20; /* 189-190: 0x28, 0x00 */
char pad30[2]; /* 191-192 */
guint16 magic25; /* 193-194: 0x96, 0x82 */
guint16 magic30; /* 195-196: 0x01, 0x00 */
char pad40[12]; /* 197-208 */
guint16 magic50; /* 209-210: 0x30, 0x00 */
char pad50[6]; /* 211-216 */
guint16 magic55; /* 217-218: 0x30, 0x00 */
char pad55[2]; /* 219-220 */
char data[0]; /* Dummy end marker, no real data required */
} auth;
struct {
char pad1[4]; /* 39-42 */
guint16 magic1; /* 43-44 */
guint32 magic2; /* 45-48 */
char pad2[8]; /* 49-56 */
guint16 magic3; /* 57-58 */
char pad3[6]; /* 59-64 */
guint16 magic4; /* 65-66 */
guint16 boundport; /* 67-68 */
char pad4[104]; /* 69-172 */
char NTLMSSP[sizeof("NTLMSSP")]; /* 173-180: "NTLMSSP" */
guint32 msgtype; /* 181-184: NTLM message type = 3 */
struct ntlm_buffer lm_resp; /* 185-192: LM response security buffer */
struct ntlm_buffer ntlm_resp; /* 193-200: NTLM response security buffer */
struct ntlm_buffer ntdomain_buf; /* 201-208: domain name security buffer */
struct ntlm_buffer username_buf; /* 209-216: username security buffer */
struct ntlm_buffer clienthost_buf; /* 217-224: hostname security buffer */
struct ntlm_buffer sessionkey_buf; /* 225-232: session key security buffer */
guint32 flags; /* 233-236: message flags */
char data[1024]; /* 237-EOP: data area */
} auth2;
struct {
guint16 magic1; /* 39-40 */
char pad1[2]; /* 41-42 */
guint16 magic2; /* 43-44 */
guint32 magic3; /* 45-48 */
char pad5[8]; /* 48-56 */
guint16 magic6; /* 57-58: 0x0200 */
guint16 destport; /* 59-60 */
guint32 destaddr; /* 61-64 */
char pad10[4]; /* 65-68 */
guint16 magic10; /* 69-70 */
char pad15[2]; /* 71-72 */
guint16 srcport; /* 73-74: port client connects from */
char pad20[82]; /* 75-156 */
char executable[256]; /* 76-EOP: application name */
} connect;
struct {
guint16 magic1; /* 39-40 */
char pad5[2]; /* 41-42 */
guint16 magic5; /* 43-44 */
guint32 magic10; /* 45-48 */
char pad10[2]; /* 49-50 */
guint16 magic15; /* 51-52 */
guint32 magic16; /* 53-56 */
guint16 magic20; /* 57-58 */
guint16 clientport; /* 59-60: forwarded port. */
guint32 clientaddr; /* 61-64: forwarded address. */
guint32 magic30; /* 65-68 */
guint32 magic35; /* 69-72 */
guint16 serverport; /* 73-74: port server will connect to us from. */
guint16 srcport; /* 75-76: connect request; port used on client behalf. */
guint16 boundport; /* 77-78: bind request; port used on client behalf. */
guint32 boundaddr; /* 79-82: addr used on client behalf */
char pad30[90]; /* 83-172 */
char data[0]; /* End marker */
} connack;
} packet;
};
struct msproxy_response_t {
guint32 packetid; /* 1-4 */
guint32 magic5; /* 5-8 */
guint32 serverid; /* 9-12 */
char clientack; /* 13: ack of last client packet. */
char pad5[3]; /* 14-16 */
unsigned char sequence; /* 17: sequence # of this packet. */
char pad10[7]; /* 18-24 */
char RWSP[4]; /* 25-28: 0x52,0x57,0x53,0x50 */
char pad15[8]; /* 29-36 */
guint16 command; /* 37-38 */
union {
struct {
char pad5[18]; /* 39-56 */
guint16 magic20; /* 57-58: 0x02, 0x00 */
char pad10[6]; /* 59-64 */
guint16 magic30; /* 65-66: 0x74, 0x01 */
char pad15[2]; /* 67-68 */
guint16 magic35; /* 69-70: 0x0c, 0x00 */
char pad20[6]; /* 71-76 */
guint16 magic50; /* 77-78: 0x04, 0x00 */
char pad30[6]; /* 79-84 */
guint16 magic60; /* 85-86: 0x65, 0x05 */
char pad35[2]; /* 87-88 */
guint16 magic65; /* 89-90: 0x02, 0x00 */
char pad40[8]; /* 91-98 */
guint16 udpport; /* 99-100 */
guint32 udpaddr; /* 101-104 */
} hello;
struct {
char pad1[6]; /* 39-44 */
guint32 magic10; /* 45-48 */
char pad3[10]; /* 49-58 */
guint16 boundport; /* 59-60: port server bound for us. */
guint32 boundaddr; /* 61-64: addr server bound for us. */
char pad10[4]; /* 65-68 */
guint16 magic15; /* 69-70 */
char pad15[102]; /* 70-172 */
char NTLMSSP[sizeof("NTLMSSP")]; /* 173-180: "NTLMSSP" */
guint32 msgtype; /* 181-184: NTLM message type = 2 */
struct ntlm_buffer target; /* 185-192: target security buffer */
guint32 flags; /* 193-196: NTLM message flags */
char challenge[8]; /* 197-204: NTLM challenge request */
char context[8]; /* 205-212: NTLM context */
char data[1024]; /* 213-EOP: target information data */
} auth;
struct {
guint16 magic1; /* 39-40 */
char pad5[18]; /* 41-58 */
guint16 clientport; /* 59-60: forwarded port. */
guint32 clientaddr; /* 61-64: forwarded address. */
guint32 magic10; /* 65-68 */
guint32 magic15; /* 69-72 */
guint16 serverport; /* 73-74: port server will connect to us from. */
guint16 srcport; /* 75-76: connect request; port used on client behalf. */
guint16 boundport; /* 77-78: bind request; port used on client behalf. */
guint32 boundaddr; /* 79-82: addr used on client behalf */
char pad10[90]; /* 83-172 */
} connect;
} packet;
};
#pragma pack()
int traverse_msproxy (int sok, char *serverAddr, int port, struct msproxy_state_t *state, netstore *ns_proxy, int csok4, int csok6, int *csok, char bound);
void msproxy_keepalive (void);
#endif

View File

@ -295,87 +295,4 @@ udp_sockets (int *sok4, int *sok6)
*sok6 = socket (AF_INET6, SOCK_DGRAM, IPPROTO_UDP);
}
/* the following functions are used only by MSPROXY and are not
proper ipv6 implementations - do not use in new code! */
void
net_store_fill_any (netstore *ns)
{
struct addrinfo *ai;
struct sockaddr_in *sin;
ai = ns->ip6_hostent;
if (ai == NULL)
{
ai = g_new0 (struct addrinfo, 1);
ns->ip6_hostent = ai;
}
sin = (struct sockaddr_in *)ai->ai_addr;
if (sin == NULL)
{
sin = g_new0 (struct sockaddr_in, 1);
ai->ai_addr = (struct sockaddr *)sin;
}
ai->ai_family = AF_INET;
ai->ai_addrlen = sizeof(struct sockaddr_in);
sin->sin_family = AF_INET;
sin->sin_addr.s_addr = INADDR_ANY;
sin->sin_port = 0;
ai->ai_next = NULL;
}
void
net_store_fill_v4 (netstore *ns, guint32 addr, int port)
{
struct addrinfo *ai;
struct sockaddr_in *sin;
ai = ns->ip6_hostent;
if (ai == NULL)
{
ai = g_new0 (struct addrinfo, 1);
ns->ip6_hostent = ai;
}
sin = (struct sockaddr_in *)ai->ai_addr;
if (sin == NULL)
{
sin = g_new0 (struct sockaddr_in, 1);
ai->ai_addr = (struct sockaddr *)sin;
}
ai->ai_family = AF_INET;
ai->ai_addrlen = sizeof(struct sockaddr_in);
sin->sin_family = AF_INET;
sin->sin_addr.s_addr = addr;
sin->sin_port = port;
ai->ai_next = NULL;
}
guint32
net_getsockaddr_v4 (netstore *ns)
{
struct addrinfo *ai;
struct sockaddr_in *sin;
ai = ns->ip6_hostent;
while (ai->ai_family != AF_INET) {
ai = ai->ai_next;
if (!ai)
return 0;
}
sin = (struct sockaddr_in *)ai->ai_addr;
return sin->sin_addr.s_addr;
}
int
net_getsockport (int sok4, int sok6)
{
struct sockaddr_in addr;
int len = sizeof (addr);
if (getsockname (sok4, (struct sockaddr *)&addr, &len) == -1)
return -1;
return addr.sin_port;
}
#endif

View File

@ -43,11 +43,5 @@ char *net_resolve (netstore *ns, char *hostname, int port, char **real_host);
void net_bind (netstore *tobindto, int sok4, int sok6);
char *net_ip (guint32 addr);
void net_sockets (int *sok4, int *sok6);
/* functions for MSPROXY only! */
void udp_sockets (int *sok4, int *sok6);
void net_store_fill_any (netstore *ns);
void net_store_fill_v4 (netstore *ns, guint32 addr, int port);
guint32 net_getsockaddr_v4 (netstore *ns);
int net_getsockport(int sok4, int sok6);
#endif

View File

@ -21,8 +21,6 @@
* Inferno Nettverk A/S, Norway. All rights reserved.
*/
/*#define DEBUG_MSPROXY*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
@ -63,10 +61,6 @@
#include "ssl.h"
#endif
#ifdef USE_MSPROXY
#include "msproxy.h"
#endif
#ifdef WIN32
#include "identd.h"
#endif
@ -906,9 +900,6 @@ server_read_child (GIOChannel *source, GIOCondition condition, server *serv)
char outbuf[512];
char host[100];
char ip[100];
#ifdef USE_MSPROXY
char *p;
#endif
waitline2 (source, tbuf, sizeof tbuf);
@ -982,23 +973,7 @@ server_read_child (GIOChannel *source, GIOCondition condition, server *serv)
break;
case '4': /* success */
waitline2 (source, tbuf, sizeof (tbuf));
#ifdef USE_MSPROXY
serv->sok = strtol (tbuf, &p, 10);
if (*p++ == ' ')
{
serv->proxy_sok = strtol (p, &p, 10);
serv->msp_state.clientid = strtol (++p, &p, 10);
serv->msp_state.serverid = strtol (++p, &p, 10);
serv->msp_state.seq_sent = atoi (++p);
} else
serv->proxy_sok = -1;
#ifdef DEBUG_MSPROXY
printf ("Parent got main socket: %d, proxy socket: %d\n", serv->sok, serv->proxy_sok);
printf ("Client ID 0x%08x server ID 0x%08x seq_sent %d\n", serv->msp_state.clientid, serv->msp_state.serverid, serv->msp_state.seq_sent);
#endif
#else
serv->sok = atoi (tbuf);
#endif
#ifdef USE_IPV6
/* close the one we didn't end up using */
if (serv->sok == serv->sok4)
@ -1451,7 +1426,7 @@ traverse_http (int print_fd, int sok, char *serverAddr, int port)
}
static int
traverse_proxy (int proxy_type, int print_fd, int sok, char *ip, int port, struct msproxy_state_t *state, netstore *ns_proxy, int csok4, int csok6, int *csok, char bound)
traverse_proxy (int proxy_type, int print_fd, int sok, char *ip, int port, netstore *ns_proxy, int csok4, int csok6, int *csok, char bound)
{
switch (proxy_type)
{
@ -1463,10 +1438,6 @@ traverse_proxy (int proxy_type, int print_fd, int sok, char *ip, int port, struc
return traverse_socks5 (print_fd, sok, ip, port);
case 4:
return traverse_http (print_fd, sok, ip, port);
#ifdef USE_MSPROXY
case 5:
return traverse_msproxy (sok, ip, port, state, ns_proxy, csok4, csok6, csok, bound);
#endif
}
return 1;
@ -1622,16 +1593,10 @@ server_child (server * serv)
/* connect succeeded */
if (proxy_ip)
{
switch (traverse_proxy (proxy_type, serv->childwrite, psok, proxy_ip, port, &serv->msp_state, ns_proxy, serv->sok4, serv->sok6, &sok, bound))
switch (traverse_proxy (proxy_type, serv->childwrite, psok, proxy_ip, port, ns_proxy, serv->sok4, serv->sok6, &sok, bound))
{
case 0: /* success */
#ifdef USE_MSPROXY
if (!serv->dont_use_proxy && (proxy_type == 5))
g_snprintf (buf, sizeof (buf), "4\n%d %d %d %d %d\n", sok, psok, serv->msp_state.clientid, serv->msp_state.serverid,
serv->msp_state.seq_sent);
else
#endif
g_snprintf (buf, sizeof (buf), "4\n%d\n", sok); /* success */
g_snprintf (buf, sizeof (buf), "4\n%d\n", sok); /* success */
write (serv->childwrite, buf, strlen (buf));
break;
case 1: /* socks traversal failed */
@ -1761,16 +1726,8 @@ server_connect (server *serv, char *hostname, int port, int no_login)
/* create both sockets now, drop one later */
net_sockets (&serv->sok4, &serv->sok6);
#ifdef USE_MSPROXY
/* In case of MS Proxy we have a separate UDP control connection */
if (!serv->dont_use_proxy && (serv->proxy_type == 5))
udp_sockets (&serv->proxy_sok4, &serv->proxy_sok6);
else
#endif
{
serv->proxy_sok4 = -1;
serv->proxy_sok6 = -1;
}
serv->proxy_sok4 = -1;
serv->proxy_sok6 = -1;
#ifdef WIN32
CloseHandle (CreateThread (NULL, 0,

View File

@ -560,9 +560,6 @@ static const char *const proxytypes[] =
N_("Socks4"),
N_("Socks5"),
N_("HTTP"),
#ifdef USE_MSPROXY
N_("MS Proxy (ISA)"),
#endif
#ifdef USE_LIBPROXY
N_("Auto"),
#endif
@ -599,11 +596,7 @@ static const setting network_settings[] =
{ST_MENU, N_("Use proxy for:"), P_OFFINTNL(hex_net_proxy_use), 0, proxyuse, 0},
{ST_HEADER, N_("Proxy Authentication"), 0, 0, 0, 0},
#ifdef USE_MSPROXY
{ST_TOGGLE, N_("Use Authentication (MS Proxy, HTTP or Socks5 only)"), P_OFFINTNL(hex_net_proxy_auth), 0, 0, 0},
#else
{ST_TOGGLE, N_("Use Authentication (HTTP or Socks5 only)"), P_OFFINTNL(hex_net_proxy_auth), 0, 0, 0},
#endif
{ST_ENTRY, N_("Username:"), P_OFFSETNL(hex_net_proxy_user), 0, 0, sizeof prefs.hex_net_proxy_user},
{ST_ENTRY, N_("Password:"), P_OFFSETNL(hex_net_proxy_pass), 0, GINT_TO_POINTER(1), sizeof prefs.hex_net_proxy_pass},