# NTFS

NTFS is the default Windows file system.

## Permissions

<table><thead><tr><th width="338">Permission</th><th width="356">Description</th></tr></thead><tbody><tr><td>F</td><td>full access</td></tr><tr><td>D</td><td>delete access</td></tr><tr><td>N</td><td>no access</td></tr><tr><td>M</td><td>modify access</td></tr><tr><td>RX</td><td>read and execute access</td></tr><tr><td>R</td><td>read-only access</td></tr><tr><td>W</td><td>write-only acces</td></tr></tbody></table>

### &#x20;icacls

`icacls` stands for **Integrity Control Access Control List**.

```powershell
# check folder's permissions
icacls c:\windows\myfolder
# grant full permissions
icacls c:\windows\myfolder /grant <USER>:f
# remove permissions
icacls c:\users /remove <USER>
```

### NTFS vs Share

* NTFS permissions apply to the system where the folder and files are hosted.&#x20;
* Share permissions apply when the folder is accessed through SMB, typically remotely.

Someone logged in locally or via RDP only need to consider NTFS permissions.

## Example

Create a folder, turn it into share, and review permissions for `htb-student` (Figure 1).

<figure><img src="https://3960676229-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmjLkek16kB60c2WFd5lf%2Fuploads%2FuZdIJZDYbtAp9PFFfoeU%2Fwindows_creating_share.png?alt=media&#x26;token=ff1eed6e-3348-499f-9986-5c5b7394fbd0" alt=""><figcaption><p>Figure 1: Turning a folder into a share and reviewing SMB permissions.</p></figcaption></figure>

Although `Everyone` has `READ` access, this does not show below. This is because Windows Defender blocks access from any device that is not joined to the same workgroup, and proper inbound rules must be in place.

```bash
smbclient -L <TARGET-IP> -U htb-student
Enter WORKGROUP\htb-student's password: 

	Sharename       Type      Comment
	---------       ----      -------
	ADMIN$          Disk      Remote Admin
	C$              Disk      Default share
	My Folder       Disk      
	IPC$            IPC       Remote IPC
```

Once inbound rules are in place, and because the account `htb-student` is part of the `Everyone` group, we will be able to inherit its permissions and access the share. We can then create a **mount point**; this is where the NTFS permissions must be considered alongside share permissions. A grey checkmark means that it was inherited from a parent directory (Figure 2).

<figure><img src="https://3960676229-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmjLkek16kB60c2WFd5lf%2Fuploads%2F7chJH16FSVeAhBjIjHMq%2Fwindows_ntfs_perms.png?alt=media&#x26;token=4d988655-70e2-496f-9f2e-5eddf8821f58" alt=""><figcaption><p>Figure 2: NTFS permissions of the My Folder directory.</p></figcaption></figure>

{% code overflow="wrap" %}

```bash
sudo mount -t cifs -o username=htb-student,password=Academy_WinFun! //<TARGET-IP>/"My Folder" /home/user/Desktop/
```

{% endcode %}

If we check all the shared folders on the system, we will notice that more than just the `My Folder` share are actually shared. The `C:\` directory is shared via SMB at install which means anyone with proper access could remotely access it!

```powershell
C:\Users\htb-student> net share

Share name   Resource                        Remark

-------------------------------------------------------------------------------
C$           C:\                             Default share
IPC$                                         Remote IPC
ADMIN$       C:\WINDOWS                      Remote Admin
My Folder    C:\Users\htb-student\Desktop\My Folder

The command completed successfully.
```
