Skip to main content

SSH in Java

Apache Mina SSHD

https://github.com/apache/mina-sshd/blob/master/docs/server-setup.md

Idea:

  • The server allows connection to known users (first iteration: txt file?)
  • The server basically is just a connection to the console
  • Run in a docker container for security

Console & Cartridge design

  • Console handles:
    • input (keys and maybe mouse?)
    • output (how?)
      • set at 80x24, smaller not supported, larger ignored
    • a user can select and configure cartridges
      • add rebinding as an option, which is a literal map of the keys
      • each user has a max of 3 save files? per game, if the game supports saving
  • Cartridge handles:
    • loop logic (in what language? just some java class files?)

Technical:

  • Potentially dynamically attach java agents to inject cartridge logic?
  • Alt: run a new java process
    • to avoid a zombie, call a health endpoint every x ms, and if it does not respond, kill it?

Java Dynamic Execution

  • Baeldung example: https://www.baeldung.com/java-string-compile-execute-code
  • Security considerations: https://stackoverflow.com/questions/10236307/restricting-java-compiler-api

Random

123456789012345678901234 6789012345678901234567890123456789012345678901234567890 
2                                                                                
3                      |                                                       | 
4                                                                                
5                      |                                                       | 
6                                                                                
7                      |                                                       | 
8                                                                                
9                      |                                                       | 
0                                                                                
1                      |                                                       | 
2                                                                                
3                      |                                                       | 
4                                                                                
5                      |                                                       | 
6                                                                                
7                      |                                                       | 
8                                                                                
9                      |                                                       | 
0                                                                                
1                      |                                                       | 
2                                                                                
3                      |                                                       | 
4 - - - - - - - - - - -/- - - - - - - - - - - - - - - - - - - - - - - - - - - -/ 

┌──────────────────────┬───────────────────────────────────────────────────────┐ 
│                      │                                                       │ 
│                      │                                                       │ 
│                      │                                                       │ 
│                      │                                                       │ 
│                      │                                                       │ 
│                      │                                                       │ 
│                      │                                                       │ 
│                      │                                                       │ 
│                      │                                                       │ 
│                      │                                                       │ 
│                      │                                                       │ 
│                      │                                                       │ 
│                      │                                                       │ 
│                      │                                                       │ 
│                      │                                                       │ 
│                      │                                                       │ 
│                      │                                                       │ 
│                      │                                                       │ 
│                      │                                                       │ 
│                      │                                                       │ 
│                      │                                                       │ 
│                      │                                                       │ 
└──────────────────────┴───────────────────────────────────────────────────────┘