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

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

## 17 statements

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# Impacket - Collection of Python classes for working with network protocols.

2#

3# SECUREAUTH LABS. Copyright (C) 2020 SecureAuth Corporation. All rights reserved.

4#

5# This software is provided under a slightly modified version

6# of the Apache Software License. See the accompanying LICENSE file

7# for more information.

8#

9# Description:

10# TCP interactive shell

11#

12# Launches a TCP shell for interactive use of clients

13# after successful relaying

14#

15# Author:

16# Dirk-jan Mollema / Fox-IT (https://www.fox-it.com)

17#

18 import socket

19#Default listen port

20 port = 11000

21 class TcpShell:

22 def __init__(self):

23 global port

24 self.port = port

25 #Increase the default port for the next attack

26 port += 1

27

28 def listen(self):

29 #Set up the listening socket

30 serversocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

31 #Bind on localhost

32 serversocket.bind(('127.0.0.1', self.port))

33 #Don't allow a backlog

34 serversocket.listen(0)

35 self.connection, host = serversocket.accept()

36 #Create file objects from the socket

37 self.stdin = self.connection.makefile("r")

38 self.stdout = self.connection.makefile("w")

39

40 def close(self):

41 self.stdout.close()

42 self.stdin.close()

43 self.connection.close()