---
title: "3. Services and internals enumeration"
date: 2025-01-24
draft: false
---

**What services and applications are installed?**  
- Create list of installed packages: 
	- `apt list --installed | tr "/" " " | cut -d" " -f1,3 | sed 's/[0-9]://g' | tee -a installed_pkgs.list`
- Always good to check if installed `sudo` version installed on system is vulnerable to legacy or recent exploits. 
	- `sudo -V` 
- Occasionally it can also happen that no direct packages are installed on the system but compiled programs in the form of binaries. These do not require installation and can be executed directly by the system itself.
	- `ls -l /bin /usr/bin/ /usr/sbin/`
	- https://gtfobins.github.io/
		- `for i in $(curl -s https://gtfobins.github.io/ | html2text | cut -d" " -f1 | sed '/^[[:space:]]*$/d');do if grep -q "$i" installed_pkgs.list;then echo "Check GTFO for: $i";fi;done`
		- Above oneliner compare the existing binaries with the ones from GTFObins to see which binaries we should investigate later. This probably isnt that valuable because it requires internet access on the compromised host to curl gtfobins. 

**What services are running?**  
- If in a slightly older system, likelihood increases that we can find installed packages that have a vuln. 
	- Doesn't omit that newer installations dont have vuln packages installed
- `ps aux | grep root` - Running services by user. 


**What sockets are in use?**  

**What users, admins, and groups exist on the system?**  

**Who is current logged in? What users recently logged in?**  
- `lastlog` command 
- `who` command (logged in with us)
- `finger` above
- `w` 

**What password policies, if any, are enforced on the host?**  

**Is the host joined to an Active Directory domain?**  

**What types of interesting information can we find in history, log, and backup files**  
- History files: `find / -type f \( -name *_hist -o -name *_history \) -exec ls -l {} \; 2>/dev/null` 

**Which files have been modified recently and how often? Are there any interesting patterns in file modification that could indicate a cron job in use that we may be able to hijack?**  
- List cron jobs: `ls -la /etc/cron.daily/` 

**Proc checks**
- `proc filesystem` - `proc` / `procfs` is a filesystem in linux that contains information about system processes, hardware, and other system information. It's the primary way to access process information. 
	- Virtual 
	- Dynmically gen'd by kernel 
	- Used to look up system information / set system params / process priority ,scheduling, memory allocation 
	- `find /proc -name cmdline -exec cat {} \; 2>/dev/null | tr " " "\n"`

**Current IP addressing information**  

**Anything interesting in the `/etc/hosts` file?**  `cat /etc/hosts` 

**Are there any interesting network connections to other systems in the internal network or even outside the network?**  

**What tools are installed on the system that we may be able to take advantage of? (Netcat, Perl, Python, Ruby, Nmap, tcpdump, gcc, etc.)**  

**Can we access the `bash_history` file for any users and can we uncover any thing interesting from their recorded command line history such as passwords?**

**Are any Cron jobs running on the system that we may be able to hijack?**

**Monitoring running processes**
- `strace` tool use to track and analyze system calls / signal processing. Follow flow of a program and understand how it accesses system resources / process signals / receives/sends data from the os. 
	- Can be used to ID attack vectors, such as specific requests to a remote host using passwords and tokens. 
	- Output of strace can be written to a file for later analysis - provides a lot of options to allow detail monitoring of a prog behavior 
- `strace ping -c1 10.129.112.20`

**Configuration files**
```bash
find / -type f \( -name *.conf -o -name *.config \) -exec ls -l {} \; 2>/dev/null
```

**Scripts**
```bash
find / -type f -name "*.sh" 2>/dev/null | grep -v "src\|snap\|share"
```
- Also, if we look at the process list, it can give us information about which scripts or binaries are in use and by which user. 
- So, for example, if it is a script created by the administrator in his path and whose rights have not been restricted, we can run it without going into the `root` directory.

Also check network information:
**What is our IP address?** `ip a`
**Does our system have any other interfaces?**
- Hence - pivot into another subnet previously unreachable
