SlideShare a Scribd company logo
Nmap Scripting Engine
(NSE)

PwC

1
3 Sections Todays Agenda – NSE
1. Nmap Overview - 10 Mins

 Nmap ?
 Basic Scan Options

2. NSE Overview – 20 Mins
 Existing Categories
 How to use these available scripts ?
 Use of 2 sample scripts
3. How to write your own NSE script ?- 20 Mins

 Baiscs on writing NSE Script
 Write a script to find website title “Null”

PwC

2
Nmap Overview

10 Mins

PwC

3
Nmap (Network Mapper) – Overview
 Was written 15 years back as a port scanner by Gordon Lyon (Fyodor)
Port Scanner : Used to discover hosts and services on a computer network by sending specially crafted
packets to the target host and then analyzes the responses.

 Current Stable release : version 6.40 (Free)
 Have CLI and GUI interfaces. GUI called Zenmap/NmapFE/Xnmap(Mac)

 Linux, Mac OS X, Windows, Solaris, Free/Net/OpenBSD are supported.
 Why Nmap? – Fast, free, easy to use, flexible in scan options, portable with
multiple OS, large community support and neat documentation.

PwC

4
How to use Nmap ? (As port scanner)
How to start with nmap ?
Single Host
# nmap 220.220.220.2xx
# nmap Target.Nmaptest.com

What i plan to scan ?
IP Address : 220.220.220.2xx
Subnet : /24
Host Name : Target.Nmaptest.com

Subnet
# nmap 220.220.220.2xx
Mulitple Targets
# nmap 220.220.220.2x1 220.220.220.2x5

IP Address Range
# nmap 220.220.220.2x1-100
Random Ip Address
(Make a list in text file - list.txt)
# nmap -sL list.txt
Sepcific ports
# nmap -p21,23,80,443 220.220.220.2xx
PwC

5
Nmap Basic Scan Output

PwC

6
Nmap Switches
Scan Options :
-sS/sT/sA: TCP SYN/Connect()/ACK/
-sU: UDP Scan
-sN/sF/sX: TCP Null, FIN, and Xmas
Specify Ports :
-p <port ranges>: scan specified ports
Eg: -p22; -p1-65535; -p U:53,111,137,
-F: Fast mode - Scan fewer ports
-r: Scan ports consecutively
--top-ports <number>:Scancommon ports
OS Detection :
-O: Enable OS detection

Host Discovery :
-sL: List Scan - simply list targets to scan
-sn: Ping Scan - disable port scan
-Pn: Treat hosts as online, skip H discovery
Time Change :
-T<0-5>: Set timing template (higher is faster)
IP version 6 scan :
-6 : Enable IPv6 scanning
Output:
-oN : Output scan in normal,
-oX : Output scan XML

How to use them together , just chain them :
# nmap [ <Scan Type> ...] [ <Options> ] { <target specification> }
e.g.
# nmap –sS –sU -T4 -A -v -Pn 220.220.220.211
#namp –T4 –randomize-host –iL list.txt –oX scanresults.xml

Cheet Sheet : http://pentestlab.wordpress.com/2012/08/17/nmap-cheat-sheet/
PwC

7
NSE Overview

20 Mins

PwC

8
Nmap Scripting Engine (NSE) – Introduction
 Nmap Scripting Engine (NSE) allows users to write simple scripts to automate
networking and pentesting tasks.

 NSE include network discovery, sophisticated version detection, vulnerability detection
and even for vulnerability exploitation.
 Uses Lua programming. Lua also used in Wireshark, snort and some Web App. F/W.
 Current download of nmap comes with 437 scripts.
 Scrips are categratized into various caterogies based on the usage. Every script needs
to be identified by a category. E.g. categories = {"intrusive", "auth"}
 Nmap.org also provides libary details for writting your own scripts.
NSE Docuemntation : http://nmap.org/nsedoc/
PwC

9
NSE Script Categories
auth

These scripts deal with authentication credentials (or bypassing them)
on the target system. E.g. ftp-anon, oracle-enum-users

broadcast

Scripts in this category typically do discovery of hosts not listed on the
command line by broadcasting on the local network. E.g. newtargets

brute

Use brute force attacks to guess authentication credentials of a remote
server. E.g. http-brute, oracle-brute, snmp-brute

default

- A option with namp E.g. http-auth, ftp-anon

discovery

try to actively discover more about the network by querying public
registries, SNMP-enabled devices, directory services, and similar.
E.g. html-title, smb-enum-shares

dos

Denial of service scripts. E.g. broadcast-avahi-dos

Exploit

Scripts aim to actively exploit some vulnerability. E.g. http-fileuploadexploiter

external

Connects to 3rd party database to get info. E.g. Whois

fuzzer

Designed to fuzz. E.g. dns-fuzz

PwC

10
NSE Script Categories
intrusive

Intrusive scripts E.g. snmp-brute, http-open-proxy

malware

Scripts test whether the target platform is infected by malware or
backdoors E.g. smtp-strangeport, auth-spoof

Safe

Most of these perform general network discovery. E.g. html-title, sshhostkey

Version

Works with –sV switch with nmap. E.g. skypev2-version, pptp-version

vuln

Check for specific known vulnerabilities and generally only report
results if they are found E.g. realvnc-auth-bypass and afp-path-vuln

PwC

11
How to use existing NSE scripts?
Existing 437 scripts with v6.40
Every Script will have category defined by the author, this will also be used to use the
script with nmap scanning. E.g. domino-enum-users

Usage :
# nmap –sC (equivalent to --script=default; sC == script)
e.g #nmap x.x.x.x –sC
# nmap --script <filename>|<category>|<directory>|<expression>
e.g # nmap --script all x.x.x.x (Runs all avalable Scripts on ip x.x.x.x)
# namp –script safe,external, http-auth x.x.x.x
# nmap --script <scriptname> --script-args <args>
e.g. nmap --script snmp-sysdescr --script-args snmpcommunity=admin example.com
#nmap --script-help <scriptname > ( provides help on the script)
e.g. #nmap --script-help http-auth
12
PwC
Sample Nmap NSE Scan Output

PwC

January 2010
13
How to write your own NSE script ?

20 Mins

PwC

14
Writing your own NSE script !!
 Writing NSE script is simple !!!
 You write them in Lua
 Pretty set structure for the script.

PwC

15
HR Portal Script (Oracle_Fussion.nse)
1.
description Field : The description field describes what a script is testing for and
any important notes the user should be aware of.
description = [[Attempts to retrieve HR Potral hosted on Oracle Fussion App.
]]

PwC

16
HR Portal Script (Oracle_Fussion.nse)
description = [[Attempts to retrieve HR Potral hosted on Oracle Fussion App.
]]
2. author Field : The author field contains the script authors' names and can also
contain contact information
author = “Sudhir Babu B <sudhir@securitytest.com >"

PwC

17
HR Portal Script (Oracle_Fussion.nse)
description = [[Attempts to retrieve HR Potral hosted on Oracle Fussion App.
]]
author = “Sudhir Babu B <sudhir@securitytest.com >“
3. categories Field : The categories field defines one or more categories to which a
script belongs.
categories = {"default", "discovery", "safe"}

PwC

18
HR Portal Script (Oracle_Fussion.nse)
description = [[Attempts to retrieve HR Potral hosted on Oracle Fussion App.
]]
author = “Sudhir Babu B <sudhir@securitytest.com >“
categories = {"default", "discovery", "safe"}
4. license Field (Optional) – Provide appropriate licence.
license = "Same as Nmap--See http://nmap.org/book/man-legal.html”"

PwC

19
HR Portal Script (Oracle_Fussion.nse)
description = [[Attempts to retrieve HR Potral hosted on Oracle Fussion App.
]]
author = “Sudhir Babu B <sudhir@securitytest.com >“
license = "Same as Nmap--See http://nmap.org/book/man-legal.html”“
categories = {"default", "discovery", "safe“}
----------------------------------------------------------------5. As it’s http app. we need the follwoing libary :
require “shortport” --- ???
require “hhtp”

Why we need short port ?
“portrule” defines when nmap when to trigger the script.
“shortport” module simplify the this process as common use for portrule

6. Portrule = shortport.port_or_service({80, 443, 8081},{“http”,”https”})
PwC

20
HR Portal Script (Oracle_Fussion.nse)
description = [[Attempts to retrieve HR Potral hosted on Oracle Fussion App.
]]
author = “Sudhir Babu B <sudhir@securitytest.com >“
license = "Same as Nmap--See http://nmap.org/book/man-legal.html”“
categories = {"default", "discovery", "safe“}
require “shortport”
require “hhtp”
Portrule = shortport.port_or_service({80, 443, 8081},{“http”,”https”})
7. Action funtion, what to do when portrule triggers.

action = function(host, port)
-- Define action
end

PwC

21
HR Portal Script (Oracle_Fussion.nse)
description = [[Attempts to retrieve HR Potral hosted on Oracle Fussion App.
]]
author = “Sudhir Babu B <sudhir@securitytest.com >“
license = "Same as Nmap--See http://nmap.org/book/man-legal.html”“
categories = {"default", "discovery", "safe“}
require “shortport”
require “hhtp”
Portrule = shortport.port_or_service({80, 443, 8081},{“http”,”https”})
action = function(host, port)
-- just checking if the directory exist with 200 OK response
local stats = http.get (host, port, ‘/Oracle_Fusion/’).status
end

PwC

22
HR Portal Script (Oracle_Fussion.nse)
description = [[Attempts to retrieve HR Potral hosted on Oracle Fussion App.
]]
author = “Sudhir Babu B <sudhir@securitytest.com >“
license = "Same as Nmap--See http://nmap.org/book/man-legal.html”“
categories = {"default", "discovery", "safe“}
require “shortport”
require “hhtp”
Portrule = shortport.port_or_service({80, 443, 8081},{“http”,”https”})
action = function(host, port)
-- just checking if the directory exist with 200 OK response
local stats = http.get (host, port, ‘/Oracle_Fusion/’).status
Need to add response : what if ?
if stats == 200 then
return “Internal HR Portal Found”
end
end
PwC

23
HR Portal Script (Oracle_Fussion.nse)
description = [[Attempts to retrieve HR Potral hosted on Oracle Fussion App.
]]
author = “Sudhir Babu B <sudhir@securitytest.com >“
license = "Same as Nmap--See http://nmap.org/book/man-legal.html”“
categories = {"default", "discovery", "safe“}
require “shortport”
require “hhtp”
Portrule = shortport.port_or_service({80, 443, 8081},{“http”,”https”})
action = function(host, port)
local stats = http.get (host, port, ‘/Oracle_Fusion/’).status
if stats == 200 then
return “Internal HR Portal Found”
end
end

PwC

24
Thanks for your time & patience

babusudhirb@gmail.com

PwC

25
NSE – Example Y ??

Slide 10

PwC

26

More Related Content

What's hot (20)

PDF
Reverse of DPAPI - BlackHat DC 2010
jmichel.p
 
PPTX
DPDK KNI interface
Denys Haryachyy
 
PPTX
A Beginner's Guide to Building Data Pipelines with Luigi
Growth Intelligence
 
PDF
Linux Systems Performance 2016
Brendan Gregg
 
PPTX
OWASP AppSecCali 2015 - Marshalling Pickles
Christopher Frohoff
 
PDF
Introduction to firewalls through Iptables
Bud Siddhisena
 
PDF
Ixgbe internals
SUSE Labs Taipei
 
PDF
Nmap Basics
amiable_indian
 
PPTX
The TCP/IP Stack in the Linux Kernel
Divye Kapoor
 
PDF
ELK Stack
Eberhard Wolff
 
PDF
Ch 2: TCP/IP Concepts Review
Sam Bowne
 
PDF
Linux Profiling at Netflix
Brendan Gregg
 
PDF
Kernel Recipes 2015: Linux Kernel IO subsystem - How it works and how can I s...
Anne Nicolas
 
PDF
YOW2021 Computing Performance
Brendan Gregg
 
PDF
Page cache in Linux kernel
Adrian Huang
 
PPTX
Tcpdump
Sourav Roy
 
PPTX
NMAP - The Network Scanner
n|u - The Open Security Community
 
PPT
Linux forensics
Santosh Khadsare
 
PDF
Hunting for Credentials Dumping in Windows Environment
Teymur Kheirkhabarov
 
Reverse of DPAPI - BlackHat DC 2010
jmichel.p
 
DPDK KNI interface
Denys Haryachyy
 
A Beginner's Guide to Building Data Pipelines with Luigi
Growth Intelligence
 
Linux Systems Performance 2016
Brendan Gregg
 
OWASP AppSecCali 2015 - Marshalling Pickles
Christopher Frohoff
 
Introduction to firewalls through Iptables
Bud Siddhisena
 
Ixgbe internals
SUSE Labs Taipei
 
Nmap Basics
amiable_indian
 
The TCP/IP Stack in the Linux Kernel
Divye Kapoor
 
ELK Stack
Eberhard Wolff
 
Ch 2: TCP/IP Concepts Review
Sam Bowne
 
Linux Profiling at Netflix
Brendan Gregg
 
Kernel Recipes 2015: Linux Kernel IO subsystem - How it works and how can I s...
Anne Nicolas
 
YOW2021 Computing Performance
Brendan Gregg
 
Page cache in Linux kernel
Adrian Huang
 
Tcpdump
Sourav Roy
 
NMAP - The Network Scanner
n|u - The Open Security Community
 
Linux forensics
Santosh Khadsare
 
Hunting for Credentials Dumping in Windows Environment
Teymur Kheirkhabarov
 

Viewers also liked (20)

KEY
Cmsms, open source & business model
Jean-Christophe Cuvelier
 
PDF
Penetration testing
Ammar WK
 
PPTX
Testing RESTful web services with REST Assured
Bas Dijkstra
 
PPTX
Telecommunication system
Jamilah Abbas
 
PPT
Hacking A Web Site And Secure Web Server Techniques Used
Siddharth Bhattacharya
 
PDF
세션 하이재킹
Yu Yongwoo
 
PPT
Web Server Technologies I: HTTP & Getting Started
Port80 Software
 
PPT
Smarty sharing-2
Ondo Simanjuntak
 
KEY
Geek Moot '09 -- Smarty 101
Ted Kulp
 
PPT
Apache Web Server Architecture Chaitanya Kulkarni
webhostingguy
 
PPTX
Web (HTTP) request to response life cycle
Gopakumar Kunduveetil
 
PPT
Web Cookies
apwebco
 
PPSX
Sessions and cookies
www.netgains.org
 
PPTX
Cookie and session
Aashish Ghale
 
PDF
Web Server Hardening
n|u - The Open Security Community
 
PPT
Mvc architecture
Surbhi Panhalkar
 
PPT
Cookies and sessions
Lena Petsenchuk
 
PDF
Hacking With Nmap - Scanning Techniques
amiable_indian
 
PPTX
REST & RESTful Web Services
Halil Burak Cetinkaya
 
PDF
Basics of telecommunication and networking
Milan Padariya
 
Cmsms, open source & business model
Jean-Christophe Cuvelier
 
Penetration testing
Ammar WK
 
Testing RESTful web services with REST Assured
Bas Dijkstra
 
Telecommunication system
Jamilah Abbas
 
Hacking A Web Site And Secure Web Server Techniques Used
Siddharth Bhattacharya
 
세션 하이재킹
Yu Yongwoo
 
Web Server Technologies I: HTTP & Getting Started
Port80 Software
 
Smarty sharing-2
Ondo Simanjuntak
 
Geek Moot '09 -- Smarty 101
Ted Kulp
 
Apache Web Server Architecture Chaitanya Kulkarni
webhostingguy
 
Web (HTTP) request to response life cycle
Gopakumar Kunduveetil
 
Web Cookies
apwebco
 
Sessions and cookies
www.netgains.org
 
Cookie and session
Aashish Ghale
 
Web Server Hardening
n|u - The Open Security Community
 
Mvc architecture
Surbhi Panhalkar
 
Cookies and sessions
Lena Petsenchuk
 
Hacking With Nmap - Scanning Techniques
amiable_indian
 
REST & RESTful Web Services
Halil Burak Cetinkaya
 
Basics of telecommunication and networking
Milan Padariya
 
Ad

Similar to Nmap scripting engine (20)

PDF
Nmap for Scriptors
n|u - The Open Security Community
 
PPTX
Nmap_Scripting_Engine_Presentations.pptx
devadon8780
 
PDF
Beginner's Guide to the nmap Scripting Engine - Redspin Engineer, David Shaw
Redspin, Inc.
 
DOCX
project_docs
Andrey Lavrinovic
 
ODP
Nmap Scripting Engine and http-enumeration
Robert Rowley
 
PDF
Ethical hacking with Python tools
Jose Manuel Ortega Candel
 
PPTX
Nmap and metasploitable
Mohammed Akbar Shariff
 
PPTX
Nmap project presentation : Unlocking Network Secrets: Mastering Port Scannin...
Boston Institute of Analytics
 
PPTX
NMap
Pritesh Raka
 
PDF
Gauntlt: Go Ahead, Be Mean to your Code
James Wickett
 
PPT
Identifying Web Servers: A First-look Into the Future of Web Server Fingerpri...
Jeremiah Grossman
 
DOCX
Contents namp
shwetha mk
 
DOCX
Contents namp
shwetha mk
 
PPTX
Nmap(network mapping)
shwetha mk
 
DOCX
Backtrack Manual Part3
Nutan Kumar Panda
 
PDF
Network Penetration Testing Toolkit - Nmap, Netcat, and Metasploit Basics
Bishop Fox
 
PPTX
Ethical hacking Chapter 6 - Port Scanning - Eric Vanderburg
Eric Vanderburg
 
PDF
A COMPREHENSIVE ANALYSIS OF NETWORK SCANNING AND SECURITY ASSESSMENT TOOL
IJNSA Journal
 
PDF
Nmap basics
itmind4u
 
Nmap_Scripting_Engine_Presentations.pptx
devadon8780
 
Beginner's Guide to the nmap Scripting Engine - Redspin Engineer, David Shaw
Redspin, Inc.
 
project_docs
Andrey Lavrinovic
 
Nmap Scripting Engine and http-enumeration
Robert Rowley
 
Ethical hacking with Python tools
Jose Manuel Ortega Candel
 
Nmap and metasploitable
Mohammed Akbar Shariff
 
Nmap project presentation : Unlocking Network Secrets: Mastering Port Scannin...
Boston Institute of Analytics
 
Gauntlt: Go Ahead, Be Mean to your Code
James Wickett
 
Identifying Web Servers: A First-look Into the Future of Web Server Fingerpri...
Jeremiah Grossman
 
Contents namp
shwetha mk
 
Contents namp
shwetha mk
 
Nmap(network mapping)
shwetha mk
 
Backtrack Manual Part3
Nutan Kumar Panda
 
Network Penetration Testing Toolkit - Nmap, Netcat, and Metasploit Basics
Bishop Fox
 
Ethical hacking Chapter 6 - Port Scanning - Eric Vanderburg
Eric Vanderburg
 
A COMPREHENSIVE ANALYSIS OF NETWORK SCANNING AND SECURITY ASSESSMENT TOOL
IJNSA Journal
 
Nmap basics
itmind4u
 
Ad

More from n|u - The Open Security Community (20)

PDF
Hardware security testing 101 (Null - Delhi Chapter)
n|u - The Open Security Community
 
PPTX
SSRF exploit the trust relationship
n|u - The Open Security Community
 
PDF
Metasploit primary
n|u - The Open Security Community
 
PDF
Api security-testing
n|u - The Open Security Community
 
PDF
Introduction to TLS 1.3
n|u - The Open Security Community
 
PDF
Gibson 101 -quick_introduction_to_hacking_mainframes_in_2020_null_infosec_gir...
n|u - The Open Security Community
 
PDF
Talking About SSRF,CRLF
n|u - The Open Security Community
 
PPTX
Building active directory lab for red teaming
n|u - The Open Security Community
 
PPTX
Owning a company through their logs
n|u - The Open Security Community
 
PPTX
Introduction to shodan
n|u - The Open Security Community
 
PDF
Detecting persistence in windows
n|u - The Open Security Community
 
PPTX
Frida - Objection Tool Usage
n|u - The Open Security Community
 
PDF
OSQuery - Monitoring System Process
n|u - The Open Security Community
 
PDF
DevSecOps Jenkins Pipeline -Security
n|u - The Open Security Community
 
PDF
Extensible markup language attacks
n|u - The Open Security Community
 
PPTX
Linux for hackers
n|u - The Open Security Community
 
PDF
Android Pentesting
n|u - The Open Security Community
 
PDF
News bytes null 200314121904
n|u - The Open Security Community
 
Hardware security testing 101 (Null - Delhi Chapter)
n|u - The Open Security Community
 
SSRF exploit the trust relationship
n|u - The Open Security Community
 
Api security-testing
n|u - The Open Security Community
 
Introduction to TLS 1.3
n|u - The Open Security Community
 
Gibson 101 -quick_introduction_to_hacking_mainframes_in_2020_null_infosec_gir...
n|u - The Open Security Community
 
Talking About SSRF,CRLF
n|u - The Open Security Community
 
Building active directory lab for red teaming
n|u - The Open Security Community
 
Owning a company through their logs
n|u - The Open Security Community
 
Introduction to shodan
n|u - The Open Security Community
 
Detecting persistence in windows
n|u - The Open Security Community
 
Frida - Objection Tool Usage
n|u - The Open Security Community
 
OSQuery - Monitoring System Process
n|u - The Open Security Community
 
DevSecOps Jenkins Pipeline -Security
n|u - The Open Security Community
 
Extensible markup language attacks
n|u - The Open Security Community
 
News bytes null 200314121904
n|u - The Open Security Community
 

Recently uploaded (20)

PPTX
Cultivation practice of Litchi in Nepal.pptx
UmeshTimilsina1
 
PPTX
PPT-Q1-WK-3-ENGLISH Revised Matatag Grade 3.pptx
reijhongidayawan02
 
PDF
The History of Phone Numbers in Stoke Newington by Billy Thomas
History of Stoke Newington
 
PPTX
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
PPTX
Growth and development and milestones, factors
BHUVANESHWARI BADIGER
 
PPTX
PATIENT ASSIGNMENTS AND NURSING CARE RESPONSIBILITIES.pptx
PRADEEP ABOTHU
 
PDF
QNL June Edition hosted by Pragya the official Quiz Club of the University of...
Pragya - UEM Kolkata Quiz Club
 
PPTX
How to Handle Salesperson Commision in Odoo 18 Sales
Celine George
 
PPTX
Identifying elements in the story. Arrange the events in the story
geraldineamahido2
 
PPTX
How to Manage Large Scrollbar in Odoo 18 POS
Celine George
 
PPTX
HUMAN RESOURCE MANAGEMENT: RECRUITMENT, SELECTION, PLACEMENT, DEPLOYMENT, TRA...
PRADEEP ABOTHU
 
PDF
The Different Types of Non-Experimental Research
Thelma Villaflores
 
PDF
CONCURSO DE POESIA “POETUFAS – PASSOS SUAVES PELO VERSO.pdf
Colégio Santa Teresinha
 
PDF
Biological Bilingual Glossary Hindi and English Medium
World of Wisdom
 
PPTX
A PPT on Alfred Lord Tennyson's Ulysses.
Beena E S
 
PDF
Exploring the Different Types of Experimental Research
Thelma Villaflores
 
PPT
Talk on Critical Theory, Part One, Philosophy of Social Sciences
Soraj Hongladarom
 
PDF
Geographical Diversity of India 100 Mcq.pdf/ 7th class new ncert /Social/Samy...
Sandeep Swamy
 
PPT
Talk on Critical Theory, Part II, Philosophy of Social Sciences
Soraj Hongladarom
 
PPTX
ASRB NET 2023 PREVIOUS YEAR QUESTION PAPER GENETICS AND PLANT BREEDING BY SAT...
Krashi Coaching
 
Cultivation practice of Litchi in Nepal.pptx
UmeshTimilsina1
 
PPT-Q1-WK-3-ENGLISH Revised Matatag Grade 3.pptx
reijhongidayawan02
 
The History of Phone Numbers in Stoke Newington by Billy Thomas
History of Stoke Newington
 
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
Growth and development and milestones, factors
BHUVANESHWARI BADIGER
 
PATIENT ASSIGNMENTS AND NURSING CARE RESPONSIBILITIES.pptx
PRADEEP ABOTHU
 
QNL June Edition hosted by Pragya the official Quiz Club of the University of...
Pragya - UEM Kolkata Quiz Club
 
How to Handle Salesperson Commision in Odoo 18 Sales
Celine George
 
Identifying elements in the story. Arrange the events in the story
geraldineamahido2
 
How to Manage Large Scrollbar in Odoo 18 POS
Celine George
 
HUMAN RESOURCE MANAGEMENT: RECRUITMENT, SELECTION, PLACEMENT, DEPLOYMENT, TRA...
PRADEEP ABOTHU
 
The Different Types of Non-Experimental Research
Thelma Villaflores
 
CONCURSO DE POESIA “POETUFAS – PASSOS SUAVES PELO VERSO.pdf
Colégio Santa Teresinha
 
Biological Bilingual Glossary Hindi and English Medium
World of Wisdom
 
A PPT on Alfred Lord Tennyson's Ulysses.
Beena E S
 
Exploring the Different Types of Experimental Research
Thelma Villaflores
 
Talk on Critical Theory, Part One, Philosophy of Social Sciences
Soraj Hongladarom
 
Geographical Diversity of India 100 Mcq.pdf/ 7th class new ncert /Social/Samy...
Sandeep Swamy
 
Talk on Critical Theory, Part II, Philosophy of Social Sciences
Soraj Hongladarom
 
ASRB NET 2023 PREVIOUS YEAR QUESTION PAPER GENETICS AND PLANT BREEDING BY SAT...
Krashi Coaching
 

Nmap scripting engine

  • 2. 3 Sections Todays Agenda – NSE 1. Nmap Overview - 10 Mins  Nmap ?  Basic Scan Options 2. NSE Overview – 20 Mins  Existing Categories  How to use these available scripts ?  Use of 2 sample scripts 3. How to write your own NSE script ?- 20 Mins  Baiscs on writing NSE Script  Write a script to find website title “Null” PwC 2
  • 4. Nmap (Network Mapper) – Overview  Was written 15 years back as a port scanner by Gordon Lyon (Fyodor) Port Scanner : Used to discover hosts and services on a computer network by sending specially crafted packets to the target host and then analyzes the responses.  Current Stable release : version 6.40 (Free)  Have CLI and GUI interfaces. GUI called Zenmap/NmapFE/Xnmap(Mac)  Linux, Mac OS X, Windows, Solaris, Free/Net/OpenBSD are supported.  Why Nmap? – Fast, free, easy to use, flexible in scan options, portable with multiple OS, large community support and neat documentation. PwC 4
  • 5. How to use Nmap ? (As port scanner) How to start with nmap ? Single Host # nmap 220.220.220.2xx # nmap Target.Nmaptest.com What i plan to scan ? IP Address : 220.220.220.2xx Subnet : /24 Host Name : Target.Nmaptest.com Subnet # nmap 220.220.220.2xx Mulitple Targets # nmap 220.220.220.2x1 220.220.220.2x5 IP Address Range # nmap 220.220.220.2x1-100 Random Ip Address (Make a list in text file - list.txt) # nmap -sL list.txt Sepcific ports # nmap -p21,23,80,443 220.220.220.2xx PwC 5
  • 6. Nmap Basic Scan Output PwC 6
  • 7. Nmap Switches Scan Options : -sS/sT/sA: TCP SYN/Connect()/ACK/ -sU: UDP Scan -sN/sF/sX: TCP Null, FIN, and Xmas Specify Ports : -p <port ranges>: scan specified ports Eg: -p22; -p1-65535; -p U:53,111,137, -F: Fast mode - Scan fewer ports -r: Scan ports consecutively --top-ports <number>:Scancommon ports OS Detection : -O: Enable OS detection Host Discovery : -sL: List Scan - simply list targets to scan -sn: Ping Scan - disable port scan -Pn: Treat hosts as online, skip H discovery Time Change : -T<0-5>: Set timing template (higher is faster) IP version 6 scan : -6 : Enable IPv6 scanning Output: -oN : Output scan in normal, -oX : Output scan XML How to use them together , just chain them : # nmap [ <Scan Type> ...] [ <Options> ] { <target specification> } e.g. # nmap –sS –sU -T4 -A -v -Pn 220.220.220.211 #namp –T4 –randomize-host –iL list.txt –oX scanresults.xml Cheet Sheet : http://pentestlab.wordpress.com/2012/08/17/nmap-cheat-sheet/ PwC 7
  • 9. Nmap Scripting Engine (NSE) – Introduction  Nmap Scripting Engine (NSE) allows users to write simple scripts to automate networking and pentesting tasks.  NSE include network discovery, sophisticated version detection, vulnerability detection and even for vulnerability exploitation.  Uses Lua programming. Lua also used in Wireshark, snort and some Web App. F/W.  Current download of nmap comes with 437 scripts.  Scrips are categratized into various caterogies based on the usage. Every script needs to be identified by a category. E.g. categories = {"intrusive", "auth"}  Nmap.org also provides libary details for writting your own scripts. NSE Docuemntation : http://nmap.org/nsedoc/ PwC 9
  • 10. NSE Script Categories auth These scripts deal with authentication credentials (or bypassing them) on the target system. E.g. ftp-anon, oracle-enum-users broadcast Scripts in this category typically do discovery of hosts not listed on the command line by broadcasting on the local network. E.g. newtargets brute Use brute force attacks to guess authentication credentials of a remote server. E.g. http-brute, oracle-brute, snmp-brute default - A option with namp E.g. http-auth, ftp-anon discovery try to actively discover more about the network by querying public registries, SNMP-enabled devices, directory services, and similar. E.g. html-title, smb-enum-shares dos Denial of service scripts. E.g. broadcast-avahi-dos Exploit Scripts aim to actively exploit some vulnerability. E.g. http-fileuploadexploiter external Connects to 3rd party database to get info. E.g. Whois fuzzer Designed to fuzz. E.g. dns-fuzz PwC 10
  • 11. NSE Script Categories intrusive Intrusive scripts E.g. snmp-brute, http-open-proxy malware Scripts test whether the target platform is infected by malware or backdoors E.g. smtp-strangeport, auth-spoof Safe Most of these perform general network discovery. E.g. html-title, sshhostkey Version Works with –sV switch with nmap. E.g. skypev2-version, pptp-version vuln Check for specific known vulnerabilities and generally only report results if they are found E.g. realvnc-auth-bypass and afp-path-vuln PwC 11
  • 12. How to use existing NSE scripts? Existing 437 scripts with v6.40 Every Script will have category defined by the author, this will also be used to use the script with nmap scanning. E.g. domino-enum-users Usage : # nmap –sC (equivalent to --script=default; sC == script) e.g #nmap x.x.x.x –sC # nmap --script <filename>|<category>|<directory>|<expression> e.g # nmap --script all x.x.x.x (Runs all avalable Scripts on ip x.x.x.x) # namp –script safe,external, http-auth x.x.x.x # nmap --script <scriptname> --script-args <args> e.g. nmap --script snmp-sysdescr --script-args snmpcommunity=admin example.com #nmap --script-help <scriptname > ( provides help on the script) e.g. #nmap --script-help http-auth 12 PwC
  • 13. Sample Nmap NSE Scan Output PwC January 2010 13
  • 14. How to write your own NSE script ? 20 Mins PwC 14
  • 15. Writing your own NSE script !!  Writing NSE script is simple !!!  You write them in Lua  Pretty set structure for the script. PwC 15
  • 16. HR Portal Script (Oracle_Fussion.nse) 1. description Field : The description field describes what a script is testing for and any important notes the user should be aware of. description = [[Attempts to retrieve HR Potral hosted on Oracle Fussion App. ]] PwC 16
  • 17. HR Portal Script (Oracle_Fussion.nse) description = [[Attempts to retrieve HR Potral hosted on Oracle Fussion App. ]] 2. author Field : The author field contains the script authors' names and can also contain contact information author = “Sudhir Babu B <[email protected] >" PwC 17
  • 18. HR Portal Script (Oracle_Fussion.nse) description = [[Attempts to retrieve HR Potral hosted on Oracle Fussion App. ]] author = “Sudhir Babu B <[email protected] >“ 3. categories Field : The categories field defines one or more categories to which a script belongs. categories = {"default", "discovery", "safe"} PwC 18
  • 19. HR Portal Script (Oracle_Fussion.nse) description = [[Attempts to retrieve HR Potral hosted on Oracle Fussion App. ]] author = “Sudhir Babu B <[email protected] >“ categories = {"default", "discovery", "safe"} 4. license Field (Optional) – Provide appropriate licence. license = "Same as Nmap--See http://nmap.org/book/man-legal.html”" PwC 19
  • 20. HR Portal Script (Oracle_Fussion.nse) description = [[Attempts to retrieve HR Potral hosted on Oracle Fussion App. ]] author = “Sudhir Babu B <[email protected] >“ license = "Same as Nmap--See http://nmap.org/book/man-legal.html”“ categories = {"default", "discovery", "safe“} ----------------------------------------------------------------5. As it’s http app. we need the follwoing libary : require “shortport” --- ??? require “hhtp” Why we need short port ? “portrule” defines when nmap when to trigger the script. “shortport” module simplify the this process as common use for portrule 6. Portrule = shortport.port_or_service({80, 443, 8081},{“http”,”https”}) PwC 20
  • 21. HR Portal Script (Oracle_Fussion.nse) description = [[Attempts to retrieve HR Potral hosted on Oracle Fussion App. ]] author = “Sudhir Babu B <[email protected] >“ license = "Same as Nmap--See http://nmap.org/book/man-legal.html”“ categories = {"default", "discovery", "safe“} require “shortport” require “hhtp” Portrule = shortport.port_or_service({80, 443, 8081},{“http”,”https”}) 7. Action funtion, what to do when portrule triggers. action = function(host, port) -- Define action end PwC 21
  • 22. HR Portal Script (Oracle_Fussion.nse) description = [[Attempts to retrieve HR Potral hosted on Oracle Fussion App. ]] author = “Sudhir Babu B <[email protected] >“ license = "Same as Nmap--See http://nmap.org/book/man-legal.html”“ categories = {"default", "discovery", "safe“} require “shortport” require “hhtp” Portrule = shortport.port_or_service({80, 443, 8081},{“http”,”https”}) action = function(host, port) -- just checking if the directory exist with 200 OK response local stats = http.get (host, port, ‘/Oracle_Fusion/’).status end PwC 22
  • 23. HR Portal Script (Oracle_Fussion.nse) description = [[Attempts to retrieve HR Potral hosted on Oracle Fussion App. ]] author = “Sudhir Babu B <[email protected] >“ license = "Same as Nmap--See http://nmap.org/book/man-legal.html”“ categories = {"default", "discovery", "safe“} require “shortport” require “hhtp” Portrule = shortport.port_or_service({80, 443, 8081},{“http”,”https”}) action = function(host, port) -- just checking if the directory exist with 200 OK response local stats = http.get (host, port, ‘/Oracle_Fusion/’).status Need to add response : what if ? if stats == 200 then return “Internal HR Portal Found” end end PwC 23
  • 24. HR Portal Script (Oracle_Fussion.nse) description = [[Attempts to retrieve HR Potral hosted on Oracle Fussion App. ]] author = “Sudhir Babu B <[email protected] >“ license = "Same as Nmap--See http://nmap.org/book/man-legal.html”“ categories = {"default", "discovery", "safe“} require “shortport” require “hhtp” Portrule = shortport.port_or_service({80, 443, 8081},{“http”,”https”}) action = function(host, port) local stats = http.get (host, port, ‘/Oracle_Fusion/’).status if stats == 200 then return “Internal HR Portal Found” end end PwC 24
  • 25. Thanks for your time & patience [email protected] PwC 25
  • 26. NSE – Example Y ?? Slide 10 PwC 26