Skip to content

Commit 2e87ade

Browse files
authored
smbserver: gracefully exit on KeyboardInterrupt (#1969)
1 parent 6b8f623 commit 2e87ade

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

examples/smbserver.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python
22
# Impacket - Collection of Python classes for working with network protocols.
33
#
4-
# Copyright Fortra, LLC and its affiliated companies
4+
# Copyright Fortra, LLC and its affiliated companies
55
#
66
# All rights reserved.
77
#
@@ -30,7 +30,7 @@
3030
print(version.BANNER)
3131

3232
parser = argparse.ArgumentParser(add_help = True, description = "This script will launch a SMB Server and add a "
33-
"share specified as an argument. You need to be root in order to bind to port 445. "
33+
"share specified as an argument. Usually, you need to be root in order to bind to port 445. "
3434
"For optional authentication, it is possible to specify username and password or the NTLM hash. "
3535
"Example: smbserver.py -comment 'My share' TMP /tmp")
3636

@@ -98,4 +98,8 @@
9898
server.setSMBChallenge('')
9999

100100
# Rock and roll
101-
server.start()
101+
try:
102+
server.start()
103+
except KeyboardInterrupt:
104+
print("\nInterrupted, exiting...")
105+
sys.exit(130)

0 commit comments

Comments
 (0)