Chapter 5 - Finding Vulnerabilities
Chapter 5 - Finding Vulnerabilities
Finding Vulnerabilities
Dr. Tran The Son
Vietnam – Korea University
Content
• Vulnerability vs Exposure
• Automated scanning
– Nessus
• Local and online vulnerability databases
• Targeted analysis
– The Nmap Scripting Engine
– Searchsploit
– Metasploit Scanner Modules
• Manual research
Computer Vulnerability vs Exposure
• Vulnerabilities are flaws in computer software, firmware,
hardware, and service components that can be exploited
by a threat actor to gain unauthorized access and carry out
a cyber-attack.
• Exposures are errors not inherent to the software,
firmware, hardware, or service component that put it at
risk of being exploited, such as misconfigurations, open
ports, and weak credentials.
• CVE, short for common vulnerability and exposure, is a
database of publicly disclosed IT security vulnerabilities
and exposures.
– assigned a unique CVE identifier (CVE ID) and added to the database (CVE List)
CVE ID
• The CVE ID is a vulnerability’s unique identifier.
• The standard format of a CVE ID is "CVE-YYYY-NNNN",
– CVE is a fixed prefix,
– YYYY is the year in which the CVE ID was assigned (not necessary the same
as when the CVE Record was published),
– NNNN is a random number with at least four digits.
• E.g.
– e.g., CVE-2021-12345, CVE-2008-4250 (MS-08-067)
https://nvd.nist.gov/vuln-metrics/cvss
Exploit Prediction Scoring System (EPSS)
• The CVSS is the most frequently cited rating system to
assess the severity of security vulnerabilities. It has been
criticized, however, as not being appropriate to assess
and prioritize risk from those vulnerabilities.
– For this reason, some have called for using the EPSS
Zero-day vulnerabilities
• A zero-day (also known as a 0-day) is a vulnerability in a
computer system that was previously unknown to its
developers or anyone capable of mitigating it.
• A zero-day vulnerability is a vulnerability in a system or
device that has been disclosed but is not yet patched. An
exploit that attacks a zero-day vulnerability is called a
zero-day exploit
CVE repositories
• https://www.cve.org/
• https://www.rapid7.com/db/
• https://attackerkb.com
• https://cve.mitre.org/
• https://attackerkb.com/
Nessus
sudo systemctl start nessusd https://kali:8834/
Scanning Result
Researching Vulnerabilities
https://www.cve.org/
https://www.shodan.io/
Bài tập
• Sử dụng Nessus để đánh giá mức độ nguy cơ của hệ
thống máy chủ công ty nào đó:
• Xuất KQ dạng bảng (.cvs) => email: [email protected]
• Tìm kiếm thông tin lỗ hổng trên các CSDL về CVE
• Phân tích kết quả
online vulnerability databases
• The National Vulnerability Database released by the US
Government, available at
– http://web.nvd.nist.gov/view/vuln/search
• Packet Storm Security, available at
– https://packetstormsecurity.com/
• SecurityFocus, available at
– http://www.securityfocus.com/vulnerabilities
• The Exploit database maintained by Offensive Security,
available at
– https://www.exploit-db.com/
• • For some 0-day vulnerabilities, penetration testers can also
keep an eye on
– https://0day.today/
Local vulnerability databases
• The Exploit database is also copied locally to Kali, and it
can be found in the /usr/share/exploitdb directory.
──(trantheson@kali)-[~]
└─$ searchsploit windows server 2016
------------------------------------------------- ---------------------------------
Exploit Title | Path
------------------------------------------------- ---------------------------------
3.3/4.0/4.2 MERCUR MailServer - Control-Service | windows/remote/21626.c
3Com 3CDaemon 2.0 FTP Server - 'Username' Remote | windows/remote/16730.rb
3Com FTP Server 2.0 - Remote Overflow | windows/remote/825.c
Abyss Web Server X1 2.11.1 - Unquoted Service Pa | windows/local/40460.txt
acFTP FTP Server 1.4 - 'USER' Remote Buffer Over | windows/dos/1749.pl
acFTP FTP Server 1.4 - 'USER' Remote Denial of S | windows/dos/1757.c
Allied Telesyn TFTP (AT-TFTP) Server/Daemon 1.9 | windows/dos/10603.c
Allied Telesyn TFTP (AT-TFTP) Server/Daemon 1.9 | windows/remote/16350.rb
Allied Telesyn TFTP (AT-TFTP) Server/Daemon 1.9 | windows/remote/2887.pl
…………………….
Bài số 2
• Cài đặt Win Server 2016 + AD
• Tìm kiếm các lỗ hổng sử dụng CSDL online và off-line
(searchsploit)
• Chạy script của searchsploit để khai thác các lỗ hổng tìm
được (nếu có)
Example
• Microsoft Exchange 2019 server that may be vulnerable
to remote code execution using valid credentials
Thực hành
• Tìm kiếm trong CSDL của searchsploit có sẵn trong Kali về
các lỗ hổng của hệ thống mạng VKU
The Nmap Scripting Engine (NSE)
• nmap --script-help default
Some NSE scripts may crash services or harm the target system, and an entire category is dedicated to denial
of service. For example, the script smb-check-vulns will check for the MS08-067 vulnerability and other SMB
vulnerabilities. Its help information notes that this script is likely dangerous and shouldn’t be run on
production systems unless you are prepared for the server to go down.
The Nmap Scripting Engine (NSE)
Scripts are written in the embedded Lua programming
language
• Network discovery
• More sophisticated version detection
• Vulnerability detection
• Backdoor detection
• Vulnerability exploitation
NSE is activated with the -sC option (or --script if you wish to specify a
custom set of scripts) and results are integrated into Nmap normal and XML
output
The Nmap Scripting Engine (NSE)
• Nmap has similarly evolved its original goal of port
scanning. The Nmap Scripting Engine (NSE) lets you run
publicly available scripts and write your own.
• in Kali: /usr/share/nmap/scripts.
The Nmap Scripting Engine (NSE)
• To tell Nmap to run a script scan in addition to port
scanning (--script=<script_name>)
• use the -sC flag: for common scripts
The Nmap Scripting Engine (NSE)
Running a
Single
NSE
Script
The Nmap Scripting Engine (NSE)
• Two types of scripts are supported: service and host
scripts.
– Service scripts relate to a certain open port (service) on the target host, and
any results they produce are included next to that port in the Nmap output
port table.
– Host scripts, on the other hand, run no more than once against each target
IP and produce results below the port table
NSE Script Categories
– Auth
• These scripts try to determine authentication credentials on the target system, often through a brute-force attack, e.g., snmp-
brute, http-auth, and ftp-anon.
– Default
• These scripts are the default set and are run when using the -sC or - A options
– Discovery
• These scripts try to actively discover more about the network by querying public registries, SNMP-enabled devices,
directory services, and the like.
– External
• Scripts in this category may send data to a third-party database or other network resource
– Intrusive:
• These are scripts that cannot be classified in the s a f e category because the risks are too high that they will crash
the target system
– Malware
• These scripts test whether the target platform is infected by malware or backdoors.
– Safe
• Scripts which weren't designed to crash services, use large amounts of network bandwidth or other resources, or
exploit security holes
– Version
• The scripts in this special category are an extension to the version detection feature and cannot be selected
explicitly
– Vuln
• These scripts check for specific known vulnerabilities and generally only report results if they are found
LUA scripting
#!/usr/bin/lua
local file = io.open("/etc/shadow", "r")
contents = file:read()
file:close()
print (contents)
Customizing NSE scripts
This calls the right library from Lua; this line calls the HTTP
ocal http=require 'http' script and makes it a local request.
description = [[ This is my custom discovery on the network ]]
categories = {"safe","discovery"} This typically has two variables, one of which declares whether
equire("http") it is safe or intrusive.
Index.html