Thanks to visit codestin.com
Credit goes to github.com

Skip to content

voycetony/htb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 

Repository files navigation

HTB


Notes


The big compliance players in information security are 

PCI

HIPAA

FISMA

, and 

ISO 27001

.

Project Organization Example


Tonyleevo@htb[/htb]$ tree Projects/

Projects/

└── Acme Company

├── EPT

│ ├── evidence

│ │ ├── credentials

│ │ ├── data

│ │ └── screenshots

│ ├── logs

│ ├── scans

│ ├── scope

│ └── tools

└── IPT

├── evidence

│ ├── credentials

│ ├── data

│ └── screenshots

├── logs

├── scans

├── scope

└── tools

TMUX


Using Tmux

Terminal multiplexers, like tmux or Screen, are great utilities for expanding a standard Linux terminal's features, like having multiple windows within one terminal and jumping between them. Let's see some examples of using tmux, which is the more common of the two. If tmux is not present on our Linux system, we can install it with the following command:

  Basic Tools

Tonyleevo@htb[/htb]$ sudo apt install tmux -y

Once we have tmux, we can start it by entering tmux as our command: images/5-1.png

The default key to input tmux commands prefix is [CTRL + B]. In order to open a new window in tmux, we can hit the prefix 'i.e. [CTRL + B]' and then hit Cimages/5-2.png

We see the numbered windows at the bottom. We can switch to each window by hitting the prefix and then inputting the window number, like 0 or 1. We can also split a window vertically into panes by hitting the prefix and then [SHIFT + %]images/5-3.png

We can also split into horizontal panes by hitting the prefix and then [SHIFT + "]images/5-4.png

We can switch between panes by hitting the prefix and then the left or right arrows for horizontal switching or the up or down arrows for vertical switching. The commands above cover some basic tmux usage. It is a powerful tool and can be used for many things, including logging, which is very important during any technical engagement. This cheatsheet is a very handy reference. Also, this Introduction to tmux video by ippsec is worth your time.

Banner Grab Example


Netcatncat, or nc, is an excellent network utility for interacting with TCP/UDP ports. It can be used for many things during a pentest. Its primary usage is for connecting to shells, which we'll discuss later in this module. In addition to that, netcat can be used to connect to any listening port and interact with the service running on that port. For example, SSH is programmed to handle connections over port 22 to send all data and keys. We can connect to TCP port 22 with netcat:

  Basic Tools

Tonyleevo@htb[/htb]$ netcat 10.10.10.10 22

SSH-2.0-OpenSSH_8.4p1 Debian-3

As we can see, port 22 sent us its banner, stating that SSH is running on it. This technique is called Banner Grabbing, and can help identify what service is running on a particular port. Netcat comes pre-installed in most Linux distributions. We can also download a copy for Windows machines from this link. There's another Windows alternative to netcat coded in PowerShell called PowerCatNetcat can also be used to transfer files between machines, as we'll discuss later.

nmap


We can use the 

-sC

 parameter to specify that 

Nmap

 scripts should be used to try and obtain more detailed information. The 

-sV

 parameter instructs 

Nmap

 to perform a version scan. In this scan, Nmap will fingerprint services on the target system and identify the service protocol, application name, and version. The version scan is underpinned by a comprehensive database of over 1,000 service signatures. Finally, 

-p-

 tells Nmap that we want to scan all 65,535 TCP ports.

Nmap Scripts

Specifying -sC will run many useful default scripts against a target, but there are cases when running a specific script is required. For example, in an assessment scope, we may be asked to audit a large Citrix installation. We could use this Nmap script to audit for the severe Citrix NetScaler vulnerability (CVE-2019–19781), while Nmap also has other scripts to audit a Citrix installation.

  Service Scanning

Tonyleevo@htb[/htb]$ locate scripts/citrix

/usr/share/nmap/scripts/citrix-brute-xml.nse

/usr/share/nmap/scripts/citrix-enum-apps-xml.nse

/usr/share/nmap/scripts/citrix-enum-apps.nse

/usr/share/nmap/scripts/citrix-enum-servers-xml.nse

/usr/share/nmap/scripts/citrix-enum-servers.nse

Banner Grabbing

As previously discussed, banner grabbing is a useful technique to fingerprint a service quickly. Often a service will look to identify itself by displaying a banner once a connection is initiated. Nmap will attempt to grab the banners if the syntax nmap -sV --script=banner <target> is specified. We can also attempt this manually using Netcat. Let us take another example, using the nc version of Netcat:

  Service Scanning

Tonyleevo@htb[/htb]$ nc -nv 10.129.42.253 21

(UNKNOWN) [10.129.42.253] 21 (ftp) open

220 (vsFTPd 3.0.3)

This reveals that the version of vsFTPd on the server is 3.0.3. We can also automate this process using Nmap's powerful scripting engine: nmap -sV --script=banner -p21 10.10.10.0/24.

FTP

It is worth gaining familiarity with FTP, as it is a standard protocol, and this service can often contain interesting data. A Nmap scan of the default port for FTP (21) reveals the vsftpd 3.0.3 installation that we identified previously. Further, it also reports that anonymous authentication is enabled and that a pub directory is available.

  Service Scanning

Tonyleevo@htb[/htb]$ nmap -sC -sV -p21 10.129.42.253

Starting Nmap 7.80 ( https://nmap.org ) at 2020-12-20 00:54 GMT

Nmap scan report for 10.129.42.253

Host is up (0.081s latency).

PORT STATE SERVICE VERSION

21/tcp open ftp vsftpd 3.0.3

| ftp-anon: Anonymous FTP login allowed (FTP code 230)

|_drwxr-xr-x 2 ftp ftp 4096 Dec 19 23:50 pub

| ftp-syst:

| STAT:

| FTP server status:

| Connected to ::ffff:10.10.14.2

| Logged in as ftp

| TYPE: ASCII

| No session bandwidth limit

| Session timeout in seconds is 300

| Control connection is plain text

| Data connections will be plain text

| At session startup, client count was 3

| vsFTPd 3.0.3 - secure, fast, stable

|_End of status

Service Info: OS: Unix

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .

Nmap done: 1 IP address (1 host up) scanned in 1.78 seconds

smb enumeration

nmap --script smb-os-discovery.nse -p445 10.10.10.40

  Service Scanning

Tonyleevo@htb[/htb]$ smbclient -N -L \\\\10.129.42.253

Sharename Type Comment

--------- ---- -------

print$ Disk Printer Drivers

users Disk

IPC$ IPC IPC Service (gs-svcscan server (Samba, Ubuntu))

SMB1 disabled -- no workgroup available

This reveals the non-default share users. Let us attempt to connect as the guest user.

  Service Scanning

Tonyleevo@htb[/htb]$ smbclient \\\\10.129.42.253\\users

Enter WORKGROUP\users's password:

Try "help" to get a list of possible commands.

smb: \> ls

NT_STATUS_ACCESS_DENIED listing \*

smb: \> exit

If we use the same scanning technique on the predefined list, the command will look like this:

  Host Discovery

Tonyleevo@htb[/htb]$ sudo nmap -sn -oA tnet -iL hosts.lst | grep for | cut -d" " -f5

Scanning Top 10 TCP Ports

  Host and Port Scanning

Tonyleevo@htb[/htb]$ sudo nmap 10.129.2.28 --top-ports=10

Starting Nmap 7.80 ( https://nmap.org ) at 2020-06-15 15:36 CEST

Nmap scan report for 10.129.2.28

Host is up (0.021s latency).

PORT STATE SERVICE

21/tcp closed ftp

22/tcp open ssh

23/tcp closed telnet

25/tcp open smtp

80/tcp open http

110/tcp open pop3

139/tcp filtered netbios-ssn

443/tcp closed https

445/tcp filtered microsoft-ds

3389/tcp closed ms-wbt-server

MAC Address: DE:AD:00:00:BE:EF (Intel Corporate)

It is also useful when the target host has a personal firewall that drops incoming packets but allows outgoing packets. In this case, a Connect scan can bypass the firewall and accurately determine the state of the target ports. However, it is important to note that the Connect scan is slower than other types of scans because it requires the scanner to wait for a response from the target after each packet it sends, which could take some time if the target is busy or unresponsive.

Scans like the SYN scan (also known as a half-open scan) are generally considered more stealthy because they do not complete the full handshake, leaving the connection incomplete after sending the initial SYN packet. This minimizes the chance of triggering connection logs while still gathering port state information. Advanced IDS/IPS systems, however, have adapted to detect even these subtler techniques.

Connect Scan on TCP Port 443

  Host and Port Scanning

Tonyleevo@htb[/htb]$ sudo nmap 10.129.2.28 -p 443 --packet-trace --disable-arp-ping -Pn -n --reason -sT

Starting Nmap 7.80 ( https://nmap.org ) at 2020-06-15 16:26 CET

CONN (0.0385s) TCP localhost > 10.129.2.28:443 => Operation now in progress

CONN (0.0396s) TCP localhost > 10.129.2.28:443 => Connected

Nmap scan report for 10.129.2.28

Host is up, received user-set (0.013s latency).

PORT STATE SERVICE REASON

443/tcp open https syn-ack

Nmap done: 1 IP address (1 host up) scanned in 0.04 seconds

Filtered Ports

When a port is shown as filtered, it can have several reasons. In most cases, firewalls have certain rules set to handle specific connections. The packets can either be dropped, or rejected. When a packet gets dropped, Nmap receives no response from our target, and by default, the retry rate (--max-retries) is set to 10. This means Nmap will resend the request to the target port to determine if the previous packet was accidentally mishandled or not.

Let us look at an example where the firewall drops the TCP packets we send for the port scan. Therefore we scan the TCP port 139, which was already shown as filtered. To be able to track how our sent packets are handled, we deactivate the ICMP echo requests (-Pn), DNS resolution (-n), and ARP ping scan (--disable-arp-ping) again.

  Host and Port Scanning

Tonyleevo@htb[/htb]$ sudo nmap 10.129.2.28 -p 139 --packet-trace -n --disable-arp-ping -Pn

Starting Nmap 7.80 ( https://nmap.org ) at 2020-06-15 15:45 CEST

SENT (0.0381s) TCP 10.10.14.2:60277 > 10.129.2.28:139 S ttl=47 id=14523 iplen=44 seq=4175236769 win=1024 <mss 1460>

SENT (1.0411s) TCP 10.10.14.2:60278 > 10.129.2.28:139 S ttl=45 id=7372 iplen=44 seq=4175171232 win=1024 <mss 1460>

Nmap scan report for 10.129.2.28

Host is up.

PORT STATE SERVICE

139/tcp filtered netbios-ssn

MAC Address: DE:AD:00:00:BE:EF (Intel Corporate)

Nmap done: 1 IP address (1 host up) scanned in 2.06 seconds

UDP Port Scan

  Host and Port Scanning

Tonyleevo@htb[/htb]$ sudo nmap 10.129.2.28 -F -sU

Starting Nmap 7.80 ( https://nmap.org ) at 2020-06-15 16:01 CEST

Nmap scan report for 10.129.2.28

Host is up (0.059s latency).

Not shown: 95 closed ports

PORT STATE SERVICE

68/udp open|filtered dhcpc

137/udp open netbios-ns

138/udp open|filtered netbios-dgm

631/udp open|filtered ipp

5353/udp open zeroconf

MAC Address: DE:AD:00:00:BE:EF (Intel Corporate)

nmap -A to resolve an IPs hostname

We can also specify the option (-oA) to save the results in all formats. The command could look like this:

  Saving the Results

Tonyleevo@htb[/htb]$ sudo nmap 10.129.2.28 -p- -oA target

Starting Nmap 7.80 ( https://nmap.org ) at 2020-06-16 12:14 CEST

Nmap scan report for 10.129.2.28

Host is up (0.0091s latency).

Not shown: 65525 closed ports

PORT STATE SERVICE

22/tcp open ssh

25/tcp open smtp

80/tcp open http

Default Scan

Performance

Tonyleevo@htb[/htb]$ sudo nmap 10.129.2.0/24 -F -oN tnet.default

<SNIP>

Nmap done: 256 IP addresses (10 hosts up) scanned in 32.44 seconds

Insane Scan

Performance

Tonyleevo@htb[/htb]$ sudo nmap 10.129.2.0/24 -F -oN tnet.T5 -T 5

<SNIP>

Nmap done: 256 IP addresses (10 hosts up) scanned in 18.07 seconds

Default Scan

  Performance

Tonyleevo@htb[/htb]$ sudo nmap 10.129.2.0/24 -F -oN tnet.default

<SNIP>

Nmap done: 256 IP addresses (10 hosts up) scanned in 32.44 seconds

Insane Scan

  Performance

Tonyleevo@htb[/htb]$ sudo nmap 10.129.2.0/24 -F -oN tnet.T5 -T 5

<SNIP>

Nmap done: 256 IP addresses (10 hosts up) scanned in 18.07 seconds

SYN-Scan

  Firewall and IDS/IPS Evasion

Tonyleevo@htb[/htb]$ sudo nmap 10.129.2.28 -p 21,22,25 -sS -Pn -n --disable-arp-ping --packet-trace

ACK-Scan

  Firewall and IDS/IPS Evasion

Tonyleevo@htb[/htb]$ sudo nmap 10.129.2.28 -p 21,22,25 -sA -Pn -n --disable-arp-ping --packet-trace

Scan by Using Decoys

  Firewall and IDS/IPS Evasion

Tonyleevo@htb[/htb]$ sudo nmap 10.129.2.28 -p 80 -sS -Pn -n --disable-arp-ping --packet-trace -D RND:5

Testing Firewall Rule

  Firewall and IDS/IPS Evasion

Tonyleevo@htb[/htb]$ sudo nmap 10.129.2.28 -n -Pn -p445 -O

Starting Nmap 7.80 ( https://nmap.org ) at 2020-06-22 01:23 CEST

Scan by Using Different Source IP

  Firewall and IDS/IPS Evasion

Tonyleevo@htb[/htb]$ sudo nmap 10.129.2.28 -n -Pn -p 445 -O -S 10.129.2.200 -e tun0

SYN-Scan of a Filtered Port

  Firewall and IDS/IPS Evasion

Tonyleevo@htb[/htb]$ sudo nmap 10.129.2.28 -p50000 -sS -Pn -n --disable-arp-ping --packet-trace

Connect To The Filtered Port

  Firewall and IDS/IPS Evasion

Tonyleevo@htb[/htb]$ ncat -nv --source-port 53 10.129.2.28 50000

nmap


We can use the 

-sC

 parameter to specify that 

Nmap

 scripts should be used to try and obtain more detailed information. The 

-sV

 parameter instructs 

Nmap

 to perform a version scan. In this scan, Nmap will fingerprint services on the target system and identify the service protocol, application name, and version. The version scan is underpinned by a comprehensive database of over 1,000 service signatures. Finally, 

-p-

 tells Nmap that we want to scan all 65,535 TCP ports.

Nmap Scripts

Specifying -sC will run many useful default scripts against a target, but there are cases when running a specific script is required. For example, in an assessment scope, we may be asked to audit a large Citrix installation. We could use this Nmap script to audit for the severe Citrix NetScaler vulnerability (CVE-2019–19781), while Nmap also has other scripts to audit a Citrix installation.

  Service Scanning

Tonyleevo@htb[/htb]$ locate scripts/citrix

/usr/share/nmap/scripts/citrix-brute-xml.nse

/usr/share/nmap/scripts/citrix-enum-apps-xml.nse

/usr/share/nmap/scripts/citrix-enum-apps.nse

/usr/share/nmap/scripts/citrix-enum-servers-xml.nse

/usr/share/nmap/scripts/citrix-enum-servers.nse

Banner Grabbing

As previously discussed, banner grabbing is a useful technique to fingerprint a service quickly. Often a service will look to identify itself by displaying a banner once a connection is initiated. Nmap will attempt to grab the banners if the syntax nmap -sV --script=banner <target> is specified. We can also attempt this manually using Netcat. Let us take another example, using the nc version of Netcat:

  Service Scanning

Tonyleevo@htb[/htb]$ nc -nv 10.129.42.253 21

(UNKNOWN) [10.129.42.253] 21 (ftp) open

220 (vsFTPd 3.0.3)

This reveals that the version of vsFTPd on the server is 3.0.3. We can also automate this process using Nmap's powerful scripting engine: nmap -sV --script=banner -p21 10.10.10.0/24.

FTP

It is worth gaining familiarity with FTP, as it is a standard protocol, and this service can often contain interesting data. A Nmap scan of the default port for FTP (21) reveals the vsftpd 3.0.3 installation that we identified previously. Further, it also reports that anonymous authentication is enabled and that a pub directory is available.

  Service Scanning

Tonyleevo@htb[/htb]$ nmap -sC -sV -p21 10.129.42.253

Starting Nmap 7.80 ( https://nmap.org ) at 2020-12-20 00:54 GMT

Nmap scan report for 10.129.42.253

Host is up (0.081s latency).

PORT STATE SERVICE VERSION

21/tcp open ftp vsftpd 3.0.3

| ftp-anon: Anonymous FTP login allowed (FTP code 230)

|_drwxr-xr-x 2 ftp ftp 4096 Dec 19 23:50 pub

| ftp-syst:

| STAT:

| FTP server status:

| Connected to ::ffff:10.10.14.2

| Logged in as ftp

| TYPE: ASCII

| No session bandwidth limit

| Session timeout in seconds is 300

| Control connection is plain text

| Data connections will be plain text

| At session startup, client count was 3

| vsFTPd 3.0.3 - secure, fast, stable

|_End of status

Service Info: OS: Unix

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .

Nmap done: 1 IP address (1 host up) scanned in 1.78 seconds

smb enumeration

nmap --script smb-os-discovery.nse -p445 10.10.10.40

  Service Scanning

Tonyleevo@htb[/htb]$ smbclient -N -L \\\\10.129.42.253

Sharename Type Comment

--------- ---- -------

print$ Disk Printer Drivers

users Disk

IPC$ IPC IPC Service (gs-svcscan server (Samba, Ubuntu))

SMB1 disabled -- no workgroup available

This reveals the non-default share users. Let us attempt to connect as the guest user.

  Service Scanning

Tonyleevo@htb[/htb]$ smbclient \\\\10.129.42.253\\users

Enter WORKGROUP\users's password:

Try "help" to get a list of possible commands.

smb: \> ls

NT_STATUS_ACCESS_DENIED listing \*

smb: \> exit

If we use the same scanning technique on the predefined list, the command will look like this:

  Host Discovery

Tonyleevo@htb[/htb]$ sudo nmap -sn -oA tnet -iL hosts.lst | grep for | cut -d" " -f5

Scanning Top 10 TCP Ports

  Host and Port Scanning

Tonyleevo@htb[/htb]$ sudo nmap 10.129.2.28 --top-ports=10

Starting Nmap 7.80 ( https://nmap.org ) at 2020-06-15 15:36 CEST

Nmap scan report for 10.129.2.28

Host is up (0.021s latency).

PORT STATE SERVICE

21/tcp closed ftp

22/tcp open ssh

23/tcp closed telnet

25/tcp open smtp

80/tcp open http

110/tcp open pop3

139/tcp filtered netbios-ssn

443/tcp closed https

445/tcp filtered microsoft-ds

3389/tcp closed ms-wbt-server

MAC Address: DE:AD:00:00:BE:EF (Intel Corporate)

It is also useful when the target host has a personal firewall that drops incoming packets but allows outgoing packets. In this case, a Connect scan can bypass the firewall and accurately determine the state of the target ports. However, it is important to note that the Connect scan is slower than other types of scans because it requires the scanner to wait for a response from the target after each packet it sends, which could take some time if the target is busy or unresponsive.

Scans like the SYN scan (also known as a half-open scan) are generally considered more stealthy because they do not complete the full handshake, leaving the connection incomplete after sending the initial SYN packet. This minimizes the chance of triggering connection logs while still gathering port state information. Advanced IDS/IPS systems, however, have adapted to detect even these subtler techniques.

Connect Scan on TCP Port 443

  Host and Port Scanning

Tonyleevo@htb[/htb]$ sudo nmap 10.129.2.28 -p 443 --packet-trace --disable-arp-ping -Pn -n --reason -sT

Starting Nmap 7.80 ( https://nmap.org ) at 2020-06-15 16:26 CET

CONN (0.0385s) TCP localhost > 10.129.2.28:443 => Operation now in progress

CONN (0.0396s) TCP localhost > 10.129.2.28:443 => Connected

Nmap scan report for 10.129.2.28

Host is up, received user-set (0.013s latency).

PORT STATE SERVICE REASON

443/tcp open https syn-ack

Nmap done: 1 IP address (1 host up) scanned in 0.04 seconds

Filtered Ports

When a port is shown as filtered, it can have several reasons. In most cases, firewalls have certain rules set to handle specific connections. The packets can either be dropped, or rejected. When a packet gets dropped, Nmap receives no response from our target, and by default, the retry rate (--max-retries) is set to 10. This means Nmap will resend the request to the target port to determine if the previous packet was accidentally mishandled or not.

Let us look at an example where the firewall drops the TCP packets we send for the port scan. Therefore we scan the TCP port 139, which was already shown as filtered. To be able to track how our sent packets are handled, we deactivate the ICMP echo requests (-Pn), DNS resolution (-n), and ARP ping scan (--disable-arp-ping) again.

  Host and Port Scanning

Tonyleevo@htb[/htb]$ sudo nmap 10.129.2.28 -p 139 --packet-trace -n --disable-arp-ping -Pn

Starting Nmap 7.80 ( https://nmap.org ) at 2020-06-15 15:45 CEST

SENT (0.0381s) TCP 10.10.14.2:60277 > 10.129.2.28:139 S ttl=47 id=14523 iplen=44 seq=4175236769 win=1024 <mss 1460>

SENT (1.0411s) TCP 10.10.14.2:60278 > 10.129.2.28:139 S ttl=45 id=7372 iplen=44 seq=4175171232 win=1024 <mss 1460>

Nmap scan report for 10.129.2.28

Host is up.

PORT STATE SERVICE

139/tcp filtered netbios-ssn

MAC Address: DE:AD:00:00:BE:EF (Intel Corporate)

Nmap done: 1 IP address (1 host up) scanned in 2.06 seconds

UDP Port Scan

  Host and Port Scanning

Tonyleevo@htb[/htb]$ sudo nmap 10.129.2.28 -F -sU

Starting Nmap 7.80 ( https://nmap.org ) at 2020-06-15 16:01 CEST

Nmap scan report for 10.129.2.28

Host is up (0.059s latency).

Not shown: 95 closed ports

PORT STATE SERVICE

68/udp open|filtered dhcpc

137/udp open netbios-ns

138/udp open|filtered netbios-dgm

631/udp open|filtered ipp

5353/udp open zeroconf

MAC Address: DE:AD:00:00:BE:EF (Intel Corporate)

nmap -A to resolve an IPs hostname

We can also specify the option (-oA) to save the results in all formats. The command could look like this:

  Saving the Results

Tonyleevo@htb[/htb]$ sudo nmap 10.129.2.28 -p- -oA target

Starting Nmap 7.80 ( https://nmap.org ) at 2020-06-16 12:14 CEST

Nmap scan report for 10.129.2.28

Host is up (0.0091s latency).

Not shown: 65525 closed ports

PORT STATE SERVICE

22/tcp open ssh

25/tcp open smtp

80/tcp open http

find filtered dns version

nmap 10.129.2.48 -p 53 -Pn -sU -sV

nmap script


nmap -sV --script=http-enum -oA nibbles_nmap_http_enum 10.129.17.122

CategoryDescription
authDetermination of authentication credentials.
broadcastScripts, which are used for host discovery by broadcasting and the discovered hosts, can be automatically added to the remaining scans.
bruteExecutes scripts that try to log in to the respective service by brute-forcing with credentials.
defaultDefault scripts executed by using the -sC option.
discoveryEvaluation of accessible services.
dosThese scripts are used to check services for denial of service vulnerabilities and are used less as it harms the services.
exploitThis category of scripts tries to exploit known vulnerabilities for the scanned port.
externalScripts that use external services for further processing.
fuzzerThis uses scripts to identify vulnerabilities and unexpected packet handling by sending different fields, which can take much time.
intrusiveIntrusive scripts that could negatively affect the target system.
malwareChecks if some malware infects the target system.
safeDefensive scripts that do not perform intrusive and destructive access.
versionExtension for service detection.
vulnIdentification of specific vulnerabilities.

onyleevo@htb[/htb]$ sudo nmap 10.129.2.28 -p 25 --script banner,smtp-commands

Starting Nmap 7.80 ( https://nmap.org ) at 2020-06-16 23:21 CEST

Nmap scan report for 10.129.2.28

Host is up (0.050s latency).

PORT STATE SERVICE

25/tcp open smtp

Nmap - Aggressive Scan

  Nmap Scripting Engine

Tonyleevo@htb[/htb]$ sudo nmap 10.129.2.28 -p 80 -A

Starting Nmap 7.80 ( https://nmap.org ) at 2020-06-17 01:38 CEST

Nmap scan report for 10.129.2.28

Host is up (0.012s latency).

PORT STATE SERVICE VERSION

80/tcp open http Apache httpd 2.4.29 ((Ubuntu))

|_http-generator: WordPress 5.3.4

|_http-server-header: Apache/2.4.29 (Ubuntu)

|_http-title: blog.inlanefreight.com

MAC Address: DE:AD:00:00:BE:EF (Intel Corporate)

Warning: OSScan results may be unreliable because we could not find at least 1 open and 1 closed port

Aggressive OS guesses: Linux 2.6.32 (96%), Linux 3.2 - 4.9 (96%), Linux 2.6.32 - 3.10 (96%), Linux 3.4 - 3.10 (95%), Linux 3.1 (95%), Linux 3.2 (95%),

AXIS 210A or 211 Network Camera (Linux 2.6.17) (94%), Synology DiskStation Manager 5.2-5644 (94%), Netgear RAIDiator 4.2.28 (94%),

Linux 2.6.32 - 2.6.35 (94%)

No exact OS matches for host (test conditions non-ideal).

Network Distance: 1 hop

tcpdump


Tcpdump

  Service Enumeration

Tonyleevo@htb[/htb]$ sudo tcpdump -i eth0 host 10.10.14.2 and 10.129.2.28

tcpdump: verbose output suppressed, use -v or -vv for full protocol decode

SMB


 Service Scanning

Tonyleevo@htb[/htb]$ smbclient -N -L \\\\10.129.42.253

Sharename Type Comment

--------- ---- -------

print$ Disk Printer Drivers

users Disk

IPC$ IPC IPC Service (gs-svcscan server (Samba, Ubuntu))

SMB1 disabled -- no workgroup available

This reveals the non-default share users. Let us attempt to connect as the guest user.

  Service Scanning

Tonyleevo@htb[/htb]$ smbclient \\\\10.129.42.253\\users

Enter WORKGROUP\users's password:

Try "help" to get a list of possible commands.

smb: \> ls

NT_STATUS_ACCESS_DENIED listing \*

smb: \> exit

smbclient -U bob \\\\10.129.42.253\\users

Samba

As mentioned earlier, there is an alternative implementation of the SMB server called Samba, which is developed for Unix-based operating systems. 

Restart Samba

  SMB

root@samba:~# sudo systemctl restart smbd

Now we can display a list (-L) of the server's shares with the smbclient command from our host. We use the so-called null session (-N), which is anonymous access without the input of existing users or valid passwords.

SMBclient - Connecting to the Share

  SMB

Tonyleevo@htb[/htb]$ smbclient -N -L //10.129.14.128

Sharename Type Comment

--------- ---- -------

print$ Disk Printer Drivers

home Disk INFREIGHT Samba

dev Disk DEVenv

notes Disk CheckIT

IPC$ IPC IPC Service (DEVSM)

SMB1 disabled -- no workgroup available

For example, with domain-level security, the samba server acts as a member of a Windows domain. Each domain has at least one domain controller, usually a Windows NT server providing password authentication. This domain controller provides the workgroup with a definitive password server. The domain controllers keep track of users and passwords in their own NTDS.dit and Security Authentication Module (SAM) and authenticate each user when they log in for the first time and wish to access another machine's share.

Samba Status

  SMB

root@samba:~# smbstatus

Samba version 4.11.6-Ubuntu

PID Username Group Machine Protocol Version Encryption Signing

----------------------------------------------------------------------------------------------------------------------------------------

75691 sambauser samba 10.10.14.4 (ipv4:10.10.14.4:45564) SMB3_11 - -

Service pid Machine Connected at Encryption Signing

---------------------------------------------------------------------------------------------

notes 75691 10.10.14.4 Do Sep 23 00:12:06 2021 CEST -

Nmap

  SMB

Tonyleevo@htb[/htb]$ sudo nmap 10.129.14.128 -sV -sC -p139,445

Starting Nmap 7.80 ( https://nmap.org ) at 2021-09-19 15:15 CEST

Nmap scan report for sharing.inlanefreight.htb (10.129.14.128)

Host is up (0.00024s latency).

PORT STATE SERVICE VERSION

139/tcp open netbios-ssn Samba smbd 4.6.2

445/tcp open netbios-ssn Samba smbd 4.6.2

MAC Address: 00:00:00:00:00:00 (VMware)

Host script results:

|_nbstat: NetBIOS name: HTB, NetBIOS user: <unknown>, NetBIOS MAC: <unknown> (unknown)

| smb2-security-mode:

| 2.02:

|_ Message signing enabled but not required

| smb2-time:

| date: 2021-09-19T13:16:04

|_ start_date: N/A

Service detection performed. Please report any inco

RPCclient

  SMB

Tonyleevo@htb[/htb]$ rpcclient -U "" 10.129.14.128

Enter WORKGROUP\'s password:

rpcclient $>

The rpcclient offers us many different requests with which we can execute specific functions on the SMB server to get information. A complete list of all these functions can be found on the man page of the rpcclient.

QueryDescription
srvinfoServer information.
enumdomainsEnumerate all domains that are deployed in the network.
querydominfoProvides domain, server, and user information of deployed domains.
netshareenumallEnumerates all available shares.
netsharegetinfo <share>Provides information about a specific share.
enumdomusersEnumerates all domain users.

RPCclient - Enumeration

  SMB

rpcclient $> srvinfo

DEVSMB Wk Sv PrQ Unx NT SNT DEVSM

platform_id : 500

os version : 6.1

server type : 0x809a03

rpcclient $> enumdomains

name:[DEVSMB] idx:[0x0]

name:[Builtin] idx:[0x1]

rpcclient $> querydominfo

Domain: DEVOPS

Server: DEVSMB

Comment: DEVSM┌─[us-academy-5]─[10.10.14.156]─[htb-ac-1723454@htb-jm5dgnol2e]─[~]

└──╼ [★]$ rpcclient -U "" 10.129.97.13

Password for [WORKGROUP\]:

rpcclient $> querydominfo

Domain: DEVOPS

Server: DEVSMB

Comment: InlaneFreight SMB server (Samba, Ubuntu)

Total Users: 0

Total Groups: 0

Total Aliases: 0

Sequence No: 1738509492

Force Logoff: -1

Domain Server State: 0x1

Server Role: ROLE_DOMAIN_PDC

Unknown 3: 0x1

Total Users: 2

Total Groups: 0

Total Aliases: 0

Sequence No: 1632361158

Force Logoff: -1

Domain Server State: 0x1

Server Role: ROLE_DOMAIN_PDC

Unknown 3: 0x1

rpcclient $> netshareenumall

netname: print$

remark: Printer Drivers

path: C:\var\lib\samba\printers

password:

netname: home

remark: INFREIGHT Samba

path: C:\home\

password:

netname: dev

remark: DEVenv

path: C:\home\sambauser\dev\

password:

netname: notes

remark: CheckIT

path: C:\mnt\notes\

password:

netname: IPC$

remark: IPC Service (DEVSM)

path: C:\tmp

password:

rpcclient $> netsharegetinfo notes

netname: notes

remark: CheckIT

path: C:\mnt\notes\

password:

type: 0x0

perms: 0

max_uses: -1

num_uses: 1

revision: 1

type: 0x8004: SEC_DESC_DACL_PRESENT SEC_DESC_SELF_RELATIVE

DACL

ACL Num ACEs: 1 revision: 2

---

ACE

type: ACCESS ALLOWED (0) flags: 0x00

Specific bits: 0x1ff

Permissions: 0x101f01ff: Generic all access SYNCHRONIZE_ACCESS WRITE_OWNER_ACCESS WRITE_DAC_ACCESS READ_CONTROL_ACCESS DELETE_ACCESS

SID: S-1-1-0

Rpcclient - User Enumeration

  SMB

rpcclient $> enumdomusers

user:[mrb3n] rid:[0x3e8]

user:[cry0l1t3] rid:[0x3e9]

rpcclient $> queryuser 0x3e9

User Name : cry0l1t3

Full Name : cry0l1t3

Home Drive : \\devsmb\cry0l1t3

Dir Drive :

Profile Path: \\devsmb\cry0l1t3\profile

Logon Script:

Description :

Workstations:

Comment :

Remote Dial :

Logon Time : Do, 01 Jan 1970 01:00:00 CET

Logoff Time : Mi, 06 Feb 2036 16:06:39 CET

Kickoff Time : Mi, 06 Feb 2036 16:06:39 CET

Password last set Time : Mi, 22 Sep 2021 17:50:56 CEST

Password can change Time : Mi, 22 Sep 2021 17:50:56 CEST

Password must change Time: Do, 14 Sep 30828 04:48:05 CEST

unknown_2[0..31]...

user_rid : 0x3e9

group_rid: 0x201

Rpcclient - Group Information

  SMB

rpcclient $> querygroup 0x201

Group Name: None

Description: Ordinary Users

Group Attribute:7┌─[us-academy-5]─[10.10.14.156]─[htb-ac-1723454@htb-jm5dgnol2e]─[~]

└──╼ [★]$ rpcclient -U "" 10.129.97.13

Password for [WORKGROUP\]:

rpcclient $> querydominfo

Domain: DEVOPS

Server: DEVSMB

Comment: InlaneFreight SMB server (Samba, Ubuntu)

Total Users: 0

Total Groups: 0

Total Aliases: 0

Sequence No: 1738509492

Force Logoff: -1

Domain Server State: 0x1

Server Role: ROLE_DOMAIN_PDC

Unknown 3: 0x1

Num Members:2

Brute Forcing User RIDs

  SMB

Tonyleevo@htb[/htb]$ for i in $(seq 500 1100);do rpcclient -N -U "" 10.129.14.128 -c "queryuser 0x$(printf '%x\n' $i)" | grep "User Name\|user_rid\|group_rid" && echo "";done

User Name : sambauser

user_rid : 0x1f5

group_rid: 0x201

User Name : mrb3n

user_rid : 0x3e8

group_rid: 0x201

User Name : cry0l1t3

user_rid : 0x3e9

group_rid: 0x201

Impacket - Samrdump.py

  SMB

Tonyleevo@htb[/htb]$ samrdump.py 10.129.14.128

Impacket v0.9.22 - Copyright 2020 SecureAuth Corporation

[*] Retrieving endpoint list from 10.129.14.128

Found domain(s):┌─[us-academy-5]─[10.10.14.156]─[htb-ac-1723454@htb-jm5dgnol2e]─[~]

└──╼ [★]$ rpcclient -U "" 10.129.97.13

Password for [WORKGROUP\]:

rpcclient $> querydominfo

Domain: DEVOPS

Server: DEVSMB

Comment: InlaneFreight SMB server (Samba, Ubuntu)

Total Users: 0

Total Groups: 0

Total Aliases: 0

Sequence No: 1738509492

Force Logoff: -1

Domain Server State: 0x1

Server Role: ROLE_DOMAIN_PDC

Unknown 3: 0x1

. DEVSMB

. Builtin

[*] Looking up users in domain DEVSMB

Found user: mrb3n, uid = 1000

version

SMBmap

  SMB

Tonyleevo@htb[/htb]$ smbmap -H 10.129.14.128

[+] Finding open SMB ports....

[+] User SMB session established on 10.129.14.128...

[+] IP: 10.129.14.128:445 Name: 10.129.14.128

Disk Permissions Comment

---- ----------- -------

print$ NO ACCESS Printer Drivers

home NO ACCESS INFREIGHT Samba

dev NO ACCESS DEVenv

notes NO ACCESS CheckIT

IPC$ NO ACCESS IPC Service (DEVSM)

CrackMapExec

  SMB

Tonyleevo@htb[/htb]$ crackmapexec smb 10.129.14.128 --shares -u '' -p ''

SMB 10.129.14.128 445 DEVSMB [*] Windows 6.1 Build 0 (name:DEVSMB) (domain:) (signing:False) (SMBv1:False)

SMB 10.129.14.128 445 DEVSMB [+] \:

SMB 10.129.14.128 445 DEVSMB [+] Enumerated shares

SMB 10.129.14.128 445 DEVSMB Share Permission

Enum4Linux-ng - Installation

  SMB

Tonyleevo@htb[/htb]$ git clone https://github.com/cddmp/enum4linux-ng.git

Tonyleevo@htb[/htb]$ cd enum4linux-ng

Tonyleevo@htb[/htb]$ pip3 insta┌─[us-academy-5]─[10.10.14.156]─[htb-ac-1723454@htb-jm5dgnol2e]─[~]

└──╼ [★]$ rpcclient -U "" 10.129.97.13

Password for [WORKGROUP\]:

rpcclient $> querydominfo

Domain: DEVOPS

Server: DEVSMB

Comment: InlaneFreight SMB server (Samba, Ubuntu)

Total Users: 0

Total Groups: 0

Total Aliases: 0

Sequence No: 1738509492

Force Logoff: -1

Domain Server State: 0x1

Server Role: ROLE_DOMAIN_PDC

Unknown 3: 0x1

ll -r requirements.txt

Enum4Linux-ng - Enumeration

  SMB

Tonyleevo@htb[/htb]$ ./enum4linux-ng.py 10.129.14.128 -A

ENUM4LINUX - next generation

==========================

| Target Information |

==========================

[*] Target ........... 10.129.14.128

[*] Username ......... ''

[*] Random Username .. 'juzgtcs

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published