Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pkg/js/compiler/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 5 additions & 1 deletion pkg/js/devtools/bindgen/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
4 changes: 3 additions & 1 deletion pkg/js/devtools/tsgen/scrape.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 12 additions & 3 deletions pkg/js/generated/go/librdp/rdp.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down
5 changes: 3 additions & 2 deletions pkg/js/generated/go/librsync/rsync.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down
16 changes: 13 additions & 3 deletions pkg/js/generated/go/libtelnet/telnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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()
}
Expand Down
29 changes: 29 additions & 0 deletions pkg/js/generated/go/libutils/utils.go
Original file line number Diff line number Diff line change
@@ -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)
}
8 changes: 4 additions & 4 deletions pkg/js/generated/ts/fs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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;
}

Expand All @@ -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;
}

Expand All @@ -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 change: 1 addition & 0 deletions pkg/js/generated/ts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
94 changes: 47 additions & 47 deletions pkg/js/generated/ts/kerberos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,9 @@ export class Config {
*/
export interface AuthorizationDataEntry {

ADData?: Uint8Array,

ADType?: number,

ADData?: Uint8Array,
}


Expand All @@ -212,9 +212,9 @@ export interface BitString {
*/
export interface BitString {

Bytes?: Uint8Array,

BitLength?: number,

Bytes?: Uint8Array,
}


Expand All @@ -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,
Expand Down Expand Up @@ -318,81 +318,81 @@ export interface HostAddress {
*/
export interface LibDefaults {

CCacheType?: number,
Forwardable?: boolean,

K5LoginAuthoritative?: boolean,
RDNS?: boolean,

Proxiable?: boolean,
DefaultTGSEnctypes?: string[],

RDNS?: boolean,
DefaultTktEnctypes?: string[],

K5LoginDirectory?: string,
DNSLookupKDC?: boolean,

KDCTimeSync?: number,
ExtraAddresses?: Uint8Array,

VerifyAPReqNofail?: boolean,
UDPPreferenceLimit?: number,

DefaultTGSEnctypes?: string[],
DefaultKeytabName?: string,

DefaultRealm?: string,

DefaultTGSEnctypeIDs?: number[],

DNSCanonicalizeHostname?: boolean,

Forwardable?: boolean,
K5LoginAuthoritative?: boolean,

/**
* time in nanoseconds
*/

RenewLifetime?: number,

AllowWeakCrypto?: boolean,

Canonicalize?: boolean,

/**
* time in nanoseconds
*/

TicketLifetime?: number,

DefaultClientKeytabName?: string,

DefaultTktEnctypeIDs?: number[],
Clockskew?: number,

DNSLookupRealm?: boolean,

ExtraAddresses?: Uint8Array,

DefaultRealm?: string,
IgnoreAcceptorHostname?: boolean,

NoAddresses?: boolean,
PermittedEnctypeIDs?: number[],

PreferredPreauthTypes?: number[],

PermittedEnctypeIDs?: number[],

RealmTryDomains?: number,

DefaultKeytabName?: string,
K5LoginDirectory?: string,

DefaultTktEnctypes?: string[],
KDCTimeSync?: number,

DNSLookupKDC?: boolean,
NoAddresses?: boolean,

IgnoreAcceptorHostname?: boolean,
PermittedEnctypes?: string[],

AllowWeakCrypto?: boolean,
/**
* time in nanoseconds
*/

Canonicalize?: boolean,
TicketLifetime?: number,

SafeChecksumType?: number,
VerifyAPReqNofail?: boolean,

UDPPreferenceLimit?: number,
DefaultClientKeytabName?: string,

/**
* time in nanoseconds
*/
Proxiable?: boolean,

Clockskew?: number,
CCacheType?: number,

PermittedEnctypes?: string[],
DefaultTktEnctypeIDs?: number[],

SafeChecksumType?: number,

KDCDefaultOptions?: BitString,
}
Expand All @@ -404,9 +404,9 @@ export interface LibDefaults {
*/
export interface PrincipalName {

NameString?: string[],

NameType?: number,

NameString?: string[],
}


Expand All @@ -416,17 +416,17 @@ export interface PrincipalName {
*/
export interface Realm {

Realm?: string,

AdminServer?: string[],

DefaultDomain?: string,

KDC?: string[],

KPasswdServer?: string[],

MasterKDC?: string[],

Realm?: string,

AdminServer?: string[],
}


Expand Down
Loading
Loading