more cosmetics

This commit is contained in:
Bernardo Damele 2012-04-04 12:33:16 +00:00
parent d106fb5184
commit 75d1dab895
2 changed files with 10 additions and 2 deletions

View File

@ -28,9 +28,11 @@ class DNSQuery:
self._query = "" self._query = ""
type_ = (ord(raw[2]) >> 3) & 15 # Opcode bits type_ = (ord(raw[2]) >> 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])
while j != 0: while j != 0:
self._query += raw[i+1:i+j+1] + '.' self._query += raw[i+1:i+j+1] + '.'
i = i + j + 1 i = i + j + 1
@ -59,26 +61,32 @@ class DNSServer:
def pop(self, prefix=None, suffix=None): def pop(self, prefix=None, suffix=None):
retVal = None retVal = None
with self._lock: with self._lock:
for _ in self._requests: for _ in self._requests:
if prefix is None and suffix is None or re.search("%s\..+\.%s" % (prefix, suffix), _, re.I): if prefix is None and suffix is None or re.search("%s\..+\.%s" % (prefix, suffix), _, re.I):
retVal = _ retVal = _
self._requests.remove(_) self._requests.remove(_)
break break
return retVal return retVal
def run(self): def run(self):
def _(): def _():
try: try:
self._running = True self._running = True
while True: while True:
data, addr = self._socket.recvfrom(1024) data, addr = self._socket.recvfrom(1024)
_ = DNSQuery(data) _ = DNSQuery(data)
self._socket.sendto(_.response("127.0.0.1"), addr) self._socket.sendto(_.response("127.0.0.1"), addr)
with self._lock: with self._lock:
self._requests.append(_._query) self._requests.append(_._query)
except KeyboardInterrupt: except KeyboardInterrupt:
raise raise
finally: finally:
self._running = False self._running = False

View File

@ -91,12 +91,12 @@ def __goDns(payload, expression):
kb.dnsTest = dnsUse(payload, "SELECT %d%s" % (randInt, FROM_DUMMY_TABLE.get(Backend.getIdentifiedDbms(), ""))) == str(randInt) kb.dnsTest = dnsUse(payload, "SELECT %d%s" % (randInt, FROM_DUMMY_TABLE.get(Backend.getIdentifiedDbms(), ""))) == str(randInt)
if not kb.dnsTest: if not kb.dnsTest:
errMsg = "test for data retrieval through DNS channel failed. Turning off DNS exfiltration support" errMsg = "data retrieval through DNS channel failed. Turning off DNS exfiltration support"
logger.error(errMsg) logger.error(errMsg)
conf.dnsDomain = None conf.dnsDomain = None
else: else:
infoMsg = "test for data retrieval through DNS channel was successful" infoMsg = "data retrieval through DNS channel was successful"
logger.info(infoMsg) logger.info(infoMsg)
if kb.dnsTest: if kb.dnsTest: