---
title: "1. Overview, intro"
date: 2025-01-05
draft: false
---

https://owasp.org/www-project-top-ten/
All webapps suffer from the same kinds of vulnerabilities + misconfigurations. Above. 

- SQLi
- XSS
- RCE 
- Local file read
- unrestr. file up

Always a common vector. 
Esp. with remote work, apps discussed here serve as foothold into an internal env during ext assessment, or as a foothold / lateral move / add'tl issue reported in internal assessment. 

State of app sec in research survey commissioned by Barracuda 
- responses from 750 decision-makers in corpos w/ 500 emp.
- 72% respondents state org suffered 1+ breach due to app vuln
- 32% two + 
- 14% three+ 
- Orgs polled broke down into categories:
	- Bot attacks (43%)
	- Software supply chain (39%)
	- Vuln detection (38%) 
	- Securing APIs (37%) 

**Categorization of common webapps and examples**

|**Category**|**Applications**|
|---|---|
|[Web Content Management](https://enlyft.com/tech/web-content-management)|Joomla, Drupal, WordPress, DotNetNuke, etc.|
|[Application Servers](https://enlyft.com/tech/application-servers)|Apache Tomcat, Phusion Passenger, Oracle WebLogic, IBM WebSphere, etc.|
|[Security Information and Event Management (SIEM)](https://enlyft.com/tech/security-information-and-event-management-siem)|Splunk, Trustwave, LogRhythm, etc.|
|[Network Management](https://enlyft.com/tech/network-management)|PRTG Network Monitor, ManageEngine Opmanger, etc.|
|[IT Management](https://enlyft.com/tech/it-management-software)|Nagios, Puppet, Zabbix, ManageEngine ServiceDesk Plus, etc.|
|[Software Frameworks](https://enlyft.com/tech/software-frameworks)|JBoss, Axis2, etc.|
|[Customer Service Management](https://enlyft.com/tech/customer-service-management)|osTicket, Zendesk, etc.|
|[Search Engines](https://enlyft.com/tech/search-engines)|Elasticsearch, Apache Solr, etc.|
|[Software Configuration Management](https://enlyft.com/tech/software-configuration-management)|Atlassian JIRA, GitHub, GitLab, Bugzilla, Bugsnag, Bitbucket, etc.|
|[Software Development Tools](https://enlyft.com/tech/software-development-tools)|Jenkins, Atlassian Confluence, phpMyAdmin, etc.|
|[Enterprise Application Integration](https://enlyft.com/tech/enterprise-application-integration)|Oracle Fusion Middleware, BizTalk Server, Apache ActiveMQ, etc.|

There are potentially thousands of apps not mentioned above. 
https://enlyft.com/tech/

Many suffer from public exploits, func to gain RCE / steal creds, access sens. information with/without valid creds. 

Enlyft site above: 3.7m companies using wordpress (70% market share) 
SIEM tool splunk 22k comp + 30% mkt share 

Goal is to make a concerted effort to understand how these work and WHY specific vulns/misconfigs exist rather than just reproducing examples in module. 
- Identify attack paths in diff. apps

---

**Module targets**

URLs will be referred to like `http://app.inlanefreight.local` 
- Simulate large realistic env w/ multiple servs - using Vhosts
- Vhosts map to diff dir on same host we need to /etc/hosts modify 
- Needs to be done for any example w/ scans or scrnshots using FQDNs 
- [[2. DNS pt2electricboogaloo and vhosts]]

```shell-session
IP=10.129.42.195
printf "%s\t%s\n\n" "$IP" "app.inlanefreight.local dev.inlanefreight.local blog.inlanefreight.local" | sudo tee -a /etc/hosts
```

---
**Application discovery and enumeration**
- Orgs should maintain + continuously update an asset inventory including all network-connected devices (servers, workstations, network appliances etc)
	- installed software
	- apps in use across env
- Org cannot audit / update / detect what they don't know is actually installed or maintained on their systems
- Questions:
	- locally hosted, or 3p 
	- current patch level or near eol 
	- detect rogue apps in network 
	- vis into each app ensure security + strongly kept (non-default pws)
		- MFA enabled?
	- admin portals restricted to certain IPs? 

Many orgs DONT. 
- no vis
- unsure whats installed
- enumeration we perform helps 

We'll likely ID forgotten apps, demo vers, trial licenses expired + converted to versions that do not require auth, apps with default creds, unauth/misconfig apps, apps w/ public vulns
- provide this data as a combinatino of the findings in our reports
	- i.e. app with default creds as appendices such as a list of identified services mapped to hosts or supplemental scan data 
	- take it step further + educate clients on some tools we use so they can perform periodic and proactive recon of their networks 

Big picture here: LAY OF THE LAND on any network starting with very little to information, (black box discovery or just set of CIDR ranges) 
ping sweep to ID live hosts and portscan responding hosts
- in a network with hundreds/thousands of hosts this enum data can become nutty 


Say we nmap a network and find an enormous amount of hosts that have services running on 80 and 443 alone - sifting through this data manually would be tremendously time consuming esp. since assessments are under time constraints. 
- Tools to tremendously assist with this process: 
	- https://github.com/FortyNorthSecurity/EyeWitness
	- https://github.com/michenriksen/aquatone
		- Both tools can be fed raw NMAP XML output (aquatone can take Masscan xml as well; eyewitness can take Nessus XML output) and be used to quickly inspect all hosts running webapps / take screenshots of each. 
		- Screenshots compiled / assembled into a report we can work through in web browser to assess attack vector 
		- Narrow down potentially hundreds of hosts and build a more targeted list of applications we should spend more time on 

---

## Organization - Tips and pointers on structuring notes

For this section, I would break down the `Enumeration & Discovery` section of my notebook into a separate `Application Discovery` section. Here I would create subsections for the scope, scans (Nmap, Nessus, Masscan, etc.), application screenshotting, and interesting/notable hosts to dig more into later. It is important to time and date stamp every scan that we perform and save all output and the exact scan syntax that was performed and the targeted hosts. This can be useful later on if the client has any questions about the activity they saw during the assessment.

- Organization from the start and keeping detailed logs/notes will help greatly in a final report 
- Setup skeleton of report at the beginning of the assessment along with notebook and fill in certain sections of a report while waiting for a scan to finish 

An example OneNote (also applicable to other tools) structure may look like the following for the discovery phase:

`External Penetration Test - <Client Name>`

- `Scope` (including in-scope IP addresses/ranges, URLs, any fragile hosts, testing timeframes, and any limitations or other relative information we need handy)
    
- `Client Points of Contact`
    
- `Credentials`
    
- `Discovery/Enumeration`
    
    - `Scans`
        
    - `Live hosts`
        
- `Application Discovery`
    
    - `Scans`

	- `Interesting/Notable Hosts`

- `Exploitation`
    
    - `<Hostname or IP>`
        
    - `<Hostname or IP>`
        
- `Post-Exploitation`
    
    - `<Hostname or IP>`
        
    - `<<Hostname or IP>`
        

We will refer back to this structure throughout the module, so it would be a very beneficial exercise to replicate this and record all of our work on this module as if we were working through an actual engagement. This will help us refine our documentation methodology, an essential skill for a successful penetration tester. **Having notes to refer back to from each section will be helpful when we get to the three skills assessments at the end of the module and will be extremely helpful as we progress in the `Penetration Tester` path.**

Assume you're given a scope: 
- Nmap common ports 
	- `80,443,8000,8080,8180,8888,10000`
	- Eyewitness/Aquatone against scan above 
	- Review SS report of common ports
	- Begin thorough scan against top 10,000 ports or all TCP (dep. on scope)

In non-evasive full scope pentest:
- Nessus scan 
	- give client bang for buck 
	- however, must be able to perform assessment without relying on automated scanning
	- Most assessments are time limited and often not time scoped appropriately - can provide clients max value by establishing a repeatable and thorough enumeration methodology that can be applied to all covered environments 
- Be efficient during info gather/discovery stage - no shortcuts 
- All scans performed during non-evasive engagement to gather data as inputs to our manual validation and manual testing process. Do niot rely solely on scanners - human element in pen testing is essential. 
	- Often find most unique + severe vulns + misconfigs through manual testing. 

1. Determine OS of servers
2. Pay attention to hostnames - Vhosts simulate subdomains 
3. Names give hints - `dev` may indicate untested features and `gitlab` etc may be nice to take a real close look at 
	1. Services that allow unauth users to register and access. 
	2. Find add'tl repos potentially uncovering creds 

**Using eyewitness**

1. Takes XML output from nmap/nessus, creates report
2. Will also categorize where possible, fingerprint, and suggest default creds based on the app
3. Can be given a list of IP addresses and URLs and be told to pre-pend `http://` and `https://` 
4. Performs DNS res for IPs and can be given specific set of ports to attempt to connect to + scerenshot. 

https://github.com/FortyNorthSecurity/EyeWitness

Example usage with `--web` to take screenshots using nmap XML output from discovery as input: 
```bash
eyewitness --web -x web_discovery.xml -d inlanefreight_eyewitness
```

**Using Aquatone**

Similar to eyewitness.
Take screenshots provided .txt file of hosts, or nmap .xml with -nmap flag.
Under active development in a new fork focusing on improvements and feature enhancements 
https://github.com/shelld3v/aquatone
```shell-session
 wget https://github.com/michenriksen/aquatone/releases/download/v1.7.0/aquatone_linux_amd64_1.7.0.zip
```

```shell-session
unzip aquatone_linux_amd64_1.7.0.zip
```

Move it to a location in our $PATH var like `/usr/local/bin` - Or, just drop binary in working directory. Personal preference but typically most effective to build our attack VMs with most tools available to use without having to constantly change directories or call them from other locations

```bash
 cat web_discovery.xml | ./aquatone -nmap
```

---

After opening report we'll see its organized in categories: `High value` being first and 'juiciest' to go after. 
Running Eyewitness against large envs and gen report with hundreds of pages that will take hours to go through. 
Often large reports will have interesting hosts buried in them. It's worth reviewing the entire thing and poking at/ researching hosts we aren't familiar with. 

Some services may be buried deep and not autodetected. 

Seeing Tomcat is a good sign. (Especially on an external assessment)
- Try `/manager` and `/host-manager` endpoints 
	- If either acccessible we can upload a malicious WAR file and get RCE using jsp code
	- https://en.wikipedia.org/wiki/Jakarta_Server_Pages

**Take notes on interesting hosts, URL with app name/version for later, DO NOT begin attacking hosts right away - You may end up in a rabbit hole and miss something crucial later in the report!**

During external tests expect mix of:
- CMS,
- Custom apps, 
- Tomcat
- Jenkins
- Splunk'
- Remote access portals (RDS - remote desktop services) 
- SSL vpn endpoints
- Outlook web access (OWA) 
- O365 
- edge network login page,
- etc....

YMMV. 

Sometimes you will encounter applications that absolutely should not be exposed, like a single page with a file upload button
Internally you will see much of  the same but the added inclusion of printer login pages, (which you could probably leverage to obtain cleartext LDAP), ESXi, vCenter login portals, iLO, and iDRAC, plethoea of network devices / IOT, IP Phones, internal code repos, sharepoints, custom intranet portals, security appliances, etc. 


**Focus on mindset and methodology.**

```bash
Many testers have great technical skills but soft skills such as a sound, and repeatable, methodology along with organization, attention to detail, strong communication, and thorough notetaking/documentation and reporting can set us apart and help to build confidence in our skillsets from both our employers as well as our clients.
```

---

## Initial web application enumeration: Using Eyewitness

```bash

sudo apt install eyewitness


stejwes@htb[/htb]$ eyewitness -h

usage: EyeWitness.py [--web] [-f Filename] [-x Filename.xml]
                     [--single Single URL] [--no-dns] [--timeout Timeout]
                     [--jitter # of Seconds] [--delay # of Seconds]
                     [--threads # of Threads]
                     [--max-retries Max retries on a timeout]
                     [-d Directory Name] [--results Hosts Per Page]
                     [--no-prompt] [--user-agent User Agent]
                     [--difference Difference Threshold]
                     [--proxy-ip 127.0.0.1] [--proxy-port 8080]
                     [--proxy-type socks5] [--show-selenium] [--resolve]
                     [--add-http-ports ADD_HTTP_PORTS]
                     [--add-https-ports ADD_HTTPS_PORTS]
                     [--only-ports ONLY_PORTS] [--prepend-https]
                     [--selenium-log-path SELENIUM_LOG_PATH] [--resume ew.db]
                     [--ocr]

EyeWitness is a tool used to capture screenshots from a list of URLs

Protocols:
  --web                 HTTP Screenshot using Selenium

Input Options:
  -f Filename           Line-separated file containing URLs to capture
  -x Filename.xml       Nmap XML or .Nessus file
  --single Single URL   Single URL/Host to capture
  --no-dns              Skip DNS resolution when connecting to websites

Timing Options:
  --timeout Timeout     Maximum number of seconds to wait while requesting a
                        web page (Default: 7)
  --jitter # of Seconds
                        Randomize URLs and add a random delay between requests
  --delay # of Seconds  Delay between the opening of the navigator and taking
                        the screenshot
  --threads # of Threads
                        Number of threads to use while using file based input
  --max-retries Max retries on a timeout
                        Max retries on timeouts

<SNIP>
```

Let's run the default `--web` option to take screenshots using the Nmap XML output from the discovery scan as input.

example nmap:

```bash
sudo nmap --open -sV 10.129.201.50
```

```bash
eyewitness --web -x web_discovery.xml -d inlanefreight_eyewitness
```

![](/img/Pasted image 20250105001043.png)

![](/img/Pasted image 20250105001255.png)


---
## Common Web applications - Using Aquatone 

```bash
┌──(root㉿kali)-[/tools]
└─# wget https://github.com/michenriksen/aquatone/releases/download/v1.7.0/aquatone_linux_amd64_1.7.0.zip
```
unzip and: 
```bash
┌──(root㉿kali)-[/tools]
└─# mv aquatone /usr/local/bin/aquatone

```

![](/img/Pasted image 20250105001640.png)

	
