Coverage for /root/GitHubProjects/impacket/impacket/examples/ntlmrelayx/utils/tcpshell.py : 35%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1# SECUREAUTH LABS. Copyright 2018 SecureAuth Corporation. All rights reserved.
2#
3# This software is provided under under a slightly modified version
4# of the Apache Software License. See the accompanying LICENSE file
5# for more information.
6#
7# TCP interactive shell
8#
9# Author:
10# Dirk-jan Mollema / Fox-IT (https://www.fox-it.com)
11#
12# Description:
13# Launches a TCP shell for interactive use of clients
14# after successful relaying
15import socket
16#Default listen port
17port = 11000
18class TcpShell:
19 def __init__(self):
20 global port
21 self.port = port
22 #Increase the default port for the next attack
23 port += 1
25 def listen(self):
26 #Set up the listening socket
27 serversocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
28 #Bind on localhost
29 serversocket.bind(('127.0.0.1', self.port))
30 #Don't allow a backlog
31 serversocket.listen(0)
32 self.connection, host = serversocket.accept()
33 #Create file objects from the socket
34 self.stdin = self.connection.makefile("r")
35 self.stdout = self.connection.makefile("w")
37 def close(self):
38 self.stdout.close()
39 self.stdin.close()
40 self.connection.close()