Skip to content

Commit

Permalink
First round of cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
mandreko committed Oct 27, 2015
1 parent 59e48e8 commit 008b492
Show file tree
Hide file tree
Showing 15 changed files with 81 additions and 81 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Note: This module also works for WebDav NTLM authentication issued from Windows

- Built-in HTTPS Auth server.

Same as above. The folder certs/ containa 2 default keys, including a dummy private key. This is *intentional*, the purpose is to have Responder working out of the box. A script was added in case you need to generate your own self signed key pair.
Same as above. The folder certs/ contains 2 default keys, including a dummy private key. This is *intentional*, the purpose is to have Responder working out of the box. A script was added in case you need to generate your own self signed key pair.

- Built-in LDAP Auth server.

Expand All @@ -46,7 +46,7 @@ This server will answer type A queries. This is really handy when it's combined

- Built-in WPAD Proxy Server.

This module will capture all HTTP requests from anyone launching Internet Explorer on the network if they have "Auto-detect settings" enabled. This module is higly effective. You can configure your custom PAC script in Responder.conf and inject HTML into the server's responses. See Responder.conf.
This module will capture all HTTP requests from anyone launching Internet Explorer on the network if they have "Auto-detect settings" enabled. This module is highly effective. You can configure your custom PAC script in Responder.conf and inject HTML into the server's responses. See Responder.conf.

- Browser Listener

Expand Down
2 changes: 1 addition & 1 deletion Responder.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ def main():
thread.start_new(serve_thread_tcp,('', 3141, HTTP_Proxy))

if settings.Config.SMB_On_Off:
if settings.Config.LM_On_Off == True:
if settings.Config.LM_On_Off:
from servers.SMB import SMB1LM
thread.start_new(serve_thread_tcp,('', 445, SMB1LM))
thread.start_new(serve_thread_tcp,('', 139, SMB1LM))
Expand Down
2 changes: 1 addition & 1 deletion odict.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def __reduce__(self):
inst_dict = vars(self).copy()
self.__map, self.__end = tmp
if inst_dict:
return (self.__class__, (items,), inst_dict)
return self.__class__, (items,), inst_dict
return self.__class__, (items,)

def keys(self):
Expand Down
104 changes: 52 additions & 52 deletions packets.py

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion poisoners/LLMNR.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def Parse_LLMNR_Name(data):
return Name

def IsOnTheSameSubnet(ip, net):
net = net+'/24'
net += '/24'
ipaddr = int(''.join([ '%02x' % int(x) for x in ip.split('.') ]), 16)
netstr, bits = net.split('/')
netaddr = int(''.join([ '%02x' % int(x) for x in netstr.split('.') ]), 16)
Expand Down
4 changes: 2 additions & 2 deletions poisoners/NBTNS.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ def Validate_NBT_NS(data):
if NBT_NS_Role(data[43:46]) == "File Server":
return True

if settings.Config.NBTNSDomain == True:
if settings.Config.NBTNSDomain:
if NBT_NS_Role(data[43:46]) == "Domain Controller":
return True

if settings.Config.Wredirect == True:
if settings.Config.Wredirect:
if NBT_NS_Role(data[43:46]) == "Workstation/Redirector":
return True

Expand Down
4 changes: 2 additions & 2 deletions servers/HTTP.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def PacketSequence(data, client):
return RespondWithFile(client, settings.Config.Exe_Filename, settings.Config.Exe_DlName)

# Serve the custom HTML if needed
if settings.Config.Serve_Html == True:
if settings.Config.Serve_Html:
return RespondWithFile(client, settings.Config.Html_Filename)

WPAD_Custom = WpadCustom(data, client)
Expand Down Expand Up @@ -209,7 +209,7 @@ def PacketSequence(data, client):
return str(Buffer)

else:
if settings.Config.Basic == True:
if settings.Config.Basic:
Response = IIS_Basic_401_Ans()
if settings.Config.Verbose:
print text("[HTTP] Sending BASIC authentication request to %s" % client)
Expand Down
10 changes: 5 additions & 5 deletions servers/HTTP_Proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
def InjectData(data, client, req_uri):

# Serve the .exe if needed
if settings.Config.Serve_Always == True:
if settings.Config.Serve_Always:
return RespondWithFile(client, settings.Config.Exe_Filename, settings.Config.Exe_DlName)

# Serve the .exe if needed and client requested a .exe
Expand All @@ -53,7 +53,7 @@ def InjectData(data, client, req_uri):
if "content-type: text/html" in Headers.lower():

# Serve the custom HTML if needed
if settings.Config.Serve_Html == True:
if settings.Config.Serve_Html:
return RespondWithFile(client, settings.Config.Html_Filename)

Len = ''.join(re.findall('(?<=Content-Length: )[^\r\n]*', Headers))
Expand Down Expand Up @@ -121,7 +121,7 @@ def connect(self, address) :
# Ask him to create a tunnel connection to the target host/port
self.socket.send(
("CONNECT %s:%d HTTP/1.1\r\n" +
"Host: %s:%d\r\n\r\n") % (self.host, self.port, self.host, self.port));
"Host: %s:%d\r\n\r\n") % (self.host, self.port, self.host, self.port))

# Get the response
resp = self.socket.recv(4096)
Expand Down Expand Up @@ -198,7 +198,7 @@ def shutdown(self, *args):

# Return the (host, port) of the actual target, not the proxy gateway
def getpeername(self) :
return (self.host, self.port)
return self.host, self.port

# Inspired from Tiny HTTP proxy, original work: SUZUKI Hisao.
class HTTP_Proxy(BaseHTTPServer.BaseHTTPRequestHandler):
Expand Down Expand Up @@ -268,7 +268,7 @@ def do_GET(self):
#self.send_error(200, "OK")
return

if scm not in ('http') or fragment or not netloc:
if scm not in 'http' or fragment or not netloc:
self.send_error(400, "bad url %s" % self.path)
return

Expand Down
2 changes: 1 addition & 1 deletion servers/MSSQL.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from packets import MSSQLPreLoginAnswer, MSSQLNTLMChallengeAnswer
from utils import *

class TDS_Login_Packet():
class TDS_Login_Packet:
def __init__(self, data):

ClientNameOff = struct.unpack('<h', data[44:46])[0]
Expand Down
2 changes: 1 addition & 1 deletion settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def populate(self, options):
self.Verbose = options.Verbose
self.CommandLine = str(sys.argv)

if self.HtmlToInject == None:
if self.HtmlToInject is None:
self.HtmlToInject = ''

self.Bind_To = utils.FindLocalIP(self.Interface, self.OURIP)
Expand Down
6 changes: 3 additions & 3 deletions tools/DHCP.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ def ParseDHCPCode(data):
Buffer.calculate()
SendDHCP(str(IP_Header)+str(Buffer), (CurrentIP, 68))

return 'Acknowleged DHCP Inform for IP: %s, Req IP: %s, MAC: %s Tid: %s' % (CurrentIP, RequestedIP, MacAddrStr, '0x'+PTid.encode('hex'))
return 'Acknowledged DHCP Inform for IP: %s, Req IP: %s, MAC: %s Tid: %s' % (CurrentIP, RequestedIP, MacAddrStr, '0x'+PTid.encode('hex'))

# DHCP Request
if OpCode == "\x03" and Respond_To_Requests:
Expand All @@ -298,7 +298,7 @@ def ParseDHCPCode(data):

SendDHCP(str(IP_Header)+str(Buffer), (IPConv, 68))

return 'Acknowleged DHCP Request for IP: %s, Req IP: %s, MAC: %s Tid: %s' % (CurrentIP, RequestedIP, MacAddrStr, '0x'+PTid.encode('hex'))
return 'Acknowledged DHCP Request for IP: %s, Req IP: %s, MAC: %s Tid: %s' % (CurrentIP, RequestedIP, MacAddrStr, '0x'+PTid.encode('hex'))

# DHCP Discover
if OpCode == "\x01" and Respond_To_Requests:
Expand All @@ -315,7 +315,7 @@ def ParseDHCPCode(data):

SendDHCP(str(IP_Header)+str(Buffer), (IPConv, 0))

return 'Acknowleged DHCP Discover for IP: %s, Req IP: %s, MAC: %s Tid: %s' % (CurrentIP, RequestedIP, MacAddrStr, '0x'+PTid.encode('hex'))
return 'Acknowledged DHCP Discover for IP: %s, Req IP: %s, MAC: %s Tid: %s' % (CurrentIP, RequestedIP, MacAddrStr, '0x'+PTid.encode('hex'))

def SendDHCP(packet,Host):
s = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.IPPROTO_RAW)
Expand Down
6 changes: 3 additions & 3 deletions tools/Icmp-Redirect.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ def ReceiveArpFrame(DstAddr):
PrintMac = ":".join([DestMac[x:x+2] for x in xrange(0, len(DestMac), 2)])
return PrintMac,DstMac
except:
print "[ARP]%s took too long to Respond. Please provide a valid host.\n"%(DstAddr)
print "[ARP]%s took too long to Respond. Please provide a valid host.\n"% DstAddr
exit(1)

def IcmpRedirectSock(DestinationIP):
Expand Down Expand Up @@ -252,10 +252,10 @@ def RunThisInLoop(host, host2, ip):
sys.exit("\r%s Exiting..." % color('[*]', 2, 1))

if __name__ == "__main__":
if ToThisHost2 != None:
if ToThisHost2 is not None:
RunThisInLoop(ToThisHost, ToThisHost2,Responder_IP)

if ToThisHost2 == None:
if ToThisHost2 is None:
print text("[ICMP-Redir] Poisoning target...")
IcmpRedirectSock(DestinationIP=ToThisHost)
print text("[ICMP-Redir] Done.")
Expand Down
2 changes: 1 addition & 1 deletion tools/RelayPackets.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import struct
from odict import OrderedDict

class Packet():
class Packet:
fields = OrderedDict([
("data", ""),
])
Expand Down
8 changes: 4 additions & 4 deletions tools/SMBRelay.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def UserCallBack(op, value, dmy, parser):
print '\033[31m'+'Use this script in combination with Responder.py for best results (remember to set SMB = Off in Responder.conf)..\nUsernames to relay (-u) are case sensitive.'+'\033[0m'
print 'To kill this script hit CRTL-C or Enter\nWill relay credentials for these users: '+'\033[1m\033[34m'+', '.join(UserToRelay)+'\033[0m\n'

class Packet():
class Packet:
fields = OrderedDict([
("data", ""),
])
Expand All @@ -88,14 +88,14 @@ def __str__(self):
def ReadData(outfile,Client, User, cmd=None):
try:
with open(ResponderPATH+outfile,"r") as filestr:
if cmd == None:
if cmd is None:
String = Client+':'+User
if re.search(String.encode('hex'), filestr.read().encode('hex')):
filestr.close()
return True
else:
return False
if cmd != None:
if cmd is not None:
String = Client+","+User+","+cmd
if re.search(String.encode('hex'), filestr.read().encode('hex')):
filestr.close()
Expand Down Expand Up @@ -255,7 +255,7 @@ def RunRelay(host, Command,Domain):
a = SmbRogueSrv139(Key,Target,DomainMachineName)
if a is not None:
LMHash,NTHash,Username,OriginalDomain, CLIENTIP = a
if Domain == None:
if Domain is None:
Domain = OriginalDomain
if ReadData("SMBRelay-Session.txt", Target, Username, CMD):
pass
Expand Down
4 changes: 2 additions & 2 deletions utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def RespondToThisName(Name):
return False

def RespondToThisHost(ClientIp, Name):
return (RespondToThisIP(ClientIp) and RespondToThisName(Name))
return RespondToThisIP(ClientIp) and RespondToThisName(Name)

def IsOsX():
return True if settings.Config.Os_version == "darwin" else False
Expand Down Expand Up @@ -121,7 +121,7 @@ def WriteData(outfile, data, user):

logging.info("[*] Captured Hash: %s" % data)

if os.path.isfile(outfile) == False:
if not os.path.isfile(outfile):
with open(outfile,"w") as outf:
outf.write(data)
outf.write("\n")
Expand Down

0 comments on commit 008b492

Please sign in to comment.