./redteamer

Functions

String Functions

Functions for the creation and manipulation of strings.


Formatting and Case Conversion

format

The format function generates a string by formatting values, akin to printf in C.

str::format("Exploit %s successful!", "CVE-2024-1234")
# Result: "Exploit CVE-2024-1234 successful!"

str::format("Detected %d open ports", 22)
# Result: "Detected 22 open ports"

format_list

The str::format_list function creates a list of formatted strings.

str::format_list("Vulnerability: %s", ["CVE-2024-1234", "CVE-2024-5678"])
# Result: ["Vulnerability: CVE-2024-1234", "Vulnerability: CVE-2024-5678"]

str::format_list("%s attack detected", ["SQL Injection", "XSS"])
# Result: ["SQL Injection attack detected", "XSS attack detected"]

lower

The str::lower function converts all letters in a string to lowercase.

str::lower("HTTP POST REQUEST")
# Result: "http post request"

str::lower("WARNING!")
# Result: "warning!"

title

The title function capitalizes the first letter of each word.

str::title("cross site scripting")
# Result: "Cross Site Scripting"

upper

The str::upper function converts all letters in a string to uppercase.

str::upper("vulnerability")
# Result: "VULNERABILITY"

str::upper("payload")
# Result: "PAYLOAD"

Trimming and Indentation

chomp

The str::chomp function removes newline characters from the end of a string.

str::chomp("response received\n")
# Result: "response received"

str::chomp("data collected\r\n")
# Result: "data collected"

indent

The str::indent function adds spaces to the start of lines in a multi-line string.

str::indent(4, "\nPOST /login HTTP/1.1\nHost: target.com\n")
# Result:
#     POST /login HTTP/1.1
#     Host: target.com

trim

The str::trim function removes specified characters from the start and end of a string.

str::trim("**alert**", "*")
# Result: "alert"

str::trim("  exploit detected  ", " ")
# Result: "exploit detected"

trim_prefix

The str::trim_prefix function removes a prefix from a string.

str::trim_prefix("https://example.com", "https://")
# Result: "example.com"

trim_suffix

The str::trim_suffix function removes a suffix from a string.

str::trim_suffix("report.docx", ".docx")
# Result: "report"

trim_space

The str::trim_space function removes spaces from the start and end of a string.

str::trim_space("  security risks found  ")
# Result: "security risks found"

Search and Query

ends_with

The str::ends_with function checks if a string ends with a suffix.

str::ends_with("audit.log", ".log")
# Result: true

str::ends_with("summary.txt", ".pdf")
# Result: false

starts_with

The str::starts_with function checks if a string starts with a prefix.

str::starts_with("https://secure.com", "https")
# Result: true

str::starts_with("ftp://files.com", "https")
# Result: false

contains

The str::contains function checks if a substring exists within a string.

str::contains("vulnerability assessment", "assessment")
# Result: true

str::contains("secure protocol", "vulnerable")
# Result: false

String Manipulation

join

The str::join function concatenates list elements with a separator.

str::join(", ", ["CVE-2024-1234", "CVE-2024-5678"])
# Result: "CVE-2024-1234, CVE-2024-5678"

split

The str::split function divides a string at each separator occurrence.

str::split("&", "param1=value1&param2=value2")
# Result: ["param1=value1", "param2=value2"]

reverse

The str::reverse function reverses the order of characters in a string.

str::reverse("malware")
# Result: "erawlam"

extract

The str::extract function extracts a substring based on offset and length.

str::extract("vulnerability", 2, 7)
# Result: "lnerab"

replace

The str::replace function replaces a substring with another string.

str::replace("GET /index.html", "index.html", "dashboard.html")
# Result: "GET /dashboard.html"

str::replace("alert('XSS')", "/XSS/", "SQLi")
# Result: "alert('SQLi')"
Previous
Special Functions