kali学习记录之端口扫描

端口扫描的目的是识别目标系统中哪些端口是开启状态,哪些服务可以使用。比如FTP/SSH/TELNET/打印服务/web服务等等。计算机系统中共有65536个端口,因此连接这些端口并扫描出可用的端口就变的有意义了。

1、网络连接

kali的网络默认是 设备未托管状态,因此需要开启。开启方法:

修改/etc/NetworkManager/下的NetworkManger.conf文件,

managed = false修改为true

重启机子

2、FPing工具

[email protected]:~# fping -h

Usage: fping [options] [targets...]
   -a         show targets that are alive
   -A         show targets by address
   -b n       amount of ping data to send, in bytes (default 56)
   -B f       set exponential backoff factor to f
   -c n       count of pings to send to each target (default 1)
   -C n       same as -c, report results in verbose format
   -e         show elapsed time on return packets
   -f file    read list of targets from a file ( - means stdin) (only if no -g specified)
   -g         generate target list (only if no -f specified)
                (specify the start and end IP in the target list, or supply a IP netmask)
                (ex. fping -g 192.168.1.0 192.168.1.255 or fping -g 192.168.1.0/24)
   -H n       Set the IP TTL value (Time To Live hops)
   -i n       interval between sending ping packets (in millisec) (default 25)
   -l         loop sending pings forever
   -m         ping multiple interfaces on target host
   -n         show targets by name (-d is equivalent)
   -p n       interval between ping packets to one target (in millisec)
                (in looping and counting modes, default 1000)
   -q         quiet (don't show per-target/per-ping results)
   -Q n       same as -q, but show summary every n seconds
   -r n       number of retries (default 3)
   -s         print final stats
   -I if      bind to a particular interface
   -S addr    set source address
   -t n       individual target initial timeout (in millisec) (default 500)
   -T n       ignored (for compatibility with fping 2.4)
   -u         show targets that are unreachable
   -O n       set the type of service (tos) flag on the ICMP packets
   -v         show version
   targets    list of targets to check (if no -f specified)

3、Nmap工具

使用方法:

[email protected]:~# nmap -h
Nmap 6.47 ( http://nmap.org )
Usage: nmap [Scan Type(s)] [Options] {target specification}
TARGET SPECIFICATION:
  Can pass hostnames, IP addresses, networks, etc.
  Ex: scanme.nmap.org, microsoft.com/24, 192.168.0.1; 10.0.0-255.1-254
  -iL <inputfilename>: Input from list of hosts/networks
  -iR <num hosts>: Choose random targets
  --exclude <host1[,host2][,host3],...>: Exclude hosts/networks
  --excludefile <exclude_file>: Exclude list from file
HOST DISCOVERY:     主机网络发现功能
  -sL: List Scan - simply list targets to scan
  -sn: Ping Scan - disable port scan
  -Pn: Treat all hosts as online -- skip host discovery  禁止网络发现功能,认为所有主机在线
  -PS/PA/PU/PY[portlist]: TCP SYN/ACK, UDP or SCTP discovery to given ports
  -PE/PP/PM: ICMP echo, timestamp, and netmask request discovery probes
  -PO[protocol list]: IP Protocol Ping
  -n/-R: Never do DNS resolution/Always resolve [default: sometimes]
  --dns-servers <serv1[,serv2],...>: Specify custom DNS servers
  --system-dns: Use OS's DNS resolver
  --traceroute: Trace hop path to each host
SCAN TECHNIQUES:
  -sS/sT/sA/sW/sM: TCP SYN/Connect()/ACK/Window/Maimon scans       SYN/TCP/ACK/windown/conn扫描参数
  -sU: UDP Scan                                                    UDP扫描参数指定
  -sN/sF/sX: TCP Null, FIN, and Xmas scans                         NULL/FIN/xmas扫描
  --scanflags <flags>: Customize TCP scan flags
  -sI <zombie host[:probeport]>: Idle scan
  -sY/sZ: SCTP INIT/COOKIE-ECHO scans
  -sO: IP protocol scan
  -b <FTP relay host>: FTP bounce scan
PORT SPECIFICATION AND SCAN ORDER:
  -p <port ranges>: Only scan specified ports
    Ex: -p22; -p1-65535; -p U:53,111,137,T:21-25,80,139,8080,S:9
  -F: Fast mode - Scan fewer ports than the default scan
  -r: Scan ports consecutively - don't randomize
  --top-ports <number>: Scan <number> most common ports
  --port-ratio <ratio>: Scan ports more common than <ratio>
SERVICE/VERSION DETECTION:
  -sV: Probe open ports to determine service/version info
  --version-intensity <level>: Set from 0 (light) to 9 (try all probes)
  --version-light: Limit to most likely probes (intensity 2)
  --version-all: Try every single probe (intensity 9)
  --version-trace: Show detailed version scan activity (for debugging)
SCRIPT SCAN:
  -sC: equivalent to --script=default
  --script=<Lua scripts>: <Lua scripts> is a comma separated list of
           directories, script-files or script-categories
  --script-args=<n1=v1,[n2=v2,...]>: provide arguments to scripts
  --script-args-file=filename: provide NSE script args in a file
  --script-trace: Show all data sent and received
  --script-updatedb: Update the script database.
  --script-help=<Lua scripts>: Show help about scripts.
           <Lua scripts> is a comma-separated list of script-files or
           script-categories.
OS DETECTION:
  -O: Enable OS detection
  --osscan-limit: Limit OS detection to promising targets
  --osscan-guess: Guess OS more aggressively
TIMING AND PERFORMANCE:
  Options which take <time> are in seconds, or append 'ms' (milliseconds),
  's' (seconds), 'm' (minutes), or 'h' (hours) to the value (e.g. 30m).
  -T<0-5>: Set timing template (higher is faster)
  --min-hostgroup/max-hostgroup <size>: Parallel host scan group sizes
  --min-parallelism/max-parallelism <numprobes>: Probe parallelization
  --min-rtt-timeout/max-rtt-timeout/initial-rtt-timeout <time>: Specifies
      probe round trip time.
  --max-retries <tries>: Caps number of port scan probe retransmissions.
  --host-timeout <time>: Give up on target after this long
  --scan-delay/--max-scan-delay <time>: Adjust delay between probes
  --min-rate <number>: Send packets no slower than <number> per second
  --max-rate <number>: Send packets no faster than <number> per second
FIREWALL/IDS EVASION AND SPOOFING:
  -f; --mtu <val>: fragment packets (optionally w/given MTU)
  -D <decoy1,decoy2[,ME],...>: Cloak a scan with decoys
  -S <IP_Address>: Spoof source address
  -e <iface>: Use specified interface
  -g/--source-port <portnum>: Use given port number
  --proxies <url1,[url2],...>: Relay connections through HTTP/SOCKS4 proxies
  --data-length <num>: Append random data to sent packets
  --ip-options <options>: Send packets with specified ip options
  --ttl <val>: Set IP time-to-live field
  --spoof-mac <mac address/prefix/vendor name>: Spoof your MAC address
  --badsum: Send packets with a bogus TCP/UDP/SCTP checksum
OUTPUT:
  -oN/-oX/-oS/-oG <file>: Output scan in normal, XML, s|<rIpt kIddi3,
     and Grepable format, respectively, to the given filename.
  -oA <basename>: Output in the three major formats at once
  -v: Increase verbosity level (use -vv or more for greater effect)
  -d: Increase debugging level (use -dd or more for greater effect)
  --reason: Display the reason a port is in a particular state
  --open: Only show open (or possibly open) ports
  --packet-trace: Show all packets sent and received
  --iflist: Print host interfaces and routes (for debugging)
  --log-errors: Log errors/warnings to the normal-format output file
  --append-output: Append to rather than clobber specified output files
  --resume <filename>: Resume an aborted scan
  --stylesheet <path/URL>: XSL stylesheet to transform XML output to HTML
  --webxml: Reference stylesheet from Nmap.Org for more portable XML
  --no-stylesheet: Prevent associating of XSL stylesheet w/XML output
MISC:
  -6: Enable IPv6 scanning
  -A: Enable OS detection, version detection, script scanning, and traceroute
  --datadir <dirname>: Specify custom Nmap data file location
  --send-eth/--send-ip: Send using raw ethernet frames or IP packets
  --privileged: Assume that the user is fully privileged
  --unprivileged: Assume the user lacks raw socket privileges
  -V: Print version number
  -h: Print this help summary page.
EXAMPLES:
  nmap -v -A scanme.nmap.org
  nmap -v -sn 192.168.0.0/16 10.0.0.0/8
  nmap -v -iR 10000 -Pn -p 80
SEE THE MAN PAGE (http://nmap.org/book/man.html) FOR MORE OPTIONS AND EXAMPLES

3.1Nmap执行TCP扫描

-sT 对TCP进行扫描

-p- 对所有端口扫描

-PN 禁用Nmap网络发现功能,假定所有系统都是活动的

[email protected]:~# nmap -sT -p- -PN   192.168.115.1

Starting Nmap 6.47 ( http://nmap.org ) at 2014-10-23 20:38 CST
Stats: 0:12:34 elapsed; 0 hosts completed (1 up), 1 undergoing Connect Scan
Connect Scan Timing: About 90.20% done; ETC: 20:51 (0:01:22 remaining)
Stats: 0:16:16 elapsed; 0 hosts completed (1 up), 1 undergoing Connect Scan
Connect Scan Timing: About 94.41% done; ETC: 20:55 (0:00:58 remaining)
Nmap scan report for 192.168.115.1
Host is up (0.0022s latency).
Not shown: 65533 closed ports
PORT   STATE SERVICE
23/tcp open  telnet
80/tcp open  http

Nmap done: 1 IP address (1 host up) scanned in 1274.21 seconds

3.2Nmap执行UDP扫描

扫描udp也是有理由的,比如一些基于udp的服务,SNMP、TFTP、DHCP、DNS等等

[email protected]:~# nmap -sU 192.168.115.188

Starting Nmap 6.47 ( http://nmap.org ) at 2014-10-23 20:21 CST
Nmap scan report for 192.168.115.188
Host is up (0.00069s latency).
Not shown: 994 closed ports
PORT     STATE         SERVICE
137/udp  open          netbios-ns
138/udp  open|filtered netbios-dgm
500/udp  open|filtered isakmp
1900/udp open|filtered upnp
4500/udp open|filtered nat-t-ike
5355/udp open|filtered llmnr
MAC Address: xxxxxxxxxxxxxx (Universal Global Scientific Industrial Co.)

Nmap done: 1 IP address (1 host up) scanned in 974.78 seconds

3.3Nmap执行SYN扫描

nmap默认就是这种方式。这种方式要比TCP扫描快,因为只执行三次握手的前两次。也不会造成拒绝服务攻击

[email protected]:~# nmap -sS -p- -PN 192.168.115.1

Starting Nmap 6.47 ( http://nmap.org ) at 2014-10-23 20:26 CST
Nmap scan report for 192.168.115.1
Host is up (0.0020s latency).
Not shown: 65533 closed ports
PORT   STATE SERVICE
23/tcp open  telnet
80/tcp open  http
MAC Address: xxxxxxxxxxxxxx (Digital China (Shanghai) Networks)

Nmap done: 1 IP address (1 host up) scanned in 368.52 seconds

哇偶,竟然开放了telnet....

3.3Nmap执行Xmas扫描

RFC文档描述了系统的技术细节,因此如果得到RFC文档,那么就可能找到系统的漏洞,xmas和null扫描的目的正是基于这一原因。

如果系统遵循了TCP RFC文档,那么不用完成连接,仅仅在发起连接的时候,namp就可以判断出目标系统的状态。

但是一般xmas针对unix或者linux系统比较有效。

[email protected]:~# nmap -sX -p- -Pn  192.168.115.1

Starting Nmap 6.47 ( http://nmap.org ) at 2014-10-23 20:42 CST
Nmap scan report for 192.168.115.1
Host is up (0.0029s latency).
Not shown: 65533 closed ports
PORT   STATE         SERVICE
23/tcp open|filtered telnet
80/tcp open|filtered http
MAC Address: XXXXXXXXXXXXX (Digital China (Shanghai) Networks)

Nmap done: 1 IP address (1 host up) scanned in 382.91 seconds

3.4Nmap执行Null

[email protected]:~# nmap -sN -p- -Pn  192.168.115.1

Starting Nmap 6.47 ( http://nmap.org ) at 2014-10-23 20:49 CST
Stats: 0:04:54 elapsed; 0 hosts completed (1 up), 1 undergoing NULL Scan
NULL Scan Timing: About 78.30% done; ETC: 20:55 (0:01:20 remaining)
Nmap scan report for 192.168.115.1
Host is up (0.0018s latency).
Not shown: 65533 closed ports
PORT   STATE         SERVICE
23/tcp open|filtered telnet
80/tcp open|filtered http
MAC Address: XXXXXXXXXXXXX (Digital China (Shanghai) Networks)

Nmap done: 1 IP address (1 host up) scanned in 376.37 seconds
时间: 2024-10-06 01:14:56

kali学习记录之端口扫描的相关文章

编写MAC记录与端口扫描脚本的shell脚本

MAC记录与端口扫描脚本 1.需求描述编写名为system.sh的小脚本,记录局域网中各主机的MAC地址,保存到/etc/ethers文件中:若此文件已存在,应先转移进行备份:每行一条记录,第1列为IP地址,第2列为对应的MAC地址检查有哪些主机开启了匿名FTP服务,扫描对象为/etc/ethers文件中的所有IP地址,扫描的端口为212.命令测试分析:记录局域网中各主机的MAC地址,保存到/etc/ethers文件中:若此文件已存在,应先转移进行备份:检查有哪些主机开启了匿名FTP服务,扫描对

&#8203;【安全牛学习笔记】端口扫描(二)

端口扫描(二) ╋━━━━━━━━━━━━━━━━━╋ ┃端口扫描                          ┃ ┃隐蔽扫描-----syn                  ┃ ┃  不建立完整链接                  ┃ ┃  应用日志不记录扫描行为-----隐蔽 ┃ ┃僵尸扫描                          ┃ ┃  极度隐蔽                        ┃ ┃  实施条件苛刻                    ┃ ┃  可伪

【安全牛学习笔记】 端口扫描

端口扫描 ╋━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╋ ┃隐蔽端口扫描                                                    ┃ ┃Syn-----syn/ack-----rst                                         ┃ ┃Scapy                                                           ┃ ┃  sr1(IP(dst="

★Kali信息收集★8.Nmap :端口扫描

★Kali信息收集~ 0.Httrack 网站复制机 http://www.cnblogs.com/dunitian/p/5061954.html ★Kali信息收集~ 1.Google Hacking + Github Hacking http://www.cnblogs.com/dunitian/p/5074765.html ★Kali信息收集~2.Whois :域名信息 http://www.cnblogs.com/dunitian/p/5074768.html ★Kali信息收集~3.子

小白日记10:kali渗透测试之端口扫描-UDP、TCP、僵尸扫描、隐蔽扫描

端口扫描 二三四层发现的目的只是为了准确发现所有活着主机IP,确定攻击面,端口扫描即发现攻击点,发现开放端口.端口对应网络服务及应用端程序,服务端程序的漏洞通过端口攻入.[所有的扫描结果,都不要完全相信] 一个端口就是一个潜在的通信通道,也就是一个入侵通道.对目标计算机进行端口扫描,能得到许多有用的信息.进行扫描的方法很多,可以是手工进行扫描,也可以用端口扫描软件进行扫描.在手工进行扫描时,需要熟悉各种命令.对命令执行后的输出进行分析.用扫描软件进行扫描时,许多扫描器软件都有分析数据的功能.通过

Android NDK学习之第一个实例---端口扫描

为什么要写一个端口扫描的程序,Java来写不是很方便吗?因为我也没有想到什么例子能够方便的来练习.于是想到以前找到的端口扫描的C代码,于是想用他们来练习.扫描服务端端口的方式有许多种,最简单的就是直接去连接该端口,复杂一些的就是看SYN的应答.其他方式就不说了.下面的portScan.c位于jni目录下:(原本可在linux下运行,修改部分代码,使之能够返回结果给Java层的调用.)#include<stdio.h> #include<stdlib.h> #include<j

Python 脚本学习笔记(五)集中式病毒扫描,端口扫描以及分段数据库操作

Clam AntiVirus是一个免费而且开放源码的防毒软件,软件与病毒库的更新由开源社区免费发布,目前ClamdAV主要为Linux.Uinux系统提供病毒扫描查杀pyClamad是一个python的第三方模块,可让python直接使用ClamAV病毒扫描守护进程clamd来实现一个高效的病毒检测功能. 一.实现集中式的病毒扫描 1.安装clamavp clamd 服务的相关程序包 yum install clamav clamd clamav-update -y chkconfig clam

多线程实现端口扫描

1 import java.net.*; 2 import java.io.*; 3 import java.awt.*; 4 import java.awt.event.*; 5 import javax.swing.*; 6 7 public class TcpThread extends Thread{ 8 9 //定义变量 10 public static InetAddress hostAddress;//主机IP地址 11 public static int MIN_port; //

端口扫描器之java实现

端口扫描器之java实现 import java.net.*;import java.io.*;import java.awt.*;import java.awt.event.*;import javax.swing.*; public class TcpThread extends Thread{ //定义变量 public static InetAddress hostAddress;//主机IP地址 public static int MIN_port; //The minimal num