Discussion:
Ncat proxy authentication
David Fifield
2009-04-06 16:27:14 UTC
Permalink
Hi,

Ncat now works as an authenticated HTTP CONNECT proxy:

ncat -l --proxy-type http --proxy-auth user:pass

Both the client and server only support the Basic authentication mode,
which is vulnerable to password sniffing. Still, it keeps just anyone
from connecting, and now with better HTTP handling in Ncat it will be
easier to add better methods in the future.

David Fifield
Thomas Buchanan
2009-04-09 17:20:28 UTC
Permalink
Post by David Fifield
Hi,
ncat -l --proxy-type http --proxy-auth user:pass
Both the client and server only support the Basic authentication mode,
which is vulnerable to password sniffing. Still, it keeps just anyone
from connecting, and now with better HTTP handling in Ncat it will be
easier to add better methods in the future.
David Fifield
Hi David,

I've played around with this a little, and it seems to work as expected.
I've done some straight-forward SSL proxying through it, using Firefox
as a client, as well as connection proxying using ncat as the client.
However, it doesn't build on my Windows system. First, I had to add
base64.h and http.h to the Header files for ncat in the project solution
file, as well as base64.c and http.c to the Source files. But even
after doing that, I still get the following build errors (with apologies
Post by David Fifield
------ Build started: Project: ncat, Configuration: Release Win32 ------
1>Compiling...
1>http.c
1>.\http.c(52) : error C2440: '=' : cannot convert from 'void *' to 'char *'
1> Conversion from 'void*' to pointer to non-'void' requires an
explicit cast
1>.\http.c(245) : error C2440: '=' : cannot convert from 'void *' to
'char *'
1> Conversion from 'void*' to pointer to non-'void' requires an
explicit cast
1>base64.c
1>.\base64.c(50) : error C3861: 'Malloc': identifier not found

Any ideas on these errors?

SVN checkout was revision 12920. Build system is Windows XP SP2 with
Visual C++ 2008 Express Edition.

Thanks,

Thomas
David Fifield
2009-04-09 18:45:44 UTC
Permalink
Post by Thomas Buchanan
I've played around with this a little, and it seems to work as expected.
I've done some straight-forward SSL proxying through it, using Firefox
as a client, as well as connection proxying using ncat as the client.
However, it doesn't build on my Windows system. First, I had to add
base64.h and http.h to the Header files for ncat in the project solution
file, as well as base64.c and http.c to the Source files. But even
after doing that, I still get the following build errors (with apologies
Post by David Fifield
------ Build started: Project: ncat, Configuration: Release Win32 ------
1>Compiling...
1>http.c
1>.\http.c(52) : error C2440: '=' : cannot convert from 'void *' to 'char *'
1> Conversion from 'void*' to pointer to non-'void' requires an
explicit cast
1>.\http.c(245) : error C2440: '=' : cannot convert from 'void *' to
'char *'
1> Conversion from 'void*' to pointer to non-'void' requires an
explicit cast
1>base64.c
1>.\base64.c(50) : error C3861: 'Malloc': identifier not found
Any ideas on these errors?
Thanks. I am always forgetting that the Microsoft compiler doesn't
automatically promote void pointers, probably because it compiles the
code as C++ as opposed to C. It should be fixed now.

David Fifield
Thomas Buchanan
2009-04-09 19:09:02 UTC
Permalink
Post by David Fifield
Thanks. I am always forgetting that the Microsoft compiler doesn't
automatically promote void pointers, probably because it compiles the
code as C++ as opposed to C. It should be fixed now.
David Fifield
David,

Thanks. That does allow it to compile correctly. Unfortunately, it
doesn't seem to run correctly. I get the following error on the server
side as soon as a connection is made to it, and the program exits:

$ ./ncat.exe -vvv -l --proxy-type http --proxy-auth user:pass 8080
Ncat version 4.85BETA7 ( http://nmap.org/ncat )
Listening on 0.0.0.0:8080
fork: No error

This is the client command I was using to connect:

$ ./ncat.exe -v --proxy localhost:8080 --proxy-type http --proxy-auth
user:pass aaa.bbb.ccc.15 22
Ncat version 4.85BETA7 ( http://nmap.org/ncat )
Connected to 127.0.0.1.

If I try these same commands on my Linux box, everything works
correctly, and I'm shown the expected output from the client (the SSH
banner on aaa.bbb.ccc.15).

Thanks,

Thomas
Thomas Buchanan
2009-04-09 20:40:58 UTC
Permalink
-----Original Message-----
Sent: Thursday, April 09, 2009 2:09 PM
To: David Fifield
Subject: Re: Ncat proxy authentication
<snip>
doesn't seem to run correctly. I get the following error on the
server
$ ./ncat.exe -vvv -l --proxy-type http --proxy-auth user:pass 8080
Ncat version 4.85BETA7 ( http://nmap.org/ncat )
Listening on 0.0.0.0:8080
fork: No error
Answering my own emails now, sorry.
...
/* We should get to a point where Fork() is never called on Windows,
* or we come up with some solution to fake fork(), but until then
* we'll just die if fork() is attempted here.
*/
ret = -1;
#endif
if(ret < 0)
die("fork");
...

So, since ncat_proxy.c uses a simple forking HTTP proxy design, it seems
obvious that this won't work on Windows, at least for now.

So, back to my Linux box for this feature for the time being.

Thanks,

Thomas
Duarte Silva
2009-04-09 19:12:42 UTC
Permalink
Hi,

Maybe it doesn't do that (automatically promote void pointers) because
the files (http.c, ncat.c, *.c) have in their Properties defined to
compile as C++ code (switch /TP). To change that, select a file, right
click, Properties, then in the tree select C/C++, then Advanced, and
in Code Generation set it to compile as C code (switch /TC).
I do that when mixing code units in C with code unit in C++.

Otherwise, a (char*) explicit conversion should suffice as well as
being portable.

Best regards,
Duarte Silva

PS: I didn't check the code neither the solution options.
Post by David Fifield
Post by Thomas Buchanan
I've played around with this a little, and it seems to work as expected.
 I've done some straight-forward SSL proxying through it, using Firefox
as a client, as well as connection proxying using ncat as the client.
However, it doesn't build on my Windows system.  First, I had to add
base64.h and http.h to the Header files for ncat in the project solution
file, as well as base64.c and http.c to the Source files.  But even
after doing that, I still get the following build errors (with apologies
Post by David Fifield
------ Build started: Project: ncat, Configuration: Release Win32 ------
1>Compiling...
1>http.c
1>.\http.c(52) : error C2440: '=' : cannot convert from 'void *' to 'char *'
1>        Conversion from 'void*' to pointer to non-'void' requires an
explicit cast
1>.\http.c(245) : error C2440: '=' : cannot convert from 'void *' to
'char *'
1>        Conversion from 'void*' to pointer to non-'void' requires an
explicit cast
1>base64.c
1>.\base64.c(50) : error C3861: 'Malloc': identifier not found
Any ideas on these errors?
Thanks. I am always forgetting that the Microsoft compiler doesn't
automatically promote void pointers, probably because it compiles the
code as C++ as opposed to C. It should be fixed now.
David Fifield
_______________________________________________
Sent through the nmap-dev mailing list
http://cgi.insecure.org/mailman/listinfo/nmap-dev
Archived at http://SecLists.Org
Duarte Silva
2009-04-09 20:43:58 UTC
Permalink
Never mind what I wrote because if you say it to compile as C code, it
will fail anyway because of the generated name for functions and
global variables in C is different from the one in C++. Gives more
problems than those it solves.
Post by Duarte Silva
Hi,
Maybe it doesn't do that (automatically promote void pointers) because
the files (http.c, ncat.c, *.c) have in their Properties defined to
compile as C++ code (switch /TP). To change that, select a file, right
click, Properties, then in the tree select C/C++, then Advanced, and
in Code Generation set it to compile as C code (switch /TC).
I do that when mixing code units in C with code unit in C++.
Otherwise, a (char*) explicit conversion should suffice as well as
being portable.
Best regards,
Duarte Silva
PS: I didn't check the code neither the solution options.
Post by David Fifield
Post by Thomas Buchanan
I've played around with this a little, and it seems to work as expected.
 I've done some straight-forward SSL proxying through it, using Firefox
as a client, as well as connection proxying using ncat as the client.
However, it doesn't build on my Windows system.  First, I had to add
base64.h and http.h to the Header files for ncat in the project solution
file, as well as base64.c and http.c to the Source files.  But even
after doing that, I still get the following build errors (with apologies
Post by David Fifield
------ Build started: Project: ncat, Configuration: Release Win32 ------
1>Compiling...
1>http.c
1>.\http.c(52) : error C2440: '=' : cannot convert from 'void *' to 'char *'
1>        Conversion from 'void*' to pointer to non-'void' requires an
explicit cast
1>.\http.c(245) : error C2440: '=' : cannot convert from 'void *' to
'char *'
1>        Conversion from 'void*' to pointer to non-'void' requires an
explicit cast
1>base64.c
1>.\base64.c(50) : error C3861: 'Malloc': identifier not found
Any ideas on these errors?
Thanks. I am always forgetting that the Microsoft compiler doesn't
automatically promote void pointers, probably because it compiles the
code as C++ as opposed to C. It should be fixed now.
David Fifield
_______________________________________________
Sent through the nmap-dev mailing list
http://cgi.insecure.org/mailman/listinfo/nmap-dev
Archived at http://SecLists.Org
Loading...