This commit is contained in:
Miroslav Stampar 2020-01-20 16:11:12 +01:00
parent 4c804a3fd6
commit 9f85412017
2 changed files with 22 additions and 18 deletions

View File

@ -18,7 +18,7 @@ from lib.core.enums import OS
from thirdparty.six import unichr as _unichr from thirdparty.six import unichr as _unichr
# sqlmap version (<major>.<minor>.<month>.<monthly commit>) # sqlmap version (<major>.<minor>.<month>.<monthly commit>)
VERSION = "1.4.1.29" VERSION = "1.4.1.30"
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable" TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34} 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) VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE)

View File

@ -11,6 +11,7 @@ import binascii
import os import os
import re import re
import socket import socket
import struct
import threading import threading
import time import time
@ -22,41 +23,44 @@ class DNSQuery(object):
Reference(s): Reference(s):
http://code.activestate.com/recipes/491264-mini-fake-dns-server/ http://code.activestate.com/recipes/491264-mini-fake-dns-server/
https://code.google.com/p/marlon-tools/source/browse/tools/dnsproxy/dnsproxy.py https://code.google.com/p/marlon-tools/source/browse/tools/dnsproxy/dnsproxy.py
>>> DNSQuery(b'|K\\x01 \\x00\\x01\\x00\\x00\\x00\\x00\\x00\\x01\\x03www\\x06google\\x03com\\x00\\x00\\x01\\x00\\x01\\x00\\x00)\\x10\\x00\\x00\\x00\\x00\\x00\\x00\\x0c\\x00\\n\\x00\\x08O4|Np!\\x1d\\xb3')._query == b"www.google.com."
True
""" """
def __init__(self, raw): def __init__(self, raw):
self._raw = raw self._raw = raw
self._query = "" self._query = b""
type_ = (ord(raw[2]) >> 3) & 15 # Opcode bits type_ = (ord(raw[2:3]) >> 3) & 15 # Opcode bits
if type_ == 0: # Standard query if type_ == 0: # Standard query
i = 12 i = 12
j = ord(raw[i]) j = ord(raw[i:i + 1])
while j != 0: while j != 0:
self._query += raw[i + 1:i + j + 1] + '.' self._query += raw[i + 1:i + j + 1] + b'.'
i = i + j + 1 i = i + j + 1
j = ord(raw[i]) j = ord(raw[i:i + 1])
def response(self, resolution): def response(self, resolution):
""" """
Crafts raw DNS resolution response packet Crafts raw DNS resolution response packet
""" """
retVal = "" retVal = b""
if self._query: if self._query:
retVal += self._raw[:2] # Transaction ID retVal += self._raw[:2] # Transaction ID
retVal += "\x85\x80" # Flags (Standard query response, No error) retVal += b"\x85\x80" # Flags (Standard query response, No error)
retVal += self._raw[4:6] + self._raw[4:6] + "\x00\x00\x00\x00" # Questions and Answers Counts retVal += self._raw[4:6] + self._raw[4:6] + b"\x00\x00\x00\x00" # Questions and Answers Counts
retVal += self._raw[12:(12 + self._raw[12:].find("\x00") + 5)] # Original Domain Name Query retVal += self._raw[12:(12 + self._raw[12:].find(b"\x00") + 5)] # Original Domain Name Query
retVal += "\xc0\x0c" # Pointer to domain name retVal += b"\xc0\x0c" # Pointer to domain name
retVal += "\x00\x01" # Type A retVal += b"\x00\x01" # Type A
retVal += "\x00\x01" # Class IN retVal += b"\x00\x01" # Class IN
retVal += "\x00\x00\x00\x20" # TTL (32 seconds) retVal += b"\x00\x00\x00\x20" # TTL (32 seconds)
retVal += "\x00\x04" # Data length retVal += b"\x00\x04" # Data length
retVal += "".join(chr(int(_)) for _ in resolution.split('.')) # 4 bytes of IP retVal += b"".join(struct.pack('B', int(_)) for _ in resolution.split('.')) # 4 bytes of IP
return retVal return retVal
@ -148,7 +152,7 @@ if __name__ == "__main__":
if _ is None: if _ is None:
break break
else: else:
print("[i] %s" % _) print("[i] %s" % _.decode())
time.sleep(1) time.sleep(1)