From 877d46e9f7b77bd7472be38484d681b558705594 Mon Sep 17 00:00:00 2001 From: Miroslav Stampar Date: Tue, 18 Oct 2016 13:46:56 +0200 Subject: [PATCH] Fixes #2234 --- lib/core/option.py | 2 + lib/core/settings.py | 2 +- thirdparty/wininetpton/__init__.py | 10 +++ thirdparty/wininetpton/win_inet_pton.py | 85 +++++++++++++++++++++++++ txt/checksum.md5 | 6 +- 5 files changed, 102 insertions(+), 3 deletions(-) create mode 100644 thirdparty/wininetpton/__init__.py create mode 100644 thirdparty/wininetpton/win_inet_pton.py diff --git a/lib/core/option.py b/lib/core/option.py index 77c5435ad..402b612d2 100644 --- a/lib/core/option.py +++ b/lib/core/option.py @@ -1794,6 +1794,8 @@ def _dirtyPatches(): httplib._MAXLINE = 1 * 1024 * 1024 # to accept overly long result lines (e.g. SQLi results in HTTP header responses) + from thirdparty.wininetpton import win_inet_pton + def _purgeOutput(): """ Safely removes (purges) output directory. diff --git a/lib/core/settings.py b/lib/core/settings.py index 020ec42ea..4fb1819d9 100644 --- a/lib/core/settings.py +++ b/lib/core/settings.py @@ -19,7 +19,7 @@ from lib.core.enums import DBMS_DIRECTORY_NAME from lib.core.enums import OS # sqlmap version (...) -VERSION = "1.0.10.43" +VERSION = "1.0.10.44" TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable" TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34} VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE) diff --git a/thirdparty/wininetpton/__init__.py b/thirdparty/wininetpton/__init__.py new file mode 100644 index 000000000..5ea298dc1 --- /dev/null +++ b/thirdparty/wininetpton/__init__.py @@ -0,0 +1,10 @@ +#!/usr/bin/env python +# +# Copyright Ryan Vennell +# +# This software released into the public domain. Anyone is free to copy, +# modify, publish, use, compile, sell, or distribute this software, +# either in source code form or as a compiled binary, for any purpose, +# commercial or non-commercial, and by any means. + +pass diff --git a/thirdparty/wininetpton/win_inet_pton.py b/thirdparty/wininetpton/win_inet_pton.py new file mode 100644 index 000000000..50ae621e5 --- /dev/null +++ b/thirdparty/wininetpton/win_inet_pton.py @@ -0,0 +1,85 @@ +#!/usr/bin/env python +# This software released into the public domain. Anyone is free to copy, +# modify, publish, use, compile, sell, or distribute this software, +# either in source code form or as a compiled binary, for any purpose, +# commercial or non-commercial, and by any means. + +import socket +import ctypes +import os + + +class sockaddr(ctypes.Structure): + _fields_ = [("sa_family", ctypes.c_short), + ("__pad1", ctypes.c_ushort), + ("ipv4_addr", ctypes.c_byte * 4), + ("ipv6_addr", ctypes.c_byte * 16), + ("__pad2", ctypes.c_ulong)] + +if hasattr(ctypes, 'windll'): + WSAStringToAddressA = ctypes.windll.ws2_32.WSAStringToAddressA + WSAAddressToStringA = ctypes.windll.ws2_32.WSAAddressToStringA +else: + def not_windows(): + raise SystemError( + "Invalid platform. ctypes.windll must be available." + ) + WSAStringToAddressA = not_windows + WSAAddressToStringA = not_windows + + +def inet_pton(address_family, ip_string): + addr = sockaddr() + addr.sa_family = address_family + addr_size = ctypes.c_int(ctypes.sizeof(addr)) + + if WSAStringToAddressA( + ip_string, + address_family, + None, + ctypes.byref(addr), + ctypes.byref(addr_size) + ) != 0: + raise socket.error(ctypes.FormatError()) + + if address_family == socket.AF_INET: + return ctypes.string_at(addr.ipv4_addr, 4) + if address_family == socket.AF_INET6: + return ctypes.string_at(addr.ipv6_addr, 16) + + raise socket.error('unknown address family') + + +def inet_ntop(address_family, packed_ip): + addr = sockaddr() + addr.sa_family = address_family + addr_size = ctypes.c_int(ctypes.sizeof(addr)) + ip_string = ctypes.create_string_buffer(128) + ip_string_size = ctypes.c_int(ctypes.sizeof(ip_string)) + + if address_family == socket.AF_INET: + if len(packed_ip) != ctypes.sizeof(addr.ipv4_addr): + raise socket.error('packed IP wrong length for inet_ntoa') + ctypes.memmove(addr.ipv4_addr, packed_ip, 4) + elif address_family == socket.AF_INET6: + if len(packed_ip) != ctypes.sizeof(addr.ipv6_addr): + raise socket.error('packed IP wrong length for inet_ntoa') + ctypes.memmove(addr.ipv6_addr, packed_ip, 16) + else: + raise socket.error('unknown address family') + + if WSAAddressToStringA( + ctypes.byref(addr), + addr_size, + None, + ip_string, + ctypes.byref(ip_string_size) + ) != 0: + raise socket.error(ctypes.FormatError()) + + return ip_string[:ip_string_size.value - 1] + +# Adding our two functions to the socket library +if os.name == 'nt': + socket.inet_pton = inet_pton + socket.inet_ntop = inet_ntop diff --git a/txt/checksum.md5 b/txt/checksum.md5 index 16e7609b5..f18ccb6e5 100644 --- a/txt/checksum.md5 +++ b/txt/checksum.md5 @@ -39,13 +39,13 @@ e4aec2b11c1ad6039d0c3dbbfbc5eb1a lib/core/exception.py cc9c82cfffd8ee9b25ba3af6284f057e lib/core/__init__.py 91c514013daa796e2cdd940389354eac lib/core/log.py 468ca9a68a5a40a1cb8395602083ba32 lib/core/optiondict.py -bf17e2bc2dc356105a159d8c093bd952 lib/core/option.py +6d3e00fe69fd2fe9a794cae18b48b56c lib/core/option.py 7af487340c138f7b5dbd443161cbb428 lib/core/profiling.py e60456db5380840a586654344003d4e6 lib/core/readlineng.py 5ef56abb8671c2ca6ceecb208258e360 lib/core/replication.py 99a2b496b9d5b546b335653ca801153f lib/core/revision.py 7c15dd2777af4dac2c89cab6df17462e lib/core/session.py -469c00ca02a5d91ca058cfc54cfa7e94 lib/core/settings.py +c2d650ebf3d2c270c8ba082bf1ae249b lib/core/settings.py 7af83e4f18cab6dff5e67840eb65be80 lib/core/shell.py 23657cd7d924e3c6d225719865855827 lib/core/subprocessng.py c3ace7874a536d801f308cf1fd03df99 lib/core/target.py @@ -352,6 +352,8 @@ d41d8cd98f00b204e9800998ecf8427e thirdparty/socks/__init__.py a2f0ee74ccc895150f310ef8d680edca thirdparty/socks/socks.py d41d8cd98f00b204e9800998ecf8427e thirdparty/termcolor/__init__.py ea649aae139d8551af513769dd913dbf thirdparty/termcolor/termcolor.py +bf55909ad163b58236e44b86e8441b26 thirdparty/wininetpton/__init__.py +a44e7cf30f2189b2fbdb635b310cdc0c thirdparty/wininetpton/win_inet_pton.py 855372c870a23d46683f8aa39d75f6a1 thirdparty/xdot/__init__.py 593473084228b63a12318d812e50f1e2 thirdparty/xdot/xdot.py 08c706478fad0acba049d0e32cbb6411 udf/mysql/linux/32/lib_mysqludf_sys.so_