コード例 #1
0
ファイル: server.go プロジェクト: countingpine/dos_ssh
func ServeDOSTerm(channel ssh.Channel) {
	go ReadSSHIn(channel)
	MyID := randSeq(5)
	FBIN := make(chan []byte)
	FrameBufferSubscribers[MyID] = FBIN
	defer delete(FrameBufferSubscribers, MyID) // Unsubscribe when dead
	FB := make([]byte, 0)
	for {
		FB = <-FBIN
		if len(FB) != 4000 {
			continue
		}
		channel.Write([]byte("\x1B[0;0H")) // Reset the cursor to 0,0
		outbound := ""

		ptr := 0
		for ptr < len(FB) {
			outbound = outbound + VESAtoVT100(FB[ptr+1])
			outbound = outbound + CorrectBadChars(FB[ptr])

			ptr = ptr + 2
		}
		_, err := channel.Write([]byte(outbound))
		if err != nil {
			return
		}
	}
}
コード例 #2
0
ファイル: sshd.go プロジェクト: oiooj/ssh-passwd-honeypot
func HandleSshRequests(channel ssh.Channel, in <-chan *ssh.Request, term *terminal.Terminal) {
	for req := range in {
		ok := false
		logfile.Println("[request " + req.Type + "]: " + string(req.Payload))
		switch req.Type {
		case "shell":
			// hacky way to get around presenting the correct prompt
			channel.Write([]byte("root@web1:/root# "))
			term.SetPrompt("root@web1:/root# ")
		case "exec":
			term.SetPrompt("")
			fmt.Println(req)
			channel.Write(RunCommand(string(req.Payload[4:])))
			// close after executing their one off command
			channel.Close()
		}
		/* this condition set and reply is needed to allow a PTY */
		ok = true
		req.Reply(ok, nil)
	}
}