劫持客户端连接

huangapple go评论92阅读模式
英文:

Go hijack client connection

问题

Go语言的HTTP连接劫持。

我知道如何在服务器端进行劫持。
http://golang.org/pkg/net/http/#example_Hijacker

但是在客户端有没有劫持的方法?

英文:

Go language http connection hijacking.

I know how to hijack on server side.
http://golang.org/pkg/net/http/#example_Hijacker

But is there way to hijack it on clients side?

答案1

得分: 9

不,你不能使用默认的http.Client来实现这个,但是net/http/httputil包中有一个ClientConn,它是一个低级别的HTTP客户端,直接封装了一个net.Conn。它可以被劫持,并且可以操作标准的http.Request

http://golang.org/pkg/net/http/httputil/#ClientConn

另外,由于你控制着两端,并且不应该出现太多意外情况,你可以直接将请求自己直接写入TCP连接(或者使用Request.Write()方法来构建请求),这可能更容易一些。

英文:

No, you can't do this with the default http.Client, but net/http/httputil has a ClientConn, which is a low level http client that directly wraps a net.Conn. It's Hijack-able, and operates on standard http.Request's.

http://golang.org/pkg/net/http/httputil/#ClientConn

Also, since you control both sides, and you shouldn't see anything too unexpected, it may be easier to simply write the request yourself directly to the TCP connection (or use Request.Write() if you want to build the request that way)

huangapple
  • 本文由 发表于 2014年5月23日 00:22:31
  • 转载请务必保留本文链接:https://go.coder-hub.com/23812330.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定