From dd61fa950f1455486d4e8867559ea51c272f58ac Mon Sep 17 00:00:00 2001 From: James Lee Date: Mon, 10 Jan 2011 08:31:10 +0000 Subject: [PATCH] when socket creation fails, return a relevant windows error code so the client will raise ::Rex::ConnectionError instead of just erroring out with a RequestError. This fixes some problems with backtraces when routing through a php meterp. See r9794, #3481. git-svn-id: file:///home/svn/framework3/trunk@11532 4d416f70-5f16-0410-b530-b9f4589650da --- data/meterpreter/ext_server_stdapi.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/data/meterpreter/ext_server_stdapi.php b/data/meterpreter/ext_server_stdapi.php index 34bd5110d4..78b743d355 100644 --- a/data/meterpreter/ext_server_stdapi.php +++ b/data/meterpreter/ext_server_stdapi.php @@ -150,6 +150,14 @@ define("TLV_TYPE_EVENT_DATA", TLV_META_TYPE_RAW | 4013); define("TLV_TYPE_POWER_FLAGS", TLV_META_TYPE_UINT | 4100); define("TLV_TYPE_POWER_REASON", TLV_META_TYPE_UINT | 4101); +## +# Errors +## + +# Special return value to match up with Windows error codes for network +# errors. +define("ERROR_CONNECTION_ERROR", 10000); + # Wrap everything in checks for existence of the new functions in case we get # eval'd twice my_print("Evaling stdapi"); @@ -888,7 +896,7 @@ function channel_create_stdapi_net_tcp_client($req, &$pkt) { } if (!$sock) { - return ERROR_FAILURE; + return ERROR_CONNECTION_ERROR; } # @@ -919,7 +927,7 @@ function channel_create_stdapi_net_udp_client($req, &$pkt) { my_print("UDP channel on {$sock}"); if (!$sock) { - return ERROR_FAILURE; + return ERROR_CONNECTION_ERROR; } #