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
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
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. *
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. *
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. *
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
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. *
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. *
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. *
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. *
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. *
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
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. *