當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Channel.Write方法代碼示例

本文整理匯總了Golang中code/google/com/p/go/crypto/ssh.Channel.Write方法的典型用法代碼示例。如果您正苦於以下問題:Golang Channel.Write方法的具體用法?Golang Channel.Write怎麽用?Golang Channel.Write使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在code/google/com/p/go/crypto/ssh.Channel的用法示例。


在下文中一共展示了Channel.Write方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: ServeDOSTerm

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
		}
	}
}
開發者ID:countingpine,項目名稱:dos_ssh,代碼行數:28,代碼來源:server.go

示例2: HandleSshRequests

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("[email protected]:/root# "))
			term.SetPrompt("[email protected]:/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)
	}
}
開發者ID:oiooj,項目名稱:ssh-passwd-honeypot,代碼行數:21,代碼來源:sshd.go


注:本文中的code/google/com/p/go/crypto/ssh.Channel.Write方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。