Implement Phase 1.4: replaces the hardcoded banner/timeout stub with a proper shell system. Adds a Shell interface with weighted registry for shell selection, a RecordingChannel wrapper (pass-through for now, prep for Phase 2.3 replay), and a bash-like shell with fake filesystem, terminal line reader, and command handling (pwd, ls, cd, cat, whoami, hostname, id, uname, exit). Sessions now log command/output pairs to the store and record the shell name. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
34 lines
815 B
Go
34 lines
815 B
Go
package shell
|
|
|
|
import (
|
|
"context"
|
|
"io"
|
|
|
|
"git.t-juice.club/torjus/oubliette/internal/storage"
|
|
)
|
|
|
|
// Shell is the interface that all honeypot shell implementations must satisfy.
|
|
type Shell interface {
|
|
Name() string
|
|
Description() string
|
|
Handle(ctx context.Context, sess *SessionContext, rw io.ReadWriteCloser) error
|
|
}
|
|
|
|
// SessionContext carries metadata about the current SSH session.
|
|
type SessionContext struct {
|
|
SessionID string
|
|
Username string
|
|
RemoteAddr string
|
|
ClientVersion string
|
|
Store storage.Store
|
|
ShellConfig map[string]any
|
|
CommonConfig ShellCommonConfig
|
|
}
|
|
|
|
// ShellCommonConfig holds settings shared across all shell types.
|
|
type ShellCommonConfig struct {
|
|
Hostname string
|
|
Banner string
|
|
FakeUser string // override username in prompt; empty = use authenticated user
|
|
}
|