Skip to content

Commit

Permalink
Merge pull request #1 from GooseYArd/banner
Browse files Browse the repository at this point in the history
Banner
  • Loading branch information
GooseYArd committed Jan 16, 2014
2 parents 997f60b + 620a563 commit 4b427de
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions telnetsrv/telnetsrvlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,12 @@ class TelnetHandlerBase(SocketServer.BaseRequestHandler):
# What will handle our inputs?
#input_reader = InputSimple
input_reader = InputBashLike
# Banner to display prior to telnet login
TELNET_BANNER = None
# What prompt to use when requesting a telnet username
PROMPT_USER = "Username: "
# What prompt to use when requesting a telnet password
PROMPT_PASS = "Password: "

# --------------------------- Environment Setup ----------------------------

Expand All @@ -447,6 +453,7 @@ def __init__(self, request, client_address, server):
self.DOOPTS = {}
# What opts have I sent WILL/WONT for and what did I send?
self.WILLOPTS = {}

# What commands does this CLI support
self.COMMANDS = {}
self.sock = None # TCP socket
Expand Down Expand Up @@ -991,9 +998,9 @@ def authentication_ok(self):
password = None
if self.authCallback:
if self.authNeedUser:
username = self.readline(prompt="Username: ", use_history=False)
username = self.readline(prompt=self.PROMPT_USER, use_history=False)
if self.authNeedPass:
password = self.readline(echo=False, prompt="Password: ", use_history=False)
password = self.readline(echo=False, prompt=self.PROMPT_PASS, use_history=False)
if self.DOECHO:
self.write("\n")
try:
Expand All @@ -1013,10 +1020,13 @@ def authentication_ok(self):

def handle(self):
"The actual service to which the user has connected."
if self.TELNET_BANNER:
self.writeline(self.TELNET_ISSUE)
if not self.authentication_ok():
return
if self.DOECHO:
self.writeline(self.WELCOME)
self.writeline("ok..")
self.session_start()
while self.RUNSHELL:
raw_input = self.readline(prompt=self.PROMPT).strip()
Expand Down

0 comments on commit 4b427de

Please sign in to comment.