From 9616e5d3a3e4b3ca76b124e8ae25a26a1369338c Mon Sep 17 00:00:00 2001 From: Tarun Koyalwar Date: Tue, 27 Feb 2024 23:45:50 +0530 Subject: [PATCH 1/7] allow specifying self-contained at requestlevel --- pkg/protocols/http/http.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/protocols/http/http.go b/pkg/protocols/http/http.go index cd88d3048d..1c9aba83c8 100644 --- a/pkg/protocols/http/http.go +++ b/pkg/protocols/http/http.go @@ -135,7 +135,7 @@ type Request struct { // description: | // SelfContained specifies if the request is self-contained. - SelfContained bool `yaml:"-" json:"-"` + SelfContained bool `yaml:"self-contained" json:"self-contained"` // description: | // Signature is the request signature method From c1a89aa6784d23d193ab3450f244c0e5fda9159f Mon Sep 17 00:00:00 2001 From: Tarun Koyalwar Date: Wed, 28 Feb 2024 17:17:15 +0530 Subject: [PATCH 2/7] fix IsSMTP js example --- pkg/js/libs/smtp/smtp.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg/js/libs/smtp/smtp.go b/pkg/js/libs/smtp/smtp.go index ff74847762..dc84017917 100644 --- a/pkg/js/libs/smtp/smtp.go +++ b/pkg/js/libs/smtp/smtp.go @@ -29,7 +29,8 @@ type ( // @example // ```javascript // const smtp = require('nuclei/smtp'); - // const isSMTP = smtp.IsSMTP('acme.com', 25); + // const client = new smtp.Client(); + // const isSMTP = client.IsSMTP('acme.com', 25); // log(toJSON(isSMTP)); // ``` IsSMTPResponse struct { @@ -42,7 +43,8 @@ type ( // @example // ```javascript // const smtp = require('nuclei/smtp'); -// const isSMTP = smtp.IsSMTP('acme.com', 25); +// const client = new smtp.Client(); +// const isSMTP = client.IsSMTP('acme.com', 25); // log(toJSON(isSMTP)); // ``` func (c *SMTPClient) IsSMTP(host string, port int) (IsSMTPResponse, error) { From 3370930d759925063d215092f7483e111c20a6f8 Mon Sep 17 00:00:00 2001 From: Tarun Koyalwar Date: Wed, 28 Feb 2024 18:04:33 +0530 Subject: [PATCH 3/7] update smtp + fix examples --- pkg/js/generated/go/liboracle/oracle.go | 2 +- pkg/js/generated/go/libpop3/pop3.go | 2 +- pkg/js/generated/go/librdp/rdp.go | 3 +- pkg/js/generated/go/librsync/rsync.go | 2 +- pkg/js/generated/go/libsmtp/smtp.go | 7 +- pkg/js/generated/go/libtelnet/telnet.go | 2 +- pkg/js/generated/go/libvnc/vnc.go | 2 +- pkg/js/generated/ts/ikev2.ts | 1 + pkg/js/generated/ts/kerberos.ts | 84 ++++++++++----------- pkg/js/generated/ts/ldap.ts | 1 + pkg/js/generated/ts/mssql.ts | 6 +- pkg/js/generated/ts/mysql.ts | 10 +-- pkg/js/generated/ts/oracle.ts | 26 ++----- pkg/js/generated/ts/pop3.ts | 26 ++----- pkg/js/generated/ts/postgres.ts | 8 +- pkg/js/generated/ts/rdp.ts | 75 ++++++++----------- pkg/js/generated/ts/rsync.ts | 26 ++----- pkg/js/generated/ts/smb.ts | 24 +++--- pkg/js/generated/ts/smtp.ts | 39 ++++++---- pkg/js/generated/ts/ssh.ts | 46 ++++++------ pkg/js/generated/ts/telnet.ts | 26 ++----- pkg/js/generated/ts/vnc.ts | 30 ++------ pkg/js/libs/kerberos/kerberosx.go | 2 +- pkg/js/libs/ldap/adenum.go | 1 + pkg/js/libs/mssql/mssql.go | 6 +- pkg/js/libs/mysql/mysql.go | 6 +- pkg/js/libs/oracle/oracle.go | 12 +-- pkg/js/libs/pop3/pop3.go | 12 +-- pkg/js/libs/postgres/postgres.go | 8 +- pkg/js/libs/rdp/rdp.go | 14 +--- pkg/js/libs/rsync/rsync.go | 12 +-- pkg/js/libs/smb/smb.go | 8 +- pkg/js/libs/smtp/smtp.go | 98 +++++++++++++++++-------- pkg/js/libs/ssh/ssh.go | 14 ++-- pkg/js/libs/telnet/telnet.go | 12 +-- pkg/js/libs/vnc/vnc.go | 12 +-- 36 files changed, 279 insertions(+), 386 deletions(-) diff --git a/pkg/js/generated/go/liboracle/oracle.go b/pkg/js/generated/go/liboracle/oracle.go index 5b4bdd7a1b..53c8dee1c5 100644 --- a/pkg/js/generated/go/liboracle/oracle.go +++ b/pkg/js/generated/go/liboracle/oracle.go @@ -15,12 +15,12 @@ func init() { module.Set( gojs.Objects{ // Functions + "IsOracle": lib_oracle.IsOracle, // Var and consts // Objects / Classes "IsOracleResponse": gojs.GetClassConstructor[lib_oracle.IsOracleResponse](&lib_oracle.IsOracleResponse{}), - "OracleClient": gojs.GetClassConstructor[lib_oracle.OracleClient](&lib_oracle.OracleClient{}), }, ).Register() } diff --git a/pkg/js/generated/go/libpop3/pop3.go b/pkg/js/generated/go/libpop3/pop3.go index a43fbe0083..c84436e2fb 100644 --- a/pkg/js/generated/go/libpop3/pop3.go +++ b/pkg/js/generated/go/libpop3/pop3.go @@ -15,12 +15,12 @@ func init() { module.Set( gojs.Objects{ // Functions + "IsPOP3": lib_pop3.IsPOP3, // Var and consts // Objects / Classes "IsPOP3Response": gojs.GetClassConstructor[lib_pop3.IsPOP3Response](&lib_pop3.IsPOP3Response{}), - "Pop3Client": gojs.GetClassConstructor[lib_pop3.Pop3Client](&lib_pop3.Pop3Client{}), }, ).Register() } diff --git a/pkg/js/generated/go/librdp/rdp.go b/pkg/js/generated/go/librdp/rdp.go index 1b5591775f..f3129ef21a 100644 --- a/pkg/js/generated/go/librdp/rdp.go +++ b/pkg/js/generated/go/librdp/rdp.go @@ -15,13 +15,14 @@ func init() { module.Set( gojs.Objects{ // Functions + "CheckRDPAuth": lib_rdp.CheckRDPAuth, + "IsRDP": lib_rdp.IsRDP, // Var and consts // Objects / Classes "CheckRDPAuthResponse": gojs.GetClassConstructor[lib_rdp.CheckRDPAuthResponse](&lib_rdp.CheckRDPAuthResponse{}), "IsRDPResponse": gojs.GetClassConstructor[lib_rdp.IsRDPResponse](&lib_rdp.IsRDPResponse{}), - "RDPClient": gojs.GetClassConstructor[lib_rdp.RDPClient](&lib_rdp.RDPClient{}), }, ).Register() } diff --git a/pkg/js/generated/go/librsync/rsync.go b/pkg/js/generated/go/librsync/rsync.go index 759fc1ff98..a8e925d8de 100644 --- a/pkg/js/generated/go/librsync/rsync.go +++ b/pkg/js/generated/go/librsync/rsync.go @@ -15,12 +15,12 @@ func init() { module.Set( gojs.Objects{ // Functions + "IsRsync": lib_rsync.IsRsync, // Var and consts // Objects / Classes "IsRsyncResponse": gojs.GetClassConstructor[lib_rsync.IsRsyncResponse](&lib_rsync.IsRsyncResponse{}), - "RsyncClient": gojs.GetClassConstructor[lib_rsync.RsyncClient](&lib_rsync.RsyncClient{}), }, ).Register() } diff --git a/pkg/js/generated/go/libsmtp/smtp.go b/pkg/js/generated/go/libsmtp/smtp.go index 07388de8c2..e27f55ac77 100644 --- a/pkg/js/generated/go/libsmtp/smtp.go +++ b/pkg/js/generated/go/libsmtp/smtp.go @@ -15,13 +15,14 @@ func init() { module.Set( gojs.Objects{ // Functions + "NewSMTPClient": lib_smtp.NewSMTPClient, // Var and consts // Objects / Classes - "IsSMTPResponse": gojs.GetClassConstructor[lib_smtp.IsSMTPResponse](&lib_smtp.IsSMTPResponse{}), - "SMTPClient": gojs.GetClassConstructor[lib_smtp.SMTPClient](&lib_smtp.SMTPClient{}), - "SMTPMessage": gojs.GetClassConstructor[lib_smtp.SMTPMessage](&lib_smtp.SMTPMessage{}), + "Client": lib_smtp.NewSMTPClient, + "SMTPMessage": gojs.GetClassConstructor[lib_smtp.SMTPMessage](&lib_smtp.SMTPMessage{}), + "SMTPResponse": gojs.GetClassConstructor[lib_smtp.SMTPResponse](&lib_smtp.SMTPResponse{}), }, ).Register() } diff --git a/pkg/js/generated/go/libtelnet/telnet.go b/pkg/js/generated/go/libtelnet/telnet.go index 1aa191aaf6..82a08c253d 100644 --- a/pkg/js/generated/go/libtelnet/telnet.go +++ b/pkg/js/generated/go/libtelnet/telnet.go @@ -15,12 +15,12 @@ func init() { module.Set( gojs.Objects{ // Functions + "IsTelnet": lib_telnet.IsTelnet, // Var and consts // Objects / Classes "IsTelnetResponse": gojs.GetClassConstructor[lib_telnet.IsTelnetResponse](&lib_telnet.IsTelnetResponse{}), - "TelnetClient": gojs.GetClassConstructor[lib_telnet.TelnetClient](&lib_telnet.TelnetClient{}), }, ).Register() } diff --git a/pkg/js/generated/go/libvnc/vnc.go b/pkg/js/generated/go/libvnc/vnc.go index 11a9144942..affc3c9331 100644 --- a/pkg/js/generated/go/libvnc/vnc.go +++ b/pkg/js/generated/go/libvnc/vnc.go @@ -15,12 +15,12 @@ func init() { module.Set( gojs.Objects{ // Functions + "IsVNC": lib_vnc.IsVNC, // Var and consts // Objects / Classes "IsVNCResponse": gojs.GetClassConstructor[lib_vnc.IsVNCResponse](&lib_vnc.IsVNCResponse{}), - "VNCClient": gojs.GetClassConstructor[lib_vnc.VNCClient](&lib_vnc.VNCClient{}), }, ).Register() } diff --git a/pkg/js/generated/ts/ikev2.ts b/pkg/js/generated/ts/ikev2.ts index 7e8b70d78f..d8283a3716 100755 --- a/pkg/js/generated/ts/ikev2.ts +++ b/pkg/js/generated/ts/ikev2.ts @@ -96,6 +96,7 @@ export class IKEMessage { * const ikev2 = require('nuclei/ikev2'); * const nonce = new ikev2.IKENonce(); * nonce.NonceData = [1, 2, 3]; + * ``` */ export interface IKENonce { diff --git a/pkg/js/generated/ts/kerberos.ts b/pkg/js/generated/ts/kerberos.ts index 580c175a19..0bcb6ffab1 100755 --- a/pkg/js/generated/ts/kerberos.ts +++ b/pkg/js/generated/ts/kerberos.ts @@ -246,6 +246,8 @@ export interface EncTicketPart { RenewTill?: Date, + Flags?: BitString, + Key?: EncryptionKey, CName?: PrincipalName, @@ -255,8 +257,6 @@ export interface EncTicketPart { CAddr?: HostAddress, AuthorizationData?: AuthorizationDataEntry, - - Flags?: BitString, } @@ -266,11 +266,11 @@ export interface EncTicketPart { */ export interface EncryptedData { - Cipher?: Uint8Array, - EType?: number, KVNO?: number, + + Cipher?: Uint8Array, } @@ -306,9 +306,9 @@ export interface EnumerateUserResponse { */ export interface HostAddress { - Address?: Uint8Array, - AddrType?: number, + + Address?: Uint8Array, } @@ -318,79 +318,79 @@ export interface HostAddress { */ export interface LibDefaults { - DefaultTGSEnctypes?: string[], - - DefaultTktEnctypes?: string[], - - K5LoginDirectory?: string, + NoAddresses?: boolean, - RealmTryDomains?: number, + CCacheType?: number, - Canonicalize?: boolean, + DefaultClientKeytabName?: string, - K5LoginAuthoritative?: boolean, + DNSCanonicalizeHostname?: boolean, - NoAddresses?: boolean, + KDCTimeSync?: number, - SafeChecksumType?: number, + /** + * time in nanoseconds + */ - DefaultClientKeytabName?: string, + TicketLifetime?: number, - DNSLookupKDC?: boolean, + Canonicalize?: boolean, IgnoreAcceptorHostname?: boolean, - Proxiable?: boolean, + RealmTryDomains?: number, /** * time in nanoseconds */ - TicketLifetime?: number, + RenewLifetime?: number, - DefaultKeytabName?: string, + DefaultTGSEnctypeIDs?: number[], - DefaultTktEnctypeIDs?: number[], + DefaultTktEnctypes?: string[], - Forwardable?: boolean, + DNSLookupKDC?: boolean, - PermittedEnctypeIDs?: number[], + ExtraAddresses?: Uint8Array, PreferredPreauthTypes?: number[], - UDPPreferenceLimit?: number, - - VerifyAPReqNofail?: boolean, + DefaultTGSEnctypes?: string[], - /** - * time in nanoseconds - */ + DefaultTktEnctypeIDs?: number[], - Clockskew?: number, + DefaultKeytabName?: string, RDNS?: boolean, - DNSCanonicalizeHostname?: boolean, + SafeChecksumType?: number, - KDCTimeSync?: number, + UDPPreferenceLimit?: number, + + VerifyAPReqNofail?: boolean, PermittedEnctypes?: string[], + Forwardable?: boolean, + DefaultRealm?: string, /** * time in nanoseconds */ - RenewLifetime?: number, + Clockskew?: number, - CCacheType?: number, + DNSLookupRealm?: boolean, - DefaultTGSEnctypeIDs?: number[], + K5LoginAuthoritative?: boolean, - DNSLookupRealm?: boolean, + K5LoginDirectory?: string, - ExtraAddresses?: Uint8Array, + PermittedEnctypeIDs?: number[], + + Proxiable?: boolean, AllowWeakCrypto?: boolean, @@ -416,8 +416,6 @@ export interface PrincipalName { */ export interface Realm { - DefaultDomain?: string, - KDC?: string[], KPasswdServer?: string[], @@ -427,6 +425,8 @@ export interface Realm { Realm?: string, AdminServer?: string[], + + DefaultDomain?: string, } @@ -454,11 +454,11 @@ export interface Ticket { Realm?: string, - SName?: PrincipalName, - EncPart?: EncryptedData, DecryptedEncPart?: EncTicketPart, + + SName?: PrincipalName, } diff --git a/pkg/js/generated/ts/ldap.ts b/pkg/js/generated/ts/ldap.ts index 241936deac..5d25faa1c8 100755 --- a/pkg/js/generated/ts/ldap.ts +++ b/pkg/js/generated/ts/ldap.ts @@ -473,6 +473,7 @@ export class Client { * const client = new ldap.Client('ldap://ldap.example.com', 'acme.com'); * const users = client.GetADUsers(); * log(to_json(users)); + * ``` */ export interface ADObject { diff --git a/pkg/js/generated/ts/mssql.ts b/pkg/js/generated/ts/mssql.ts index 0e9f28f201..bff2edf8b5 100755 --- a/pkg/js/generated/ts/mssql.ts +++ b/pkg/js/generated/ts/mssql.ts @@ -6,7 +6,7 @@ * @example * ```javascript * const mssql = require('nuclei/mssql'); - * const client = new mssql.Client(); + * const client = new mssql.MSSQLClient; * ``` */ export class MSSQLClient { @@ -22,7 +22,7 @@ export class MSSQLClient { * @example * ```javascript * const mssql = require('nuclei/mssql'); - * const client = new mssql.Client(); + * const client = new mssql.MSSQLClient; * const connected = client.Connect('acme.com', 1433, 'username', 'password'); * ``` */ @@ -39,7 +39,7 @@ export class MSSQLClient { * @example * ```javascript * const mssql = require('nuclei/mssql'); - * const client = new mssql.Client(); + * const client = new mssql.MSSQLClient; * const connected = client.ConnectWithDB('acme.com', 1433, 'username', 'password', 'master'); * ``` */ diff --git a/pkg/js/generated/ts/mysql.ts b/pkg/js/generated/ts/mysql.ts index d8fabb13e8..40a31a62c6 100755 --- a/pkg/js/generated/ts/mysql.ts +++ b/pkg/js/generated/ts/mysql.ts @@ -23,7 +23,7 @@ export function BuildDSN(opts: MySQLOptions): string | null { * @example * ```javascript * const mysql = require('nuclei/mysql'); - * const client = new mysql.Client(); + * const client = new mysql.MySQLClient; * ``` */ export class MySQLClient { @@ -54,7 +54,7 @@ export class MySQLClient { * @example * ```javascript * const mysql = require('nuclei/mysql'); - * const client = new mysql.Client(); + * const client = new mysql.MySQLClient; * const connected = client.Connect('acme.com', 3306, 'username', 'password'); * ``` */ @@ -84,7 +84,7 @@ export class MySQLClient { * @example * ```javascript * const mysql = require('nuclei/mysql'); - * const client = new mysql.Client(); + * const client = new mysql.MySQLClient; * const connected = client.ConnectWithDSN('username:password@tcp(acme.com:3306)/'); * ``` */ @@ -221,10 +221,10 @@ export interface SQLResult { */ export interface ServiceMySQL { - PacketType?: string, - ErrorMessage?: string, ErrorCode?: number, + + PacketType?: string, } diff --git a/pkg/js/generated/ts/oracle.ts b/pkg/js/generated/ts/oracle.ts index fa895a976f..852e919e7b 100755 --- a/pkg/js/generated/ts/oracle.ts +++ b/pkg/js/generated/ts/oracle.ts @@ -1,32 +1,16 @@ /** - * OracleClient is a minimal Oracle client for nuclei scripts. + * IsOracle checks if a host is running an Oracle server * @example * ```javascript * const oracle = require('nuclei/oracle'); - * const client = new oracle.Client(); + * const isOracle = oracle.IsOracle('acme.com', 1521); + * log(toJSON(isOracle)); * ``` */ -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(host: string, port: number): IsOracleResponse | null { - return null; - } - - +export function IsOracle(host: string, port: number): IsOracleResponse | null { + return null; } diff --git a/pkg/js/generated/ts/pop3.ts b/pkg/js/generated/ts/pop3.ts index c7bc2cf6c1..84de1718a4 100755 --- a/pkg/js/generated/ts/pop3.ts +++ b/pkg/js/generated/ts/pop3.ts @@ -1,32 +1,16 @@ /** - * Pop3Client is a minimal POP3 client for nuclei scripts. + * IsPOP3 checks if a host is running a POP3 server. * @example * ```javascript * const pop3 = require('nuclei/pop3'); - * const client = new pop3.Client(); + * const isPOP3 = pop3.IsPOP3('acme.com', 110); + * log(toJSON(isPOP3)); * ``` */ -export class Pop3Client { - - - // Constructor of Pop3Client - constructor() {} - /** - * IsPOP3 checks if a host is running a POP3 server. - * @example - * ```javascript - * const pop3 = require('nuclei/pop3'); - * const isPOP3 = pop3.IsPOP3('acme.com', 110); - * log(toJSON(isPOP3)); - * ``` - */ - public IsPOP3(host: string, port: number): IsPOP3Response | null { - return null; - } - - +export function IsPOP3(host: string, port: number): IsPOP3Response | null { + return null; } diff --git a/pkg/js/generated/ts/postgres.ts b/pkg/js/generated/ts/postgres.ts index dff06a9d0d..31efd44c33 100755 --- a/pkg/js/generated/ts/postgres.ts +++ b/pkg/js/generated/ts/postgres.ts @@ -6,7 +6,7 @@ * @example * ```javascript * const postgres = require('nuclei/postgres'); - * const client = new postgres.Client(); + * const client = new postgres.PGClient; * ``` */ export class PGClient { @@ -37,7 +37,7 @@ export class PGClient { * @example * ```javascript * const postgres = require('nuclei/postgres'); - * const client = new postgres.Client(); + * const client = new postgres.PGClient; * const connected = client.Connect('acme.com', 5432, 'username', 'password'); * ``` */ @@ -53,7 +53,7 @@ export class PGClient { * @example * ```javascript * const postgres = require('nuclei/postgres'); - * const client = new postgres.Client(); + * const client = new postgres.PGClient; * const result = client.ExecuteQuery('acme.com', 5432, 'username', 'password', 'dbname', 'select * from users'); * log(to_json(result)); * ``` @@ -71,7 +71,7 @@ export class PGClient { * @example * ```javascript * const postgres = require('nuclei/postgres'); - * const client = new postgres.Client(); + * const client = new postgres.PGClient; * const connected = client.ConnectWithDB('acme.com', 5432, 'username', 'password', 'dbname'); * ``` */ diff --git a/pkg/js/generated/ts/rdp.ts b/pkg/js/generated/ts/rdp.ts index 2c1ab13747..7858b78319 100755 --- a/pkg/js/generated/ts/rdp.ts +++ b/pkg/js/generated/ts/rdp.ts @@ -1,51 +1,36 @@ /** - * RDPClient is a minimal RDP client for nuclei scripts. + * CheckRDPAuth checks if the given host and port are running rdp server + * with authentication and returns their metadata. + * If connection is successful, it returns true. * @example * ```javascript * const rdp = require('nuclei/rdp'); - * const client = new rdp.Client(); + * const checkRDPAuth = rdp.CheckRDPAuth('acme.com', 3389); + * log(toJSON(checkRDPAuth)); * ``` */ -export class RDPClient { - +export function CheckRDPAuth(host: string, port: number): CheckRDPAuthResponse | null { + return null; +} - // Constructor of RDPClient - constructor() {} - /** - * IsRDP checks if the given host and port are running rdp server. - * If connection is successful, it returns true. - * If connection is unsuccessful, it returns false and error. - * The Name of the OS is also returned if the connection is successful. - * @example - * ```javascript - * const rdp = require('nuclei/rdp'); - * const isRDP = rdp.IsRDP('acme.com', 3389); - * log(toJSON(isRDP)); - * ``` - */ - public IsRDP(host: string, port: number): IsRDPResponse | null { - return null; - } - - /** - * CheckRDPAuth checks if the given host and port are running rdp server - * with authentication and returns their metadata. - * If connection is successful, it returns true. - * @example - * ```javascript - * const rdp = require('nuclei/rdp'); - * const checkRDPAuth = rdp.CheckRDPAuth('acme.com', 3389); - * log(toJSON(checkRDPAuth)); - * ``` - */ - public CheckRDPAuth(host: string, port: number): CheckRDPAuthResponse | null { - return null; - } - +/** + * IsRDP checks if the given host and port are running rdp server. + * If connection is successful, it returns true. + * If connection is unsuccessful, it returns false and error. + * The Name of the OS is also returned if the connection is successful. + * @example + * ```javascript + * const rdp = require('nuclei/rdp'); + * const isRDP = rdp.IsRDP('acme.com', 3389); + * log(toJSON(isRDP)); + * ``` + */ +export function IsRDP(host: string, port: number): IsRDPResponse | null { + return null; } @@ -93,14 +78,6 @@ export interface IsRDPResponse { */ export interface ServiceRDP { - NetBIOSComputerName?: string, - - NetBIOSDomainName?: string, - - DNSComputerName?: string, - - DNSDomainName?: string, - ForestName?: string, OSFingerprint?: string, @@ -108,5 +85,13 @@ export interface ServiceRDP { OSVersion?: string, TargetName?: string, + + NetBIOSComputerName?: string, + + NetBIOSDomainName?: string, + + DNSComputerName?: string, + + DNSDomainName?: string, } diff --git a/pkg/js/generated/ts/rsync.ts b/pkg/js/generated/ts/rsync.ts index 06ac1500a5..afe2146803 100755 --- a/pkg/js/generated/ts/rsync.ts +++ b/pkg/js/generated/ts/rsync.ts @@ -1,32 +1,16 @@ /** - * RsyncClient is a minimal Rsync client for nuclei scripts. + * IsRsync checks if a host is running a Rsync server. * @example * ```javascript * const rsync = require('nuclei/rsync'); - * const client = new rsync.Client(); + * const isRsync = rsync.IsRsync('acme.com', 873); + * log(toJSON(isRsync)); * ``` */ -export class RsyncClient { - - - // Constructor of RsyncClient - constructor() {} - /** - * IsRsync checks if a host is running a Rsync server. - * @example - * ```javascript - * const rsync = require('nuclei/rsync'); - * const isRsync = rsync.IsRsync('acme.com', 873); - * log(toJSON(isRsync)); - * ``` - */ - public IsRsync(host: string, port: number): IsRsyncResponse | null { - return null; - } - - +export function IsRsync(host: string, port: number): IsRsyncResponse | null { + return null; } diff --git a/pkg/js/generated/ts/smb.ts b/pkg/js/generated/ts/smb.ts index 8e577b3404..14550e9ee9 100755 --- a/pkg/js/generated/ts/smb.ts +++ b/pkg/js/generated/ts/smb.ts @@ -7,7 +7,7 @@ * @example * ```javascript * const smb = require('nuclei/smb'); - * const client = new smb.Client(); + * const client = new smb.SMBClient(); * ``` */ export class SMBClient { @@ -23,7 +23,7 @@ export class SMBClient { * @example * ```javascript * const smb = require('nuclei/smb'); - * const client = new smb.Client(); + * const client = new smb.SMBClient(); * const info = client.ConnectSMBInfoMode('acme.com', 445); * log(to_json(info)); * ``` @@ -41,7 +41,7 @@ export class SMBClient { * @example * ```javascript * const smb = require('nuclei/smb'); - * const client = new smb.Client(); + * const client = new smb.SMBClient(); * const metadata = client.ListSMBv2Metadata('acme.com', 445); * log(to_json(metadata)); * ``` @@ -59,7 +59,7 @@ export class SMBClient { * @example * ```javascript * const smb = require('nuclei/smb'); - * const client = new smb.Client(); + * const client = new smb.SMBClient(); * const shares = client.ListShares('acme.com', 445, 'username', 'password'); * for (const share of shares) { * log(share); @@ -137,6 +137,8 @@ export interface NegotiationLog { */ export interface SMBCapabilities { + DFSSupport?: boolean, + Leasing?: boolean, LargeMTU?: boolean, @@ -148,8 +150,6 @@ export interface SMBCapabilities { DirLeasing?: boolean, Encryption?: boolean, - - DFSSupport?: boolean, } @@ -159,16 +159,16 @@ export interface SMBCapabilities { */ export interface SMBLog { + SupportV1?: boolean, + + NativeOs?: string, + NTLM?: string, GroupName?: string, HasNTLM?: boolean, - SupportV1?: boolean, - - NativeOs?: string, - Version?: SMBVersions, Capabilities?: SMBCapabilities, @@ -201,6 +201,8 @@ export interface SMBVersions { */ export interface ServiceSMB { + DNSComputerName?: string, + DNSDomainName?: string, ForestName?: string, @@ -214,8 +216,6 @@ export interface ServiceSMB { NetBIOSComputerName?: string, NetBIOSDomainName?: string, - - DNSComputerName?: string, } diff --git a/pkg/js/generated/ts/smtp.ts b/pkg/js/generated/ts/smtp.ts index e8dbd4e08f..d92544e3db 100755 --- a/pkg/js/generated/ts/smtp.ts +++ b/pkg/js/generated/ts/smtp.ts @@ -1,28 +1,31 @@ /** - * SMTPClient is a minimal SMTP client for nuclei scripts. + * Client is a minimal SMTP client for nuclei scripts. * @example * ```javascript * const smtp = require('nuclei/smtp'); - * const client = new smtp.Client(); + * const client = new smtp.Client('acme.com', 25); * ``` */ -export class SMTPClient { +export class Client { + + + // Constructor of Client + constructor(public host: string, public port: string ) {} - // Constructor of SMTPClient - constructor() {} /** * IsSMTP checks if a host is running a SMTP server. * @example * ```javascript * const smtp = require('nuclei/smtp'); - * const isSMTP = smtp.IsSMTP('acme.com', 25); - * log(toJSON(isSMTP)); + * const client = new smtp.Client('acme.com', 25); + * const isSMTP = client.IsSMTP(); + * log(isSMTP) * ``` */ - public IsSMTP(host: string, port: number): IsSMTPResponse | null { + public IsSMTP(): SMTPResponse | null { return null; } @@ -37,10 +40,11 @@ export class SMTPClient { * message.To('xyz2@projectdiscoveyr.io'); * message.Subject('hello'); * message.Body('hello'); - * const isRelay = smtp.IsOpenRelay('acme.com', 25, message); + * const client = new smtp.Client('acme.com', 25); + * const isRelay = client.IsOpenRelay(message); * ``` */ - public IsOpenRelay(host: string, port: number, msg: SMTPMessage): boolean | null { + public IsOpenRelay(msg: SMTPMessage): boolean | null { return null; } @@ -55,10 +59,12 @@ export class SMTPClient { * message.To('xyz2@projectdiscoveyr.io'); * message.Subject('hello'); * message.Body('hello'); - * const isSent = smtp.SendMail('acme.com', 25, message); + * const client = new smtp.Client('acme.com', 25); + * const isSent = client.SendMail(message); + * log(isSent) * ``` */ - public SendMail(host: string, port: string, msg: SMTPMessage): boolean | null { + public SendMail(msg: SMTPMessage): boolean | null { return null; } @@ -174,15 +180,16 @@ export class SMTPMessage { /** - * IsSMTPResponse is the response from the IsSMTP function. + * SMTPResponse is the response from the IsSMTP function. * @example * ```javascript * const smtp = require('nuclei/smtp'); - * const isSMTP = smtp.IsSMTP('acme.com', 25); - * log(toJSON(isSMTP)); + * const client = new smtp.Client('acme.com', 25); + * const isSMTP = client.IsSMTP(); + * log(isSMTP) * ``` */ -export interface IsSMTPResponse { +export interface SMTPResponse { IsSMTP?: boolean, diff --git a/pkg/js/generated/ts/ssh.ts b/pkg/js/generated/ts/ssh.ts index 6d10ce8376..b25f3d788b 100755 --- a/pkg/js/generated/ts/ssh.ts +++ b/pkg/js/generated/ts/ssh.ts @@ -6,7 +6,7 @@ * @example * ```javascript * const ssh = require('nuclei/ssh'); - * const client = new ssh.Client(); + * const client = new ssh.SSHClient(); * ``` */ export class SSHClient { @@ -19,7 +19,7 @@ export class SSHClient { * @example * ```javascript * const ssh = require('nuclei/ssh'); - * const client = new ssh.Client(); + * const client = new ssh.SSHClient(); * client.SetTimeout(10); * ``` */ @@ -36,7 +36,7 @@ export class SSHClient { * @example * ```javascript * const ssh = require('nuclei/ssh'); - * const client = new ssh.Client(); + * const client = new ssh.SSHClient(); * const connected = client.Connect('acme.com', 22, 'username', 'password'); * ``` */ @@ -53,7 +53,7 @@ export class SSHClient { * @example * ```javascript * const ssh = require('nuclei/ssh'); - * const client = new ssh.Client(); + * const client = new ssh.SSHClient(); * const privateKey = `-----BEGIN RSA PRIVATE KEY----- ...`; * const connected = client.ConnectWithKey('acme.com', 22, 'username', privateKey); * ``` @@ -73,7 +73,7 @@ export class SSHClient { * @example * ```javascript * const ssh = require('nuclei/ssh'); - * const client = new ssh.Client(); + * const client = new ssh.SSHClient(); * const info = client.ConnectSSHInfoMode('acme.com', 22); * log(to_json(info)); * ``` @@ -92,7 +92,7 @@ export class SSHClient { * @example * ```javascript * const ssh = require('nuclei/ssh'); - * const client = new ssh.Client(); + * const client = new ssh.SSHClient(); * client.Connect('acme.com', 22, 'username', 'password'); * const output = client.Run('id'); * log(output); @@ -110,7 +110,7 @@ export class SSHClient { * @example * ```javascript * const ssh = require('nuclei/ssh'); - * const client = new ssh.Client(); + * const client = new ssh.SSHClient(); * client.Connect('acme.com', 22, 'username', 'password'); * const closed = client.Close(); * ``` @@ -129,13 +129,13 @@ export class SSHClient { */ export interface Algorithms { - Kex?: string, - HostKey?: string, - W?: DirectionAlgorithms, + Kex?: string, R?: DirectionAlgorithms, + + W?: DirectionAlgorithms, } @@ -179,8 +179,6 @@ export interface HandshakeLog { UserAuth?: string[], - AlgorithmSelection?: Algorithms, - ServerID?: EndpointId, ClientID?: EndpointId, @@ -188,6 +186,8 @@ export interface HandshakeLog { ServerKex?: KexInitMsg, ClientKex?: KexInitMsg, + + AlgorithmSelection?: Algorithms, } @@ -197,34 +197,34 @@ export interface HandshakeLog { */ export interface KexInitMsg { + LanguagesClientServer?: string[], + + Reserved?: number, + CompressionClientServer?: string[], - FirstKexFollows?: boolean, + CompressionServerClient?: string[], MACsClientServer?: string[], - LanguagesClientServer?: string[], - - LanguagesServerClient?: string[], + KexAlgos?: string[], - Reserved?: number, + CiphersServerClient?: string[], - KexAlgos?: string[], + LanguagesServerClient?: string[], - CiphersClientServer?: string[], + FirstKexFollows?: boolean, - CiphersServerClient?: string[], + ServerHostKeyAlgos?: string[], MACsServerClient?: string[], - CompressionServerClient?: string[], - /** * fixed size array of length: [16] */ Cookie?: Uint8Array, - ServerHostKeyAlgos?: string[], + CiphersClientServer?: string[], } diff --git a/pkg/js/generated/ts/telnet.ts b/pkg/js/generated/ts/telnet.ts index 5ddabc4712..cd49c2078e 100755 --- a/pkg/js/generated/ts/telnet.ts +++ b/pkg/js/generated/ts/telnet.ts @@ -1,32 +1,16 @@ /** - * TelnetClient is a minimal Telnet client for nuclei scripts. + * IsTelnet checks if a host is running a Telnet server. * @example * ```javascript * const telnet = require('nuclei/telnet'); - * const client = new telnet.Client(); + * const isTelnet = telnet.IsTelnet('acme.com', 23); + * log(toJSON(isTelnet)); * ``` */ -export class TelnetClient { - - - // Constructor of TelnetClient - constructor() {} - /** - * IsTelnet checks if a host is running a Telnet server. - * @example - * ```javascript - * const telnet = require('nuclei/telnet'); - * const isTelnet = telnet.IsTelnet('acme.com', 23); - * log(toJSON(isTelnet)); - * ``` - */ - public IsTelnet(host: string, port: number): IsTelnetResponse | null { - return null; - } - - +export function IsTelnet(host: string, port: number): IsTelnetResponse | null { + return null; } diff --git a/pkg/js/generated/ts/vnc.ts b/pkg/js/generated/ts/vnc.ts index 86a0bcd021..870151e2bc 100755 --- a/pkg/js/generated/ts/vnc.ts +++ b/pkg/js/generated/ts/vnc.ts @@ -1,34 +1,18 @@ /** - * VNCClient is a minimal VNC client for nuclei scripts. + * IsVNC checks if a host is running a VNC server. + * It returns a boolean indicating if the host is running a VNC server + * and the banner of the VNC server. * @example * ```javascript * const vnc = require('nuclei/vnc'); - * const client = new vnc.Client(); + * const isVNC = vnc.IsVNC('acme.com', 5900); + * log(toJSON(isVNC)); * ``` */ -export class VNCClient { - - - // Constructor of VNCClient - constructor() {} - /** - * IsVNC checks if a host is running a VNC server. - * It returns a boolean indicating if the host is running a VNC server - * and the banner of the VNC server. - * @example - * ```javascript - * const vnc = require('nuclei/vnc'); - * const isVNC = vnc.IsVNC('acme.com', 5900); - * log(toJSON(isVNC)); - * ``` - */ - public IsVNC(host: string, port: number): IsVNCResponse | null { - return null; - } - - +export function IsVNC(host: string, port: number): IsVNCResponse | null { + return null; } diff --git a/pkg/js/libs/kerberos/kerberosx.go b/pkg/js/libs/kerberos/kerberosx.go index bb00fe2995..ea3e5921d5 100644 --- a/pkg/js/libs/kerberos/kerberosx.go +++ b/pkg/js/libs/kerberos/kerberosx.go @@ -88,7 +88,7 @@ type ( } ) -// Constructor for KerberosClient +// Constructor for Kerberos Client // Constructor: constructor(public domain: string, public controller?: string) // When controller is empty or not given krb5 will perform a DNS lookup for the default KDC server // and retrieve its address from the DNS server diff --git a/pkg/js/libs/ldap/adenum.go b/pkg/js/libs/ldap/adenum.go index 0939ec826c..23d2a4fc11 100644 --- a/pkg/js/libs/ldap/adenum.go +++ b/pkg/js/libs/ldap/adenum.go @@ -82,6 +82,7 @@ type ( // const client = new ldap.Client('ldap://ldap.example.com', 'acme.com'); // const users = client.GetADUsers(); // log(to_json(users)); + // ``` ADObject struct { DistinguishedName string SAMAccountName string diff --git a/pkg/js/libs/mssql/mssql.go b/pkg/js/libs/mssql/mssql.go index 18004f31ed..3b5c2630fc 100644 --- a/pkg/js/libs/mssql/mssql.go +++ b/pkg/js/libs/mssql/mssql.go @@ -20,7 +20,7 @@ type ( // @example // ```javascript // const mssql = require('nuclei/mssql'); - // const client = new mssql.Client(); + // const client = new mssql.MSSQLClient; // ``` MSSQLClient struct{} ) @@ -32,7 +32,7 @@ type ( // @example // ```javascript // const mssql = require('nuclei/mssql'); -// const client = new mssql.Client(); +// const client = new mssql.MSSQLClient; // const connected = client.Connect('acme.com', 1433, 'username', 'password'); // ``` func (c *MSSQLClient) Connect(host string, port int, username, password string) (bool, error) { @@ -46,7 +46,7 @@ func (c *MSSQLClient) Connect(host string, port int, username, password string) // @example // ```javascript // const mssql = require('nuclei/mssql'); -// const client = new mssql.Client(); +// const client = new mssql.MSSQLClient; // const connected = client.ConnectWithDB('acme.com', 1433, 'username', 'password', 'master'); // ``` func (c *MSSQLClient) ConnectWithDB(host string, port int, username, password, dbName string) (bool, error) { diff --git a/pkg/js/libs/mysql/mysql.go b/pkg/js/libs/mysql/mysql.go index 8bf8e5ec1c..4c4ce2e4fa 100644 --- a/pkg/js/libs/mysql/mysql.go +++ b/pkg/js/libs/mysql/mysql.go @@ -22,7 +22,7 @@ type ( // @example // ```javascript // const mysql = require('nuclei/mysql'); - // const client = new mysql.Client(); + // const client = new mysql.MySQLClient; // ``` MySQLClient struct{} ) @@ -64,7 +64,7 @@ func (c *MySQLClient) IsMySQL(host string, port int) (bool, error) { // @example // ```javascript // const mysql = require('nuclei/mysql'); -// const client = new mysql.Client(); +// const client = new mysql.MySQLClient; // const connected = client.Connect('acme.com', 3306, 'username', 'password'); // ``` func (c *MySQLClient) Connect(host string, port int, username, password string) (bool, error) { @@ -149,7 +149,7 @@ func (c *MySQLClient) FingerprintMySQL(host string, port int) (MySQLInfo, error) // @example // ```javascript // const mysql = require('nuclei/mysql'); -// const client = new mysql.Client(); +// const client = new mysql.MySQLClient; // const connected = client.ConnectWithDSN('username:password@tcp(acme.com:3306)/'); // ``` func (c *MySQLClient) ConnectWithDSN(dsn string) (bool, error) { diff --git a/pkg/js/libs/oracle/oracle.go b/pkg/js/libs/oracle/oracle.go index bc4d1be518..424c83fab5 100644 --- a/pkg/js/libs/oracle/oracle.go +++ b/pkg/js/libs/oracle/oracle.go @@ -11,16 +11,6 @@ import ( "github.com/projectdiscovery/nuclei/v3/pkg/protocols/common/protocolstate" ) -type ( - // OracleClient is a minimal Oracle client for nuclei scripts. - // @example - // ```javascript - // const oracle = require('nuclei/oracle'); - // const client = new oracle.Client(); - // ``` - OracleClient struct{} -) - type ( // IsOracleResponse is the response from the IsOracle function. // this is returned by IsOracle function. @@ -42,7 +32,7 @@ type ( // const isOracle = oracle.IsOracle('acme.com', 1521); // log(toJSON(isOracle)); // ``` -func (c *OracleClient) IsOracle(host string, port int) (IsOracleResponse, error) { +func IsOracle(host string, port int) (IsOracleResponse, error) { resp := IsOracleResponse{} timeout := 5 * time.Second diff --git a/pkg/js/libs/pop3/pop3.go b/pkg/js/libs/pop3/pop3.go index 12f59b5b03..165885ba2e 100644 --- a/pkg/js/libs/pop3/pop3.go +++ b/pkg/js/libs/pop3/pop3.go @@ -11,16 +11,6 @@ import ( "github.com/projectdiscovery/nuclei/v3/pkg/protocols/common/protocolstate" ) -type ( - // Pop3Client is a minimal POP3 client for nuclei scripts. - // @example - // ```javascript - // const pop3 = require('nuclei/pop3'); - // const client = new pop3.Client(); - // ``` - Pop3Client struct{} -) - type ( // IsPOP3Response is the response from the IsPOP3 function. // this is returned by IsPOP3 function. @@ -43,7 +33,7 @@ type ( // const isPOP3 = pop3.IsPOP3('acme.com', 110); // log(toJSON(isPOP3)); // ``` -func (c *Pop3Client) IsPOP3(host string, port int) (IsPOP3Response, error) { +func IsPOP3(host string, port int) (IsPOP3Response, error) { resp := IsPOP3Response{} timeout := 5 * time.Second diff --git a/pkg/js/libs/postgres/postgres.go b/pkg/js/libs/postgres/postgres.go index e97ee7a55a..3ac0e409c3 100644 --- a/pkg/js/libs/postgres/postgres.go +++ b/pkg/js/libs/postgres/postgres.go @@ -22,7 +22,7 @@ type ( // @example // ```javascript // const postgres = require('nuclei/postgres'); - // const client = new postgres.Client(); + // const client = new postgres.PGClient; // ``` PGClient struct{} ) @@ -64,7 +64,7 @@ func (c *PGClient) IsPostgres(host string, port int) (bool, error) { // @example // ```javascript // const postgres = require('nuclei/postgres'); -// const client = new postgres.Client(); +// const client = new postgres.PGClient; // const connected = client.Connect('acme.com', 5432, 'username', 'password'); // ``` func (c *PGClient) Connect(host string, port int, username, password string) (bool, error) { @@ -77,7 +77,7 @@ func (c *PGClient) Connect(host string, port int, username, password string) (bo // @example // ```javascript // const postgres = require('nuclei/postgres'); -// const client = new postgres.Client(); +// const client = new postgres.PGClient; // const result = client.ExecuteQuery('acme.com', 5432, 'username', 'password', 'dbname', 'select * from users'); // log(to_json(result)); // ``` @@ -113,7 +113,7 @@ func (c *PGClient) ExecuteQuery(host string, port int, username, password, dbNam // @example // ```javascript // const postgres = require('nuclei/postgres'); -// const client = new postgres.Client(); +// const client = new postgres.PGClient; // const connected = client.ConnectWithDB('acme.com', 5432, 'username', 'password', 'dbname'); // ``` func (c *PGClient) ConnectWithDB(host string, port int, username, password, dbName string) (bool, error) { diff --git a/pkg/js/libs/rdp/rdp.go b/pkg/js/libs/rdp/rdp.go index 8df039d1a1..d7790e7d3b 100644 --- a/pkg/js/libs/rdp/rdp.go +++ b/pkg/js/libs/rdp/rdp.go @@ -10,16 +10,6 @@ import ( "github.com/projectdiscovery/nuclei/v3/pkg/protocols/common/protocolstate" ) -type ( - // RDPClient is a minimal RDP client for nuclei scripts. - // @example - // ```javascript - // const rdp = require('nuclei/rdp'); - // const client = new rdp.Client(); - // ``` - RDPClient struct{} -) - type ( // IsRDPResponse is the response from the IsRDP function. // this is returned by IsRDP function. @@ -45,7 +35,7 @@ type ( // const isRDP = rdp.IsRDP('acme.com', 3389); // log(toJSON(isRDP)); // ``` -func (c *RDPClient) IsRDP(host string, port int) (IsRDPResponse, error) { +func IsRDP(host string, port int) (IsRDPResponse, error) { resp := IsRDPResponse{} timeout := 5 * time.Second @@ -91,7 +81,7 @@ type ( // const checkRDPAuth = rdp.CheckRDPAuth('acme.com', 3389); // log(toJSON(checkRDPAuth)); // ``` -func (c *RDPClient) CheckRDPAuth(host string, port int) (CheckRDPAuthResponse, error) { +func CheckRDPAuth(host string, port int) (CheckRDPAuthResponse, error) { resp := CheckRDPAuthResponse{} timeout := 5 * time.Second diff --git a/pkg/js/libs/rsync/rsync.go b/pkg/js/libs/rsync/rsync.go index a28dea2d79..41a334ddb6 100644 --- a/pkg/js/libs/rsync/rsync.go +++ b/pkg/js/libs/rsync/rsync.go @@ -11,16 +11,6 @@ import ( "github.com/projectdiscovery/nuclei/v3/pkg/protocols/common/protocolstate" ) -type ( - // RsyncClient is a minimal Rsync client for nuclei scripts. - // @example - // ```javascript - // const rsync = require('nuclei/rsync'); - // const client = new rsync.Client(); - // ``` - RsyncClient struct{} -) - type ( // IsRsyncResponse is the response from the IsRsync function. // this is returned by IsRsync function. @@ -43,7 +33,7 @@ type ( // const isRsync = rsync.IsRsync('acme.com', 873); // log(toJSON(isRsync)); // ``` -func (c *RsyncClient) IsRsync(host string, port int) (IsRsyncResponse, error) { +func IsRsync(host string, port int) (IsRsyncResponse, error) { resp := IsRsyncResponse{} timeout := 5 * time.Second diff --git a/pkg/js/libs/smb/smb.go b/pkg/js/libs/smb/smb.go index da23c40833..46937c5d76 100644 --- a/pkg/js/libs/smb/smb.go +++ b/pkg/js/libs/smb/smb.go @@ -18,7 +18,7 @@ type ( // @example // ```javascript // const smb = require('nuclei/smb'); - // const client = new smb.Client(); + // const client = new smb.SMBClient(); // ``` SMBClient struct{} ) @@ -30,7 +30,7 @@ type ( // @example // ```javascript // const smb = require('nuclei/smb'); -// const client = new smb.Client(); +// const client = new smb.SMBClient(); // const info = client.ConnectSMBInfoMode('acme.com', 445); // log(to_json(info)); // ``` @@ -70,7 +70,7 @@ func (c *SMBClient) ConnectSMBInfoMode(host string, port int) (*smb.SMBLog, erro // @example // ```javascript // const smb = require('nuclei/smb'); -// const client = new smb.Client(); +// const client = new smb.SMBClient(); // const metadata = client.ListSMBv2Metadata('acme.com', 445); // log(to_json(metadata)); // ``` @@ -89,7 +89,7 @@ func (c *SMBClient) ListSMBv2Metadata(host string, port int) (*plugins.ServiceSM // @example // ```javascript // const smb = require('nuclei/smb'); -// const client = new smb.Client(); +// const client = new smb.SMBClient(); // const shares = client.ListShares('acme.com', 445, 'username', 'password'); // // for (const share of shares) { diff --git a/pkg/js/libs/smtp/smtp.go b/pkg/js/libs/smtp/smtp.go index dc84017917..a24e424959 100644 --- a/pkg/js/libs/smtp/smtp.go +++ b/pkg/js/libs/smtp/smtp.go @@ -8,57 +8,92 @@ import ( "strconv" "time" + "github.com/dop251/goja" "github.com/praetorian-inc/fingerprintx/pkg/plugins" + "github.com/projectdiscovery/nuclei/v3/pkg/js/utils" "github.com/projectdiscovery/nuclei/v3/pkg/protocols/common/protocolstate" pluginsmtp "github.com/praetorian-inc/fingerprintx/pkg/plugins/services/smtp" ) type ( - // SMTPClient is a minimal SMTP client for nuclei scripts. + // SMTPResponse is the response from the IsSMTP function. // @example // ```javascript // const smtp = require('nuclei/smtp'); - // const client = new smtp.Client(); + // const client = new smtp.Client('acme.com', 25); + // const isSMTP = client.IsSMTP(); + // log(isSMTP) // ``` - SMTPClient struct{} + SMTPResponse struct { + IsSMTP bool + Banner string + } ) type ( - // IsSMTPResponse is the response from the IsSMTP function. + // Client is a minimal SMTP client for nuclei scripts. // @example // ```javascript // const smtp = require('nuclei/smtp'); - // const client = new smtp.Client(); - // const isSMTP = client.IsSMTP('acme.com', 25); - // log(toJSON(isSMTP)); + // const client = new smtp.Client('acme.com', 25); // ``` - IsSMTPResponse struct { - IsSMTP bool - Banner string + Client struct { + nj *utils.NucleiJS + host string + port string } ) +// Constructor for SMTP Client +// Constructor: constructor(public host: string, public port: string) +func NewSMTPClient(call goja.ConstructorCall, runtime *goja.Runtime) *goja.Object { + // setup nucleijs utils + c := &Client{nj: utils.NewNucleiJS(runtime)} + c.nj.ObjectSig = "Client(host, port)" // will be included in error messages + + host, _ := c.nj.GetArg(call.Arguments, 0).(string) // host + port, _ := c.nj.GetArg(call.Arguments, 1).(string) // port + + // validate arguments + c.nj.Require(host != "", "host cannot be empty") + c.nj.Require(port != "", "port cannot be empty") + + // validate port + portInt, err := strconv.Atoi(port) + c.nj.Require(err == nil && portInt > 0 && portInt < 65536, "port must be a valid number") + c.host = host + c.port = port + + // check if this is allowed address + c.nj.Require(protocolstate.IsHostAllowed(host+":"+port), protocolstate.ErrHostDenied.Msgf(host+":"+port).Error()) + + // Link Constructor to Client and return + return utils.LinkConstructor(call, runtime, c) +} + // IsSMTP checks if a host is running a SMTP server. // @example // ```javascript // const smtp = require('nuclei/smtp'); -// const client = new smtp.Client(); -// const isSMTP = client.IsSMTP('acme.com', 25); -// log(toJSON(isSMTP)); +// const client = new smtp.Client('acme.com', 25); +// const isSMTP = client.IsSMTP(); +// log(isSMTP) // ``` -func (c *SMTPClient) IsSMTP(host string, port int) (IsSMTPResponse, error) { - resp := IsSMTPResponse{} +func (c *Client) IsSMTP() (SMTPResponse, error) { + resp := SMTPResponse{} + c.nj.Require(c.host != "", "host cannot be empty") + c.nj.Require(c.port != "", "port cannot be empty") timeout := 5 * time.Second - conn, err := protocolstate.Dialer.Dial(context.TODO(), "tcp", net.JoinHostPort(host, strconv.Itoa(port))) + conn, err := protocolstate.Dialer.Dial(context.TODO(), "tcp", net.JoinHostPort(c.host, c.port)) if err != nil { return resp, err } defer conn.Close() smtpPlugin := pluginsmtp.SMTPPlugin{} - service, err := smtpPlugin.Run(conn, timeout, plugins.Target{Host: host}) + service, err := smtpPlugin.Run(conn, timeout, plugins.Target{Host: c.host}) if err != nil { return resp, err } @@ -79,20 +114,20 @@ func (c *SMTPClient) IsSMTP(host string, port int) (IsSMTPResponse, error) { // message.To('xyz2@projectdiscoveyr.io'); // message.Subject('hello'); // message.Body('hello'); -// const isRelay = smtp.IsOpenRelay('acme.com', 25, message); +// const client = new smtp.Client('acme.com', 25); +// const isRelay = client.IsOpenRelay(message); // ``` -func (c *SMTPClient) IsOpenRelay(host string, port int, msg *SMTPMessage) (bool, error) { - if !protocolstate.IsHostAllowed(host) { - return false, protocolstate.ErrHostDenied.Msgf(host) - } +func (c *Client) IsOpenRelay(msg *SMTPMessage) (bool, error) { + c.nj.Require(c.host != "", "host cannot be empty") + c.nj.Require(c.port != "", "port cannot be empty") - addr := net.JoinHostPort(host, strconv.Itoa(port)) + addr := net.JoinHostPort(c.host, c.port) conn, err := protocolstate.Dialer.Dial(context.TODO(), "tcp", addr) if err != nil { return false, err } defer conn.Close() - client, err := smtp.NewClient(conn, host) + client, err := smtp.NewClient(conn, c.host) if err != nil { return false, err } @@ -137,20 +172,21 @@ func (c *SMTPClient) IsOpenRelay(host string, port int, msg *SMTPMessage) (bool, // message.To('xyz2@projectdiscoveyr.io'); // message.Subject('hello'); // message.Body('hello'); -// const isSent = smtp.SendMail('acme.com', 25, message); +// const client = new smtp.Client('acme.com', 25); +// const isSent = client.SendMail(message); +// log(isSent) // ``` -func (c *SMTPClient) SendMail(host string, port string, msg *SMTPMessage) (bool, error) { - if !protocolstate.IsHostAllowed(host) { - return false, protocolstate.ErrHostDenied.Msgf(host) - } +func (c *Client) SendMail(msg *SMTPMessage) (bool, error) { + c.nj.Require(c.host != "", "host cannot be empty") + c.nj.Require(c.port != "", "port cannot be empty") var auth smtp.Auth if msg.user != "" && msg.pass != "" { - auth = smtp.PlainAuth("", msg.user, msg.pass, host) + auth = smtp.PlainAuth("", msg.user, msg.pass, c.host) } // send mail - addr := net.JoinHostPort(host, port) + addr := net.JoinHostPort(c.host, c.port) if err := smtp.SendMail(addr, auth, msg.from, msg.to, []byte(msg.String())); err != nil { return false, err } diff --git a/pkg/js/libs/ssh/ssh.go b/pkg/js/libs/ssh/ssh.go index e2f2793f77..920b820296 100644 --- a/pkg/js/libs/ssh/ssh.go +++ b/pkg/js/libs/ssh/ssh.go @@ -16,7 +16,7 @@ type ( // @example // ```javascript // const ssh = require('nuclei/ssh'); - // const client = new ssh.Client(); + // const client = new ssh.SSHClient(); // ``` SSHClient struct { connection *ssh.Client @@ -28,7 +28,7 @@ type ( // @example // ```javascript // const ssh = require('nuclei/ssh'); -// const client = new ssh.Client(); +// const client = new ssh.SSHClient(); // client.SetTimeout(10); // ``` func (c *SSHClient) SetTimeout(sec int) { @@ -42,7 +42,7 @@ func (c *SSHClient) SetTimeout(sec int) { // @example // ```javascript // const ssh = require('nuclei/ssh'); -// const client = new ssh.Client(); +// const client = new ssh.SSHClient(); // const connected = client.Connect('acme.com', 22, 'username', 'password'); // ``` func (c *SSHClient) Connect(host string, port int, username, password string) (bool, error) { @@ -67,7 +67,7 @@ func (c *SSHClient) Connect(host string, port int, username, password string) (b // @example // ```javascript // const ssh = require('nuclei/ssh'); -// const client = new ssh.Client(); +// const client = new ssh.SSHClient(); // const privateKey = `-----BEGIN RSA PRIVATE KEY----- ...`; // const connected = client.ConnectWithKey('acme.com', 22, 'username', privateKey); // ``` @@ -96,7 +96,7 @@ func (c *SSHClient) ConnectWithKey(host string, port int, username, key string) // @example // ```javascript // const ssh = require('nuclei/ssh'); -// const client = new ssh.Client(); +// const client = new ssh.SSHClient(); // const info = client.ConnectSSHInfoMode('acme.com', 22); // log(to_json(info)); // ``` @@ -115,7 +115,7 @@ func (c *SSHClient) ConnectSSHInfoMode(host string, port int) (*ssh.HandshakeLog // @example // ```javascript // const ssh = require('nuclei/ssh'); -// const client = new ssh.Client(); +// const client = new ssh.SSHClient(); // client.Connect('acme.com', 22, 'username', 'password'); // const output = client.Run('id'); // log(output); @@ -144,7 +144,7 @@ func (c *SSHClient) Run(cmd string) (string, error) { // @example // ```javascript // const ssh = require('nuclei/ssh'); -// const client = new ssh.Client(); +// const client = new ssh.SSHClient(); // client.Connect('acme.com', 22, 'username', 'password'); // const closed = client.Close(); // ``` diff --git a/pkg/js/libs/telnet/telnet.go b/pkg/js/libs/telnet/telnet.go index 6c620ef277..02135a952d 100644 --- a/pkg/js/libs/telnet/telnet.go +++ b/pkg/js/libs/telnet/telnet.go @@ -11,16 +11,6 @@ import ( "github.com/projectdiscovery/nuclei/v3/pkg/protocols/common/protocolstate" ) -type ( - // TelnetClient is a minimal Telnet client for nuclei scripts. - // @example - // ```javascript - // const telnet = require('nuclei/telnet'); - // const client = new telnet.Client(); - // ``` - TelnetClient struct{} -) - type ( // IsTelnetResponse is the response from the IsTelnet function. // this is returned by IsTelnet function. @@ -43,7 +33,7 @@ type ( // const isTelnet = telnet.IsTelnet('acme.com', 23); // log(toJSON(isTelnet)); // ``` -func (c *TelnetClient) IsTelnet(host string, port int) (IsTelnetResponse, error) { +func IsTelnet(host string, port int) (IsTelnetResponse, error) { resp := IsTelnetResponse{} timeout := 5 * time.Second diff --git a/pkg/js/libs/vnc/vnc.go b/pkg/js/libs/vnc/vnc.go index f2747c3a53..17f2c19984 100644 --- a/pkg/js/libs/vnc/vnc.go +++ b/pkg/js/libs/vnc/vnc.go @@ -11,16 +11,6 @@ import ( "github.com/projectdiscovery/nuclei/v3/pkg/protocols/common/protocolstate" ) -type ( - // VNCClient is a minimal VNC client for nuclei scripts. - // @example - // ```javascript - // const vnc = require('nuclei/vnc'); - // const client = new vnc.Client(); - // ``` - VNCClient struct{} -) - type ( // IsVNCResponse is the response from the IsVNC function. // @example @@ -44,7 +34,7 @@ type ( // const isVNC = vnc.IsVNC('acme.com', 5900); // log(toJSON(isVNC)); // ``` -func (c *VNCClient) IsVNC(host string, port int) (IsVNCResponse, error) { +func IsVNC(host string, port int) (IsVNCResponse, error) { resp := IsVNCResponse{} timeout := 5 * time.Second From b804cc041070f5627b303270758d5de8eb32b1a6 Mon Sep 17 00:00:00 2001 From: Tarun Koyalwar Date: Wed, 28 Feb 2024 18:34:59 +0530 Subject: [PATCH 4/7] update smtp error message --- pkg/js/libs/smtp/smtp.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/js/libs/smtp/smtp.go b/pkg/js/libs/smtp/smtp.go index a24e424959..7fe9076e22 100644 --- a/pkg/js/libs/smtp/smtp.go +++ b/pkg/js/libs/smtp/smtp.go @@ -188,7 +188,7 @@ func (c *Client) SendMail(msg *SMTPMessage) (bool, error) { // send mail addr := net.JoinHostPort(c.host, c.port) if err := smtp.SendMail(addr, auth, msg.from, msg.to, []byte(msg.String())); err != nil { - return false, err + c.nj.Throw("failed to send mail with message(%s) got %v", msg.String(), err) } return true, nil } From c0d4a7c4829bcf7b7919c80f0a428a150af1a3d9 Mon Sep 17 00:00:00 2001 From: Tarun Koyalwar Date: Fri, 1 Mar 2024 02:44:29 +0530 Subject: [PATCH 5/7] add code reference in js protocol --- pkg/protocols/common/interactsh/interactsh.go | 1 + pkg/protocols/javascript/js.go | 4 +-- pkg/templates/templates.go | 25 +++++++++++++++++++ 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/pkg/protocols/common/interactsh/interactsh.go b/pkg/protocols/common/interactsh/interactsh.go index b808359856..5e7a446c53 100644 --- a/pkg/protocols/common/interactsh/interactsh.go +++ b/pkg/protocols/common/interactsh/interactsh.go @@ -170,6 +170,7 @@ func (c *Client) processInteractionForRequest(interaction *server.Interaction, d data.Event.Unlock() if data.Operators != nil { + fmt.Printf("processing interaction for request %v\n", interaction.UniqueID) result, matched = data.Operators.Execute(data.Event.InternalEvent, data.MatchFunc, data.ExtractFunc, c.options.Debug || c.options.DebugRequest || c.options.DebugResponse) } else { // this is most likely a bug so error instead of warning diff --git a/pkg/protocols/javascript/js.go b/pkg/protocols/javascript/js.go index 3ca587e495..fc32486937 100644 --- a/pkg/protocols/javascript/js.go +++ b/pkg/protocols/javascript/js.go @@ -447,7 +447,7 @@ func (request *Request) executeRequestParallel(ctxParent context.Context, hostPo } } -func (request *Request) executeRequestWithPayloads(hostPort string, input *contextargs.Context, hostname string, payload map[string]interface{}, previous output.InternalEvent, callback protocols.OutputEventCallback, requestOptions *protocols.ExecutorOptions) error { +func (request *Request) executeRequestWithPayloads(hostPort string, input *contextargs.Context, _ string, payload map[string]interface{}, previous output.InternalEvent, callback protocols.OutputEventCallback, requestOptions *protocols.ExecutorOptions) error { payloadValues := generators.MergeMaps(payload, previous) argsCopy, err := request.getArgsCopy(input, payloadValues, requestOptions, false) if err != nil { @@ -580,7 +580,7 @@ func (request *Request) getArgsCopy(input *contextargs.Context, payloadValues ma } // evaluateArgs evaluates arguments using available payload values and returns a copy of args -func (request *Request) evaluateArgs(payloadValues map[string]interface{}, requestOptions *protocols.ExecutorOptions, ignoreErrors bool) (map[string]interface{}, error) { +func (request *Request) evaluateArgs(payloadValues map[string]interface{}, _ *protocols.ExecutorOptions, ignoreErrors bool) (map[string]interface{}, error) { argsCopy := make(map[string]interface{}) mainLoop: for k, v := range request.Args { diff --git a/pkg/templates/templates.go b/pkg/templates/templates.go index c98f220eda..1bd5a683e2 100644 --- a/pkg/templates/templates.go +++ b/pkg/templates/templates.go @@ -371,6 +371,17 @@ func (template *Template) ImportFileRefs(options *protocols.ExecutorOptions) err } } + // for javascript protocol code references + for _, request := range template.RequestsJavascript { + // simple test to check if source is a file or a snippet + if len(strings.Split(request.Code, "\n")) == 1 && fileutil.FileExists(request.Code) { + if val, ok := loadFile(request.Code); ok { + template.ImportedFiles = append(template.ImportedFiles, request.Code) + request.Code = val + } + } + } + // flow code references if template.Flow != "" { if len(template.Flow) > 0 && filepath.Ext(template.Flow) == ".js" && fileutil.FileExists(template.Flow) { @@ -398,6 +409,20 @@ func (template *Template) ImportFileRefs(options *protocols.ExecutorOptions) err } } } + + // for javascript protocol code references + for _, req := range template.RequestsQueue { + if req.Type() == types.JavascriptProtocol { + request := req.(*javascript.Request) + // simple test to check if source is a file or a snippet + if len(strings.Split(request.Code, "\n")) == 1 && fileutil.FileExists(request.Code) { + if val, ok := loadFile(request.Code); ok { + template.ImportedFiles = append(template.ImportedFiles, request.Code) + request.Code = val + } + } + } + } } return multierr.Combine(errs...) From 66a7a5555dadd3ccf44cf304d0a888f42dca0cfa Mon Sep 17 00:00:00 2001 From: Tarun Koyalwar Date: Fri, 1 Mar 2024 03:57:37 +0530 Subject: [PATCH 6/7] update js docs --- pkg/js/generated/ts/kerberos.ts | 106 ++++++++++++++++---------------- pkg/js/generated/ts/mysql.ts | 8 +-- pkg/js/generated/ts/net.ts | 54 +++++++++++++--- pkg/js/generated/ts/rdp.ts | 4 +- pkg/js/generated/ts/smb.ts | 26 ++++---- pkg/js/generated/ts/ssh.ts | 28 ++++----- pkg/js/libs/net/net.go | 56 ++++++++++++++--- 7 files changed, 178 insertions(+), 104 deletions(-) diff --git a/pkg/js/generated/ts/kerberos.ts b/pkg/js/generated/ts/kerberos.ts index 0bcb6ffab1..a142e536bb 100755 --- a/pkg/js/generated/ts/kerberos.ts +++ b/pkg/js/generated/ts/kerberos.ts @@ -236,6 +236,8 @@ export interface Config { */ export interface EncTicketPart { + RenewTill?: Date, + CRealm?: string, AuthTime?: Date, @@ -244,19 +246,17 @@ export interface EncTicketPart { EndTime?: Date, - RenewTill?: Date, + Transited?: TransitedEncoding, + + CAddr?: HostAddress, + + AuthorizationData?: AuthorizationDataEntry, Flags?: BitString, Key?: EncryptionKey, CName?: PrincipalName, - - Transited?: TransitedEncoding, - - CAddr?: HostAddress, - - AuthorizationData?: AuthorizationDataEntry, } @@ -266,11 +266,11 @@ export interface EncTicketPart { */ export interface EncryptedData { + Cipher?: Uint8Array, + EType?: number, KVNO?: number, - - Cipher?: Uint8Array, } @@ -318,82 +318,82 @@ export interface HostAddress { */ export interface LibDefaults { - NoAddresses?: boolean, - - CCacheType?: number, - - DefaultClientKeytabName?: string, + /** + * time in nanoseconds + */ - DNSCanonicalizeHostname?: boolean, + Clockskew?: number, KDCTimeSync?: number, + SafeChecksumType?: number, + /** * time in nanoseconds */ TicketLifetime?: number, - Canonicalize?: boolean, - - IgnoreAcceptorHostname?: boolean, - - RealmTryDomains?: number, + Forwardable?: boolean, - /** - * time in nanoseconds - */ + K5LoginAuthoritative?: boolean, - RenewLifetime?: number, + AllowWeakCrypto?: boolean, - DefaultTGSEnctypeIDs?: number[], + DefaultClientKeytabName?: string, DefaultTktEnctypes?: string[], - DNSLookupKDC?: boolean, - ExtraAddresses?: Uint8Array, - PreferredPreauthTypes?: number[], + K5LoginDirectory?: string, - DefaultTGSEnctypes?: string[], + PreferredPreauthTypes?: number[], - DefaultTktEnctypeIDs?: number[], + RDNS?: boolean, DefaultKeytabName?: string, - RDNS?: boolean, + DefaultRealm?: string, - SafeChecksumType?: number, + DefaultTGSEnctypeIDs?: number[], - UDPPreferenceLimit?: number, + DNSCanonicalizeHostname?: boolean, + + PermittedEnctypes?: string[], VerifyAPReqNofail?: boolean, - PermittedEnctypes?: string[], + DNSLookupRealm?: boolean, - Forwardable?: boolean, + UDPPreferenceLimit?: number, - DefaultRealm?: string, + Canonicalize?: boolean, + + CCacheType?: number, + + DefaultTGSEnctypes?: string[], + + Proxiable?: boolean, + + DNSLookupKDC?: boolean, + + RealmTryDomains?: number, /** * time in nanoseconds */ - Clockskew?: number, + RenewLifetime?: number, - DNSLookupRealm?: boolean, + DefaultTktEnctypeIDs?: number[], - K5LoginAuthoritative?: boolean, + IgnoreAcceptorHostname?: boolean, - K5LoginDirectory?: string, + NoAddresses?: boolean, PermittedEnctypeIDs?: number[], - Proxiable?: boolean, - - AllowWeakCrypto?: boolean, - KDCDefaultOptions?: BitString, } @@ -416,17 +416,17 @@ export interface PrincipalName { */ export interface Realm { - KDC?: string[], - - KPasswdServer?: string[], - - MasterKDC?: string[], - Realm?: string, AdminServer?: string[], DefaultDomain?: string, + + KDC?: string[], + + KPasswdServer?: string[], + + MasterKDC?: string[], } @@ -450,15 +450,15 @@ export interface TGS { */ export interface Ticket { + Realm?: string, + TktVNO?: number, - Realm?: string, + SName?: PrincipalName, EncPart?: EncryptedData, DecryptedEncPart?: EncTicketPart, - - SName?: PrincipalName, } diff --git a/pkg/js/generated/ts/mysql.ts b/pkg/js/generated/ts/mysql.ts index 40a31a62c6..a8c331cde0 100755 --- a/pkg/js/generated/ts/mysql.ts +++ b/pkg/js/generated/ts/mysql.ts @@ -209,9 +209,9 @@ export interface MySQLOptions { */ export interface SQLResult { - Count?: number, - Columns?: string[], + + Count?: number, } @@ -221,10 +221,10 @@ export interface SQLResult { */ export interface ServiceMySQL { + PacketType?: string, + ErrorMessage?: string, ErrorCode?: number, - - PacketType?: string, } diff --git a/pkg/js/generated/ts/net.ts b/pkg/js/generated/ts/net.ts index 2a601ae780..f68846e557 100755 --- a/pkg/js/generated/ts/net.ts +++ b/pkg/js/generated/ts/net.ts @@ -115,46 +115,64 @@ export class NetConn { /** - * Recv receives data from the connection with a timeout. + * RecvFull receives data from the connection with a timeout. * If N is 0, it will read all data sent by the server with 8MB limit. * it tries to read until N bytes or timeout is reached. * @example * ```javascript * const net = require('nuclei/net'); * const conn = net.Open('tcp', 'acme.com:80'); - * const data = conn.Recv(1024); + * const data = conn.RecvFull(1024); * ``` */ - public Recv(N: number): Uint8Array | null { + public RecvFull(N: number): Uint8Array | null { return null; } /** - * RecvPartial is similar to Recv but it does not perform full read instead + * Recv is similar to RecvFull but does not guarantee full read instead * it creates a buffer of N bytes and returns whatever is returned by the connection - * this is usually used when fingerprinting services to get initial bytes from the server. + * for reading headers or initial bytes from the server this is usually used. + * for reading a fixed number of already known bytes (ex: body based on content-length) use RecvFull. * @example * ```javascript * const net = require('nuclei/net'); * const conn = net.Open('tcp', 'acme.com:80'); - * const data = conn.RecvPartial(1024); + * const data = conn.Recv(1024); * log(`Received ${data.length} bytes from the server`) * ``` */ - public RecvPartial(N: number): Uint8Array | null { + public Recv(N: number): Uint8Array | null { return null; } /** - * RecvString receives data from the connection with a timeout + * RecvFullString receives data from the connection with a timeout * output is returned as a string. * If N is 0, it will read all data sent by the server with 8MB limit. * @example * ```javascript * const net = require('nuclei/net'); * const conn = net.Open('tcp', 'acme.com:80'); + * const data = conn.RecvFullString(1024); + * ``` + */ + public RecvFullString(N: number): string | null { + return null; + } + + + /** + * RecvString is similar to RecvFullString but does not guarantee full read, instead + * it creates a buffer of N bytes and returns whatever is returned by the connection + * for reading headers or initial bytes from the server this is usually used. + * for reading a fixed number of already known bytes (ex: body based on content-length) use RecvFullString. + * @example + * ```javascript + * const net = require('nuclei/net'); + * const conn = net.Open('tcp', 'acme.com:80'); * const data = conn.RecvString(1024); * ``` */ @@ -164,9 +182,27 @@ export class NetConn { /** - * RecvHex receives data from the connection with a timeout + * RecvFullHex receives data from the connection with a timeout * in hex format. * If N is 0,it will read all data sent by the server with 8MB limit. + * until N bytes or timeout is reached. + * @example + * ```javascript + * const net = require('nuclei/net'); + * const conn = net.Open('tcp', 'acme.com:80'); + * const data = conn.RecvFullHex(1024); + * ``` + */ + public RecvFullHex(N: number): string | null { + return null; + } + + + /** + * RecvHex is similar to RecvFullHex but does not guarantee full read instead + * it creates a buffer of N bytes and returns whatever is returned by the connection + * for reading headers or initial bytes from the server this is usually used. + * for reading a fixed number of already known bytes (ex: body based on content-length) use RecvFull. * @example * ```javascript * const net = require('nuclei/net'); diff --git a/pkg/js/generated/ts/rdp.ts b/pkg/js/generated/ts/rdp.ts index 7858b78319..77dfeafb13 100755 --- a/pkg/js/generated/ts/rdp.ts +++ b/pkg/js/generated/ts/rdp.ts @@ -78,6 +78,8 @@ export interface IsRDPResponse { */ export interface ServiceRDP { + DNSDomainName?: string, + ForestName?: string, OSFingerprint?: string, @@ -91,7 +93,5 @@ export interface ServiceRDP { NetBIOSDomainName?: string, DNSComputerName?: string, - - DNSDomainName?: string, } diff --git a/pkg/js/generated/ts/smb.ts b/pkg/js/generated/ts/smb.ts index 14550e9ee9..b2bcb08f95 100755 --- a/pkg/js/generated/ts/smb.ts +++ b/pkg/js/generated/ts/smb.ts @@ -113,6 +113,8 @@ export interface HeaderLog { */ export interface NegotiationLog { + SecurityMode?: number, + DialectRevision?: number, ServerGuid?: Uint8Array, @@ -125,8 +127,6 @@ export interface NegotiationLog { AuthenticationTypes?: string[], - SecurityMode?: number, - HeaderLog?: HeaderLog, } @@ -159,8 +159,6 @@ export interface SMBCapabilities { */ export interface SMBLog { - SupportV1?: boolean, - NativeOs?: string, NTLM?: string, @@ -169,13 +167,15 @@ export interface SMBLog { HasNTLM?: boolean, - Version?: SMBVersions, + SupportV1?: boolean, Capabilities?: SMBCapabilities, NegotiationLog?: NegotiationLog, SessionSetupLog?: SessionSetupLog, + + Version?: SMBVersions, } @@ -201,12 +201,6 @@ export interface SMBVersions { */ export interface ServiceSMB { - DNSComputerName?: string, - - DNSDomainName?: string, - - ForestName?: string, - SigningEnabled?: boolean, SigningRequired?: boolean, @@ -216,6 +210,12 @@ export interface ServiceSMB { NetBIOSComputerName?: string, NetBIOSDomainName?: string, + + DNSComputerName?: string, + + DNSDomainName?: string, + + ForestName?: string, } @@ -225,12 +225,12 @@ export interface ServiceSMB { */ export interface SessionSetupLog { + SetupFlags?: number, + TargetName?: string, NegotiateFlags?: number, - SetupFlags?: number, - HeaderLog?: HeaderLog, } diff --git a/pkg/js/generated/ts/ssh.ts b/pkg/js/generated/ts/ssh.ts index b25f3d788b..37d04ae670 100755 --- a/pkg/js/generated/ts/ssh.ts +++ b/pkg/js/generated/ts/ssh.ts @@ -129,13 +129,13 @@ export class SSHClient { */ export interface Algorithms { - HostKey?: string, - Kex?: string, - R?: DirectionAlgorithms, + HostKey?: string, W?: DirectionAlgorithms, + + R?: DirectionAlgorithms, } @@ -197,34 +197,34 @@ export interface HandshakeLog { */ export interface KexInitMsg { + CiphersServerClient?: string[], + + MACsClientServer?: string[], + + MACsServerClient?: string[], + LanguagesClientServer?: string[], + KexAlgos?: string[], + + CiphersClientServer?: string[], + Reserved?: number, CompressionClientServer?: string[], CompressionServerClient?: string[], - MACsClientServer?: string[], - - KexAlgos?: string[], - - CiphersServerClient?: string[], - LanguagesServerClient?: string[], FirstKexFollows?: boolean, - ServerHostKeyAlgos?: string[], - - MACsServerClient?: string[], - /** * fixed size array of length: [16] */ Cookie?: Uint8Array, - CiphersClientServer?: string[], + ServerHostKeyAlgos?: string[], } diff --git a/pkg/js/libs/net/net.go b/pkg/js/libs/net/net.go index 7c2bb8b438..f1237f0eb1 100644 --- a/pkg/js/libs/net/net.go +++ b/pkg/js/libs/net/net.go @@ -172,16 +172,16 @@ func (c *NetConn) Send(data string) error { return nil } -// Recv receives data from the connection with a timeout. +// RecvFull receives data from the connection with a timeout. // If N is 0, it will read all data sent by the server with 8MB limit. // it tries to read until N bytes or timeout is reached. // @example // ```javascript // const net = require('nuclei/net'); // const conn = net.Open('tcp', 'acme.com:80'); -// const data = conn.Recv(1024); +// const data = conn.RecvFull(1024); // ``` -func (c *NetConn) Recv(N int) ([]byte, error) { +func (c *NetConn) RecvFull(N int) ([]byte, error) { c.setDeadLine() defer c.unsetDeadLine() if N == 0 { @@ -195,17 +195,18 @@ func (c *NetConn) Recv(N int) ([]byte, error) { return bin, nil } -// RecvPartial is similar to Recv but it does not perform full read instead +// Recv is similar to RecvFull but does not guarantee full read instead // it creates a buffer of N bytes and returns whatever is returned by the connection -// this is usually used when fingerprinting services to get initial bytes from the server. +// for reading headers or initial bytes from the server this is usually used. +// for reading a fixed number of already known bytes (ex: body based on content-length) use RecvFull. // @example // ```javascript // const net = require('nuclei/net'); // const conn = net.Open('tcp', 'acme.com:80'); -// const data = conn.RecvPartial(1024); +// const data = conn.Recv(1024); // log(`Received ${data.length} bytes from the server`) // ``` -func (c *NetConn) RecvPartial(N int) ([]byte, error) { +func (c *NetConn) Recv(N int) ([]byte, error) { c.setDeadLine() defer c.unsetDeadLine() if N == 0 { @@ -219,13 +220,31 @@ func (c *NetConn) RecvPartial(N int) ([]byte, error) { return b[:n], nil } -// RecvString receives data from the connection with a timeout +// RecvFullString receives data from the connection with a timeout // output is returned as a string. // If N is 0, it will read all data sent by the server with 8MB limit. // @example // ```javascript // const net = require('nuclei/net'); // const conn = net.Open('tcp', 'acme.com:80'); +// const data = conn.RecvFullString(1024); +// ``` +func (c *NetConn) RecvFullString(N int) (string, error) { + bin, err := c.RecvFull(N) + if err != nil { + return "", err + } + return string(bin), nil +} + +// RecvString is similar to RecvFullString but does not guarantee full read, instead +// it creates a buffer of N bytes and returns whatever is returned by the connection +// for reading headers or initial bytes from the server this is usually used. +// for reading a fixed number of already known bytes (ex: body based on content-length) use RecvFullString. +// @example +// ```javascript +// const net = require('nuclei/net'); +// const conn = net.Open('tcp', 'acme.com:80'); // const data = conn.RecvString(1024); // ``` func (c *NetConn) RecvString(N int) (string, error) { @@ -236,9 +255,28 @@ func (c *NetConn) RecvString(N int) (string, error) { return string(bin), nil } -// RecvHex receives data from the connection with a timeout +// RecvFullHex receives data from the connection with a timeout // in hex format. // If N is 0,it will read all data sent by the server with 8MB limit. +// until N bytes or timeout is reached. +// @example +// ```javascript +// const net = require('nuclei/net'); +// const conn = net.Open('tcp', 'acme.com:80'); +// const data = conn.RecvFullHex(1024); +// ``` +func (c *NetConn) RecvFullHex(N int) (string, error) { + bin, err := c.RecvFull(N) + if err != nil { + return "", err + } + return hex.Dump(bin), nil +} + +// RecvHex is similar to RecvFullHex but does not guarantee full read instead +// it creates a buffer of N bytes and returns whatever is returned by the connection +// for reading headers or initial bytes from the server this is usually used. +// for reading a fixed number of already known bytes (ex: body based on content-length) use RecvFull. // @example // ```javascript // const net = require('nuclei/net'); From b7082f4613d5355da97adef5534a9d5e00db3c74 Mon Sep 17 00:00:00 2001 From: Tarun Koyalwar Date: Fri, 1 Mar 2024 04:06:03 +0530 Subject: [PATCH 7/7] remove debug stmt --- pkg/protocols/common/interactsh/interactsh.go | 1 - 1 file changed, 1 deletion(-) diff --git a/pkg/protocols/common/interactsh/interactsh.go b/pkg/protocols/common/interactsh/interactsh.go index 5e7a446c53..b808359856 100644 --- a/pkg/protocols/common/interactsh/interactsh.go +++ b/pkg/protocols/common/interactsh/interactsh.go @@ -170,7 +170,6 @@ func (c *Client) processInteractionForRequest(interaction *server.Interaction, d data.Event.Unlock() if data.Operators != nil { - fmt.Printf("processing interaction for request %v\n", interaction.UniqueID) result, matched = data.Operators.Execute(data.Event.InternalEvent, data.MatchFunc, data.ExtractFunc, c.options.Debug || c.options.DebugRequest || c.options.DebugResponse) } else { // this is most likely a bug so error instead of warning