polishing signal reception, creation of ap class, added time class,further work on logging and features. Hidden Dragon is unfinished, do not use.
41 lines
1.6 KiB
Python
41 lines
1.6 KiB
Python
# Copyright (c) 2024 Anoduck
|
|
#
|
|
# This software is released under the MIT License.
|
|
# https://opensource.org/licenses/MIT
|
|
|
|
def std_TXT_qry(msg):
|
|
qs = msg.question
|
|
print str(len(qs)) + ' questions.'
|
|
iparpa = qs[0].to_text().split(' ', 1)[0]
|
|
print 'Host: ' + iparpa
|
|
resp = make_response(qry=msg)
|
|
|
|
host = iparpa[:-1]
|
|
punto = host.find(".")
|
|
dominio = host[punto:]
|
|
host = "."+host
|
|
spfresponse = ''
|
|
if (dominio in dominios) or (host in dominios):
|
|
ttl = 1
|
|
DEBUGLOG('Alert domain! (TXT) ID: ' + host)
|
|
# Here the HANDLE!
|
|
#os.popen("python /yowsup/yowsup-cli -c /yowsup/config -s <number> \"Host %s\nIP %s\" > /dev/null &"%(id,prov_ip));
|
|
save_req(LOGALERTFILE, 'Alert domain! (TXT) ID: ' + host+ '\n')
|
|
if host in dominios: spfresponse = "v=spf1 a:mail%s/24 mx -all "%host
|
|
if dominio in dominios: spfresponse = "v=spf1 a:mail%s/24 mx -all "%dominio
|
|
DEBUGLOG('Responding with SPF = ' + spfresponse)
|
|
rrset = dns.rrset.from_text(iparpa, ttl, dns.rdataclass.IN, dns.rdatatype.TXT, spfresponse)
|
|
resp.answer.append(rrset)
|
|
return resp
|
|
|
|
|
|
hosts = respuestas(iparpa[:-1], 'TXT')
|
|
if isinstance(hosts, numbers.Integral):
|
|
print 'No host....'
|
|
resp = make_response(qry=msg, RCODE=3) # RCODE = 3 NXDOMAIN
|
|
return resp
|
|
|
|
for host in hosts:
|
|
print 'Adding ' + host.to_text()
|
|
rrset = dns.rrset.from_text(iparpa, 1000, dns.rdataclass.IN, dns.rdatatype.TXT, host.to_text())
|
|
resp.answer.append(rrset)
|