Automating tests for some of Owasp top 10 with nmap

Jun. 21, 2020

This article shows how to solve some of the OWASP Top 10 checks automated with nmap, the list and explenations are from The OWASP Top 10 2017 Website

Nmap can be used to run automated tests for some of the OWASP Top 10 checks, this list is from OWASP Top 10 2017 website

This is not a how-to, as almost every case and target is unique, but it does show the flexibility of nmap and how you can choose to use nmap and suit it to you own needs, the example target below is a LAMP-server running Wordpress.

The article does also not exploit every point to the fullest, but will skim the surface for low hanging fruits making it usefull in a mass monitoring scenario, but not in a specialized target scenario (but ofcourse it could be)

For the point A1,A4,A7,A8 more specialized tools like SQLmap and Burp is better suited. This article does not touch these points.

Table of Contents

A1:2017-Injection

Description: *Injection flaws, such as SQL, NoSQL, OS, and LDAP injection, occur when untrusted data is sent to an interpreter as part of a command or query. The attacker’s hostile data can trick the interpreter into executing unintended commands or accessing data without proper authorization. *

A2:2017-Broken Authentication

Description: *Application functions related to authentication and session management are often implemented incorrectly, allowing attackers to compromise passwords, keys, or session tokens, or to exploit other implementation flaws to assume other users’ identities temporarily or permanently. *

A2: Nmap resolution

Foo

A3:2017-Sensitive Data Exposure

Description: *Many web applications and APIs do not properly protect sensitive data, such as financial, healthcare, and PII. Attackers may steal or modify such weakly protected data to conduct credit card fraud, identity theft, or other crimes. Sensitive data may be compromised without extra protection, such as encryption at rest or in transit, and requires special precautions when exchanged with the browser. *

A3: Nmap resolution

We will probe the webserver for information leakage, as this is Wordpress we will start by probing wordpress, the Wordpress API allows you to query for valid users, and this is in most cases not blocked by WP users.

nmap -sV –script=http-wordpress-users –script-args=http.host=host.com,limit=100 -p 443 host.com

Second, we will probe for files the developer/admin migth have forgotten to delete, or misplaced on the server like config.php.bak, vim swp files and nano backup files:

nmap –script=http-config-backup –script-args=http.host=host.com host.com -p 443

A4:2017-XML External Entities (XXE)

Description: *Many older or poorly configured XML processors evaluate external entity references within XML documents. External entities can be used to disclose internal files using the file URI handler, internal file shares, internal port scanning, remote code execution, and denial of service attacks. *

A5:2017-Broken Access Control

Description: *Restrictions on what authenticated users are allowed to do are often not properly enforced. Attackers can exploit these flaws to access unauthorized functionality and/or data, such as access other users’ accounts, view sensitive files, modify other users’ data, change access rights, etc. *

A6:2017-Security Misconfiguration

Description: *Security misconfiguration is the most commonly seen issue. This is commonly a result of insecure default configurations, incomplete or ad hoc configurations, open cloud storage, misconfigured HTTP headers, and verbose error messages containing sensitive information. Not only must all operating systems, frameworks, libraries, and applications be securely configured, but they must be patched/upgraded in a timely fashion. *

A6: Nmap resolution

Foo

A7:2017-Cross-Site Scripting (XSS)

Description: *XSS flaws occur whenever an application includes untrusted data in a new web page without proper validation or escaping, or updates an existing web page with user-supplied data using a browser API that can create HTML or JavaScript. XSS allows attackers to execute scripts in the victim’s browser which can hijack user sessions, deface web sites, or redirect the user to malicious sites. *

A8:2017-Insecure Deserialization

Descripton: *Insecure deserialization often leads to remote code execution. Even if deserialization flaws do not result in remote code execution, they can be used to perform attacks, including replay attacks, injection attacks, and privilege escalation attacks. *

A9:2017-Using Components with Known Vulnerabilities

Description: *Components, such as libraries, frameworks, and other software modules, run with the same privileges as the application. If a vulnerable component is exploited, such an attack can facilitate serious data loss or server takeover. Applications and APIs using components with known vulnerabilities may undermine application defenses and enable various attacks and impacts. *

A9: Nmap resolution

Since we know that this website runs Wordpress we will probe for plugins, after the plugins and versions have been gathered they can be checked up against expoitdb and similar services.

nmap -sV –script=http-wordpress-enum –script-args=http.host=host.com,http-wordpress-enum.search-limit=all,http-wordpress-enum.check-latest=true -p 443 host.com

We may also probe other services and the versions and compare it with a list of known vuln software:

nmap -sV host.com

A10:2017-Insufficient Logging & Monitoring

Description: *Insufficient logging and monitoring, coupled with missing or ineffective integration with incident response, allows attackers to further attack systems, maintain persistence, pivot to more systems, and tamper, extract, or destroy data. Most breach studies show time to detect a breach is over 200 days, typically detected by external parties rather than internal processes or monitoring. *