-
public class HttpHeadersThe `HttpHeaders` class provides utility methods for generating various HTTP headers used in SIP signaling and communication. This class includes methods for generating random HTTP methods, user agents, page names, connection types, language types, authorization strings, and both long and short HTTP headers. It also provides methods for generating empty headers and custom "CONNECT" headers for signaling. The headers generated by this class are used to simulate realistic HTTP traffic and to obfuscate the true nature of SIP signaling in certain scenarios.
-
-
Method Summary
Modifier and Type Method Description static StringgetHeaders()Randomly selects and returns an HTTP method from a predefined list.The method currently supports "GET" and "POST". static StringgetUserAgent()Returns a random user agent string from a predefined list.This method is used to simulate different web browsers when making HTTP requests.It randomly selects a user agent string from an array of common user agents. static StringgetPageName()Retrieves a random page name from a predefined list of web page paths.This method simulates fetching a random web page request by selecting a randomelement from an array of page paths. static StringgetConnectionType()Randomly selects a connection type from a predefined list.This method returns either "Keep-Alive" or "Upgrade" as the connection type,chosen randomly using a pseudorandom number generator. static StringgetLanguageType()Retrieves a random language type from a predefined list.This method returns a randomly selected language type from an arraycontaining "en-us", "en-uk", "en-US", "en", "fr", "sp", and "gr".The selection is based on a pseudo-random number generated usingthe `SIPProvider.rand` Random object. static StringgetAuthoRization()Generates a random authorization string.This method creates a random string of characters using a predefined alphabet.The length of the string is between 15 and 26 characters (inclusive). static Array<byte>getLongHeaders()Constructs and returns the long-form HTTP headers as a byte array.This method assembles the HTTP headers required for the request, including:- Common headers obtained from `getHeaders()`- Page name- User agent- Accept language- Authorization- Connection typeThe headers are formatted according to the HTTP protocol and then convertedinto a byte array for transmission. static Array<byte>getShortHeaders()Generates a random short HTTP header.This method selects a random header from a predefined list of short HTTP headers.The selection is randomized using a secure random number generator.Note: Currently, only the "HTTP/1.1 301 Moved Permanently" header is included in the list.The commented-out headers were potentially used in previous versions but are not activein the current implementation. static Array<byte>getShortHeadersFromList()Retrieves a short HTTP header from a predefined list.This method returns a byte array representation of a randomly selected HTTP headerfrom a list of short headers. static Array<byte>getShortHeadersForSignalling()Retrieves the short headers used for signaling.This method first checks if the provisioning information contains a custom header length.If the header length is greater than 0, it returns the custom header defined in the provisioning information.Otherwise, it falls back to retrieving the short headers from a predefined list. static Array<byte>getEmptyHeader()Returns an empty header as a byte array.This method is typically used when a header is not required orwhen an empty header needs to be explicitly specified. static Array<byte>getRandomConnectHeaderForSignalling()Generates a random "CONNECT" header for signaling purposes.This method creates a "CONNECT" header with a random path.The path is generated using lowercase letters and its length is determined bythe `headerLength` specified in the provisioning information.If the randomly generated path is shorter than the specified `headerLength`,it is padded with additional random lowercase letters.This header is typically used in the initial signaling phase of a SIP connectionto obfuscate the true destination and potentially bypass firewalls or other network restrictions. -
-
Method Detail
-
getHeaders
static String getHeaders()
Randomly selects and returns an HTTP method from a predefined list.The method currently supports "GET" and "POST". Other methodslike "HEAD", "PUT", "DELETE", "TRACE", "OPTIONS", "CONNECT", "PATCH"are commented out and can be included if needed.
-
getUserAgent
static String getUserAgent()
Returns a random user agent string from a predefined list.This method is used to simulate different web browsers when making HTTP requests.It randomly selects a user agent string from an array of common user agents.
-
getPageName
static String getPageName()
Retrieves a random page name from a predefined list of web page paths.This method simulates fetching a random web page request by selecting a randomelement from an array of page paths. The page paths include various fileextensions and directory structures.
-
getConnectionType
static String getConnectionType()
Randomly selects a connection type from a predefined list.This method returns either "Keep-Alive" or "Upgrade" as the connection type,chosen randomly using a pseudorandom number generator.
-
getLanguageType
static String getLanguageType()
Retrieves a random language type from a predefined list.This method returns a randomly selected language type from an arraycontaining "en-us", "en-uk", "en-US", "en", "fr", "sp", and "gr".The selection is based on a pseudo-random number generated usingthe `SIPProvider.rand` Random object.
-
getAuthoRization
static String getAuthoRization()
Generates a random authorization string.This method creates a random string of characters using a predefined alphabet.The length of the string is between 15 and 26 characters (inclusive).
-
getLongHeaders
static Array<byte> getLongHeaders()
Constructs and returns the long-form HTTP headers as a byte array.This method assembles the HTTP headers required for the request, including:- Common headers obtained from `getHeaders()`- Page name- User agent- Accept language- Authorization- Connection typeThe headers are formatted according to the HTTP protocol and then convertedinto a byte array for transmission.
-
getShortHeaders
static Array<byte> getShortHeaders()
Generates a random short HTTP header.This method selects a random header from a predefined list of short HTTP headers.The selection is randomized using a secure random number generator.Note: Currently, only the "HTTP/1.1 301 Moved Permanently" header is included in the list.The commented-out headers were potentially used in previous versions but are not activein the current implementation.
-
getShortHeadersFromList
static Array<byte> getShortHeadersFromList()
Retrieves a short HTTP header from a predefined list.This method returns a byte array representation of a randomly selected HTTP headerfrom a list of short headers. The selection is based on a modulo operation usingthe `SIPProvider.headerIndex` value, ensuring a cyclical selection through the list.The list includes a variety of standard and non-standard HTTP status codes and theircorresponding reason phrases, covering common response categories like informational,success, redirection, client error, and server error.Note: Some commonly used headers like "HTTP/1.1 200 OK" and "HTTP/1.1 301 Moved Permanently"are commented out in the list and are not currently included in the selection.
-
getShortHeadersForSignalling
static Array<byte> getShortHeadersForSignalling()
Retrieves the short headers used for signaling.This method first checks if the provisioning information contains a custom header length.If the header length is greater than 0, it returns the custom header defined in the provisioning information.Otherwise, it falls back to retrieving the short headers from a predefined list.
-
getEmptyHeader
static Array<byte> getEmptyHeader()
Returns an empty header as a byte array.This method is typically used when a header is not required orwhen an empty header needs to be explicitly specified.
-
getRandomConnectHeaderForSignalling
static Array<byte> getRandomConnectHeaderForSignalling()
Generates a random "CONNECT" header for signaling purposes.This method creates a "CONNECT" header with a random path.The path is generated using lowercase letters and its length is determined bythe `headerLength` specified in the provisioning information.If the randomly generated path is shorter than the specified `headerLength`,it is padded with additional random lowercase letters.This header is typically used in the initial signaling phase of a SIP connectionto obfuscate the true destination and potentially bypass firewalls or other network restrictions.
-
-
-
-