Documentation
¶
Overview ¶
Package sip is a very basic (and incomplete) implementation of SIP messaging protocol.
Based on the sipgo library, we are only adding some helpers useful in the context of exploitation. For example, we prefer to avoid the complexity of concepts like transactions or dialogs.
References: - https://github.com/emiago/sipgo - https://datatracker.ietf.org/doc/html/rfc3261 - https://datatracker.ietf.org/doc/html/rfc3311 - https://datatracker.ietf.org/doc/html/rfc3581 - https://datatracker.ietf.org/doc/html/rfc3265 - https://datatracker.ietf.org/doc/html/rfc7118
Index ¶
- Constants
- Variables
- func AddMethodHeaders(req *sip.Request, method sip.RequestMethod) bool
- func IsContactRequired(method sip.RequestMethod) bool
- func NewDefaultInviteBody(host, sessid, sessver string) string
- func NewDefaultNotifyBody(id, status, contact, ts string) string
- func NewDefaultPublishBody(id, status, entity string) string
- func NewRequestBody(method sip.RequestMethod) (string, string)
- func NewSipRequest(method sip.RequestMethod, host string, opts *NewSipRequestOpts) (*sip.Request, bool)
- func NewViaHeader(opts *NewViaOpts) (*sip.ViaHeader, bool)
- func ReadMessageTCP(conn net.Conn) (sip.Message, bool)
- func ReadMessageUDP(conn *net.UDPConn) (sip.Message, bool)
- func SendAndReceiveTCP(conn net.Conn, req sip.Message) (*sip.Response, bool)
- func SendAndReceiveUDP(conn *net.UDPConn, req sip.Message) (*sip.Response, bool)
- type NewSipRequestOpts
- type NewViaOpts
- type TransportType
Constants ¶
const ( // SIP over UDP message size should be lower than 1300 bytes. // https://datatracker.ietf.org/doc/html/rfc3261#section-18.1.1 UDPMessageLength = 1300 DefaultMaxForwards = 70 DefaultCSeq = 1 DefaultInviteContentType = "application/sdp" DefaultMessageContentType = "text/plain" DefaultMessageBodyContent = "Hello, this is a test message." DefaultInfoContentType = "application/dtmf-relay" DefaultInfoBodyContent = "Signal=1Signal=1\nDuration=100" DefaultExpiresHeader = 3600 DefaultRackCSeq = 1 DefaultRackInviteCSeq = 314159 ContentTypePidf = "application/pidf+xml" )
Variables ¶
var DefaultPorts = map[TransportType]int{ UDP: sip.DefaultUdpPort, TCP: sip.DefaultTcpPort, TLS: sip.DefaultTlsPort, WS: sip.DefaultWsPort, WSS: sip.DefaultWssPort, }
Default server ports for each transport protocol.
var GlobalUA string
GlobalUA is the default User-Agent for all SIP go-exploit comms.
Functions ¶
func AddMethodHeaders ¶
func AddMethodHeaders(req *sip.Request, method sip.RequestMethod) bool
Adds generic method-specific headers to a request.
INVITE and MESSAGE ones are handled in the function 'NewRequestBody'.
func IsContactRequired ¶
func IsContactRequired(method sip.RequestMethod) bool
Checks if contact header is required for a method.
func NewDefaultInviteBody ¶
Returns a default body for an INVITE request.
Default parameters: - host: "randomIPv4()". - sessid: random digits. - sessver: random digits.
func NewDefaultNotifyBody ¶
Returns a default body for a NOTIFY request.
Default parameters: - id: random letters. - status: "open". - contact: "sip:bob@randomIPv4():5060". - ts: current UTC time in RFC 3339 format.
func NewDefaultPublishBody ¶
Returns a default body for a PUBLISH request.
Default parameters: - id: random letters. - status: "open". - entity: "sip:bob@randomIPv4():5060".
func NewRequestBody ¶
func NewRequestBody(method sip.RequestMethod) (string, string)
Returns a valid body and content type header for the given method.
func NewSipRequest ¶
func NewSipRequest( method sip.RequestMethod, host string, opts *NewSipRequestOpts, ) (*sip.Request, bool)
Returns a generic well-formed request. Useful to start the communication.
Depending on the method (if not set in 'opts') required headers and body content is automatically added.
func NewViaHeader ¶
func NewViaHeader(opts *NewViaOpts) (*sip.ViaHeader, bool)
Returns a 'Via' header for a SIP request.
func ReadMessageTCP ¶
Returns a SIP message from a TCP connection.
func ReadMessageUDP ¶
Returns a SIP message from a UDP connection using the message length defined in the RFC 3261. https://datatracker.ietf.org/doc/html/rfc3261#section-18.1.1
func SendAndReceiveTCP ¶
Sends a TCP/TLS message and returns the response.
Types ¶
type NewSipRequestOpts ¶
type NewSipRequestOpts struct { // Default: 0. The host could be a domain name. Port int // Default: 'host' function parameter. LocalHost string // Default: 'Port' property. LocalPort int // Default: No user set in the request (Via and To headers). ToUser string // Default: No user set in the request (From header). User string // Default: No password set in the request (From header). Password string // Default: UDP. Transport TransportType }
Optional parameters to create a request.
type NewViaOpts ¶
type NewViaOpts struct { // Default: "SIP" ProtocolName string // Default: "2.0" ProtocolVersion string // Default: "UDP" Transport string // Default: "localhost" Host string // Default: 0 Port int }
Optional parameters to create a Via header.
type TransportType ¶
type TransportType int
Supported transport protocol.
const ( UNKNOWN TransportType = iota UDP TCP TLS WS WSS )
func (TransportType) String ¶
func (t TransportType) String() string
Directories
¶
Path | Synopsis |
---|---|
examples
|
|
call
command
This example registers an endpoint (user authentication) in a server and starts a call (only the SIP related part).
|
This example registers an endpoint (user authentication) in a server and starts a call (only the SIP related part). |
ping
command
This example checks if a UDP server is up.
|
This example checks if a UDP server is up. |
tcp
command
This example sends an OPTIONS request over TCP (or TLS).
|
This example sends an OPTIONS request over TCP (or TLS). |