> ## Documentation Index
> Fetch the complete documentation index at: https://projectdiscovery-nuclei-syntax-docs.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Smb.SMBClient

# Class: SMBClient

[smb](/templates/protocols/javascript/modules/smb).SMBClient

SMBClient is a client for SMB servers.
Internally client uses github.com/zmap/zgrab2/lib/smb/smb driver.
github.com/projectdiscovery/go-smb2 driver

**`Example`**

```javascript
const smb = require('nuclei/smb');
const client = new smb.SMBClient();
```

## Table of contents

### Constructors

* [constructor](/templates/protocols/javascript/modules/smb.SMBClient#constructor)

### Methods

* [ConnectSMBInfoMode](/templates/protocols/javascript/modules/smb.SMBClient#connectsmbinfomode)
* [DetectSMBGhost](/templates/protocols/javascript/modules/smb.SMBClient#detectsmbghost)
* [ListSMBv2Metadata](/templates/protocols/javascript/modules/smb.SMBClient#listsmbv2metadata)
* [ListShares](/templates/protocols/javascript/modules/smb.SMBClient#listshares)

## Constructors

### constructor

• **new SMBClient**(): [`SMBClient`](/templates/protocols/javascript/modules/smb.SMBClient)

#### Returns

[`SMBClient`](/templates/protocols/javascript/modules/smb.SMBClient)

#### Defined in

smb.ts:17

## Methods

### ConnectSMBInfoMode

▸ **ConnectSMBInfoMode**(`host`, `port`): [`SMBLog`](/templates/protocols/javascript/modules/smb.SMBLog)

ConnectSMBInfoMode tries to connect to provided host and port
and discovery SMB information
Returns handshake log and error. If error is not nil,
state will be false

#### Parameters

| Name   | Type     |
| :----- | :------- |
| `host` | `string` |
| `port` | `number` |

#### Returns

[`SMBLog`](/templates/protocols/javascript/modules/smb.SMBLog)

**`Example`**

```javascript
const smb = require('nuclei/smb');
const client = new smb.SMBClient();
const info = client.ConnectSMBInfoMode('acme.com', 445);
log(to_json(info));
```

#### Defined in

smb.ts:31

***

### DetectSMBGhost

▸ **DetectSMBGhost**(`host`, `port`): `boolean`

DetectSMBGhost tries to detect SMBGhost vulnerability
by using SMBv3 compression feature.
If the host is vulnerable, it returns true.

#### Parameters

| Name   | Type     |
| :----- | :------- |
| `host` | `string` |
| `port` | `number` |

#### Returns

`boolean`

**`Example`**

```javascript
const smb = require('nuclei/smb');
const isSMBGhost = smb.DetectSMBGhost('acme.com', 445);
```

#### Defined in

smb.ts:84

***

### ListSMBv2Metadata

▸ **ListSMBv2Metadata**(`host`, `port`): [`ServiceSMB`](/templates/protocols/javascript/modules/smb.ServiceSMB)

ListSMBv2Metadata tries to connect to provided host and port
and list SMBv2 metadata.
Returns metadata and error. If error is not nil,
state will be false

#### Parameters

| Name   | Type     |
| :----- | :------- |
| `host` | `string` |
| `port` | `number` |

#### Returns

[`ServiceSMB`](/templates/protocols/javascript/modules/smb.ServiceSMB)

**`Example`**

```javascript
const smb = require('nuclei/smb');
const client = new smb.SMBClient();
const metadata = client.ListSMBv2Metadata('acme.com', 445);
log(to_json(metadata));
```

#### Defined in

smb.ts:49

***

### ListShares

▸ **ListShares**(`host`, `port`, `user`): `string`\[]

ListShares tries to connect to provided host and port
and list shares by using given credentials.
Credentials cannot be blank. guest or anonymous credentials
can be used by providing empty password.

#### Parameters

| Name   | Type     |
| :----- | :------- |
| `host` | `string` |
| `port` | `number` |
| `user` | `string` |

#### Returns

`string`\[]

**`Example`**

```javascript
const smb = require('nuclei/smb');
const client = new smb.SMBClient();
const shares = client.ListShares('acme.com', 445, 'username', 'password');
	for (const share of shares) {
		  log(share);
	}
```

#### Defined in

smb.ts:69
