Skip to content

teverett/ktelnet

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
src
 
 
 
 
 
 
 
 
 
 
 
 

CI Codacy Badge DepShield Badge

kTelnet

A Java library which implements an embeddable Telnet server. The server is fully multithreaded and supports numerous Telnet RFC's.

License

kTelnet is licensed under the BSD terms

Maven Coordinates

<groupId>com.khubla.ktelnet</groupId>
<artifactId>ktelnet</artifactId>
<packaging>jar</packaging>
<version>1.1</version>

Using kTelnet

A simple example using the default Telnet implementation:

   private final static int THREADS = 20;
   private final static int PORT = 2121;

   public static void main(String[] args) {
      try {
         /*
          * telnet
          */
         final TelnetServer telnetServer = new TelnetServer(PORT, THREADS, new BasicShellFactoryImpl());
         telnetServer.start();
         /*
          * wait
          */
         Thread.sleep(1000);
         System.out.println("Press any key to exit");
         System.in.read();
         /*
          * shutdown
          */
         telnetServer.shutdown();
      } catch (final Exception e) {
         e.printStackTrace();
         System.exit(0);
      }

Implemented RFC's

  • RFC 856 - Binary
  • RFC 857 - Echo
  • RFC 1091 - Termtype
  • RFC 1073 - Winsize
  • RFC 1079 - Termspeed

Login

Login is implemented by passing an implementation of AuthenticationHandler to the shell constructor. A simple properties file based implementation PropertiesFileAuthenticationHandlerImpl is provided.

Custom shells

Custom shells can be implemented by extending the classes ShellFactory, BasicTelnetCommandRegistryImpl and AbstractCommand. A very simple shell which implements the "quit" command is provided: BasicShellImpl

Logging

kTelnet supports logging at the byte level via NVTSpy. A console implementation ConsoleNVTSpyImpl and a log file implementation LoggingNVTSpyImpl are provided.