1
mirror of https://github.com/rapid7/metasploit-payloads synced 2025-01-14 17:37:27 +01:00

Don't fall back to 0.0.0.0

This allows the client side to determine whether to fall back and gives
the user a better chance of seeing that it isn't listening where they
told it to.
This commit is contained in:
James Lee 2015-10-30 11:46:25 -05:00
parent 2492316f55
commit 4d37ec6646
No known key found for this signature in database
GPG Key ID: 2D6094C7CEA0A321

View File

@ -1,6 +1,6 @@
/*!
* @file tcp_server.c
* @brief
* @brief
*/
#include "precomp.h"
#include "tcp.h"
@ -306,24 +306,10 @@ DWORD request_net_tcp_server_channel_open(Remote * remote, Packet * packet)
{
#ifdef _WIN32
dwResult = WSAGetLastError();
if (dwResult != WSAEADDRNOTAVAIL)
#else
dwResult = errno;
if (dwResult != EADDRNOTAVAIL)
#endif
{
BREAK_ON_WSAERROR("[TCP-SERVER] request_net_tcp_server_channel_open. bind failed");
}
dprintf("[TCP-SERVER] Failed to bind to %s, trying 0.0.0.0 ...", lhost);
// try again, but this time bind to any/all interfaces.
lhost = "0.0.0.0";
saddr.sin_addr.s_addr = inet_addr(lhost);
if (bind(ctx->fd, (SOCKADDR *)&saddr, sizeof(SOCKADDR_IN)) == SOCKET_ERROR)
{
BREAK_ON_WSAERROR("[TCP-SERVER] request_net_tcp_server_channel_open. bind failed");
}
BREAK_ON_WSAERROR("[TCP-SERVER] request_net_tcp_server_channel_open. bind failed");
dwResult = ERROR_SUCCESS;
}