-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathETAC.py
178 lines (147 loc) · 7.39 KB
/
ETAC.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
#!/usr/bin/env python
# This file was part of Responder and now is part of ETAC
# ETAC work by Felix Ryan
# Responder work by Laurent Gaffie - Trustwave Holdings
#
# 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 <http://www.gnu.org/licenses/>.
import optparse
from SocketServer import TCPServer, UDPServer, ThreadingMixIn
from threading import Thread
from utils import *
banner()
parser = optparse.OptionParser(usage='python %prog -I eth0 -w -r -f\nor:\npython %prog -I eth0 -wrf',
version=settings.__version__, prog=sys.argv[0])
parser.add_option('-A', '--analyze', action="store_true",
help="Analyze mode. This option allows you to see NBT-NS, BROWSER, LLMNR requests without responding.",
dest="Analyze", default=False)
parser.add_option('-I', '--interface', action="store", help="Network interface to use", dest="Interface",
metavar="eth0", default=None)
parser.add_option('-i', '--ip', action="store", help="Local IP to use \033[1m\033[31m(only for OSX)\033[0m",
dest="OURIP", metavar="10.0.0.21", default=None)
parser.add_option('-b', '--basic', action="store_true", help="Return a Basic HTTP authentication. Default: NTLM",
dest="Basic", default=False)
parser.add_option('-r', '--wredir', action="store_true",
help="Enable answers for netbios wredir suffix queries. Answering to wredir will likely break stuff on the network. Default: False",
dest="Wredirect", default=False)
parser.add_option('-d', '--NBTNSdomain', action="store_true",
help="Enable answers for netbios domain suffix queries. Answering to domain suffixes will likely break stuff on the network. Default: False",
dest="NBTNSDomain", default=False)
parser.add_option('-f', '--fingerprint', action="store_true",
help="This option allows you to fingerprint a host that issued an NBT-NS or LLMNR query.",
dest="Finger", default=False)
parser.add_option('-w', '--wpad', action="store_true", help="Start the WPAD rogue proxy server. Default value is False",
dest="WPAD_On_Off", default=False)
parser.add_option('-H', '--html-poisoner', action="store_true",
help="Enable the HTML poisoning proxy. Default value is False", dest="HTML_On_Off", default=False)
parser.add_option('-u', '--upstream-proxy', action="store",
help="Upstream HTTP proxy used by the rogue WPAD Proxy for outgoing requests (format: host:port)",
dest="Upstream_Proxy", default=None)
parser.add_option('-F', '--ForceWpadAuth', action="store_true",
help="Force NTLM/Basic authentication on wpad.dat file retrieval. This may cause a login prompt. Default: False",
dest="Force_WPAD_Auth", default=False)
parser.add_option('--lm', action="store_true",
help="Force LM hashing downgrade for Windows XP/2003 and earlier. Default: False", dest="LM_On_Off",
default=False)
parser.add_option('-v', '--verbose', action="store_true", help="Increase verbosity.", dest="Verbose")
options, args = parser.parse_args()
if not os.geteuid() == 0:
print color("[!] Responder must be run as root.")
sys.exit(-1)
if options.OURIP is None and IsOsX() is True:
print "\n\033[1m\033[31mOSX detected, -i mandatory option is missing\033[0m\n"
parser.print_help()
exit(-1)
settings.init()
settings.Config.populate(options)
StartupMessage()
settings.Config.ExpandIPRanges()
class ThreadingUDPServer(ThreadingMixIn, UDPServer):
def server_bind(self):
if OsInterfaceIsSupported():
try:
self.socket.setsockopt(socket.SOL_SOCKET, 25, settings.Config.Bind_To + '\0')
except:
pass
UDPServer.server_bind(self)
class ThreadingTCPServer(ThreadingMixIn, TCPServer):
def server_bind(self):
if OsInterfaceIsSupported():
try:
self.socket.setsockopt(socket.SOL_SOCKET, 25, settings.Config.Bind_To + '\0')
except:
pass
TCPServer.server_bind(self)
ThreadingUDPServer.allow_reuse_address = 1
ThreadingTCPServer.allow_reuse_address = 1
def serve_thread_udp_broadcast(host, port, handler):
try:
server = ThreadingUDPServer(('', port), handler)
server.serve_forever()
except:
print color("[!] ", 1, 1) + "Error starting UDP server on port " + str(
port) + ", check permissions or other servers running."
def serve_thread_udp(host, port, handler):
try:
if OsInterfaceIsSupported():
server = ThreadingUDPServer((settings.Config.Bind_To, port), handler)
server.serve_forever()
else:
server = ThreadingUDPServer((host, port), handler)
server.serve_forever()
except:
print color("[!] ", 1, 1) + "Error starting UDP server on port " + str(
port) + ", check permissions or other servers running."
def serve_thread_tcp(host, port, handler):
try:
if OsInterfaceIsSupported():
server = ThreadingTCPServer((settings.Config.Bind_To, port), handler)
server.serve_forever()
else:
server = ThreadingTCPServer((host, port), handler)
server.serve_forever()
except:
print color("[!] ", 1, 1) + "Error starting TCP server on port " + str(
port) + ", check permissions or other servers running."
def main():
try:
threads = []
# Load HTML Poisoner
if settings.Config.HTML_On_Off:
from poisoners import HTML
threads.append(Thread(target=HTML.main))
# Load Browser Listener
from servers.Browser import Browser
threads.append(Thread(target=serve_thread_udp_broadcast, args=('', 138, Browser,)))
if settings.Config.SMB_On_Off:
if settings.Config.LM_On_Off:
from servers.SMB import SMB1LM
threads.append(Thread(target=serve_thread_tcp, args=('', 445, SMB1LM,)))
threads.append(Thread(target=serve_thread_tcp, args=('', 139, SMB1LM,)))
else:
from servers.SMB import SMB1
threads.append(Thread(target=serve_thread_tcp, args=('', 445, SMB1,)))
threads.append(Thread(target=serve_thread_tcp, args=('', 139, SMB1,)))
for thread in threads:
thread.setDaemon(True)
thread.start()
print color('[+]', 2, 1) + " Listening for events..."
while True:
time.sleep(1)
except KeyboardInterrupt:
if settings.Config.HTML_On_Off:
# remove the IPtables redirect rule
os.system('iptables -D PREROUTING -t nat -i br-lan -p tcp --dport 80 -j REDIRECT --to-port 3128')
HTML.sys.exit("\r%s Exiting..." % color('[+]', 2, 1))
if __name__ == '__main__':
main()