Compare commits

...
Author SHA1 Message Date
Ice3man ae98eabe2e misc changes 2026-02-05 21:01:26 +05:30
Ice3man 7dc042b933 misc 2026-01-25 23:47:07 +05:30
Ice3man 9b3f2335d3 feat(js): add comprehensive utils library and enhance net connection methods
Add new nuclei/utils JavaScript library with utility functions for:
- Binary manipulation and cyclic pattern generation (pwntools-style)
- Struct packing/unpacking with P8/P16/P32/P64 aliases
- Encoding (Base64, Hex, URL, HTML, UTF-16)
- Hashing (MD4, MD5, SHA1/256/384/512, HMAC, CRC32)
- Cryptography (AES-ECB/CBC/GCM, DES, 3DES, RC4, XOR)
- Compression (zlib, gzip, deflate)
- Padding (PKCS7, zero padding)
- Time utilities (Sleep, Unix timestamps)

Enhance nuclei/net library with:
- SendBytes, SendLine for improved sending
- RecvUntil, RecvLine, RecvN for flexible receiving

Includes comprehensive unit tests and updated TypeScript definitions.
2026-01-25 21:30:15 +05:30
36 changed files with 5092 additions and 427 deletions

No files matched your search

+1
View File
@@ -31,6 +31,7 @@ import (
_ "github.com/projectdiscovery/nuclei/v3/pkg/js/generated/go/libssh"
_ "github.com/projectdiscovery/nuclei/v3/pkg/js/generated/go/libstructs"
_ "github.com/projectdiscovery/nuclei/v3/pkg/js/generated/go/libtelnet"
_ "github.com/projectdiscovery/nuclei/v3/pkg/js/generated/go/libutils"
_ "github.com/projectdiscovery/nuclei/v3/pkg/js/generated/go/libvnc"
"github.com/projectdiscovery/nuclei/v3/pkg/js/global"
"github.com/projectdiscovery/nuclei/v3/pkg/js/gojs"
+5 -1
View File
@@ -105,7 +105,11 @@ func CreateTemplateData(directory string, packagePrefix string) (*TemplateData,
fmt.Println(directory)
fset := token.NewFileSet()
pkgs, err := parser.ParseDir(fset, directory, nil, parser.ParseComments)
// Filter out test files (_test.go) which shouldn't be included in bindings
filter := func(fi os.FileInfo) bool {
return !strings.HasSuffix(fi.Name(), "_test.go")
}
pkgs, err := parser.ParseDir(fset, directory, filter, parser.ParseComments)
if err != nil {
return nil, errors.Wrap(err, "could not parse directory")
}
+3 -1
View File
@@ -34,9 +34,11 @@ func (p *EntityParser) scrapeAndCreate(typeName string) error {
return errkit.Newf("%v is not a type name", typeName)
}
// Ensure the type is a named struct type
// Skip interfaces (like net.Conn) - they can't be scraped for fields
namedStruct, ok := typeNameObj.Type().Underlying().(*types.Struct)
if !ok {
return fmt.Errorf("%s is not a named struct type", typeName)
// Not a struct (could be interface, etc.) - skip silently
return nil
}
// fmt.Printf("got named struct %v\n", namedStruct)
// Iterate over the struct fields
+12 -3
View File
@@ -20,11 +20,20 @@ func init() {
"IsRDP": lib_rdp.IsRDP,
// Var and consts
"EncryptionLevelFIPS140_1": lib_rdp.EncryptionLevelFIPS140_1,
"EncryptionLevelRC4_128bit": lib_rdp.EncryptionLevelRC4_128bit,
"EncryptionLevelRC4_40bit": lib_rdp.EncryptionLevelRC4_40bit,
"EncryptionLevelRC4_56bit": lib_rdp.EncryptionLevelRC4_56bit,
"SecurityLayerCredSSP": lib_rdp.SecurityLayerCredSSP,
"SecurityLayerCredSSPWithEarlyUserAuth": lib_rdp.SecurityLayerCredSSPWithEarlyUserAuth,
"SecurityLayerNativeRDP": lib_rdp.SecurityLayerNativeRDP,
"SecurityLayerRDSTLS": lib_rdp.SecurityLayerRDSTLS,
"SecurityLayerSSL": lib_rdp.SecurityLayerSSL,
// Objects / Classes
"CheckRDPAuthResponse": gojs.GetClassConstructor[lib_rdp.CheckRDPAuthResponse](&lib_rdp.CheckRDPAuthResponse{}),
"CheckRDPEncryptionResponse": gojs.GetClassConstructor[lib_rdp.RDPEncryptionResponse](&lib_rdp.RDPEncryptionResponse{}),
"IsRDPResponse": gojs.GetClassConstructor[lib_rdp.IsRDPResponse](&lib_rdp.IsRDPResponse{}),
"CheckRDPAuthResponse": gojs.GetClassConstructor[lib_rdp.CheckRDPAuthResponse](&lib_rdp.CheckRDPAuthResponse{}),
"IsRDPResponse": gojs.GetClassConstructor[lib_rdp.IsRDPResponse](&lib_rdp.IsRDPResponse{}),
"RDPEncryptionResponse": gojs.GetClassConstructor[lib_rdp.RDPEncryptionResponse](&lib_rdp.RDPEncryptionResponse{}),
},
).Register()
}
+3 -2
View File
@@ -20,8 +20,9 @@ func init() {
// Var and consts
// Objects / Classes
"IsRsyncResponse": gojs.GetClassConstructor[lib_rsync.IsRsyncResponse](&lib_rsync.IsRsyncResponse{}),
"RsyncClient": gojs.GetClassConstructor[lib_rsync.RsyncClient](&lib_rsync.RsyncClient{}),
"IsRsyncResponse": gojs.GetClassConstructor[lib_rsync.IsRsyncResponse](&lib_rsync.IsRsyncResponse{}),
"RsyncClient": gojs.GetClassConstructor[lib_rsync.RsyncClient](&lib_rsync.RsyncClient{}),
"RsyncListResponse": gojs.GetClassConstructor[lib_rsync.RsyncListResponse](&lib_rsync.RsyncListResponse{}),
},
).Register()
}
+13 -3
View File
@@ -2,7 +2,6 @@ package telnet
import (
lib_telnet "github.com/projectdiscovery/nuclei/v3/pkg/js/libs/telnet"
telnetmini "github.com/projectdiscovery/nuclei/v3/pkg/utils/telnetmini"
"github.com/Mzack9999/goja"
"github.com/projectdiscovery/nuclei/v3/pkg/js/gojs"
@@ -19,12 +18,23 @@ func init() {
"IsTelnet": lib_telnet.IsTelnet,
// Var and consts
"DO": lib_telnet.DO,
"DONT": lib_telnet.DONT,
"ECHO": lib_telnet.ECHO,
"ENCRYPT": lib_telnet.ENCRYPT,
"IAC": lib_telnet.IAC,
"NAWS": lib_telnet.NAWS,
"SB": lib_telnet.SB,
"SE": lib_telnet.SE,
"SUPPRESS_GO_AHEAD": lib_telnet.SUPPRESS_GO_AHEAD,
"TERMINAL_TYPE": lib_telnet.TERMINAL_TYPE,
"WILL": lib_telnet.WILL,
"WONT": lib_telnet.WONT,
// Objects / Classes
"TelnetClient": gojs.GetClassConstructor[lib_telnet.TelnetClient](&lib_telnet.TelnetClient{}),
"IsTelnetResponse": gojs.GetClassConstructor[lib_telnet.IsTelnetResponse](&lib_telnet.IsTelnetResponse{}),
"TelnetClient": gojs.GetClassConstructor[lib_telnet.TelnetClient](&lib_telnet.TelnetClient{}),
"TelnetInfoResponse": gojs.GetClassConstructor[lib_telnet.TelnetInfoResponse](&lib_telnet.TelnetInfoResponse{}),
"NTLMInfoResponse": gojs.GetClassConstructor[telnetmini.NTLMInfoResponse](&telnetmini.NTLMInfoResponse{}),
},
).Register()
}
+29
View File
@@ -0,0 +1,29 @@
package utils
import (
lib_utils "github.com/projectdiscovery/nuclei/v3/pkg/js/libs/utils"
"github.com/Mzack9999/goja"
"github.com/projectdiscovery/nuclei/v3/pkg/js/gojs"
)
var (
module = gojs.NewGojaModule("nuclei/utils")
)
func init() {
module.Set(
gojs.Objects{
// Functions
// Var and consts
// Objects / Classes
"Utils": gojs.GetClassConstructor[lib_utils.Utils](&lib_utils.Utils{}),
},
).Register()
}
func Enable(runtime *goja.Runtime) {
module.Enable(runtime)
}
+4 -4
View File
@@ -23,7 +23,7 @@
* const items = fs.ListDir('/tmp');
* ```
*/
export function ListDir(path: string, itemType: string): string[] | null {
export function ListDir(ctx: any, path: string, itemType: string): string[] | null {
return null;
}
@@ -39,7 +39,7 @@ export function ListDir(path: string, itemType: string): string[] | null {
* const content = fs.ReadFile('helpers/usernames.txt');
* ```
*/
export function ReadFile(path: string): Uint8Array | null {
export function ReadFile(ctx: any, path: string): Uint8Array | null {
return null;
}
@@ -55,7 +55,7 @@ export function ReadFile(path: string): Uint8Array | null {
* const content = fs.ReadFileAsString('helpers/usernames.txt');
* ```
*/
export function ReadFileAsString(path: string): string | null {
export function ReadFileAsString(ctx: any, path: string): string | null {
return null;
}
@@ -72,7 +72,7 @@ export function ReadFileAsString(path: string): string | null {
* log(contents);
* ```
*/
export function ReadFilesFromDir(dir: string): string[] | null {
export function ReadFilesFromDir(ctx: any, dir: string): string[] | null {
return null;
}
+1
View File
@@ -18,4 +18,5 @@ export * as smtp from './smtp';
export * as ssh from './ssh';
export * as structs from './structs';
export * as telnet from './telnet';
export * as utils from './utils';
export * as vnc from './vnc';
+62 -62
View File
@@ -188,9 +188,9 @@ export class Config {
*/
export interface AuthorizationDataEntry {
ADData?: Uint8Array,
ADType?: number,
ADData?: Uint8Array,
}
@@ -212,9 +212,9 @@ export interface BitString {
*/
export interface BitString {
Bytes?: Uint8Array,
BitLength?: number,
Bytes?: Uint8Array,
}
@@ -236,16 +236,16 @@ export interface Config {
*/
export interface EncTicketPart {
EndTime?: Date,
RenewTill?: Date,
CRealm?: string,
AuthTime?: Date,
StartTime?: Date,
EndTime?: Date,
RenewTill?: Date,
Flags?: BitString,
Key?: EncryptionKey,
@@ -318,27 +318,29 @@ export interface HostAddress {
*/
export interface LibDefaults {
CCacheType?: number,
K5LoginAuthoritative?: boolean,
Proxiable?: boolean,
Forwardable?: boolean,
RDNS?: boolean,
K5LoginDirectory?: string,
KDCTimeSync?: number,
VerifyAPReqNofail?: boolean,
DefaultTGSEnctypes?: string[],
DefaultTktEnctypes?: string[],
DNSLookupKDC?: boolean,
ExtraAddresses?: Uint8Array,
UDPPreferenceLimit?: number,
DefaultKeytabName?: string,
DefaultRealm?: string,
DefaultTGSEnctypeIDs?: number[],
DNSCanonicalizeHostname?: boolean,
Forwardable?: boolean,
K5LoginAuthoritative?: boolean,
/**
* time in nanoseconds
@@ -346,54 +348,52 @@ export interface LibDefaults {
RenewLifetime?: number,
/**
* time in nanoseconds
*/
TicketLifetime?: number,
DefaultClientKeytabName?: string,
DefaultTktEnctypeIDs?: number[],
DNSLookupRealm?: boolean,
ExtraAddresses?: Uint8Array,
DefaultRealm?: string,
NoAddresses?: boolean,
PreferredPreauthTypes?: number[],
PermittedEnctypeIDs?: number[],
RealmTryDomains?: number,
DefaultKeytabName?: string,
DefaultTktEnctypes?: string[],
DNSLookupKDC?: boolean,
IgnoreAcceptorHostname?: boolean,
AllowWeakCrypto?: boolean,
Canonicalize?: boolean,
SafeChecksumType?: number,
UDPPreferenceLimit?: number,
/**
* time in nanoseconds
*/
Clockskew?: number,
DNSLookupRealm?: boolean,
IgnoreAcceptorHostname?: boolean,
PermittedEnctypeIDs?: number[],
PreferredPreauthTypes?: number[],
RealmTryDomains?: number,
K5LoginDirectory?: string,
KDCTimeSync?: number,
NoAddresses?: boolean,
PermittedEnctypes?: string[],
/**
* time in nanoseconds
*/
TicketLifetime?: number,
VerifyAPReqNofail?: boolean,
DefaultClientKeytabName?: string,
Proxiable?: boolean,
CCacheType?: number,
DefaultTktEnctypeIDs?: number[],
SafeChecksumType?: number,
KDCDefaultOptions?: BitString,
}
@@ -404,9 +404,9 @@ export interface LibDefaults {
*/
export interface PrincipalName {
NameString?: string[],
NameType?: number,
NameString?: string[],
}
@@ -416,10 +416,6 @@ export interface PrincipalName {
*/
export interface Realm {
Realm?: string,
AdminServer?: string[],
DefaultDomain?: string,
KDC?: string[],
@@ -427,6 +423,10 @@ export interface Realm {
KPasswdServer?: string[],
MasterKDC?: string[],
Realm?: string,
AdminServer?: string[],
}
+19 -4
View File
@@ -399,8 +399,8 @@ export class Client {
* client.Authenticate('user', 'password');
* ```
*/
public Authenticate(username: string): void {
return;
public Authenticate(username: string): boolean {
return false;
}
@@ -413,8 +413,8 @@ export class Client {
* client.AuthenticateWithNTLMHash('pdtm', 'hash');
* ```
*/
public AuthenticateWithNTLMHash(username: string): void {
return;
public AuthenticateWithNTLMHash(username: string): boolean {
return false;
}
@@ -463,6 +463,21 @@ export class Client {
}
/**
* GetVersion returns the LDAP versions being used by the server
* @example
* ```javascript
* const ldap = require('nuclei/ldap');
* const client = new ldap.Client('ldap://ldap.example.com', 'acme.com');
* const versions = client.GetVersion();
* log(versions);
* ```
*/
public GetVersion(): string[] {
return [];
}
/**
* close the ldap connection
* @example
+4 -4
View File
@@ -26,7 +26,7 @@ export class MSSQLClient {
* const connected = client.Connect('acme.com', 1433, 'username', 'password');
* ```
*/
public Connect(host: string, port: number, username: string): boolean | null {
public Connect(ctx: any, host: string, port: number, username: string): boolean | null {
return null;
}
@@ -43,7 +43,7 @@ export class MSSQLClient {
* const connected = client.ConnectWithDB('acme.com', 1433, 'username', 'password', 'master');
* ```
*/
public ConnectWithDB(host: string, port: number, username: string): boolean | null {
public ConnectWithDB(ctx: any, host: string, port: number, username: string): boolean | null {
return null;
}
@@ -58,7 +58,7 @@ export class MSSQLClient {
* const isMssql = mssql.IsMssql('acme.com', 1433);
* ```
*/
public IsMssql(host: string, port: number): boolean | null {
public IsMssql(ctx: any, host: string, port: number): boolean | null {
return null;
}
@@ -74,7 +74,7 @@ export class MSSQLClient {
* log(to_json(result));
* ```
*/
public ExecuteQuery(host: string, port: number, username: string): SQLResult | null | null {
public ExecuteQuery(ctx: any, host: string, port: number, username: string): SQLResult | null | null {
return null;
}
+7 -7
View File
@@ -41,7 +41,7 @@ export class MySQLClient {
* const isMySQL = mysql.IsMySQL('acme.com', 3306);
* ```
*/
public IsMySQL(host: string, port: number): boolean | null {
public IsMySQL(ctx: any, host: string, port: number): boolean | null {
return null;
}
@@ -58,7 +58,7 @@ export class MySQLClient {
* const connected = client.Connect('acme.com', 3306, 'username', 'password');
* ```
*/
public Connect(host: string, port: number, username: string): boolean | null {
public Connect(ctx: any, host: string, port: number, username: string): boolean | null {
return null;
}
@@ -72,7 +72,7 @@ export class MySQLClient {
* log(to_json(info));
* ```
*/
public FingerprintMySQL(host: string, port: number): MySQLInfo | null {
public FingerprintMySQL(ctx: any, host: string, port: number): MySQLInfo | null {
return null;
}
@@ -88,7 +88,7 @@ export class MySQLClient {
* const connected = client.ConnectWithDSN('username:password@tcp(acme.com:3306)/');
* ```
*/
public ConnectWithDSN(dsn: string): boolean | null {
public ConnectWithDSN(ctx: any, dsn: string): boolean | null {
return null;
}
@@ -106,7 +106,7 @@ export class MySQLClient {
* log(to_json(result));
* ```
*/
public ExecuteQueryWithOpts(opts: MySQLOptions, query: string): SQLResult | null | null {
public ExecuteQueryWithOpts(ctx: any, opts: MySQLOptions, query: string): SQLResult | null | null {
return null;
}
@@ -121,7 +121,7 @@ export class MySQLClient {
* log(to_json(result));
* ```
*/
public ExecuteQuery(host: string, port: number, username: string): SQLResult | null | null {
public ExecuteQuery(ctx: any, host: string, port: number, username: string): SQLResult | null | null {
return null;
}
@@ -136,7 +136,7 @@ export class MySQLClient {
* log(to_json(result));
* ```
*/
public ExecuteQueryOnDB(host: string, port: number, username: string): SQLResult | null | null {
public ExecuteQueryOnDB(ctx: any, host: string, port: number, username: string): SQLResult | null | null {
return null;
}
+87 -2
View File
@@ -9,7 +9,7 @@
* const conn = net.Open('tcp', 'acme.com:80');
* ```
*/
export function Open(protocol: string): NetConn | null {
export function Open(ctx: any, protocol: string): NetConn | null {
return null;
}
@@ -24,7 +24,7 @@ export function Open(protocol: string): NetConn | null {
* const conn = net.OpenTLS('tcp', 'acme.com:443');
* ```
*/
export function OpenTLS(protocol: string): NetConn | null {
export function OpenTLS(ctx: any, protocol: string): NetConn | null {
return null;
}
@@ -215,5 +215,90 @@ export class NetConn {
}
/**
* SendBytes sends raw bytes to the connection (accepts []byte from JS)
* @example
* ```javascript
* const net = require('nuclei/net');
* const conn = net.Open('tcp', 'acme.com:80');
* conn.SendBytes([0x48, 0x45, 0x4c, 0x4c, 0x4f]);
* ```
*/
public SendBytes(data: Uint8Array): void {
return;
}
/**
* SendLine sends data with a newline appended
* @example
* ```javascript
* const net = require('nuclei/net');
* const conn = net.Open('tcp', 'acme.com:80');
* conn.SendLine('GET / HTTP/1.1');
* ```
*/
public SendLine(data: string): void {
return;
}
/**
* RecvUntil receives data until the delimiter is found
* Returns all data including the delimiter
* @example
* ```javascript
* const net = require('nuclei/net');
* const conn = net.Open('tcp', 'acme.com:80');
* const data = conn.RecvUntil('\r\n\r\n');
* ```
*/
public RecvUntil(delim: Uint8Array): Uint8Array | null {
return null;
}
/**
* RecvUntilString receives data until the delimiter string is found
* @example
* ```javascript
* const net = require('nuclei/net');
* const conn = net.Open('tcp', 'acme.com:80');
* const data = conn.RecvUntilString('\r\n\r\n');
* ```
*/
public RecvUntilString(delim: string): string | null {
return null;
}
/**
* RecvLine receives data until a newline is found
* @example
* ```javascript
* const net = require('nuclei/net');
* const conn = net.Open('tcp', 'acme.com:80');
* const line = conn.RecvLine();
* ```
*/
public RecvLine(): string | null {
return null;
}
/**
* RecvN receives exactly N bytes (alias for RecvFull)
* @example
* ```javascript
* const net = require('nuclei/net');
* const conn = net.Open('tcp', 'acme.com:80');
* const header = conn.RecvN(16);
* ```
*/
public RecvN(n: number): Uint8Array | null {
return null;
}
}
+91 -82
View File
@@ -1,106 +1,115 @@
/**
* Client is a client for Oracle database.
* Internally client uses oracle/godror driver.
* @example
* ```javascript
* const oracle = require('nuclei/oracle');
* const client = new oracle.OracleClient();
* ```
*/
export class OracleClient {
// Constructor of OracleClient
constructor() {}
/**
* IsOracle checks if a host is running an Oracle server
* @example
* ```javascript
* const oracle = require('nuclei/oracle');
* const isOracle = oracle.IsOracle('acme.com', 1521);
* log(toJSON(isOracle));
* ```
*/
public IsOracle(ctx: any, host: string, port: number): IsOracleResponse | null {
return null;
}
/**
* Connect connects to an Oracle database
* @example
* ```javascript
* const oracle = require('nuclei/oracle');
* const client = new oracle.OracleClient;
* client.Connect('acme.com', 1521, 'XE', 'user', 'password');
* ```
*/
public Connect(ctx: any, host: string, port: number, serviceName: string, username: string, password: string): boolean | null {
return null;
}
/**
* ConnectWithDSN Method
*/
public ConnectWithDSN(ctx: any, dsn: string): boolean | null {
return null;
}
/**
* ExecuteQuery connects to MS SQL database using given credentials and executes a query.
* It returns the results of the query or an error if something goes wrong.
* @example
* ```javascript
* const oracle = require('nuclei/oracle');
* const client = new oracle.OracleClient;
* const result = client.ExecuteQuery('acme.com', 1521, 'username', 'password', 'XE', 'SELECT @@version');
* log(to_json(result));
* ```
*/
public ExecuteQuery(ctx: any, host: string, port: number, username: string): SQLResult | null | null {
return null;
}
/**
* ExecuteQueryWithDSN executes a query on an Oracle database using a DSN
* @example
* ```javascript
* const oracle = require('nuclei/oracle');
* const client = new oracle.OracleClient;
* const result = client.ExecuteQueryWithDSN('oracle://user:password@host:port/service', 'SELECT @@version');
* log(to_json(result));
* ```
*/
public ExecuteQueryWithDSN(ctx: any, dsn: string, query: string): SQLResult | null | null {
return null;
}
}
/**
* IsOracleResponse is the response from the IsOracle function.
* this is returned by IsOracle function.
* @example
* ```javascript
* const oracle = require('nuclei/oracle');
* const client = new oracle.OracleClient();
* const isOracle = client.IsOracle('acme.com', 1521);
* const isOracle = oracle.IsOracle('acme.com', 1521);
* ```
*/
export interface IsOracleResponse {
IsOracle?: boolean,
Banner?: string,
}
/**
* Client is a client for Oracle database.
* Internally client uses go-ora driver.
* @example
* ```javascript
* const oracle = require('nuclei/oracle');
* const client = new oracle.OracleClient();
* ```
*/
export class OracleClient {
// Constructor of OracleClient
constructor() {}
/**
* Connect connects to an Oracle database
* @example
* ```javascript
* const oracle = require('nuclei/oracle');
* const client = new oracle.OracleClient();
* client.Connect('acme.com', 1521, 'XE', 'user', 'password');
* ```
*/
public Connect(host: string, port: number, serviceName: string, username: string, password: string): boolean | null {
return null;
}
/**
* ConnectWithDSN connects to an Oracle database using a DSN string
* @example
* ```javascript
* const oracle = require('nuclei/oracle');
* const client = new oracle.OracleClient();
* client.ConnectWithDSN('oracle://user:password@host:port/service', 'SELECT @@version');
* ```
*/
public ConnectWithDSN(dsn: string): boolean | null {
return null;
}
/**
* IsOracle checks if a host is running an Oracle server
* @example
* ```javascript
* const oracle = require('nuclei/oracle');
* const isOracle = oracle.IsOracle('acme.com', 1521);
* ```
*/
public IsOracle(host: string, port: number): IsOracleResponse | null {
return null;
}
/**
* ExecuteQuery connects to Oracle database using given credentials and executes a query.
* It returns the results of the query or an error if something goes wrong.
* @example
* ```javascript
* const oracle = require('nuclei/oracle');
* const client = new oracle.OracleClient();
* const result = client.ExecuteQuery('acme.com', 1521, 'username', 'password', 'XE', 'SELECT * FROM dual');
* log(to_json(result));
* ```
*/
public ExecuteQuery(host: string, port: number, username: string, password: string, dbName: string, query: string): SQLResult | null {
return null;
}
/**
* ExecuteQueryWithDSN executes a query on an Oracle database using a DSN
* @example
* ```javascript
* const oracle = require('nuclei/oracle');
* const client = new oracle.OracleClient();
* const result = client.ExecuteQueryWithDSN('oracle://user:password@host:port/service', 'SELECT * FROM dual');
* log(to_json(result));
* ```
*/
public ExecuteQueryWithDSN(dsn: string, query: string): SQLResult | null {
return null;
}
}
/**
* SQLResult Interface
*/
export interface SQLResult {
Count?: number,
Columns?: string[],
Rows?: any[],
}
+1 -1
View File
@@ -9,7 +9,7 @@
* log(toJSON(isPOP3));
* ```
*/
export function IsPOP3(host: string, port: number): IsPOP3Response | null {
export function IsPOP3(ctx: any, host: string, port: number): IsPOP3Response | null {
return null;
}
+4 -4
View File
@@ -24,7 +24,7 @@ export class PGClient {
* const isPostgres = postgres.IsPostgres('acme.com', 5432);
* ```
*/
public IsPostgres(host: string, port: number): boolean | null {
public IsPostgres(ctx: any, host: string, port: number): boolean | null {
return null;
}
@@ -41,7 +41,7 @@ export class PGClient {
* const connected = client.Connect('acme.com', 5432, 'username', 'password');
* ```
*/
public Connect(host: string, port: number, username: string): boolean | null {
public Connect(ctx: any, host: string, port: number, username: string, password: string): boolean | null {
return null;
}
@@ -58,7 +58,7 @@ export class PGClient {
* log(to_json(result));
* ```
*/
public ExecuteQuery(host: string, port: number, username: string): SQLResult | null | null {
public ExecuteQuery(ctx: any, host: string, port: number, username: string, password: string, dbName: string, query: string): SQLResult | null | null {
return null;
}
@@ -75,7 +75,7 @@ export class PGClient {
* const connected = client.ConnectWithDB('acme.com', 5432, 'username', 'password', 'dbname');
* ```
*/
public ConnectWithDB(host: string, port: number, username: string): boolean | null {
public ConnectWithDB(ctx: any, host: string, port: number, username: string, password: string, dbName: string): boolean | null {
return null;
}
+88 -33
View File
@@ -1,3 +1,32 @@
export const EncryptionLevelFIPS140_1 = "FIPS140_1";
export const EncryptionLevelRC4_128bit = "RC4_128bit";
export const EncryptionLevelRC4_40bit = "RC4_40bit";
export const EncryptionLevelRC4_56bit = "RC4_56bit";
export const SecurityLayerCredSSP = "CredSSP";
export const SecurityLayerCredSSPWithEarlyUserAuth = "CredSSPWithEarlyUserAuth";
export const SecurityLayerNativeRDP = "NativeRDP";
export const SecurityLayerRDSTLS = "RDSTLS";
export const SecurityLayerSSL = "SSL";
/**
* CheckRDPAuth checks if the given host and port are running rdp server
* with authentication and returns their metadata.
@@ -9,10 +38,12 @@
* log(toJSON(checkRDPAuth));
* ```
*/
export function CheckRDPAuth(host: string, port: number): CheckRDPAuthResponse | null {
export function CheckRDPAuth(ctx: any, host: string, port: number): CheckRDPAuthResponse | null {
return null;
}
/**
* CheckRDPEncryption checks the RDP server's supported security layers and encryption levels.
* It tests different protocols and ciphers to determine what is supported.
@@ -23,10 +54,12 @@ export function CheckRDPAuth(host: string, port: number): CheckRDPAuthResponse |
* log(toJSON(encryption));
* ```
*/
export function CheckRDPEncryption(host: string, port: number): RDPEncryptionResponse | null {
export function CheckRDPEncryption(ctx: any, host: string, port: number): RDPEncryptionResponse | null {
return null;
}
/**
* IsRDP checks if the given host and port are running rdp server.
* If connection is successful, it returns true.
@@ -39,10 +72,12 @@ export function CheckRDPEncryption(host: string, port: number): RDPEncryptionRes
* log(toJSON(isRDP));
* ```
*/
export function IsRDP(host: string, port: number): IsRDPResponse | null {
export function IsRDP(ctx: any, host: string, port: number): IsRDPResponse | null {
return null;
}
/**
* CheckRDPAuthResponse is the response from the CheckRDPAuth function.
* this is returned by CheckRDPAuth function.
@@ -60,30 +95,7 @@ export interface CheckRDPAuthResponse {
Auth?: boolean,
}
/**
* RDPEncryptionResponse is the response from the CheckRDPEncryption function.
* This is returned by CheckRDPEncryption function.
* @example
* ```javascript
* const rdp = require('nuclei/rdp');
* const encryption = rdp.CheckRDPEncryption('acme.com', 3389);
* log(toJSON(encryption));
* ```
*/
export interface RDPEncryptionResponse {
// Security Layer Protocols
NativeRDP: boolean;
SSL: boolean;
CredSSP: boolean;
RDSTLS: boolean;
CredSSPWithEarlyUserAuth: boolean;
// Encryption Levels
RC4_40bit: boolean;
RC4_56bit: boolean;
RC4_128bit: boolean;
FIPS140_1: boolean;
}
/**
* IsRDPResponse is the response from the IsRDP function.
@@ -102,17 +114,54 @@ export interface IsRDPResponse {
OS?: string,
}
/**
* RDPEncryptionResponse is the response from the CheckRDPEncryption function.
* This is returned by CheckRDPEncryption function.
* @example
* ```javascript
* const rdp = require('nuclei/rdp');
* const encryption = rdp.CheckRDPEncryption('acme.com', 3389);
* log(toJSON(encryption));
* ```
*/
export interface RDPEncryptionResponse {
/**
* Protocols
*/
NativeRDP?: boolean,
SSL?: boolean,
CredSSP?: boolean,
RDSTLS?: boolean,
CredSSPWithEarlyUserAuth?: boolean,
/**
* EncryptionLevels
*/
RC4_40bit?: boolean,
RC4_56bit?: boolean,
RC4_128bit?: boolean,
FIPS140_1?: boolean,
}
/**
* ServiceRDP Interface
*/
export interface ServiceRDP {
ForestName?: string,
OSFingerprint?: string,
OSVersion?: string,
TargetName?: string,
NetBIOSComputerName?: string,
@@ -122,5 +171,11 @@ export interface ServiceRDP {
DNSComputerName?: string,
DNSDomainName?: string,
ForestName?: string,
OSFingerprint?: string,
OSVersion?: string,
}
+5 -5
View File
@@ -8,7 +8,7 @@
* const connected = redis.Connect('acme.com', 6379, 'password');
* ```
*/
export function Connect(host: string, port: number, password: string): boolean | null {
export function Connect(ctx: any, host: string, port: number, password: string): boolean | null {
return null;
}
@@ -22,7 +22,7 @@ export function Connect(host: string, port: number, password: string): boolean |
* const info = redis.GetServerInfo('acme.com', 6379);
* ```
*/
export function GetServerInfo(host: string, port: number): string | null {
export function GetServerInfo(ctx: any, host: string, port: number): string | null {
return null;
}
@@ -36,7 +36,7 @@ export function GetServerInfo(host: string, port: number): string | null {
* const info = redis.GetServerInfoAuth('acme.com', 6379, 'password');
* ```
*/
export function GetServerInfoAuth(host: string, port: number, password: string): string | null {
export function GetServerInfoAuth(ctx: any, host: string, port: number, password: string): string | null {
return null;
}
@@ -50,7 +50,7 @@ export function GetServerInfoAuth(host: string, port: number, password: string):
* const isAuthenticated = redis.IsAuthenticated('acme.com', 6379);
* ```
*/
export function IsAuthenticated(host: string, port: number): boolean | null {
export function IsAuthenticated(ctx: any, host: string, port: number): boolean | null {
return null;
}
@@ -64,7 +64,7 @@ export function IsAuthenticated(host: string, port: number): boolean | null {
* const result = redis.RunLuaScript('acme.com', 6379, 'password', 'return redis.call("get", KEYS[1])');
* ```
*/
export function RunLuaScript(host: string, port: number, password: string, script: string): any | null {
export function RunLuaScript(ctx: any, host: string, port: number, password: string, script: string): any | null {
return null;
}
+49 -34
View File
@@ -9,10 +9,12 @@
* log(toJSON(isRsync));
* ```
*/
export function IsRsync(host: string, port: number): IsRsyncResponse | null {
export function IsRsync(ctx: any, host: string, port: number): IsRsyncResponse | null {
return null;
}
/**
* RsyncClient is a client for RSYNC servers.
* Internally client uses https://github.com/gokrazy/rsync driver.
@@ -24,51 +26,43 @@ export function IsRsync(host: string, port: number): IsRsyncResponse | null {
*/
export class RsyncClient {
// Constructor of RsyncClient
constructor() {}
/**
* Connect establishes a connection to the rsync server with authentication.
* @example
* ```javascript
* const rsync = require('nuclei/rsync');
* const client = new rsync.RsyncClient();
* const connected = client.Connect('acme.com', 873, 'username', 'password', 'backup');
* ```
*/
public Connect(host: string, port: number, username: string, password: string, module: string): boolean | null {
* ListModules lists the modules of a Rsync server.
* @example
* ```javascript
* const rsync = require('nuclei/rsync');
* const client = new rsync.RsyncClient();
* const listModules = client.ListModules('acme.com', 873, 'username', 'password');
* log(toJSON(listModules));
* ```
*/
public ListModules(ctx: any, host: string, port: number, username: string, password: string): RsyncListResponse | null {
return null;
}
/**
* ListModules lists available modules on the rsync server.
* @example
* ```javascript
* const rsync = require('nuclei/rsync');
* const client = new rsync.RsyncClient();
* const modules = client.ListModules('acme.com', 873, 'username', 'password');
* log(toJSON(modules));
* ```
*/
public ListModules(host: string, port: number, username: string, password: string): string[] | null {
* ListShares lists the shares of a Rsync server.
* @example
* ```javascript
* const rsync = require('nuclei/rsync');
* const client = new rsync.RsyncClient();
* const listShares = client.ListFilesInModule('acme.com', 873, 'username', 'password', '/');
* log(toJSON(listShares));
* ```
*/
public ListFilesInModule(ctx: any, host: string, port: number, username: string, password: string, module: string): RsyncListResponse | null {
return null;
}
/**
* ListFilesInModule lists files in a specific module on the rsync server.
* @example
* ```javascript
* const rsync = require('nuclei/rsync');
* const client = new rsync.RsyncClient();
* const files = client.ListFilesInModule('acme.com', 873, 'username', 'password', 'backup');
* log(toJSON(files));
* ```
*/
public ListFilesInModule(host: string, port: number, username: string, password: string, module: string): string[] | null {
return null;
}
}
/**
* IsRsyncResponse is the response from the IsRsync function.
* this is returned by IsRsync function.
@@ -86,3 +80,24 @@ export interface IsRsyncResponse {
Banner?: string,
}
/**
* ListSharesResponse is the response from the ListShares function.
* this is returned by ListShares function.
* @example
* ```javascript
* const rsync = require('nuclei/rsync');
* const client = new rsync.RsyncClient();
* const listShares = client.ListShares('acme.com', 873);
* log(toJSON(listShares));
*/
export interface RsyncListResponse {
Modules?: string[],
Files?: string[],
Output?: string,
}
+20 -20
View File
@@ -28,7 +28,7 @@ export class SMBClient {
* log(to_json(info));
* ```
*/
public ConnectSMBInfoMode(host: string, port: number): SMBLog | null | null {
public ConnectSMBInfoMode(ctx: any, host: string, port: number): SMBLog | null | null {
return null;
}
@@ -46,7 +46,7 @@ export class SMBClient {
* log(to_json(metadata));
* ```
*/
public ListSMBv2Metadata(host: string, port: number): ServiceSMB | null | null {
public ListSMBv2Metadata(ctx: any, host: string, port: number): ServiceSMB | null | null {
return null;
}
@@ -66,7 +66,7 @@ export class SMBClient {
* }
* ```
*/
public ListShares(host: string, port: number, user: string): string[] | null {
public ListShares(ctx: any, host: string, port: number, user: string): string[] | null {
return null;
}
@@ -81,7 +81,7 @@ export class SMBClient {
* const isSMBGhost = smb.DetectSMBGhost('acme.com', 445);
* ```
*/
public DetectSMBGhost(host: string, port: number): boolean | null {
public DetectSMBGhost(ctx: any, host: string, port: number): boolean | null {
return null;
}
@@ -113,12 +113,6 @@ export interface HeaderLog {
*/
export interface NegotiationLog {
SecurityMode?: number,
DialectRevision?: number,
ServerGuid?: Uint8Array,
Capabilities?: number,
SystemTime?: number,
@@ -127,6 +121,12 @@ export interface NegotiationLog {
AuthenticationTypes?: string[],
SecurityMode?: number,
DialectRevision?: number,
ServerGuid?: Uint8Array,
HeaderLog?: HeaderLog,
}
@@ -159,16 +159,16 @@ export interface SMBCapabilities {
*/
export interface SMBLog {
NTLM?: string,
GroupName?: string,
HasNTLM?: boolean,
SupportV1?: boolean,
NativeOs?: string,
NTLM?: string,
GroupName?: string,
Version?: SMBVersions,
Capabilities?: SMBCapabilities,
@@ -185,13 +185,13 @@ export interface SMBLog {
*/
export interface SMBVersions {
Major?: number,
Minor?: number,
Revision?: number,
VerString?: string,
Major?: number,
Minor?: number,
}
@@ -201,8 +201,6 @@ export interface SMBVersions {
*/
export interface ServiceSMB {
OSVersion?: string,
NetBIOSComputerName?: string,
NetBIOSDomainName?: string,
@@ -216,6 +214,8 @@ export interface ServiceSMB {
SigningEnabled?: boolean,
SigningRequired?: boolean,
OSVersion?: string,
}
+27 -27
View File
@@ -40,7 +40,7 @@ export class SSHClient {
* const connected = client.Connect('acme.com', 22, 'username', 'password');
* ```
*/
public Connect(host: string, port: number, username: string): boolean | null {
public Connect(ctx: any, host: string, port: number, username: string): boolean | null {
return null;
}
@@ -58,7 +58,7 @@ export class SSHClient {
* const connected = client.ConnectWithKey('acme.com', 22, 'username', privateKey);
* ```
*/
public ConnectWithKey(host: string, port: number, username: string): boolean | null {
public ConnectWithKey(ctx: any, host: string, port: number, username: string): boolean | null {
return null;
}
@@ -78,7 +78,7 @@ export class SSHClient {
* log(to_json(info));
* ```
*/
public ConnectSSHInfoMode(host: string, port: number): HandshakeLog | null | null {
public ConnectSSHInfoMode(ctx: any, host: string, port: number): HandshakeLog | null | null {
return null;
}
@@ -129,10 +129,10 @@ export class SSHClient {
*/
export interface Algorithms {
Kex?: string,
HostKey?: string,
Kex?: string,
W?: DirectionAlgorithms,
R?: DirectionAlgorithms,
@@ -159,13 +159,13 @@ export interface DirectionAlgorithms {
*/
export interface EndpointId {
ProtoVersion?: string,
SoftwareVersion?: string,
Comment?: string,
Raw?: string,
ProtoVersion?: string,
}
@@ -179,15 +179,15 @@ export interface HandshakeLog {
UserAuth?: string[],
ServerID?: EndpointId,
ClientID?: EndpointId,
ServerKex?: KexInitMsg,
ClientKex?: KexInitMsg,
AlgorithmSelection?: Algorithms,
ServerID?: EndpointId,
ClientID?: EndpointId,
}
@@ -197,34 +197,34 @@ export interface HandshakeLog {
*/
export interface KexInitMsg {
KexAlgos?: string[],
CiphersClientServer?: string[],
MACsServerClient?: string[],
LanguagesClientServer?: string[],
CompressionClientServer?: string[],
CompressionServerClient?: string[],
Reserved?: number,
MACsClientServer?: string[],
/**
* fixed size array of length: [16]
*/
Cookie?: Uint8Array,
KexAlgos?: string[],
ServerHostKeyAlgos?: string[],
CiphersClientServer?: string[],
CiphersServerClient?: string[],
MACsClientServer?: string[],
MACsServerClient?: string[],
CompressionClientServer?: string[],
CompressionServerClient?: string[],
LanguagesClientServer?: string[],
LanguagesServerClient?: string[],
FirstKexFollows?: boolean,
Reserved?: number,
}
+115 -96
View File
@@ -1,5 +1,41 @@
/** Do */
export const DO = 253;
/** Don't */
export const DONT = 254;
/** Echo */
export const ECHO = 1;
/** Encryption option (0x26) */
export const ENCRYPT = 38;
/** Interpret As Command */
export const IAC = 255;
/** Negotiate About Window Size */
export const NAWS = 31;
/** Subnegotiation Begin */
export const SB = 250;
/** Subnegotiation End */
export const SE = 240;
/** Suppress Go Ahead */
export const SUPPRESS_GO_AHEAD = 3;
/** Terminal Type */
export const TERMINAL_TYPE = 24;
/** Will */
export const WILL = 251;
/** Won't */
export const WONT = 252;
/**
* IsTelnet checks if a host is running a Telnet server.
* @example
@@ -9,10 +45,12 @@
* log(toJSON(isTelnet));
* ```
*/
export function IsTelnet(host: string, port: number): IsTelnetResponse | null {
export function IsTelnet(ctx: any, host: string, port: number): IsTelnetResponse | null {
return null;
}
/**
* TelnetClient is a client for Telnet servers.
* @example
@@ -23,56 +61,65 @@ export function IsTelnet(host: string, port: number): IsTelnetResponse | null {
*/
export class TelnetClient {
/**
* Connect tries to connect to provided host and port with telnet.
* Optionally provides username and password for authentication.
* Returns state of connection. If the connection is successful,
* the function will return true, otherwise false.
* @example
* ```javascript
* const telnet = require('nuclei/telnet');
* const client = new telnet.TelnetClient();
* const connected = client.Connect('acme.com', 23, 'username', 'password');
* ```
*/
public Connect(host: string, port: number, username: string, password: string): boolean {
return false;
}
// Constructor of TelnetClient
constructor() {}
/**
* Info gathers information about the telnet server including encryption support.
* Uses the telnetmini library's DetectEncryption helper function.
* WARNING: The connection used for detection becomes unusable after this call.
* @example
* ```javascript
* const telnet = require('nuclei/telnet');
* const client = new telnet.TelnetClient();
* const info = client.Info('acme.com', 23);
* log(toJSON(info));
* ```
*/
public Info(host: string, port: number): TelnetInfoResponse | null {
* Connect tries to connect to provided host and port with telnet.
* Optionally provides username and password for authentication.
* Returns state of connection. If the connection is successful,
* the function will return true, otherwise false.
* @example
* ```javascript
* const telnet = require('nuclei/telnet');
* const client = new telnet.TelnetClient();
* const connected = client.Connect('acme.com', 23, 'username', 'password');
* ```
*/
public Connect(ctx: any, host: string, port: number, username: string, password: string): boolean | null {
return null;
}
/**
* GetTelnetNTLMInfo implements the Nmap telnet-ntlm-info.nse script functionality.
* This function uses the telnetmini library and SMB packet crafting functions to send
* MS-TNAP NTLM authentication requests with null credentials. It might work only on
* Microsoft Telnet servers.
* @example
* ```javascript
* const telnet = require('nuclei/telnet');
* const client = new telnet.TelnetClient();
* const ntlmInfo = client.GetTelnetNTLMInfo('acme.com', 23);
* log(toJSON(ntlmInfo));
* ```
*/
public GetTelnetNTLMInfo(host: string, port: number): NTLMInfoResponse | null {
* Info gathers information about the telnet server including encryption support.
* Uses the telnetmini library's DetectEncryption helper function.
* WARNING: The connection used for detection becomes unusable after this call.
* @example
* ```javascript
* const telnet = require('nuclei/telnet');
* const client = new telnet.TelnetClient();
* const info = client.Info('acme.com', 23);
* log(toJSON(info));
* ```
*/
public Info(ctx: any, host: string, port: number): TelnetInfoResponse | null {
return null;
}
/**
* GetTelnetNTLMInfo implements the Nmap telnet-ntlm-info.nse script functionality.
* This function uses the telnetmini library and SMB packet crafting functions to send
* MS-TNAP NTLM authentication requests with null credentials. It might work only on
* Microsoft Telnet servers.
* @example
* ```javascript
* const telnet = require('nuclei/telnet');
* const client = new telnet.TelnetClient();
* const ntlmInfo = client.GetTelnetNTLMInfo('acme.com', 23);
* log(toJSON(ntlmInfo));
* ```
*/
public GetTelnetNTLMInfo(ctx: any, host: string, port: number): NTLMInfoResponse | null | null {
return null;
}
}
/**
* IsTelnetResponse is the response from the IsTelnet function.
* this is returned by IsTelnet function.
@@ -90,6 +137,32 @@ export interface IsTelnetResponse {
Banner?: string,
}
/**
* NTLMInfoResponse Interface
*/
export interface NTLMInfoResponse {
DNSComputerName?: string,
DNSTreeName?: string,
ProductVersion?: string,
Timestamp?: number,
TargetName?: string,
NetBIOSDomainName?: string,
NetBIOSComputerName?: string,
DNSDomainName?: string,
}
/**
* TelnetInfoResponse is the response from the Info function.
* @example
@@ -106,60 +179,6 @@ export interface TelnetInfoResponse {
Banner?: string,
Options?: { [key: number]: number[] },
}
/**
* NTLMInfoResponse represents the response from NTLM information gathering.
* This matches exactly the output structure from the Nmap telnet-ntlm-info.nse script.
* @example
* ```javascript
* const telnet = require('nuclei/telnet');
* const client = new telnet.TelnetClient();
* const ntlmInfo = client.GetTelnetNTLMInfo('acme.com', 23);
* log(toJSON(ntlmInfo));
* ```
*/
export interface NTLMInfoResponse {
/**
* Target_Name from script (target_realm in script)
*/
TargetName?: string,
/**
* NetBIOS_Domain_Name from script
*/
NetBIOSDomainName?: string,
/**
* NetBIOS_Computer_Name from script
*/
NetBIOSComputerName?: string,
/**
* DNS_Domain_Name from script
*/
DNSDomainName?: string,
/**
* DNS_Computer_Name from script (fqdn in script)
*/
DNSComputerName?: string,
/**
* DNS_Tree_Name from script (dns_forest_name in script)
*/
DNSTreeName?: string,
/**
* Product_Version from script
*/
ProductVersion?: string,
/**
* Raw timestamp for skew calculation
*/
Timestamp?: number,
Options?: Record<number, number[]>,
}
+1426
View File
File diff suppressed because it is too large. Load diff
+37 -32
View File
@@ -11,12 +11,48 @@
* log(toJSON(isVNC));
* ```
*/
export function IsVNC(host: string, port: number): IsVNCResponse | null {
export function IsVNC(ctx: any, host: string, port: number): IsVNCResponse | null {
return null;
}
/**
* VNCClient is a client for VNC servers.
* @example
* ```javascript
* const vnc = require('nuclei/vnc');
* const client = new vnc.VNCClient();
* const connected = client.Connect('acme.com', 5900, 'password');
* log(toJSON(connected));
* ```
*/
export class VNCClient {
// Constructor of VNCClient
constructor() {}
/**
* Connect connects to VNC server using given password.
* If connection and authentication is successful, it returns true.
* If connection or authentication is unsuccessful, it returns false and error.
* The connection is closed after the function returns.
* @example
* ```javascript
* const vnc = require('nuclei/vnc');
* const client = new vnc.VNCClient();
* const connected = client.Connect('acme.com', 5900, 'password');
* ```
*/
public Connect(ctx: any, host: string, port: number, password: string): boolean | null {
return null;
}
}
/**
* IsVNCResponse is the response from the IsVNC function.
* @example
@@ -33,34 +69,3 @@ export interface IsVNCResponse {
Banner?: string,
}
/**
* VNCClient is a client for VNC servers.
* @example
* ```javascript
* const vnc = require('nuclei/vnc');
* const client = new vnc.VNCClient();
* ```
*/
export class VNCClient {
// Constructor of VNCClient
constructor() {}
/**
* Connect connects to VNC server using given password.
* If connection and authentication is successful, it returns true.
* If connection or authentication is unsuccessful, it returns false and error.
* The connection is closed after the function returns.
* @example
* ```javascript
* const vnc = require('nuclei/vnc');
* const client = new vnc.VNCClient();
* const connected = client.Connect('acme.com', 5900, 'password');
* ```
*/
public Connect(host: string, port: number, password: string): boolean | null {
return null;
}
}
+112
View File
@@ -301,3 +301,115 @@ func (c *NetConn) RecvHex(N int) (string, error) {
}
return hex.Dump(bin), nil
}
// SendBytes sends raw bytes to the connection (accepts []byte from JS)
// @example
// ```javascript
// const net = require('nuclei/net');
// const conn = net.Open('tcp', 'acme.com:80');
// conn.SendBytes([0x48, 0x45, 0x4c, 0x4c, 0x4f]);
// ```
func (c *NetConn) SendBytes(data []byte) error {
c.setDeadLine()
defer c.unsetDeadLine()
length, err := c.conn.Write(data)
if err != nil {
return err
}
if length < len(data) {
return fmt.Errorf("failed to write all bytes (%d bytes written, %d bytes expected)", length, len(data))
}
return nil
}
// SendLine sends data with a newline appended
// @example
// ```javascript
// const net = require('nuclei/net');
// const conn = net.Open('tcp', 'acme.com:80');
// conn.SendLine('GET / HTTP/1.1');
// ```
func (c *NetConn) SendLine(data string) error {
return c.Send(data + "\n")
}
// RecvUntil receives data until the delimiter is found
// Returns all data including the delimiter
// @example
// ```javascript
// const net = require('nuclei/net');
// const conn = net.Open('tcp', 'acme.com:80');
// const data = conn.RecvUntil('\r\n\r\n');
// ```
func (c *NetConn) RecvUntil(delim []byte) ([]byte, error) {
c.setDeadLine()
defer c.unsetDeadLine()
var result []byte
buf := make([]byte, 1)
for {
n, err := c.conn.Read(buf)
if err != nil {
if len(result) > 0 {
return result, nil
}
return nil, err
}
if n > 0 {
result = append(result, buf[0])
if len(result) >= len(delim) {
if bytesEqual(result[len(result)-len(delim):], delim) {
return result, nil
}
}
}
}
}
// RecvUntilString receives data until the delimiter string is found
// @example
// ```javascript
// const net = require('nuclei/net');
// const conn = net.Open('tcp', 'acme.com:80');
// const data = conn.RecvUntilString('\r\n\r\n');
// ```
func (c *NetConn) RecvUntilString(delim string) (string, error) {
data, err := c.RecvUntil([]byte(delim))
if err != nil {
return "", err
}
return string(data), nil
}
// RecvLine receives data until a newline is found
// @example
// ```javascript
// const net = require('nuclei/net');
// const conn = net.Open('tcp', 'acme.com:80');
// const line = conn.RecvLine();
// ```
func (c *NetConn) RecvLine() (string, error) {
return c.RecvUntilString("\n")
}
// RecvN receives exactly N bytes (alias for RecvFull)
// @example
// ```javascript
// const net = require('nuclei/net');
// const conn = net.Open('tcp', 'acme.com:80');
// const header = conn.RecvN(16);
// ```
func (c *NetConn) RecvN(n int) ([]byte, error) {
return c.RecvFull(n)
}
func bytesEqual(a, b []byte) bool {
if len(a) != len(b) {
return false
}
for i := range a {
if a[i] != b[i] {
return false
}
}
return true
}
+245
View File
@@ -0,0 +1,245 @@
package utils
import (
"bytes"
"crypto/rand"
"math/big"
"strings"
)
const alphanumCharset = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
// PatternCreate creates a cyclic pattern of specified length for buffer overflow analysis
// The pattern is designed to have unique 4-byte sequences for easy offset identification
// @example
// ```javascript
// const utils = require('nuclei/utils');
// const pattern = utils.PatternCreate(1000);
// ```
func (u *Utils) PatternCreate(length int) []byte {
if length <= 0 {
return []byte{}
}
pattern := make([]byte, length)
idx := 0
for i := 0; i < 26 && idx < length; i++ {
for j := 0; j < 26 && idx < length; j++ {
for k := 0; k < 10 && idx < length; k++ {
pattern[idx] = byte('A' + i)
idx++
if idx < length {
pattern[idx] = byte('a' + j)
idx++
}
if idx < length {
pattern[idx] = byte('0' + k)
idx++
}
}
}
}
return pattern
}
// PatternOffset finds the offset of a 4-byte pattern within a cyclic pattern
// Returns -1 if pattern is not found
// @example
// ```javascript
// const utils = require('nuclei/utils');
// const pattern = utils.PatternCreate(1000);
// const offset = utils.PatternOffset(pattern, ToBytes('Aa0A'));
// ```
func (u *Utils) PatternOffset(pattern, search []byte) int {
return bytes.Index(pattern, search)
}
// FindBytes finds the first occurrence of needle in haystack
// Returns -1 if not found
// @example
// ```javascript
// const utils = require('nuclei/utils');
// const idx = utils.FindBytes([0x41, 0x42, 0x43, 0x44], [0x42, 0x43]);
// ```
func (u *Utils) FindBytes(haystack, needle []byte) int {
return bytes.Index(haystack, needle)
}
// FindAllBytes finds all occurrences of needle in haystack
// Returns array of indices
// @example
// ```javascript
// const utils = require('nuclei/utils');
// const indices = utils.FindAllBytes([0x41, 0x42, 0x41, 0x42], [0x41, 0x42]);
// ```
func (u *Utils) FindAllBytes(haystack, needle []byte) []int {
if len(needle) == 0 {
return []int{}
}
var indices []int
start := 0
for {
idx := bytes.Index(haystack[start:], needle)
if idx == -1 {
break
}
indices = append(indices, start+idx)
start += idx + 1
}
return indices
}
// ReplaceBytes replaces all occurrences of old with new in data
// @example
// ```javascript
// const utils = require('nuclei/utils');
// const result = utils.ReplaceBytes([0x41, 0x42, 0x43], [0x42], [0x44, 0x45]);
// ```
func (u *Utils) ReplaceBytes(data, old, new []byte) []byte {
return bytes.ReplaceAll(data, old, new)
}
// RepeatBytes repeats data count times
// @example
// ```javascript
// const utils = require('nuclei/utils');
// const repeated = utils.RepeatBytes([0x41, 0x42], 3);
// ```
func (u *Utils) RepeatBytes(data []byte, count int) []byte {
return bytes.Repeat(data, count)
}
// ReverseBytes reverses a byte slice
// @example
// ```javascript
// const utils = require('nuclei/utils');
// const reversed = utils.ReverseBytes([0x41, 0x42, 0x43]);
// ```
func (u *Utils) ReverseBytes(data []byte) []byte {
result := make([]byte, len(data))
for i, j := 0, len(data)-1; j >= 0; i, j = i+1, j-1 {
result[i] = data[j]
}
return result
}
// SwapEndian16 swaps endianness of 16-bit values in data
// @example
// ```javascript
// const utils = require('nuclei/utils');
// const swapped = utils.SwapEndian16([0x01, 0x02, 0x03, 0x04]);
// ```
func (u *Utils) SwapEndian16(data []byte) []byte {
result := make([]byte, len(data))
copy(result, data)
for i := 0; i+1 < len(result); i += 2 {
result[i], result[i+1] = result[i+1], result[i]
}
return result
}
// SwapEndian32 swaps endianness of 32-bit values in data
// @example
// ```javascript
// const utils = require('nuclei/utils');
// const swapped = utils.SwapEndian32([0x01, 0x02, 0x03, 0x04]);
// ```
func (u *Utils) SwapEndian32(data []byte) []byte {
result := make([]byte, len(data))
copy(result, data)
for i := 0; i+3 < len(result); i += 4 {
result[i], result[i+1], result[i+2], result[i+3] = result[i+3], result[i+2], result[i+1], result[i]
}
return result
}
// GenerateRandomString generates a random string of specified length
// using alphanumeric characters
// @example
// ```javascript
// const utils = require('nuclei/utils');
// const str = utils.GenerateRandomString(16);
// ```
func (u *Utils) GenerateRandomString(length int) string {
b := make([]byte, length)
charsetLen := big.NewInt(int64(len(alphanumCharset)))
for i := range b {
idx, err := rand.Int(rand.Reader, charsetLen)
if err != nil {
b[i] = alphanumCharset[0]
continue
}
b[i] = alphanumCharset[idx.Int64()]
}
return string(b)
}
// GenerateRandomAlphanumeric generates a random alphanumeric string
// (alias for GenerateRandomString)
// @example
// ```javascript
// const utils = require('nuclei/utils');
// const str = utils.GenerateRandomAlphanumeric(16);
// ```
func (u *Utils) GenerateRandomAlphanumeric(length int) string {
return u.GenerateRandomString(length)
}
// GenerateRandomBytes generates random bytes of specified length
// @example
// ```javascript
// const utils = require('nuclei/utils');
// const bytes = utils.GenerateRandomBytes(16);
// ```
func (u *Utils) GenerateRandomBytes(length int) []byte {
b := make([]byte, length)
_, _ = rand.Read(b)
return b
}
// RepeatString repeats a string count times
// @example
// ```javascript
// const utils = require('nuclei/utils');
// const repeated = utils.RepeatString('A', 100);
// ```
func (u *Utils) RepeatString(s string, count int) string {
return strings.Repeat(s, count)
}
// PadLeft pads string on the left to specified length
// @example
// ```javascript
// const utils = require('nuclei/utils');
// const padded = utils.PadLeft('123', 8, '0');
// ```
func (u *Utils) PadLeft(s string, length int, pad string) string {
if len(s) >= length {
return s
}
if pad == "" {
pad = " "
}
for len(s) < length {
s = pad + s
}
return s[len(s)-length:]
}
// PadRight pads string on the right to specified length
// @example
// ```javascript
// const utils = require('nuclei/utils');
// const padded = utils.PadRight('123', 8, '0');
// ```
func (u *Utils) PadRight(s string, length int, pad string) string {
if len(s) >= length {
return s
}
if pad == "" {
pad = " "
}
for len(s) < length {
s = s + pad
}
return s[:length]
}
+132
View File
@@ -0,0 +1,132 @@
package utils
import (
"bytes"
"compress/flate"
"compress/gzip"
"compress/zlib"
"io"
)
// ZlibCompress compresses data using zlib
// @example
// ```javascript
// const utils = require('nuclei/utils');
// const compressed = utils.ZlibCompress('hello world');
// ```
func (u *Utils) ZlibCompress(data []byte) ([]byte, error) {
var buf bytes.Buffer
w := zlib.NewWriter(&buf)
_, err := w.Write(data)
if err != nil {
return nil, err
}
if err := w.Close(); err != nil {
return nil, err
}
return buf.Bytes(), nil
}
// ZlibDecompress decompresses zlib compressed data
// @example
// ```javascript
// const utils = require('nuclei/utils');
// const decompressed = utils.ZlibDecompress(compressed);
// ```
func (u *Utils) ZlibDecompress(data []byte) ([]byte, error) {
r, err := zlib.NewReader(bytes.NewReader(data))
if err != nil {
return nil, err
}
result, err := io.ReadAll(r)
cerr := r.Close()
if err != nil {
return nil, err
}
if cerr != nil {
return nil, cerr
}
return result, nil
}
// GzipCompress compresses data using gzip
// @example
// ```javascript
// const utils = require('nuclei/utils');
// const compressed = utils.GzipCompress('hello world');
// ```
func (u *Utils) GzipCompress(data []byte) ([]byte, error) {
var buf bytes.Buffer
w := gzip.NewWriter(&buf)
_, err := w.Write(data)
if err != nil {
return nil, err
}
if err := w.Close(); err != nil {
return nil, err
}
return buf.Bytes(), nil
}
// GzipDecompress decompresses gzip compressed data
// @example
// ```javascript
// const utils = require('nuclei/utils');
// const decompressed = utils.GzipDecompress(compressed);
// ```
func (u *Utils) GzipDecompress(data []byte) ([]byte, error) {
r, err := gzip.NewReader(bytes.NewReader(data))
if err != nil {
return nil, err
}
result, err := io.ReadAll(r)
cerr := r.Close()
if err != nil {
return nil, err
}
if cerr != nil {
return nil, cerr
}
return result, nil
}
// DeflateCompress compresses data using raw deflate (no zlib header)
// @example
// ```javascript
// const utils = require('nuclei/utils');
// const compressed = utils.DeflateCompress('hello world');
// ```
func (u *Utils) DeflateCompress(data []byte) ([]byte, error) {
var buf bytes.Buffer
w, err := flate.NewWriter(&buf, flate.DefaultCompression)
if err != nil {
return nil, err
}
_, err = w.Write(data)
if err != nil {
return nil, err
}
if err := w.Close(); err != nil {
return nil, err
}
return buf.Bytes(), nil
}
// DeflateDecompress decompresses raw deflate compressed data
// @example
// ```javascript
// const utils = require('nuclei/utils');
// const decompressed = utils.DeflateDecompress(compressed);
// ```
func (u *Utils) DeflateDecompress(data []byte) ([]byte, error) {
r := flate.NewReader(bytes.NewReader(data))
result, err := io.ReadAll(r)
cerr := r.Close()
if err != nil {
return nil, err
}
if cerr != nil {
return nil, cerr
}
return result, nil
}
+285
View File
@@ -0,0 +1,285 @@
package utils
import (
"crypto/aes"
"crypto/cipher"
"crypto/des"
"crypto/rc4"
"errors"
"fmt"
)
// AESEncryptECB encrypts data using AES in ECB mode
// Key must be 16, 24, or 32 bytes for AES-128, AES-192, AES-256
// @example
// ```javascript
// const utils = require('nuclei/utils');
// const key = Rand(16);
// const encrypted = utils.AESEncryptECB(ToBytes('plaintext'), key);
// ```
func (u *Utils) AESEncryptECB(plaintext, key []byte) ([]byte, error) {
block, err := aes.NewCipher(key)
if err != nil {
return nil, err
}
plaintext = pkcs7Pad(plaintext, aes.BlockSize)
ciphertext := make([]byte, len(plaintext))
for i := 0; i < len(plaintext); i += aes.BlockSize {
block.Encrypt(ciphertext[i:], plaintext[i:])
}
return ciphertext, nil
}
// AESDecryptECB decrypts data using AES in ECB mode
// @example
// ```javascript
// const utils = require('nuclei/utils');
// const decrypted = utils.AESDecryptECB(encrypted, key);
// ```
func (u *Utils) AESDecryptECB(ciphertext, key []byte) ([]byte, error) {
block, err := aes.NewCipher(key)
if err != nil {
return nil, err
}
if len(ciphertext)%aes.BlockSize != 0 {
return nil, errors.New("ciphertext is not a multiple of the block size")
}
plaintext := make([]byte, len(ciphertext))
for i := 0; i < len(ciphertext); i += aes.BlockSize {
block.Decrypt(plaintext[i:], ciphertext[i:])
}
return pkcs7Unpad(plaintext)
}
// AESEncryptCBC encrypts data using AES in CBC mode
// Key must be 16, 24, or 32 bytes. IV must be 16 bytes.
// @example
// ```javascript
// const utils = require('nuclei/utils');
// const key = Rand(16);
// const iv = Rand(16);
// const encrypted = utils.AESEncryptCBC(ToBytes('plaintext'), key, iv);
// ```
func (u *Utils) AESEncryptCBC(plaintext, key, iv []byte) ([]byte, error) {
block, err := aes.NewCipher(key)
if err != nil {
return nil, err
}
if len(iv) != aes.BlockSize {
return nil, errors.New("IV must be 16 bytes")
}
plaintext = pkcs7Pad(plaintext, aes.BlockSize)
ciphertext := make([]byte, len(plaintext))
mode := cipher.NewCBCEncrypter(block, iv)
mode.CryptBlocks(ciphertext, plaintext)
return ciphertext, nil
}
// AESDecryptCBC decrypts data using AES in CBC mode
// @example
// ```javascript
// const utils = require('nuclei/utils');
// const decrypted = utils.AESDecryptCBC(encrypted, key, iv);
// ```
func (u *Utils) AESDecryptCBC(ciphertext, key, iv []byte) ([]byte, error) {
block, err := aes.NewCipher(key)
if err != nil {
return nil, err
}
if len(iv) != aes.BlockSize {
return nil, errors.New("IV must be 16 bytes")
}
if len(ciphertext)%aes.BlockSize != 0 {
return nil, errors.New("ciphertext is not a multiple of the block size")
}
plaintext := make([]byte, len(ciphertext))
mode := cipher.NewCBCDecrypter(block, iv)
mode.CryptBlocks(plaintext, ciphertext)
return pkcs7Unpad(plaintext)
}
// AESEncryptGCM encrypts data using AES in GCM mode
// Key must be 16, 24, or 32 bytes. Nonce should be 12 bytes.
// Returns ciphertext with authentication tag appended.
// @example
// ```javascript
// const utils = require('nuclei/utils');
// const key = Rand(16);
// const nonce = Rand(12);
// const encrypted = utils.AESEncryptGCM(ToBytes('plaintext'), key, nonce);
// ```
func (u *Utils) AESEncryptGCM(plaintext, key, nonce []byte) ([]byte, error) {
block, err := aes.NewCipher(key)
if err != nil {
return nil, err
}
gcm, err := cipher.NewGCM(block)
if err != nil {
return nil, err
}
if len(nonce) != gcm.NonceSize() {
return nil, fmt.Errorf("invalid nonce length: got %d, want %d", len(nonce), gcm.NonceSize())
}
ciphertext := gcm.Seal(nil, nonce, plaintext, nil)
return ciphertext, nil
}
// AESDecryptGCM decrypts data using AES in GCM mode
// Expects ciphertext with authentication tag appended.
// @example
// ```javascript
// const utils = require('nuclei/utils');
// const decrypted = utils.AESDecryptGCM(encrypted, key, nonce);
// ```
func (u *Utils) AESDecryptGCM(ciphertext, key, nonce []byte) ([]byte, error) {
block, err := aes.NewCipher(key)
if err != nil {
return nil, err
}
gcm, err := cipher.NewGCM(block)
if err != nil {
return nil, err
}
if len(nonce) != gcm.NonceSize() {
return nil, fmt.Errorf("invalid nonce length: got %d, want %d", len(nonce), gcm.NonceSize())
}
return gcm.Open(nil, nonce, ciphertext, nil)
}
// DESEncryptECB encrypts data using DES in ECB mode
// Key must be 8 bytes
// @example
// ```javascript
// const utils = require('nuclei/utils');
// const key = Rand(8);
// const encrypted = utils.DESEncryptECB(ToBytes('plaintext'), key);
// ```
func (u *Utils) DESEncryptECB(plaintext, key []byte) ([]byte, error) {
block, err := des.NewCipher(key)
if err != nil {
return nil, err
}
plaintext = pkcs7Pad(plaintext, des.BlockSize)
ciphertext := make([]byte, len(plaintext))
for i := 0; i < len(plaintext); i += des.BlockSize {
block.Encrypt(ciphertext[i:], plaintext[i:])
}
return ciphertext, nil
}
// DESDecryptECB decrypts data using DES in ECB mode
// @example
// ```javascript
// const utils = require('nuclei/utils');
// const decrypted = utils.DESDecryptECB(encrypted, key);
// ```
func (u *Utils) DESDecryptECB(ciphertext, key []byte) ([]byte, error) {
block, err := des.NewCipher(key)
if err != nil {
return nil, err
}
if len(ciphertext)%des.BlockSize != 0 {
return nil, errors.New("ciphertext is not a multiple of the block size")
}
plaintext := make([]byte, len(ciphertext))
for i := 0; i < len(ciphertext); i += des.BlockSize {
block.Decrypt(plaintext[i:], ciphertext[i:])
}
return pkcs7Unpad(plaintext)
}
// DES3EncryptCBC encrypts data using Triple DES in CBC mode
// Key must be 24 bytes. IV must be 8 bytes.
// @example
// ```javascript
// const utils = require('nuclei/utils');
// const key = Rand(24);
// const iv = Rand(8);
// const encrypted = utils.DES3EncryptCBC(ToBytes('plaintext'), key, iv);
// ```
func (u *Utils) DES3EncryptCBC(plaintext, key, iv []byte) ([]byte, error) {
block, err := des.NewTripleDESCipher(key)
if err != nil {
return nil, err
}
if len(iv) != des.BlockSize {
return nil, errors.New("IV must be 8 bytes")
}
plaintext = pkcs7Pad(plaintext, des.BlockSize)
ciphertext := make([]byte, len(plaintext))
mode := cipher.NewCBCEncrypter(block, iv)
mode.CryptBlocks(ciphertext, plaintext)
return ciphertext, nil
}
// DES3DecryptCBC decrypts data using Triple DES in CBC mode
// @example
// ```javascript
// const utils = require('nuclei/utils');
// const decrypted = utils.DES3DecryptCBC(encrypted, key, iv);
// ```
func (u *Utils) DES3DecryptCBC(ciphertext, key, iv []byte) ([]byte, error) {
block, err := des.NewTripleDESCipher(key)
if err != nil {
return nil, err
}
if len(iv) != des.BlockSize {
return nil, errors.New("IV must be 8 bytes")
}
if len(ciphertext)%des.BlockSize != 0 {
return nil, errors.New("ciphertext is not a multiple of the block size")
}
plaintext := make([]byte, len(ciphertext))
mode := cipher.NewCBCDecrypter(block, iv)
mode.CryptBlocks(plaintext, ciphertext)
return pkcs7Unpad(plaintext)
}
// RC4Encrypt encrypts/decrypts data using RC4 (symmetric)
// @example
// ```javascript
// const utils = require('nuclei/utils');
// const key = Rand(16);
// const encrypted = utils.RC4Encrypt(ToBytes('plaintext'), key);
// const decrypted = utils.RC4Encrypt(encrypted, key); // RC4 is symmetric
// ```
func (u *Utils) RC4Encrypt(data, key []byte) ([]byte, error) {
c, err := rc4.NewCipher(key)
if err != nil {
return nil, err
}
result := make([]byte, len(data))
c.XORKeyStream(result, data)
return result, nil
}
// XORBytes XORs data with a repeating key
// @example
// ```javascript
// const utils = require('nuclei/utils');
// const xored = utils.XORBytes([0x41, 0x42, 0x43], [0x01, 0x02]);
// ```
func (u *Utils) XORBytes(data, key []byte) []byte {
if len(key) == 0 {
return data
}
result := make([]byte, len(data))
for i := range data {
result[i] = data[i] ^ key[i%len(key)]
}
return result
}
// XORSingleByte XORs each byte of data with a single byte key
// @example
// ```javascript
// const utils = require('nuclei/utils');
// const xored = utils.XORSingleByte([0x41, 0x42, 0x43], 0x01);
// ```
func (u *Utils) XORSingleByte(data []byte, key byte) []byte {
result := make([]byte, len(data))
for i := range data {
result[i] = data[i] ^ key
}
return result
}
+217
View File
@@ -0,0 +1,217 @@
package utils
import (
"encoding/base64"
"encoding/hex"
"html"
"net/url"
"unicode/utf16"
)
// URLEncode URL encodes a string
// @example
// ```javascript
// const utils = require('nuclei/utils');
// const encoded = utils.URLEncode('hello world');
// ```
func (u *Utils) URLEncode(data string) string {
return url.QueryEscape(data)
}
// URLDecode URL decodes a string
// @example
// ```javascript
// const utils = require('nuclei/utils');
// const decoded = utils.URLDecode('hello%20world');
// ```
func (u *Utils) URLDecode(data string) (string, error) {
return url.QueryUnescape(data)
}
// HTMLEncode HTML encodes a string
// @example
// ```javascript
// const utils = require('nuclei/utils');
// const encoded = utils.HTMLEncode('<script>alert(1)</script>');
// ```
func (u *Utils) HTMLEncode(data string) string {
return html.EscapeString(data)
}
// HTMLDecode HTML decodes a string
// @example
// ```javascript
// const utils = require('nuclei/utils');
// const decoded = utils.HTMLDecode('&lt;script&gt;');
// ```
func (u *Utils) HTMLDecode(data string) string {
return html.UnescapeString(data)
}
// HexEncode encodes bytes to hex string
// @example
// ```javascript
// const utils = require('nuclei/utils');
// const hex = utils.HexEncode([0x48, 0x65, 0x6c, 0x6c, 0x6f]);
// ```
func (u *Utils) HexEncode(data []byte) string {
return hex.EncodeToString(data)
}
// HexDecode decodes hex string to bytes
// @example
// ```javascript
// const utils = require('nuclei/utils');
// const bytes = utils.HexDecode('48656c6c6f');
// ```
func (u *Utils) HexDecode(data string) ([]byte, error) {
return hex.DecodeString(data)
}
// Base64Encode encodes bytes to base64 string (standard encoding)
// @example
// ```javascript
// const utils = require('nuclei/utils');
// const encoded = utils.Base64Encode([0x48, 0x65, 0x6c, 0x6c, 0x6f]);
// ```
func (u *Utils) Base64Encode(data []byte) string {
return base64.StdEncoding.EncodeToString(data)
}
// Base64Decode decodes base64 string to bytes (standard encoding)
// @example
// ```javascript
// const utils = require('nuclei/utils');
// const bytes = utils.Base64Decode('SGVsbG8=');
// ```
func (u *Utils) Base64Decode(data string) ([]byte, error) {
return base64.StdEncoding.DecodeString(data)
}
// Base64URLEncode encodes bytes to URL-safe base64 string
// @example
// ```javascript
// const utils = require('nuclei/utils');
// const encoded = utils.Base64URLEncode([0x48, 0x65, 0x6c, 0x6c, 0x6f]);
// ```
func (u *Utils) Base64URLEncode(data []byte) string {
return base64.URLEncoding.EncodeToString(data)
}
// Base64URLDecode decodes URL-safe base64 string to bytes
// @example
// ```javascript
// const utils = require('nuclei/utils');
// const bytes = utils.Base64URLDecode('SGVsbG8');
// ```
func (u *Utils) Base64URLDecode(data string) ([]byte, error) {
return base64.URLEncoding.DecodeString(data)
}
// Base64RawEncode encodes bytes to base64 string without padding
// @example
// ```javascript
// const utils = require('nuclei/utils');
// const encoded = utils.Base64RawEncode([0x48, 0x65, 0x6c, 0x6c, 0x6f]);
// ```
func (u *Utils) Base64RawEncode(data []byte) string {
return base64.RawStdEncoding.EncodeToString(data)
}
// Base64RawDecode decodes base64 string without padding to bytes
// @example
// ```javascript
// const utils = require('nuclei/utils');
// const bytes = utils.Base64RawDecode('SGVsbG8');
// ```
func (u *Utils) Base64RawDecode(data string) ([]byte, error) {
return base64.RawStdEncoding.DecodeString(data)
}
// Base64RawURLEncode encodes bytes to URL-safe base64 string without padding
// @example
// ```javascript
// const utils = require('nuclei/utils');
// const encoded = utils.Base64RawURLEncode([0x48, 0x65, 0x6c, 0x6c, 0x6f]);
// ```
func (u *Utils) Base64RawURLEncode(data []byte) string {
return base64.RawURLEncoding.EncodeToString(data)
}
// Base64RawURLDecode decodes URL-safe base64 string without padding to bytes
// @example
// ```javascript
// const utils = require('nuclei/utils');
// const bytes = utils.Base64RawURLDecode('SGVsbG8');
// ```
func (u *Utils) Base64RawURLDecode(data string) ([]byte, error) {
return base64.RawURLEncoding.DecodeString(data)
}
// UTF16LEEncode encodes a string to UTF-16 Little Endian bytes
// @example
// ```javascript
// const utils = require('nuclei/utils');
// const encoded = utils.UTF16LEEncode('hello');
// ```
func (u *Utils) UTF16LEEncode(data string) []byte {
runes := []rune(data)
u16 := utf16.Encode(runes)
result := make([]byte, len(u16)*2)
for i, r := range u16 {
result[i*2] = byte(r)
result[i*2+1] = byte(r >> 8)
}
return result
}
// UTF16LEDecode decodes UTF-16 Little Endian bytes to a string
// @example
// ```javascript
// const utils = require('nuclei/utils');
// const decoded = utils.UTF16LEDecode([0x68, 0x00, 0x65, 0x00]);
// ```
func (u *Utils) UTF16LEDecode(data []byte) string {
if len(data)%2 != 0 {
data = append(data, 0)
}
u16 := make([]uint16, len(data)/2)
for i := 0; i < len(u16); i++ {
u16[i] = uint16(data[i*2]) | uint16(data[i*2+1])<<8
}
return string(utf16.Decode(u16))
}
// UTF16BEEncode encodes a string to UTF-16 Big Endian bytes
// @example
// ```javascript
// const utils = require('nuclei/utils');
// const encoded = utils.UTF16BEEncode('hello');
// ```
func (u *Utils) UTF16BEEncode(data string) []byte {
runes := []rune(data)
u16 := utf16.Encode(runes)
result := make([]byte, len(u16)*2)
for i, r := range u16 {
result[i*2] = byte(r >> 8)
result[i*2+1] = byte(r)
}
return result
}
// UTF16BEDecode decodes UTF-16 Big Endian bytes to a string
// @example
// ```javascript
// const utils = require('nuclei/utils');
// const decoded = utils.UTF16BEDecode([0x00, 0x68, 0x00, 0x65]);
// ```
func (u *Utils) UTF16BEDecode(data []byte) string {
if len(data)%2 != 0 {
data = append(data, 0)
}
u16 := make([]uint16, len(data)/2)
for i := 0; i < len(u16); i++ {
u16[i] = uint16(data[i*2])<<8 | uint16(data[i*2+1])
}
return string(utf16.Decode(u16))
}
+217
View File
@@ -0,0 +1,217 @@
package utils
import (
"crypto/hmac"
"crypto/md5"
"crypto/sha1"
"crypto/sha256"
"crypto/sha512"
"encoding/hex"
"hash/adler32"
"hash/crc32"
//nolint:staticcheck // SA1019: MD4 is deprecated but required for NTLM compatibility
"golang.org/x/crypto/md4"
)
// MD4 computes MD4 hash of data (needed for NTLM)
// @example
// ```javascript
// const utils = require('nuclei/utils');
// const hash = utils.MD4('password');
// ```
func (u *Utils) MD4(data []byte) string {
h := md4.New()
h.Write(data)
return hex.EncodeToString(h.Sum(nil))
}
// MD4Raw computes MD4 hash of data and returns raw bytes
// @example
// ```javascript
// const utils = require('nuclei/utils');
// const hash = utils.MD4Raw('password');
// ```
func (u *Utils) MD4Raw(data []byte) []byte {
h := md4.New()
h.Write(data)
return h.Sum(nil)
}
// MD5 computes MD5 hash of data
// @example
// ```javascript
// const utils = require('nuclei/utils');
// const hash = utils.MD5('password');
// ```
func (u *Utils) MD5(data []byte) string {
h := md5.Sum(data)
return hex.EncodeToString(h[:])
}
// MD5Raw computes MD5 hash of data and returns raw bytes
// @example
// ```javascript
// const utils = require('nuclei/utils');
// const hash = utils.MD5Raw('password');
// ```
func (u *Utils) MD5Raw(data []byte) []byte {
h := md5.Sum(data)
return h[:]
}
// SHA1 computes SHA1 hash of data
// @example
// ```javascript
// const utils = require('nuclei/utils');
// const hash = utils.SHA1('password');
// ```
func (u *Utils) SHA1(data []byte) string {
h := sha1.Sum(data)
return hex.EncodeToString(h[:])
}
// SHA1Raw computes SHA1 hash of data and returns raw bytes
// @example
// ```javascript
// const utils = require('nuclei/utils');
// const hash = utils.SHA1Raw('password');
// ```
func (u *Utils) SHA1Raw(data []byte) []byte {
h := sha1.Sum(data)
return h[:]
}
// SHA256 computes SHA256 hash of data
// @example
// ```javascript
// const utils = require('nuclei/utils');
// const hash = utils.SHA256('password');
// ```
func (u *Utils) SHA256(data []byte) string {
h := sha256.Sum256(data)
return hex.EncodeToString(h[:])
}
// SHA256Raw computes SHA256 hash of data and returns raw bytes
// @example
// ```javascript
// const utils = require('nuclei/utils');
// const hash = utils.SHA256Raw('password');
// ```
func (u *Utils) SHA256Raw(data []byte) []byte {
h := sha256.Sum256(data)
return h[:]
}
// SHA384 computes SHA384 hash of data
// @example
// ```javascript
// const utils = require('nuclei/utils');
// const hash = utils.SHA384('password');
// ```
func (u *Utils) SHA384(data []byte) string {
h := sha512.Sum384(data)
return hex.EncodeToString(h[:])
}
// SHA384Raw computes SHA384 hash of data and returns raw bytes
// @example
// ```javascript
// const utils = require('nuclei/utils');
// const hash = utils.SHA384Raw('password');
// ```
func (u *Utils) SHA384Raw(data []byte) []byte {
h := sha512.Sum384(data)
return h[:]
}
// SHA512 computes SHA512 hash of data
// @example
// ```javascript
// const utils = require('nuclei/utils');
// const hash = utils.SHA512('password');
// ```
func (u *Utils) SHA512(data []byte) string {
h := sha512.Sum512(data)
return hex.EncodeToString(h[:])
}
// SHA512Raw computes SHA512 hash of data and returns raw bytes
// @example
// ```javascript
// const utils = require('nuclei/utils');
// const hash = utils.SHA512Raw('password');
// ```
func (u *Utils) SHA512Raw(data []byte) []byte {
h := sha512.Sum512(data)
return h[:]
}
// HMACMD5 computes HMAC-MD5 of data with key
// @example
// ```javascript
// const utils = require('nuclei/utils');
// const hmac = utils.HMACMD5('message', 'key');
// ```
func (u *Utils) HMACMD5(data, key []byte) []byte {
h := hmac.New(md5.New, key)
h.Write(data)
return h.Sum(nil)
}
// HMACSHA1 computes HMAC-SHA1 of data with key
// @example
// ```javascript
// const utils = require('nuclei/utils');
// const hmac = utils.HMACSHA1('message', 'key');
// ```
func (u *Utils) HMACSHA1(data, key []byte) []byte {
h := hmac.New(sha1.New, key)
h.Write(data)
return h.Sum(nil)
}
// HMACSHA256 computes HMAC-SHA256 of data with key
// @example
// ```javascript
// const utils = require('nuclei/utils');
// const hmac = utils.HMACSHA256('message', 'key');
// ```
func (u *Utils) HMACSHA256(data, key []byte) []byte {
h := hmac.New(sha256.New, key)
h.Write(data)
return h.Sum(nil)
}
// HMACSHA512 computes HMAC-SHA512 of data with key
// @example
// ```javascript
// const utils = require('nuclei/utils');
// const hmac = utils.HMACSHA512('message', 'key');
// ```
func (u *Utils) HMACSHA512(data, key []byte) []byte {
h := hmac.New(sha512.New, key)
h.Write(data)
return h.Sum(nil)
}
// CRC32 computes CRC32 checksum of data
// @example
// ```javascript
// const utils = require('nuclei/utils');
// const checksum = utils.CRC32('data');
// ```
func (u *Utils) CRC32(data []byte) uint32 {
return crc32.ChecksumIEEE(data)
}
// Adler32 computes Adler32 checksum of data
// @example
// ```javascript
// const utils = require('nuclei/utils');
// const checksum = utils.Adler32('data');
// ```
func (u *Utils) Adler32(data []byte) uint32 {
return adler32.Checksum(data)
}
+98
View File
@@ -0,0 +1,98 @@
package utils
import (
"bytes"
"errors"
)
// PKCS7Pad pads data to the specified block size using PKCS7 padding
// @example
// ```javascript
// const utils = require('nuclei/utils');
// const padded = utils.PKCS7Pad([0x41, 0x42, 0x43], 16);
// ```
func (u *Utils) PKCS7Pad(data []byte, blockSize int) []byte {
if blockSize <= 0 || blockSize > 255 {
return data
}
return pkcs7Pad(data, blockSize)
}
// PKCS7Unpad removes PKCS7 padding from data
// @example
// ```javascript
// const utils = require('nuclei/utils');
// const unpadded = utils.PKCS7Unpad(padded);
// ```
func (u *Utils) PKCS7Unpad(data []byte) ([]byte, error) {
return pkcs7Unpad(data)
}
// ZeroPad pads data with zeros to the specified length
// @example
// ```javascript
// const utils = require('nuclei/utils');
// const padded = utils.ZeroPad([0x41, 0x42], 8);
// ```
func (u *Utils) ZeroPad(data []byte, length int) []byte {
if len(data) >= length {
return data
}
result := make([]byte, length)
copy(result, data)
return result
}
// NullPad pads data with null bytes to the specified length
// (same as ZeroPad, provided for clarity)
// @example
// ```javascript
// const utils = require('nuclei/utils');
// const padded = utils.NullPad([0x41, 0x42], 8);
// ```
func (u *Utils) NullPad(data []byte, length int) []byte {
return u.ZeroPad(data, length)
}
// PadToBlockSize pads data to be a multiple of blockSize using zero padding
// @example
// ```javascript
// const utils = require('nuclei/utils');
// const padded = utils.PadToBlockSize([0x41, 0x42, 0x43], 8);
// ```
func (u *Utils) PadToBlockSize(data []byte, blockSize int) []byte {
if blockSize <= 0 {
return data
}
remainder := len(data) % blockSize
if remainder == 0 {
return data
}
padding := blockSize - remainder
return append(data, bytes.Repeat([]byte{0}, padding)...)
}
func pkcs7Pad(data []byte, blockSize int) []byte {
if blockSize <= 0 || blockSize > 255 {
return data
}
padding := blockSize - len(data)%blockSize
padtext := bytes.Repeat([]byte{byte(padding)}, padding)
return append(data, padtext...)
}
func pkcs7Unpad(data []byte) ([]byte, error) {
if len(data) == 0 {
return nil, errors.New("data is empty")
}
padding := int(data[len(data)-1])
if padding == 0 || padding > len(data) {
return nil, errors.New("invalid padding")
}
for i := len(data) - padding; i < len(data); i++ {
if data[i] != byte(padding) {
return nil, errors.New("invalid padding")
}
}
return data[:len(data)-padding], nil
}
+330
View File
@@ -0,0 +1,330 @@
package utils
import (
"encoding/binary"
)
// PackUint8 packs a uint8 value into a byte slice
// @example
// ```javascript
// const utils = require('nuclei/utils');
// const u = new utils.Utils();
// const packed = u.PackUint8(255);
// ```
func (u *Utils) PackUint8(value int) []byte {
return []byte{byte(value & 0xFF)}
}
// PackUint16LE packs a uint16 value into a little-endian byte slice
// @example
// ```javascript
// const utils = require('nuclei/utils');
// const u = new utils.Utils();
// const packed = u.PackUint16LE(0x1234); // returns [0x34, 0x12]
// ```
func (u *Utils) PackUint16LE(value int) []byte {
buf := make([]byte, 2)
binary.LittleEndian.PutUint16(buf, uint16(value))
return buf
}
// PackUint16BE packs a uint16 value into a big-endian byte slice
// @example
// ```javascript
// const utils = require('nuclei/utils');
// const u = new utils.Utils();
// const packed = u.PackUint16BE(0x1234); // returns [0x12, 0x34]
// ```
func (u *Utils) PackUint16BE(value int) []byte {
buf := make([]byte, 2)
binary.BigEndian.PutUint16(buf, uint16(value))
return buf
}
// PackUint32LE packs a uint32 value into a little-endian byte slice
// @example
// ```javascript
// const utils = require('nuclei/utils');
// const u = new utils.Utils();
// const packed = u.PackUint32LE(0x12345678); // returns [0x78, 0x56, 0x34, 0x12]
// ```
func (u *Utils) PackUint32LE(value int) []byte {
buf := make([]byte, 4)
binary.LittleEndian.PutUint32(buf, uint32(value))
return buf
}
// PackUint32BE packs a uint32 value into a big-endian byte slice
// @example
// ```javascript
// const utils = require('nuclei/utils');
// const u = new utils.Utils();
// const packed = u.PackUint32BE(0x12345678); // returns [0x12, 0x34, 0x56, 0x78]
// ```
func (u *Utils) PackUint32BE(value int) []byte {
buf := make([]byte, 4)
binary.BigEndian.PutUint32(buf, uint32(value))
return buf
}
// PackUint64LE packs a uint64 value into a little-endian byte slice
// @example
// ```javascript
// const utils = require('nuclei/utils');
// const u = new utils.Utils();
// const packed = u.PackUint64LE(0x123456789ABCDEF0);
// ```
func (u *Utils) PackUint64LE(value int64) []byte {
buf := make([]byte, 8)
binary.LittleEndian.PutUint64(buf, uint64(value))
return buf
}
// PackUint64BE packs a uint64 value into a big-endian byte slice
// @example
// ```javascript
// const utils = require('nuclei/utils');
// const u = new utils.Utils();
// const packed = u.PackUint64BE(0x123456789ABCDEF0);
// ```
func (u *Utils) PackUint64BE(value int64) []byte {
buf := make([]byte, 8)
binary.BigEndian.PutUint64(buf, uint64(value))
return buf
}
// UnpackUint16LE unpacks a little-endian uint16 from bytes at the given offset
// @example
// ```javascript
// const utils = require('nuclei/utils');
// const u = new utils.Utils();
// const value = u.UnpackUint16LE([0x34, 0x12, 0x00, 0x00], 0); // returns 0x1234
// ```
func (u *Utils) UnpackUint16LE(data []byte, offset int) int {
if offset+2 > len(data) {
return 0
}
return int(binary.LittleEndian.Uint16(data[offset:]))
}
// UnpackUint16BE unpacks a big-endian uint16 from bytes at the given offset
// @example
// ```javascript
// const utils = require('nuclei/utils');
// const u = new utils.Utils();
// const value = u.UnpackUint16BE([0x12, 0x34, 0x00, 0x00], 0); // returns 0x1234
// ```
func (u *Utils) UnpackUint16BE(data []byte, offset int) int {
if offset+2 > len(data) {
return 0
}
return int(binary.BigEndian.Uint16(data[offset:]))
}
// UnpackUint32LE unpacks a little-endian uint32 from bytes at the given offset
// @example
// ```javascript
// const utils = require('nuclei/utils');
// const u = new utils.Utils();
// const value = u.UnpackUint32LE([0x78, 0x56, 0x34, 0x12], 0); // returns 0x12345678
// ```
func (u *Utils) UnpackUint32LE(data []byte, offset int) int {
if offset+4 > len(data) {
return 0
}
return int(binary.LittleEndian.Uint32(data[offset:]))
}
// UnpackUint32BE unpacks a big-endian uint32 from bytes at the given offset
// @example
// ```javascript
// const utils = require('nuclei/utils');
// const u = new utils.Utils();
// const value = u.UnpackUint32BE([0x12, 0x34, 0x56, 0x78], 0); // returns 0x12345678
// ```
func (u *Utils) UnpackUint32BE(data []byte, offset int) int {
if offset+4 > len(data) {
return 0
}
return int(binary.BigEndian.Uint32(data[offset:]))
}
// UnpackUint64LE unpacks a little-endian uint64 from bytes at the given offset
// @example
// ```javascript
// const utils = require('nuclei/utils');
// const u = new utils.Utils();
// const value = u.UnpackUint64LE(bytes, 0);
// ```
func (u *Utils) UnpackUint64LE(data []byte, offset int) int64 {
if offset+8 > len(data) {
return 0
}
return int64(binary.LittleEndian.Uint64(data[offset:]))
}
// UnpackUint64BE unpacks a big-endian uint64 from bytes at the given offset
// @example
// ```javascript
// const utils = require('nuclei/utils');
// const u = new utils.Utils();
// const value = u.UnpackUint64BE(bytes, 0);
// ```
func (u *Utils) UnpackUint64BE(data []byte, offset int) int64 {
if offset+8 > len(data) {
return 0
}
return int64(binary.BigEndian.Uint64(data[offset:]))
}
// ConcatBytes concatenates multiple byte slices into one
// @example
// ```javascript
// const utils = require('nuclei/utils');
// const u = new utils.Utils();
// const result = u.ConcatBytes([0x01, 0x02], [0x03, 0x04], [0x05]);
// ```
func (u *Utils) ConcatBytes(arrays ...[]byte) []byte {
totalLen := 0
for _, arr := range arrays {
totalLen += len(arr)
}
result := make([]byte, 0, totalLen)
for _, arr := range arrays {
result = append(result, arr...)
}
return result
}
// StringToBytes converts a string to a byte slice
// @example
// ```javascript
// const utils = require('nuclei/utils');
// const u = new utils.Utils();
// const bytes = u.StringToBytes('hello');
// ```
func (u *Utils) StringToBytes(s string) []byte {
return []byte(s)
}
// BytesToString converts a byte slice to a string
// @example
// ```javascript
// const utils = require('nuclei/utils');
// const u = new utils.Utils();
// const str = u.BytesToString([0x68, 0x65, 0x6c, 0x6c, 0x6f]);
// ```
func (u *Utils) BytesToString(data []byte) string {
return string(data)
}
// ToBytes converts various input types to a byte slice
// Handles: []byte, []interface{} (with numeric values), string
// @example
// ```javascript
// const utils = require('nuclei/utils');
// const u = new utils.Utils();
// const bytes = u.ToBytes([0x41, 0x42, 0x43]);
// ```
func (u *Utils) ToBytes(data interface{}) []byte {
switch v := data.(type) {
case []byte:
return v
case string:
return []byte(v)
case []interface{}:
result := make([]byte, len(v))
for i, val := range v {
switch n := val.(type) {
case int:
result[i] = byte(n)
case int64:
result[i] = byte(n)
case float64:
result[i] = byte(int(n))
default:
result[i] = 0
}
}
return result
default:
return nil
}
}
// P8 packs a uint8 value (pwntools-style alias for PackUint8)
func (u *Utils) P8(value int) []byte { return u.PackUint8(value) }
// P16 packs a uint16 value as little-endian (pwntools-style alias)
func (u *Utils) P16(value int) []byte { return u.PackUint16LE(value) }
// P16BE packs a uint16 value as big-endian
func (u *Utils) P16BE(value int) []byte { return u.PackUint16BE(value) }
// P32 packs a uint32 value as little-endian (pwntools-style alias)
func (u *Utils) P32(value int) []byte { return u.PackUint32LE(value) }
// P32BE packs a uint32 value as big-endian
func (u *Utils) P32BE(value int) []byte { return u.PackUint32BE(value) }
// P64 packs a uint64 value as little-endian (pwntools-style alias)
func (u *Utils) P64(value int64) []byte { return u.PackUint64LE(value) }
// P64BE packs a uint64 value as big-endian
func (u *Utils) P64BE(value int64) []byte { return u.PackUint64BE(value) }
// U16 unpacks a little-endian uint16 (pwntools-style alias)
func (u *Utils) U16(data []byte, offset int) int { return u.UnpackUint16LE(data, offset) }
// U16BE unpacks a big-endian uint16
func (u *Utils) U16BE(data []byte, offset int) int { return u.UnpackUint16BE(data, offset) }
// U32 unpacks a little-endian uint32 (pwntools-style alias)
func (u *Utils) U32(data []byte, offset int) int { return u.UnpackUint32LE(data, offset) }
// U32BE unpacks a big-endian uint32
func (u *Utils) U32BE(data []byte, offset int) int { return u.UnpackUint32BE(data, offset) }
// U64 unpacks a little-endian uint64 (pwntools-style alias)
func (u *Utils) U64(data []byte, offset int) int64 { return u.UnpackUint64LE(data, offset) }
// U64BE unpacks a big-endian uint64
func (u *Utils) U64BE(data []byte, offset int) int64 { return u.UnpackUint64BE(data, offset) }
// Flat combines multiple items into a single byte slice
// Accepts: []byte, string, int (single byte), []interface{}, or any Pack result
// @example
// ```javascript
// const utils = require('nuclei/utils');
// const u = new utils.Utils();
// const payload = u.Flat(u.P32(0x41414141), "AAAA", [0x00, 0x01], 0x42);
// ```
func (u *Utils) Flat(items ...interface{}) []byte {
var result []byte
for _, item := range items {
switch v := item.(type) {
case []byte:
result = append(result, v...)
case string:
result = append(result, []byte(v)...)
case int:
result = append(result, byte(v))
case int64:
result = append(result, byte(v))
case float64:
result = append(result, byte(int(v)))
case []interface{}:
for _, elem := range v {
switch n := elem.(type) {
case int:
result = append(result, byte(n))
case int64:
result = append(result, byte(n))
case float64:
result = append(result, byte(int(n)))
}
}
}
}
return result
}
+45
View File
@@ -0,0 +1,45 @@
package utils
import (
"time"
)
// Sleep pauses execution for the specified number of milliseconds
// @example
// ```javascript
// const utils = require('nuclei/utils');
// utils.Sleep(1000); // sleep for 1 second
// ```
func (u *Utils) Sleep(milliseconds int) {
time.Sleep(time.Duration(milliseconds) * time.Millisecond)
}
// UnixTimestamp returns the current Unix timestamp in seconds
// @example
// ```javascript
// const utils = require('nuclei/utils');
// const ts = utils.UnixTimestamp();
// ```
func (u *Utils) UnixTimestamp() int64 {
return time.Now().Unix()
}
// UnixTimestampMilli returns the current Unix timestamp in milliseconds
// @example
// ```javascript
// const utils = require('nuclei/utils');
// const ts = utils.UnixTimestampMilli();
// ```
func (u *Utils) UnixTimestampMilli() int64 {
return time.Now().UnixMilli()
}
// UnixTimestampNano returns the current Unix timestamp in nanoseconds
// @example
// ```javascript
// const utils = require('nuclei/utils');
// const ts = utils.UnixTimestampNano();
// ```
func (u *Utils) UnixTimestampNano() int64 {
return time.Now().UnixNano()
}
+10
View File
@@ -0,0 +1,10 @@
package utils
type (
// Utils is a struct for utils functions
// @example
// ```javascript
// const utils = require('nuclei/utils');
// ```
Utils struct{}
)
File diff suppressed because it is too large. Load diff