⚡ Connection Runtime Service (CRS)
Connection Runtime Service (CRS) is an in-house network & transport engine based on Go (Golang) designed to replace dependency on external/third-party networking libraries (like requests, http_requests, socket, etc.)
By abstracting network communications into a CRS, The system gains full control over transport behavior, memory footprint, security boundaries, and performance optimization through Go's built-in concurrency model.
⚙️ Architectural Motivation
- Dependency Decoupling & Supply Chain Security: Reduces the risk of vulnerabilities and breaking changes from third-party libraries by isolating all I/O operations into one centralized engine.
- Performance & Low Latency: Leverages Go's execution speed and I/O model to minimize overhead when handling high-density communications.
- Connection Stability: Provides custom connection pooling management, retry mechanisms, and predictable timeout handling.
- Concurrency Management: Leverage native Goroutines to handle concurrent I/O tasks efficiently with controlled resource consumption.
📝 Technical Specifications
Tech Stack & Runtime
- Language: Go (Golang)
- Primary Paradigm: Asynchronous / Non-blocking via Goroutines
- Interface Boundary: Accessible via Wrapper & IPC Layer
Supported Protocols & Status
Currently CRS implements a subset of network protocols focused on the system's core requirements. Although the protocol coverage is still being developed, the existing implementation has been optimized (tuned) and passed validation testing on various production modules.
Note on Concurrency: Although Goroutines are widely used across engines, Some specific protocol handlers still use precise synchronous/sequential execution to avoid race conditions or out-of-order execution in stateful protocols.
📖 Information
Name: CRS Engine
Version: 1.0.0
Objective: Network library
Language: Golang
License: BSD 3-Clause License
Protocol (available)
Socket:
- Library: golang.org/x/sys/unix
- License: BSD 3-Clause License
Http:
- Library: github.com/projectdiscovery/rawhttp
- License: MIT License
- Library: github.com/projectdiscovery/retryablehttp-go
- License: Mozilla Public License, version 2.0
Dns:
- Library: github.com/miekg/dns
- License: BSD 3-Clause License
🛠️ Ways of working CRS
Modules: Just need to call the required API and send the data to CRS. The module does not need to know or implement any connection or communication mechanisms with the CRS.
API: Tasked with compiling data received from module before forwarding it to IPC. The wrapper also handles the response data received from IPC, then transforms it into a form that is easier for the module to use.
IPC: Responsible for managing communications between Storm and CRS. Upon receiving the first request, IPC will start the CRS process as a daemon if it is not already running. Next data is sent to CRS via stdin, while the response is received by listening to stdout.
CRS: It will read the data from stdin and perform certain execution then it will return the response to stdout. CRS Runs in a separate process from Storm and continues to listen to stdin as long as the process is active. When the Storm process is stopped, Storm send signal-15 to PID right CRS running, until a certain time if CRS is still active then Storm sends this signal-9 just before it exits completely.
💡 Protocol Parameters
All protocols definitely have different parameters, here you can learn what parameters the current protocols have.
🔌 Socket Parameters
Open Socket
sock = net.Socket()
sock.socket(family, type, proto)Parameter
- family: Address Family such as:
sock.AF_INET,sock.AF_INET6, etc. - type: Sock Type like:
sock.SOCK_STREAM,sock.SOCK_DGRAM, etc. - proto: Protocols such as:
sock.IPPROTO_IP, etc. | Optional Default 0
Connect to Socket
sock.connect(address)Parameter
- address: tuple (host, port).
Send Data
sock.send(data, flags)sock.sendall(data, flags)Parameter
- data: Can be bytes / http request / payload etc.
- flags: (Optional) | Default 0
Response
status: SUCCESS/WARN/ERROR/TIMEOUT.
message: Messages adjust to status.
ok: Return boolean from SUCCESS status. Allows the syntax: if resp.ok:
is_reused: Returns a Boolean. True=Using the same connection. False=Create a new connection.
rtt_ms: Returns the Round Trip Time in milliseconds.
checked_type: Returns the connection status to see if the tls/tcp connection is working. | Debug.
status_tls: Returns a Boolean. If True=TLS is enabled. False=TLS is disabled.
sock.sendto(data, address, flags)Parameter
- data: Can be bytes / http request / payload etc.
- address: tuple (host, port).
- flags: Optional Default 0.
Response
- status: SUCCESS/WARN/ERROR/TIMEOUT.
- message: Messages adjust to status.
- ok: Return boolean from SUCCESS status. Allows the syntax: if resp.ok:
- is_reused: Returns a Boolean. True=Using the same connection. False=Create a new connection.
- rtt_ms: Returns the Round Trip Time in milliseconds.
sock.sendfile(file)- file: Files in the form of video.mp4, foto.jpg, etc.
Viewing the buffer
sock.recv(buffer, flags)Parameter
- buffer: To determine how many bytes of buffer to take.
- flags: (Optional) | Default 0
Response
status: SUCCESS/WARN/ERROR/TIMEOUT.
message: Messages adjust to status.
ok: Return boolean from SUCCESS status. Allows the syntax: if raw.ok:
raw_bytes: Returning Raw Bytes.
str_bytes: Returns Raw Bytes as String.
hex_bytes: Returns Hex Bytes.
int_bytes: Returns the number of Bytes.
is_reused: Returns a Boolean. True=Using the same connection. False=Create a new connection.
rtt_ms: Returns the Round Trip Time in milliseconds.
checked_type: Returns the connection status to see if the tls/tcp connection is working. | Debug.
status_tls: Returns a Boolean. If True=TLS is active. False=TLS is disabled.
sock.recvfrom(buffer, flags)Parameter
- buffer: To determine how many bytes of buffer to take.
- flags: Optional | Default 0.
Response
status: SUCCESS/WARN/ERROR/TIMEOUT.
message: Messages adjust to status.
ok: Return boolean from SUCCESS status. Allows the syntax: if raw.ok:
raw_bytes: Returning Raw Bytes.
str_bytes: Returns Raw Bytes as String.
hex_bytes: Returns Hex Bytes.
int_bytes: Returns the number of Bytes.
remote_ip: Returns the target IP:PORT.
is_reused: Returns a Boolean. True=Using the same connection. False=Create a new connection.
rtt_ms: Returns the Round Trip Time in milliseconds.
TLS Upgrade
tls_obj, resp = sock.uptls(cert, key, ca, verify)Parameter
- cert: Path to the certificate file.
- key: Path to the Key certificate file.
- ca: Path to the CA certificate file.
- verify: Boolean. verify=True client certificate. False=Skip verification. | Default True.
tls_obj
- sendall
- send
- recv
- setsockopt
- getsockopt
- getsockname
- getpeername
- close
Response
status: SUCCESS/WARN/ERROR/TIMEOUT.
message: Messages adjust to status.
ok: Return boolean from SUCCESS status. Allows the syntax: if resp.ok:
raw_bytes: Returning Raw Bytes.
str_bytes: Returns Raw Bytes as UTF-8.
hex_bytes: Returns Hex Bytes.
int_bytes: Returns the number of Bytes.
is_reused: Returns a Boolean. True=Using the same connection. False=Create a new connection.
rtt_ms: Returns the Round Trip Time in milliseconds.
checked_type: Returns the connection status to see if the tls/tcp connection is working. | Debug.
status_tls: Returns a Boolean. True=TLS is enabled. False=TLS is disabled.
tls: Responses that inherit TLS information.
TLS Information
- version: Returns TLS Version 1.0/1.1/1.2/1.3.
- cipher: Returning Cipher Suite.
- protocol: Returns TLS protocols like h1/h2/h3.
- hostname: Returns Host like (example.com).
- handshake: Returns a Boolean. True=Handshake succeeded. False=Handshake failed.
- session_resume: Returns a Boolean. True=If the TLS session was resumed. False=If the handshake was complete.
- subject: Returns the (CN) of the server certificate.
- issuer: Returns the (CN) of the (CA) that issued the certificate. Examples: R13, ISRG Root X1, etc.
- dns_name: Returns a list of hostnames in the Subject Alternative Name (SAN) extension.
- expires: Returns the certificate Expiration Time in RFC3339 format.
- cert_chain: Returns the number of certificate chains that were successfully verified.
IMPORTANT
You can also use the Python SSL library with wrap_socket.
Bind
sock.bind(address)Parameter
- address: Tuple (host, port).
Listen
sock.listen(backlog)Parameter
- backlog: Maximum limit of inbound connection queue allowed to hang before
accept().
Accept
conn, resp = sock.accept()Conn: Returns a special object:
- sendall
- send
- recv
- sendto
- recvfrom
- setsockopt
- getsockopt
- getsockname
- getpeername
- fileno
- settimeout
- gettimeout
- close
Response: Client address format tuple[str, int].
Set Socket Options
sock.setsockopt(level, name, value)Parameter
- level: OptLevel such as:
sock.SOL_SOCKET, etc. - name: OptName such as:
sock.SO_REUSEADDR,sock.TCP_NODELAY, etc. - value: OptVal it is the value of a pointer to a Buffer Memory | int
Get Socket Options
sock.getsockopt(level, name)Response: This function directly returns an int.
Timeout
sock.settimeout(value)Description: The timeout function is created to set a default timeout for all functions executed after it, eliminating the need to apply timeouts repeatedly in each function. Default = 0 Bloking.
Value: The input must be in the form of a float or Int.
sock.gettimout()Description: Returns float or None.
Creating Connection
sock.create_connection(address, timeout)Description: This function is used to immediately open a connection quickly without having to perform socket() and connect() literacy because this is done automatically by the binary CRS. This makes it faster and requires less code. Send, receive, and uptls still require manual processing afterward.
Get Address Information
sock.getaddrinfo(address, service, family, type, proto, flags)Parameter
- address: Hostname such as: example.com, etc.
- service: Int (80, 8080, 443, etc.) or Str ("http", "https", etc.)
- family: Address Family such as:
sock.AF_INET,sock.AF_INET6, etc. - type: Sock Type like:
sock.SOCK_STREAM,sock.SOCK_DGRAM, etc. - proto: Protocols such as:
sock.IPPROTO_IP, etc. | Default 0 - flags: MSG_* such as:
sock.MSG_OOB,sock.MSG_MORE, etc. | Optional Default 0.
Response: This function can return IPv4 with the format: list[tuple[int, int, int, str, tuple[str, int]]] or IPv6 with the format: list[tuple[int, int, int, str, tuple[str, int, int, int]]] and the order is family, socktype, protocol, cannonname, sockaddr.
Get Name Info
sock.getnameinfo(address, flags)- address: You can use two host and port elements, or four host, port, flowinfo, and scopeid elements. We recommend using only two host and port elements for future compatibility.
Response: Returns a tuple[str, str] of (host, serv).
Get Socket Name
sock.getsockname()Response: Returns the local IP in the format tuple[str, int] (IP, Port).
Get Peer Name
sock.getpeername()Response: Returns the server IP in the format tuple[str, int] (IP, Port).
Fileno
sock.fileno()Description: This function returns the Python FD table number, and needs to be closed if it is called but not used. Can be closed with sock.close(sock.fileno()) this will automatically close the Golang and Python FDs.
Closing the connection
sock.close(fileno)Description: This is used to close the connection when it is finished or when an error occurs, so that the connection does not hang and to avoid OOM.
Argument: fileno It is optional to close the Python FD with os.close() running simultaneously with the Golang FD closure.
Taking over ownership of FD
sock.detach()Description: detach() returns the FD number of the Python table process and it also automatically closes the FD of the Golang table process. The detach object is also always called in SSLSocket in CPython.
Exception Socket
try:
...
except sock.SocketError:
except sock.ConnectionRefused:
except sock.RuntimeError:
except sock.Exception:
except sock.Timeout:
except sock.ValueError:
# Or use a single exception that covers everything.
except sock.SocketException:Description: This is used to stop the program script when the CRS throws an ERROR/CRITICAL. Capture the ERROR message using smflogd if necessary.
☎️ DNS
DNS Lookup
dns = net.DNSL()
dns.query(domain, type, proto)
dns.timeout(value)
dns.setlimit(ratelimit, frate)
resp = dns.run()Description: DNSL are stateless, and you get a response immediately after each run.
Parameter
- domain: example.com | str.
- type: DNS query type. Example: A, AAAA, TXT, etc. | Default A | str.
- proto: Can TCP/UDP | Default TCP.
- timeout: To limit the open connection time. | Default 5s
- ratelimit: Blocking requests if the token runs out. | Default 150/1s | int.
- frate: Fixed Rate Limit untuk upgrade (ratelimit) saat terkena WAF. | Default 10/1s | int
- con: Number of Goroutines for Concurrency, allows to run parallel connections. | int.
Response
status: ERROR/SUCCESS/TIMEOUT/WARNING.
message: Messages adjust to status.
ok: Returns a boolean of the SUCCESS status and RCODE is NOERROR (0). Allows the syntax: if resp.ok:
rcode: DNS Response Code (example: 0 = NOERROR, 3 = NXDOMAIN).
rcode_str: String representation of RCODE.
records: List of resolution results / answers from DNS server.
truncated: Indicator if the UDP payload is too large and is truncated (will trigger a retry via TCP).
authoritative: Indicator whether the response comes from the Authoritative Name Server directly.
Exception DNS
try:
...
except dns.DTrace:
except dns.Timeout:
except dns.NXDOMAIN:Description: This is used to stop the program script when the CRS throws an ERROR/CRITICAL. Capture the ERROR message using smflogd if necessary.
🖇️ HTTP Requests
Standard HTTP
http = net.HTTPR()
http.get(url, headers)
http.post(url, headers, body)
# http methods provided: get, post, put, patch, etc.Parameter
- url: https://example.com | str.
- header: Example: {"User-Agent": "Storm-Framework/3.0 (CRS Engine)"} | Dict.
- body: Can be empty, can also be filled. | Default empty | str.
Raw HTTP
http.rawhttp.get(url, headers)
http.rawhttp.post(url, headers, body)
# http methods provided: get, post, put, patch, etc.Description: Raw HTTP freely accepts custom or malformed headers or bodies.
Parameter
- url: https://example.com | str.
- header: Example: {"User-Agent": "Storm-Framework/3.0 (CRS Engine)"} | Dict.
- body: Can be empty, can also be filled. | Default empty | str or bytes.
HTTP Global Settings & Runing
http.setoptions(ca, retry, redirect, verify, tls)
http.timeout(value)
# Only runing returns a response
resp = http.run()Description: HTTP Requests are stateless, you can send them and get a response straight away.
Parameter
- redirect: To do a page redirect. | Default True. | Boolean.
- tls: To display TLS information in the Response. | Default False | Boolean.
- verify: True=Verifying client certificate. False=Skip verification. | Default True. | Boolean.
- retry: Performs Retryable http / Retry connection if failed. | Default 2. | int.
- timeout: To limit the open connection time. | Default 5s.
- ca: Can path, can raw pem string, can base64. | Default Empty | str.
Response
status: ERROR/SUCCESS/TIMEOUT/WARNING.
message: Messages adjust to status.
status_code: HTTP Status Code (Example: 200, 404, 500).
ok: Returns a boolean of the SUCCESS. Allows the syntax: if resp.ok
body: Returns the body string.
raw_bytes: Returns the response body in raw bytes.
headers: The original header dictionary from the response.
get_headers: Case-insensitive lookup for HTTP Headers. Example: resp.get_headers("content-type", "unknown") will find 'Content-Type'.
proto: HTTP Protocol (Example: HTTP/1.1, HTTP/2.0).
engine: The connection provider engine from CRS (Example: retryablehttp).
tls: Responses that inherit TLS information.
json: Parses the string body into a JSON dict/list. Returns None if the body is not a valid JSON format.
TLS Information
- version: Returns TLS Version 1.0/1.1/1.2/1.3.
- cipher: Returning Cipher Suite.
- protocol: Returns TLS protocols like h1/h2/h3.
- hostname: Returns Host like (example.com).
- handshake: Returns a Boolean. True=Handshake succeeded. False=Handshake failed.
- session_resume: Returns a Boolean. True=If the TLS session was resumed. False=If the handshake was complete.
- subject: Returns the (CN) of the server certificate.
- issuer: Returns the (CN) of the (CA) that issued the certificate. Examples: R13, ISRG Root X1, etc.
- dns_name: Returns a list of hostnames in the Subject Alternative Name (SAN) extension.
- expires: Returns the certificate Expiration Time in RFC3339 format.
- cert_chain: Certificate chain successfully verified against a trusted root CA.
Exception HTTPR
try:
...
except http.HttpError:
except http.Timeout:
except http.Exception:
except http.RuntimeError:
# Or use a single exception that covers everything.
except http.HttpException:Description: This is used to stop the program script when the CRS throws an ERROR/CRITICAL. Capture the ERROR message using smflogd if necessary.
🔌 Telnet
1. Open koneksi
def execute(options, net):
r = net.Telnet(host, port, timeout)Description: Telnet is stateful, you will get inherited functions.
Parameter
- host: This can be IP / Domain.
- port: This is a typical port.
- timeout: To limit the open connection time. | Default 10.0s.
Inheritance
You will get the legacy send and read functions.
2. Send Data
res, var = r.send(command, expected, timeout, raw)Parameter
- command: This can be filled with a wordlist file of username or password or a free command or bytes.
- expected: This can contain the desired response expectation variables.
- timeout: To limit the open connection time. | Default 0.3s.
- raw: This is a boolean if True: The first response is Bytes. If False: The first response is a UTF-8 decoded string. | Default False.
Response
- res: This will contain the raw bytes response.
- var: Can contain a variable number of expectation parameters. For example, there are two expectation variables, so the response variable is calculated as 0 and 1. If it is below 0 such as -1 or -2 etc. it is considered False or not found.
3. Read Response
res, var = r.read(expected, timeout, raw)Parameter
- expected: This can contain the desired response expectation variables.
- timeout: To limit the open connection time. | Default 0.3s.
- raw: This is a boolean if True: The first response is Bytes. If False: The first response is a UTF-8 decoded string. | Default False.
Response
- res: This will contain the raw bytes response.
- var: Can contain a variable number of expectation parameters. For example, there are two expectation variables, so the response variable is calculated as 0 and 1. If it is below 0 such as -1 or -2 etc. it is considered False or not found.
📡 Use of Response & Inheritance
1. Socket
Description: This socket implementation adheres to POSIX standards. While some functions may be implemented differently or bear different names, the core logic remains the same; furthermore, certain features or functions may be missing either because we intentionally chose not to implement them or simply because they have not yet been implemented.
Status:
StatefulInheritance
sock = net.Socket()
# Open Socket
sock.socket(family, type, proto)
# Get Python table FD
sock.fileno()
# Open connection to Socket
sock.connect(("127.0.0.1", 0))
sock.getsockname()
sock.getpeername()
sock.setsockopt(level, name, value)
sock.getsockopt(level, name)
# Send Data
sock.send(data, flags)
sock.sendto(data, ("127.0.0.1", 443), flags)
# Buffer Fetching
sock.recv(buffer, flags)
sock.recvfrom(buffer, flags)
# TLS Upgrade has legacy
sock.uptls(cert, key, ca, verify)
# Automatically be on a TLS encrypted connection. Except: sendto and recvfrom.
sock.send()
sock.recv()
# Closing Connection
sock.close()
# Timeout function
sock.settimeout(value)
sock.gettimeout() # Returns float or None
# Create a tcp stream connection
sock.create_connection((address))
# socket argument function
sock.AF_*
sock.SOCK_*
sock.IPPROTO_*sock = net.Socket()
resp = sock.getaddrinfo(...)
# The response from getaddrinfo returns a `list[tuple]` with 5 elements
# that is: [0]family, [1]socktype, [2]protocol, [3]canonname, [4]sockaddr- Response
# send data
r = sock.send(data, timeout)
smf.printf(r.status, r.message)
smf.printf(r.isreused, r.rtt_ms, etc.)
# read buffer
r = sock.recv(buffer)
smf.printf(r.status, r.message)
smf.printf(r.raw_bytes, r.hex_bytes, etc.)
# TLS Upgrade
r = sock.uptls(cert, key, ca, verify)
smf.printf(r.status, r.message)
smf.printf(r.tls.version, r.tls.cipher, etc.)2. DNS Lookup
- Status:
Stateless - Response
dns = net.DNSL()
dns.timeout(0.2) # Set Timeout
resp = dns.run() # Runing DNS and return response
# Show response
smf.printf(resp.status, resp.message)
smf.printf(resp.rcode, resp.records, etc.)
# Boolean SUCCESS
if resp.ok:3. HTTP Requests
- Status:
Stateless - Response
path_ca = "/path/path/ca.pem"
http = net.HTTPR(...)
http.setoptions(path_ca, 2, true, true, true) # Set CA, retry, redirect, verify tls, tls response
http.timeout(5.0)
http.get()
http.rawhttp.post()
resp = http.run() # Runing HTTP and return response
# Show response
smf.printf(resp.status, resp.message)
smf.printf(resp.status_code, resp.tls.cipher, etc.)
smf.printf(resp.get_headers("server", "unknown"))
# Boolean SUCCESS
if resp.ok:4. Telnet
- Status:
Stateful - Inheritance
# Open Connection
r = net.Telnet(...)
# Viewing the response
raw, var = r.read(...)
smf.printf(raw) # Return raw bytes response.
smf.printf(var) # Return Amount expected.
# Sending data
raw, var = r.send(...)
smf.printf(raw) # Return raw bytes response.
smf.printf(var) # Return Amount expected.
if var < 0: # -1 = Beyond expected.
if var >= 0: # 0+ = As expected.