TCP SYN Port Scanner - Metasploit
This page contains detailed information about how to use the auxiliary/scanner/portscan/syn metasploit module. For list of all metasploit modules, visit the Metasploit Module Library.
Module Overview
Name: TCP SYN Port Scanner
Module: auxiliary/scanner/portscan/syn
Source code: modules/auxiliary/scanner/portscan/syn.rb
Disclosure date: -
Last modification time: 2017-07-24 06:26:21 +0000
Supported architecture(s): -
Supported platform(s): -
Target service / protocol: -
Target network port(s): -
List of CVEs: -
Enumerate open TCP services using a raw SYN scan.
Module Ranking and Traits
Module Ranking:
- normal: The exploit is otherwise reliable, but depends on a specific version and can't (or doesn't) reliably autodetect. More information about ranking can be found here.
Basic Usage
This module is a scanner module, and is capable of testing against multiple hosts.
msf > use auxiliary/scanner/portscan/syn
msf auxiliary(syn) > show options
... show and set options ...
msf auxiliary(syn) > set RHOSTS ip-range
msf auxiliary(syn) > exploit
Other examples of setting the RHOSTS option:
Example 1:
msf auxiliary(syn) > set RHOSTS 192.168.1.3-192.168.1.200
Example 2:
msf auxiliary(syn) > set RHOSTS 192.168.1.1/24
Example 3:
msf auxiliary(syn) > set RHOSTS file:/tmp/ip_list.txt
Required Options
- RHOSTS: The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
Knowledge Base
Description
This module will attempt to initiate a TCP/IP connection with ports on the victim machine. It is this done by sending a SYN packet, and if victim replies with a SYN/ACK packet that means the port is open. Then the attacker sends a RST packet, and as a result the victim's machine assumes that there is a communication error. The attacker now knows the state of port without a full tcp connection. Major benefit of TCP SYN scan is that most logging applications do not log the TCP/RST by default.
Options
PORTS
This is the list of TCP ports to test on each host.
Formats like 1-3
, 1,2,3
, 1,2-3
, etc. are all supported. Default
options is to scan 1-10000
ports.
TIMEOUT
Maximum time to wait for a response. The default value is 500 milliseconds.
VERBOSE
Gives detailed message about the scan of all the ports. It also shows the ports that were closed.
Verification Steps
- Do:
use auxiliary/scanner/portscan/syn
- Do:
set RHOSTS [IP]
- Do:
set PORTS [PORTS]
- Do:
run
- If any of the TCP ports were open they will be discovered, status will be printed indicating as such.
Scenarios
Metaspliotable 2
msf > use auxiliary/scanner/portscan/syn
msf auxiliary(syn) > set RHOSTS 192.168.45.159
RHOSTS => 192.168.45.159
msf auxiliary(syn) > set PORTS 1-10000
PORTS => 1-10000
msf auxiliary(syn) > run
[*] TCP OPEN 192.168.45.159:22
[*] TCP OPEN 192.168.45.159:23
[*] TCP OPEN 192.168.45.159:111
[*] TCP OPEN 192.168.45.159:445
[*] TCP OPEN 192.168.45.159:512
[*] TCP OPEN 192.168.45.159:513
[*] TCP OPEN 192.168.45.159:1099
[*] TCP OPEN 192.168.45.159:2121
[*] TCP OPEN 192.168.45.159:3306
[*] TCP OPEN 192.168.45.159:3632
[*] TCP OPEN 192.168.45.159:6000
[*] TCP OPEN 192.168.45.159:6697
[*] TCP OPEN 192.168.45.159:8009
[*] Scanned 1 of 1 hosts (100% complete)
[*] Auxiliary module execution completed
Go back to menu.
Msfconsole Usage
Here is how the scanner/portscan/syn auxiliary module looks in the msfconsole:
msf6 > use auxiliary/scanner/portscan/syn
msf6 auxiliary(scanner/portscan/syn) > show info
Name: TCP SYN Port Scanner
Module: auxiliary/scanner/portscan/syn
License: Metasploit Framework License (BSD)
Rank: Normal
Provided by:
kris katterjohn <[email protected]>
Check supported:
No
Basic options:
Name Current Setting Required Description
---- --------------- -------- -----------
BATCHSIZE 256 yes The number of hosts to scan per set
DELAY 0 yes The delay between connections, per thread, in milliseconds
INTERFACE no The name of the interface
JITTER 0 yes The delay jitter factor (maximum value by which to +/- DELAY) in milliseconds.
PORTS 1-10000 yes Ports to scan (e.g. 22-25,80,110-900)
RHOSTS yes The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
SNAPLEN 65535 yes The number of bytes to capture
THREADS 1 yes The number of concurrent threads (max one per host)
TIMEOUT 500 yes The reply read timeout in milliseconds
Description:
Enumerate open TCP services using a raw SYN scan.
Module Options
This is a complete list of options available in the scanner/portscan/syn auxiliary module:
msf6 auxiliary(scanner/portscan/syn) > show options
Module options (auxiliary/scanner/portscan/syn):
Name Current Setting Required Description
---- --------------- -------- -----------
BATCHSIZE 256 yes The number of hosts to scan per set
DELAY 0 yes The delay between connections, per thread, in milliseconds
INTERFACE no The name of the interface
JITTER 0 yes The delay jitter factor (maximum value by which to +/- DELAY) in milliseconds.
PORTS 1-10000 yes Ports to scan (e.g. 22-25,80,110-900)
RHOSTS yes The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
SNAPLEN 65535 yes The number of bytes to capture
THREADS 1 yes The number of concurrent threads (max one per host)
TIMEOUT 500 yes The reply read timeout in milliseconds
Advanced Options
Here is a complete list of advanced options supported by the scanner/portscan/syn auxiliary module:
msf6 auxiliary(scanner/portscan/syn) > show advanced
Module advanced options (auxiliary/scanner/portscan/syn):
Name Current Setting Required Description
---- --------------- -------- -----------
GATEWAY_PROBE_HOST 8.8.8.8 yes Send a TTL=1 random UDP datagram to this host to discover the default gateway's MAC
GATEWAY_PROBE_PORT no The port on GATEWAY_PROBE_HOST to send a random UDP probe to (random if 0 or unset)
SECRET 1297303073 yes A 32-bit cookie for probe requests.
ShowProgress true yes Display progress messages during a scan
ShowProgressPercent 10 yes The interval in percent that progress should be shown
VERBOSE false no Enable detailed status messages
WORKSPACE no Specify the workspace for this module
Auxiliary Actions
This is a list of all auxiliary actions that the scanner/portscan/syn module can do:
msf6 auxiliary(scanner/portscan/syn) > show actions
Auxiliary actions:
Name Description
---- -----------
Evasion Options
Here is the full list of possible evasion options supported by the scanner/portscan/syn auxiliary module in order to evade defenses (e.g. Antivirus, EDR, Firewall, NIDS etc.):
msf6 auxiliary(scanner/portscan/syn) > show evasion
Module evasion options:
Name Current Setting Required Description
---- --------------- -------- -----------
Go back to menu.
Error Messages
This module may fail with the following error messages:
Check for the possible causes from the code snippets below found in the module source code. This can often times help in identifying the root cause of the problem.
PORTS
Here is a relevant code snippet related to the "PORTS" error message:
40: end
41:
42: def run_batch(hosts)
43: ports = Rex::Socket.portspec_crack(datastore['PORTS'])
44: if ports.empty?
45: raise Msf::OptionValidateError.new(['PORTS'])
46: end
47:
48: jitter_value = datastore['JITTER'].to_i
49: if jitter_value < 0
50: raise Msf::OptionValidateError.new(['JITTER'])
JITTER
Here is a relevant code snippet related to the "JITTER" error message:
45: raise Msf::OptionValidateError.new(['PORTS'])
46: end
47:
48: jitter_value = datastore['JITTER'].to_i
49: if jitter_value < 0
50: raise Msf::OptionValidateError.new(['JITTER'])
51: end
52:
53: delay_value = datastore['DELAY'].to_i
54: if delay_value < 0
55: raise Msf::OptionValidateError.new(['DELAY'])
DELAY
Here is a relevant code snippet related to the "DELAY" error message:
50: raise Msf::OptionValidateError.new(['JITTER'])
51: end
52:
53: delay_value = datastore['DELAY'].to_i
54: if delay_value < 0
55: raise Msf::OptionValidateError.new(['DELAY'])
56: end
57:
58: open_pcap
59: pcap = self.capture
60:
Error
Here is a relevant code snippet related to the "Error" error message:
87: if (reply.is_tcp? and reply.tcp_flags.syn == 1 and reply.tcp_flags.ack == 1)
88: print_good(" TCP OPEN #{dhost}:#{dport}")
89: report_service(:host => dhost, :port => dport)
90: end
91: rescue ::Exception
92: print_error("Error: #{$!.class} #{$!}")
93: end
94: end
95: end
96:
97: close_pcap
Go back to menu.
Related Pull Requests
- #8716 Merged Pull Request: Print_Status -> Print_Good (And OCD bits 'n bobs)
- #8338 Merged Pull Request: Fix msf/core and self.class msftidy warnings
- #6655 Merged Pull Request: use MetasploitModule as a class name
- #6648 Merged Pull Request: Change metasploit class names
- #6317 Merged Pull Request: Add capability for delays (+/- jitter) to all auxiliary scanner modules & implement in portscan modules
- #6010 Merged Pull Request: Fix #6008, incorrect usage of capture_sendto
- #2779 Merged Pull Request: Raise Msf::OptionValidateError when the PORTS option is invalid
- #2525 Merged Pull Request: Change module boilerplate
- #1228 Merged Pull Request: MSFTIDY cleanup #1 - auxiliary
Go back to menu.
See Also
Check also the following modules related to this module:
- auxiliary/scanner/natpmp/natpmp_portscan
- auxiliary/scanner/portscan/ack
- auxiliary/scanner/portscan/ftpbounce
- auxiliary/scanner/portscan/tcp
- auxiliary/scanner/portscan/xmas
- auxiliary/scanner/sap/sap_router_portscanner
- auxiliary/dos/tcp/synflood
- auxiliary/scanner/http/synology_forget_passwd_user_enum
- auxiliary/scanner/rsync/modules_list
- exploit/linux/http/synology_dsm_sliceupload_exec_noauth
- exploit/linux/http/synology_dsm_smart_exec_auth
- exploit/multi/http/mediawiki_syntaxhighlight
- exploit/multi/local/vagrant_synced_folder_vagrantfile_breakout
- exploit/windows/browser/synactis_connecttosynactis_bof
- exploit/windows/fileformat/syncbreeze_xml
- exploit/windows/http/kentico_staging_syncserver
- exploit/windows/http/syncbreeze_bof
- exploit/windows/misc/cloudme_sync
- post/windows/gather/credentials/razer_synapse
- exploit/linux/http/pineapp_ldapsyncnow_exec
- exploit/linux/http/saltstack_salt_wheel_async_rce
- exploit/multi/misc/weblogic_deserialize_asyncresponseservice
- exploit/windows/ftp/aasync_list_reply
- exploit/windows/ftp/ftpsynch_list_reply
- exploit/windows/local/adobe_sandbox_adobecollabsync
- exploit/windows/local/druva_insync_insynccphwnet64_rcp_type_5_priv_esc
- post/multi/gather/rsyncd_creds
Authors
kris katterjohn
Version
This page has been produced using Metasploit Framework version 6.2.26-dev. For more modules, visit the Metasploit Module Library.
Go back to menu.