toxyl / ossh

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

Added OverlayFS creation per source IP #15

Closed dylandreimerink closed 2 years ago

dylandreimerink commented 2 years ago

This PR closed #4

This commit adds overlay file system support to ossh. The overlayFS will provide isolated, persistant, on-disk file storage. Actual working file storage is important since uploading/downloading files is a common operation when trying to exploit servers over SSH.

OverlayFS has a base directory within the datadir called 'ffs'. Which contains the 'defaultfs' dir which is always the lower most layer and the default file system until it is changed by a ssh client. The 'sandboxes' dir contains all the individual sandboxes, which currently are isolated by source IP(this is subject to change in the future). This means that each source IP will see the same files across multiple ssh sessions. Each session is tracked based on the unix time stamp it was created. Each session has its own layer so changes in that session can be viewed.

While the session is active, a merged-{timestamp} and work-{timestam} directory exist within the sandbox directory. The merged dir is where the merged overlay is mounted and it is the actual FS where the session can read from and write to. The workdir is just an artifact of how the overlay FS works. Both are deleted as soon as the session is done and the FS unmounted.

In theory it is possible that multiple sessions interact with the same sandbox at the same time. Both should get a seperate merge and upper dir, but the first session will not see changes made by the second session since those changes are only present in the seconds upper dir. This is a compromise which seems fine for now.

The shell does not yet use the overlayFS this will be added in a later commit