Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1b072f6

Browse files
committed
laying foundation for DNS based data retrieval
1 parent 645fc8a commit 1b072f6

5 files changed

Lines changed: 74 additions & 1 deletion

File tree

lib/parse/cmdline.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -628,6 +628,9 @@ def cmdLineParser():
628628
parser.add_option("--test-filter", dest="testFilter",
629629
help=SUPPRESS_HELP)
630630

631+
parser.add_option("--dns-domain", dest="dnsDomain",
632+
help=SUPPRESS_HELP)
633+
631634
parser.add_option_group(target)
632635
parser.add_option_group(request)
633636
parser.add_option_group(optimization)

lib/request/dnsquery.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/usr/bin/env python
2+
3+
"""
4+
$Id$
5+
6+
Copyright (c) 2006-2012 sqlmap developers (http://www.sqlmap.org/)
7+
See the file 'doc/COPYING' for copying permission
8+
"""
9+
10+
class DNSQuery:
11+
"""
12+
Used for making fake DNS resolution responses based on received
13+
raw request
14+
15+
Reference(s):
16+
http://code.activestate.com/recipes/491264-mini-fake-dns-server/
17+
https://code.google.com/p/marlon-tools/source/browse/tools/dnsproxy/dnsproxy.py
18+
"""
19+
20+
def __init__(self, raw):
21+
self._raw = raw
22+
self._query = ""
23+
24+
type_ = (ord(raw[2]) >> 3) & 15 # Opcode bits
25+
if type_ == 0: # Standard query
26+
i = 12
27+
j = ord(raw[i])
28+
while j != 0:
29+
self._query += raw[i+1:i+j+1] + '.'
30+
i = i + j + 1
31+
j = ord(raw[i])
32+
33+
def response(self, resolution):
34+
retval = ""
35+
36+
if self._query:
37+
retval += self._raw[:2] + "\x81\x80"
38+
retval += self._raw[4:6] + self._raw[4:6] + "\x00\x00\x00\x00" # Questions and Answers Counts
39+
retval += self._raw[12:] # Original Domain Name Question
40+
retval += "\xc0\x0c" # Pointer to domain name
41+
retval += "\x00\x01\x00\x01\x00\x00\x00\x3c\x00\x04" # Response type, ttl and resource data length -> 4 bytes
42+
retval += "".join(chr(int(_)) for _ in resolution.split('.')) # 4 bytes of IP
43+
44+
return retval

lib/techniques/dns/__init__.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env python
2+
3+
"""
4+
$Id$
5+
6+
Copyright (c) 2006-2012 sqlmap developers (http://www.sqlmap.org/)
7+
See the file 'doc/COPYING' for copying permission
8+
"""
9+
10+
pass

lib/techniques/dns/use.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env python
2+
3+
"""
4+
$Id$
5+
6+
Copyright (c) 2006-2012 sqlmap developers (http://www.sqlmap.org/)
7+
See the file 'doc/COPYING' for copying permission
8+
"""
9+
10+
def dnsUse(expression, expected=None, dump=False):
11+
"""
12+
Retrieve the output of a SQL query taking advantage of the DNS
13+
resolution mechanism by making request back to attacker's machine.
14+
"""
15+
16+
raise NotImplementedError

procs/README.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
Files in this folder represent SQL Procedural Language snippets used
1+
Files in this folder represent SQL (Procedural Language) snippets used
22
by sqlmap on the target system. They are licensed under the terms of
33
the GNU Lesser General Public License.

0 commit comments

Comments
 (0)