Coder Social home page Coder Social logo

ktelnet's Introduction

CI Codacy 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></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

Telnet options are enumerated here

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.

ktelnet's People

Contributors

dannykurniawan80 avatar dependabot[bot] avatar personalsoft-fabianobonin avatar teverett avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

ktelnet's Issues

Pushed artifact jar contains dependencies

The Maven build seems to be configured to create and publish fat jar which includes classes from all dependencies (logback, apache.commons.cli, slf4j). Flat jar is handy when running the Telnet server directly from the jar as no extra dependencies needs to be added to classpath. However, it causes problems when using the Telnet server as a library. Can we publish a jar with compiled classes only?

ServerSocket.accept() may block indefinitely

In TelnetServer, row 67. And there is a possibility that even if to set running variable to false, server may not respond until the next incoming socket is accepted. So my suggestion is to add a ServerSocket.close() in shutdown method.

Bug in NVT.java on backspace

Hi,

NVT.java, line 341.

  String str = baos.toString(charsetUTF8.name());
  baos = new ByteArrayOutputStream();
  str = str.substring(0, str.length() - 1);
  if (str.length() > 0) {
     baos.write(str.getBytes(), 0, str.length());
  }
  // echo the BS/DEL back
  if (isEcho()) {
     write(b);
  }

If we call nvt.readln() and the first key pressed is a KEY_BS or KEY_DEL, "str" will contain an empty String and str.substring(0, str.length() - 1) will evaluate to str.substring(0, -1), which will throw an exception.

A simple check would avoid this:

  String str = baos.toString(charsetUTF8.name());
  if (str.length() > 0) {
    baos = new ByteArrayOutputStream();
    str = str.substring(0, str.length() - 1);
    if (str.length() > 0) {
       baos.write(str.getBytes(), 0, str.length());
    }
    // echo the BS/DEL back
    if (isEcho()) {
       write(b);
    }
  }

Don't know if this project is active, but I can create a PR if needed.

Regards,

Fabiano

[DepShield] Vulnerability due to usage of ch.qos.logback:logback-classic:1.1.5

DepShield reports that this application's usage of ch.qos.logback:logback-classic:1.1.5 results in the following vulnerability(s):

This is an automated GitHub Issue created by Sonatype DepShield. Details on managing GitHub Apps, including DepShield, are available for personal and organization accounts. Please submit questions or feedback about DepShield to the Sonatype DepShield Community.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.