toxyl / ossh

... is a dirty mix of honey and tar, delivered by a fake SSH server.
Other
2 stars 1 forks source link

Script execution support #6

Closed dylandreimerink closed 1 year ago

dylandreimerink commented 2 years ago

It would be nice if we could support script execution, bash / sh scripts are a common way to automate something, simply upload a script via SCP or download it via wget/curl and execute it.

This is easier said than done, first step is to recognize when we call scripts. We should consider that a client is attempting to call a file on the FS like ./somescript.sh or via bash somescript.sh. In the first case we have to check for the shebang line #!/bin/bash or #!/bin/sh. We don't have to do this if the script is envoked directly by the bash command.

Bash/sh scripts must be parsed and evaluated since it can contain commands(cat somefile), builtins(echo or alias) and even logic like for and if statements. Support for these features will likely be added gradually, but having some rudimentary support would be handy.

toxyl commented 2 years ago

Maybe we can use https://github.com/mvdan/sh as a starting point for the implementation