Documentation
¶
Overview ¶
Package whatsapp implements a noisecat transport that speaks WhatsApp's multi-device Noise wire protocol: a Noise_XX_25519_AESGCM_SHA256 handshake whose messages are wrapped in protobuf and framed with a one-time "WA" header plus 3-byte length prefixes.
It operates in two modes:
Real-backend mode (Dial with no address): connects over WebSocket to wss://web.whatsapp.com/ws/chat and verifies the server certificate chain against WhatsApp's pinned root key. This proves protocol-level interoperability with the live backend but does NOT log in (the ClientFinish payload is sent empty; real login needs account credentials / QR pairing and the Signal app protocol, out of scope).
Peer-to-peer mode (Dial with an address, or Listen): two noisecat instances speak the same WhatsApp framing to each other over plain TCP, exactly like the raw/noisesocket/bolt8 transports. No certificate is exchanged or verified. This is what enables, e.g., a bind shell: `noisecat -transport whatsapp -l -p 4444 -e /bin/sh`.
Index ¶
- Variables
- type Conn
- func (c *Conn) Close() error
- func (c *Conn) CloseWrite() error
- func (c *Conn) LocalAddr() net.Addr
- func (c *Conn) PeerStaticKey() []byte
- func (c *Conn) Read(p []byte) (int, error)
- func (c *Conn) RemoteAddr() net.Addr
- func (c *Conn) SetDeadline(t time.Time) error
- func (c *Conn) SetReadDeadline(t time.Time) error
- func (c *Conn) SetWriteDeadline(t time.Time) error
- func (c *Conn) Write(p []byte) (int, error)
- type Transport
Constants ¶
This section is empty.
Variables ¶
var WACertPubKey = [32]byte{
0x14, 0x23, 0x75, 0x57, 0x4d, 0x0a, 0x58, 0x71, 0x66, 0xaa, 0xe7, 0x1e, 0xbe, 0x51, 0x64, 0x37,
0xc4, 0xa2, 0x8b, 0x73, 0xe3, 0x69, 0x5c, 0x6c, 0xe1, 0xf7, 0xf9, 0x54, 0x5d, 0xa8, 0xee, 0x6b,
}
WACertPubKey is WhatsApp's pinned Noise-certificate root public key (a 32-byte Curve25519/Montgomery key), copied verbatim from whatsmeow's handshake.go. It is the trust anchor for the server certificate chain.
Functions ¶
This section is empty.
Types ¶
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
Conn is a WhatsApp Noise transport connection (net.Conn). After the handshake completes, each application message is AES-256-GCM encrypted under the derived write key with an incrementing big-endian counter nonce and wrapped in a 3-byte length frame (no protobuf), mirroring whatsmeow's NoiseSocket.
func (*Conn) CloseWrite ¶
CloseWrite forwards a half-close if the underlying conn supports it (peer-to-peer TCP), or falls back to a full Close otherwise (e.g. the websocket-backed real-backend connection), matching the other transports.
func (*Conn) PeerStaticKey ¶
PeerStaticKey returns the remote peer's Noise static public key. For a real-WhatsApp connection this is the server static bound to the verified certificate; for a peer-to-peer connection it is the other noisecat's key. It is nil until the handshake has run (i.e. until the first Read/Write on a freshly accepted connection).
func (*Conn) RemoteAddr ¶
type Transport ¶
type Transport struct {
// contains filtered or unexported fields
}
Transport implements transport.Transport for WhatsApp.
func New ¶
func New() *Transport
New returns a Transport ready to dial the live WhatsApp backend or peer with another noisecat instance.
func (*Transport) Dial ¶
func (t *Transport) Dial(network, addr, localAddr string, cfg *noise.Config, opts transport.Options) (net.Conn, error)
Dial connects either to the real WhatsApp backend (when addr has no host — the endpoint is the fixed wss URL, and the server certificate is verified) or, when addr names a host:port, to another noisecat over plain TCP (peer-to-peer, no certificate).
func (*Transport) Listen ¶
func (t *Transport) Listen(network, laddr string, cfg *noise.Config, opts transport.Options) (net.Listener, error)
Listen binds a TCP listener whose accepted connections run the WhatsApp p2p handshake as the responder. (You cannot impersonate WhatsApp's real servers, so this is noisecat-to-noisecat only.)