henri
a687f70af3
Removed our copy of mkstr, which has been moved to nbase.
2013-04-22 19:37:03 +00:00
henri
b867fa4721
Fixed ID type in format string.
2013-04-22 19:36:55 +00:00
henri
c8f7d4b7ac
Refactored the proxy object model to enforce speration between operations and data.
2013-04-22 19:36:47 +00:00
henri
03ff0651c7
Made proxy handlers return errors to caller when unable to handle proxy replies.
...
Errors are returned internally as -1 * <errno code>.
2013-04-22 19:36:38 +00:00
henri
eda720a389
Style fixes
2013-04-22 19:36:30 +00:00
henri
1780d0a655
Refactored HTTP proxy code to highlight execution flow.
2013-04-22 19:36:22 +00:00
henri
8a260bc209
Refactored code to highlight execution flow.
2013-04-22 19:36:15 +00:00
henri
7c1f9aa780
Removed a kinda brutal assert(0);
...
Don't abort when a socks4 proxy returns an invalid message,
just ignore it instead.
2013-04-22 19:36:07 +00:00
henri
157922dfe0
Replaced proxy_chain->specstr by node->nodestr.
...
The global proxy chain specification string wasn't
used anywhere, and I'd need a string to represent
each node of the chain.
2013-04-22 19:35:59 +00:00
henri
5cf3780a93
Added a nsock log message to nsock_connect_internal.
...
Explicitely indicates that a connection is about to be
redirected through the proxy chain.
2013-04-22 19:35:50 +00:00
henri
1455bf0624
Declare local constant string as array instead of pointer to
...
follow coding best practices. Also made string static.
2013-04-22 19:35:30 +00:00
henri
5be3de1477
Minor style fixes.
2013-04-22 19:35:22 +00:00
henri
9d8c84b17f
Replaced hardcoded value by a sizeof() call.
2013-04-22 19:35:14 +00:00
henri
b54590c344
Don't artificially increase timeouts to establish proxy
...
connections. It's now up to the caller to adjust timeout
values accordingly.
2013-04-22 19:35:07 +00:00
henri
a729e0047c
Reworked expression for readability.
2013-04-22 19:34:58 +00:00
henri
4998b3f20a
Updated email addresses in licence terms of the new files.
2013-04-22 19:34:50 +00:00
henri
a5fee3f2b4
Updated nsock_proxy to use nsock_log_*
2013-04-22 19:34:41 +00:00
henri
11fdeed8fb
Restrict proxying to TCP operations.
2013-04-22 19:34:18 +00:00
henri
ab6a7a4f9e
Added SOCKS4 support
...
Beware socks4a extention is not supported. Target hostnames
therefore need to be resolved somehow.
Initial patch by David and sed :)
2013-04-22 19:34:11 +00:00
henri
a3fbe7d7d6
Style change, neater syntax.
2013-04-22 19:34:01 +00:00
henri
af59333757
Perform the proxy connexion hook in connect_internal().
...
This allows to generically handle all kinds of connexions instead of manually
providing a handler for tcp connect, ssl connect...
The drawback is that would it makes it harder to implement support of SSL
proxies. Not sure whether there's a need though, looks like regular clients
don't handle them at least.
2013-04-22 19:33:53 +00:00
henri
5906c97ff9
Enfore node=NULL on error.
2013-04-22 19:33:37 +00:00
henri
6700abe1e8
Added svn properties.
2013-04-22 19:33:08 +00:00
henri
71e23318e9
Removed list of todo items from source.
2013-04-22 19:33:00 +00:00
henri
6e8b30d721
Added support to resolve proxy hostnames.
2013-04-22 19:32:52 +00:00
henri
b7b3b4bd3e
Default port is set to -1 (and not zero) when not specified in proxy specification string.
2013-04-22 19:32:44 +00:00
henri
c9d237f26b
Added a new NSE_STATUS_PROXYERROR status type to report proxy-related errors
...
back to caller.
2013-04-22 19:32:29 +00:00
henri
da1559b237
Replaced a couple macros by corresponding static inline functions.
...
Removed unused PROXY_CTX_NODES() macro.
2013-04-22 19:32:20 +00:00
henri
6c0d537efb
Removed unused http_proxy_info structure.
2013-04-22 19:32:11 +00:00
henri
152490e630
Removed per-node information structures as well as data encoding/decoding
...
interface.
These were unused and I think won't be required by any proxy type (HTTP and
SOCKS).
2013-04-22 19:32:04 +00:00
henri
173adc678b
Implemented a more robust URI parser. Code largely adapted from ncat/http.c.
2013-04-22 19:31:56 +00:00
henri
26f918e310
Use an intermediate proxy_chain pointer for readability.
2013-04-22 19:31:47 +00:00
henri
ba27c10458
Removed the proxy-specific tcp_connect hook.
...
This simplifies the interface that proxies export to the library but also relies
upon the assumption that a proxy chain starts with a TCP connection from the
scanner to the next hop proxy. That will be enough ATM.
2013-04-22 19:31:40 +00:00
henri
4d5bb41361
Added skeletton for having px_info list in each Nsock IOD.
...
When establishing the tunnel through proxy chain, we need to track status of
each proxy (storing R/W buffers, stats, retries...).
This patch lets proxies store and manage whatever structure they want to have
for this in a Nsock IOD. Since types can differ between proxy types, the
proxy_info are stored as a list of void *, ordered like the proxy nodes.
2013-04-22 19:31:30 +00:00
henri
21327ee56c
Return 1 on success to (try to) improve consistency.
2013-04-22 19:31:21 +00:00
henri
af65c7448f
Removed 'data_' prefixes to encoding/decoding functions to avoid confusion with functions that deal with proxy internal data structures.
2013-04-22 19:31:14 +00:00
henri
5168ff9113
Moved prototypes to nsock_proxy.h
2013-04-22 19:31:06 +00:00
henri
4b9ff7f562
Removed unused macros.
2013-04-22 19:30:57 +00:00
henri
f1a04abd6b
Removed the global ProxyOps list.
...
Each proxy node now provides a pointer to its operations struct.
2013-04-22 19:30:49 +00:00
henri
3451220630
Refactored proxy code to use a "strategy" design pattern.
...
Proxy backends are selected at runtime. Each proxy exports a list of operations
to the rest of the library. This is similar to the way IO engines are
implemented within nsock.
2013-04-22 19:30:40 +00:00
henri
08c44fe775
Added nsock_proxy.h to the DEPS list.
2013-04-22 19:30:30 +00:00
henri
48354754a8
Renamed proxy actions into proxy op, which seems to be rather more meaningful.
2013-04-22 19:30:23 +00:00
henri
e1030f2fe7
Cosmetic fixes.
2013-04-22 19:30:14 +00:00
henri
f5e437cdbf
Removed undesired debugging printf() call.
2013-04-22 19:30:07 +00:00
henri
2b3a3ca5df
Fixed ProxyAction extern declaration.
2013-04-22 19:29:58 +00:00
henri
91af533ca2
Added missing initializer.
2013-04-22 19:29:43 +00:00
henri
641d63efb4
Reduced scope of the top level proxy event handler.
...
There is no need anymore for exporting this function to the rest of the library.
It's called by the proxy hooks when registering new events.
2013-04-22 19:29:35 +00:00
henri
9084805bbf
Added destructor for proxy_chain_context.
2013-04-22 19:29:26 +00:00
henri
28604b63e3
Design improvements.
...
Externally:
The calling application can build a proxychain object and assign it to one (or
more) NSP. Once a NSP get assigned a proxychain it's not possible to remove
it so that consistency is (should be...) ensured.
Internally:
An IOD comes with a proxychain context structure storing the whole tunnel
state. Also each proxy type now has a table of associated functions to use
as hooks for TCP connects(), read() and write() requests. As a result, adding
support of new proxy type should be easier. Code also gains readability in
comparison to large switch/cases that redirect the execution flow according to
the given proxy type.
2013-04-22 19:29:18 +00:00
henri
06219414a6
Initial version with a _very_ raw support for HTTP proxy chains (using the
...
CONNECT method). This is mostly intended to validate the concepts, data models
and programming approach.
2013-04-22 19:28:53 +00:00