安全牛学习笔记端口扫描

author author     2022-09-19     375

关键词:

端口扫描

╋━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╋

┃隐蔽端口扫描                                                    ┃

┃Syn-----syn/ack-----rst                                         ┃

┃Scapy                                                           ┃

┃  sr1(IP(dst="192.168.60.3")/TCP(dport=80),timeout=1,verbose=1) ┃

┃  ./syn_scan.py                                                 ┃

╋━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╋

[email protected]:~# scapy

WARNING: No route found for IPv6 destination :: (no default route?)

Welcome to Scapy (2.2.0)

>>> a=sr1(IP(dst="192.168.1.134")/TCP(dport=80),timeout=1,verbose=1)

>>>a.display

>>> a=sr1(IP(dst="192.168.1.134")/TCP(flags="S"dport=22),timeout=1)

>>> a=sr1(IP(dst="192.168.1.134")/TCP(flags="S"dport=2222),timeout=1)

╭────────────────────────────────────────────╮

[syn_scan.py]

#!/usr/bin/python

import loggging

logging.getLogger("scapy.runtime").setLevel(logging.ERROR)

from scapy.all import *

import sys

if len(sys.argv)!=4;

  print "Usage - ./syn_scan.py [Target.IP] [First Port] [Las Port]"

  print "Example - ./syn_scan.py 1.1.1.5 1 100"

  print "Example will TCP SYN port 1 thorough 100 om 10.0.0.5"

  sys.exit()

ip=sys.argv[1]

start=int(sys.argv[2])

end=int(sys.argv[3]

for port in range(start,end);

     a=str(IP(dst=ip)/UDP(dport=prot),timeout=1,verbose=0)

     if a==None;

        pass

     else;

        if(int(a(TCP),flags)==18;

            print port

         else

            pass

╰────────────────────────────────────────────╯

[email protected]:~# chmod u+x syn_scan.py

[email protected]:~# ./syn_scan.py 192.168.1.134 1 100

[email protected]:~# ./syn_scan.py 192.168.1.134 100 200

[email protected]:~# ./syn_scan.py 192.168.1.134 440 450

╋━━━━━━━━━━━━━━━━━━━╋

┃隐蔽端口扫描                          ┃

┃nmap -sS 1.1.1.1 -p 80,21,25,110,443  ┃

┃nmap -sS 1.1.1.1 -p 1-65535 --open    ┃

┃nmap -sS 1.1.1.1 -p- --open           ┃

┃nmap -sS -iL iplist.txt -p 80         ┃

╋━━━━━━━━━━━━━━━━━━━╋

[email protected]:~# nmap 192.168.1.134 -p1-100

Starting Nmap 6.49BETA5 ( https://nmap.org ) at 2015-10-01 23:01 CST

Nmap scan report for 192.168.1.134

Host is up (0.00068s latency).

Not shown: 94 closed ports

PORT   STATE SERVICE

21/tcp open  ftp

22/tcp open  ssh

23/tcp open  telnet

25/tcp open  smtb

53/tcp open  domain

80/tcp open  http

MAC Address: 80:00:27:B0:3A:76(Cadmus Computer Systems)

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

[email protected]:~# nmap 192.168.1.134 -p1-100 --open

╋━━━━━━━━━━━━━━━━━━━━━━━━╋

┃隐蔽端口扫描                                    ┃

┃hping3                                          ┃

┃hping3 1.1.1.1 --scan 80 -S                     ┃

┃hping3 1.1.1.1 --scan 80,21,25,443 -S           ┃

┃hping3 1.1.1.1 --scan 0-65535                   ┃

┃hping3 -c 10 -S --spoof 1.1.1.2 -p ++1 1.1.1.3  ┃

╋━━━━━━━━━━━━━━━━━━━━━━━━╋

[email protected]:~# hping3 192.168.1.134 --scan 1-100 -S

Scanning 192.168.1.134 (192.168.1.134), port 1-100

100 ports to scan, use -V to see all the replies

+----+-----------+---------+---+-----+-----+-----+

|port| serv name |  flags  |ttl| id  | win | len |

+----+-----------+---------+---+-----+-----+-----+

   21 ftp        : .S..A...  64     0  5840     46  

   22 ssh        : .S..A...  64     0  5840     46

   23 telnet     : .S..A...  64     0  5840     46

   25 smtp       : .S..A...  64     0  5840     46

   53 domain     : .S..A...  64     0  5840     46

   80 http       : .S..A...  64     0  5840     46

All replies received Done.

Not responding ports:

[email protected]:~# hping3 -c 10 -S --spoof 1.1.1.2 -p ++1 1.1.1.3

HPING 1.1.1.3 (eth0 1.1.1.3): S set, 40 headers + 0 data bytes

--- 1.1.1.3 hping statistic ---

10 packets transmitted, 0 packets received, 100% packet loss

round-trip min/avg/max = 0.0/0.0/0.0 ms

[email protected]:~# hping3 -c 10 -S --spoof 192.168.1.140 -p ++1 192.168.1.134

HPING 192.168.1.134 (eth0 192.168.1.134): S set, 40 headers + 0 data bytes

--- 192.168.1.134 hping statistic ---

10 packets transmitted, 0 packets received, 100% packet loss

round-trip min/avg/max = 0.0/0.0/0.0 ms

[email protected]:~# hping3 -c 100 -S --spoof 192.168.1.140 -p ++1 192.168.1.134

HPING 192.168.1.134 (eth0 192.168.1.134): S set, 40 headers + 0 data bytes

--- 192.168.1.134 hping statistic ---

100 packets transmitted, 0 packets received, 100% packet loss

round-trip min/avg/max = 0.0/0.0/0.0 ms

╋━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╋

┃全连接端口扫描                                                        ┃

┃Scapy                                                                 ┃

┃    Syn扫描不需要raw packets                                          ┃

┃    内核认为syn/ack是非法包,直接发rst终端连接                        ┃

┃    全连接扫描对scapy比较困难                                         ┃

┃sr1(IP(dst="192.168.20.2")/TCP(dport=22,flags=‘S‘))                   ┃

┃./tcp_scan1.py                                                        ┃

┃./tcp_scan2.py                                                        ┃

┃iptables -A OUTPUT -p tcp --tcp-flags RST RST -d 192.168.20.2 -j DROP ┃

╋━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╋

╭────────────────────────────────────────────╮

[tcp_scan1.py]

#!/usr/bin/python

import loggging

logging.getLogger("scapy.runtime").setLevel(logging.ERROR)

from scapy.all import *

response=sr1(IP(dst="192.168.60.4")/TCP(dport=80,flags=‘S‘)) 

reply=sr1(IP(dst="192.168.60.4")/TCP(dport=80,flags=‘A‘,ack(response[TCP].seq+1)))

╰────────────────────────────────────────────╯

直接按F5运行代码!

╭────────────────────────────────────────────╮

[tcp_scan2.py]

#!/usr/bin/python

import loggging

logging.getLogger("scapy.runtime").setLevel(logging.ERROR)

from scapy.all import *

SYN=IP(dst="192.168.1.134")/TCP(dport=25,flags=‘S‘)

print"-- SENT --"

SYN.display()

print" -- RECEIVED --"

response=sr1(SYN,timeout=1,verbose=0)

response.display()

if int(response[TCP].flags)==18;

    print" -- SENT --"

    A=IP(dst="192.168.1.134")/TCP(dport=25flags=‘A‘,ack(response[TCP].seq+1))

    A.display()

    print" -- RECEIVED --"

    response2=sr1(A,timeout=1,verbose=0)

    response2.display()

else;

    print"SYN-ACK not returned"

╰────────────────────────────────────────────╯

[email protected]:~# iptables -A OUTPUT -p tcp --tcp-flags RST RST -d 192.168.20.2 -j DROP

[email protected]:~# iptables -A OUTPUT -p tcp --tcp-flags RST RST -d 192.168.1.134 -j DROP

[email protected]:~# iptables -L

Chain INPUT (policy ACCEPT)

target     prot opt source               destination         

Chain FORWARD (policy ACCEPT)

target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)

target     prot opt source               destination 

╋━━━━━━━━━━━━━━━━╋

┃全连接端口扫描                  ┃

┃nmap -sT 1.1.1.1 -p 80          ┃

┃nmap -sT 1.1.1.1 -p 80,21,25    ┃

┃nmap -sT 1.1.1.1 -p 80-2000     ┃

┃nmap -sT -iL iplist.txt -p 80   ┃

┃默认1000个常用端口              ┃

╋━━━━━━━━━━━━━━━━╋

[email protected]:~# nmap -sT 192.168.1.134 1-100

Starting Nmap 6.49BETA5 ( https://nmap.org ) at 2015-10-02 13:56 CSTn

Nmap scan report for localhost(192.168.1.134)

Host is up (0.0020s latency).

Not shown 94 closed ports

PORT   STATE SERVICE

21/tcp open  ftp

22/tcp open  ssh

23/tcp open  telnet

25/tcp open  smtb

53/tcp open  domain

80/tcp open  http

MAC Address: 80:00:27:B0:3A:76(Cadmus Computer Systems)

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

╋━━━━━━━━━━━━━━━━━╋

┃全连接端口扫描                    ┃

┃dmitry                            ┃

┃    功能简单,但使用简便          ┃

┃    默认150个最常用的端口         ┃

┃dmitry -p 172.16.36.135           ┃

┃dmitry -p 172.16.36.135 -o output ┃

╋━━━━━━━━━━━━━━━━━╋

[email protected]:~# dmitry -p 192.168.1.134

Deepmagic Information Gathering Tool

"There be some deep magic going on"

ERROR: Unable to locate Host Name for 192.168.1.134

Continuing with limited modules

HostIP:192.168.1.134

HostName:

Gathered TCP Port information for 192.168.1.134

---------------------------------

 Port State

21/tcp          open

22/tcp          open

23/tcp          open

25/tcp          open

53/tcp          open

80/tcp          open

111/tcp         open

139/tcp         open

Portscan Finished: Scanned 150 ports, 141 ports were in state closed

All scans completed, exiting

[email protected]:~# dmitry -h

Deepmagic Information Gathering Tool

"There be some deep magic going on"

dmitry: invalid option -- ‘h‘

Usage: dmitry [-winsepfb] [-t 0-9] [-o %host.txt] host

  -o Save output to %host.txt or to file specified by -o file

  -i Perform a whois lookup on the IP address of a host

  -w Perform a whois lookup on the domain name of a host

  -n Retrieve Netcraft.com information on a host

  -s Perform a search for possible subdomains

  -e Perform a search for possible email addresses

  -p Perform a TCP port scan on a host

* -f Perform a TCP port scan on a host showing output reporting filtered ports

* -b Read in the banner received from the scanned port

* -t 0-9 Set the TTL in seconds when scanning a TCP port ( Default 2 )

*Requires the -p flagged to be passed

╋━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╋

┃全连接端口扫描                                                      ┃

┃nc -nv -w 1 -z 192.168.60.4 1-100                                   ┃

┃for x in $(seq 20 30);do nc -nv -w 1 -z 1.1.1.1 $x;done | grep open ┃

┃for x in $(seq 20 30);do nc -nv -w 1 -z 1.1.1.$x;done               ┃

╋━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╋

[email protected]:~# nc -h

[v1.10-41]

connect to somewhere: nc [-options] hostname port[s] [ports] ... 

listen for inbound: nc -l -p port [-options] [hostname] [port]

options:

-c shell commands as `-e‘; use /bin/sh to exec [dangerous!!]

-e filename program to exec after connect [dangerous!!]

-b allow broadcasts

-g gateway source-routing hop point[s], up to 8

-G num source-routing pointer: 4, 8, 12, ...

-h this cruft

-i secs delay interval for lines sent, ports scanned

        -k                      set keepalive option on socket

-l listen mode, for inbound connects

-n numeric-only IP addresses, no DNS

-o file hex dump of traffic

-p port local port number

-r randomize local and remote ports

-q secs quit after EOF on stdin and delay of secs

-s addr local source address

-T tos set Type Of Service

-t answer TELNET negotiation

-u UDP mode

-v verbose [use twice to be more verbose]

-w secs timeout for connects and final net reads

-C Send CRLF as line-ending

-z zero-I/O mode [used for scanning]

port numbers can be individual or ranges: lo-hi [inclusive];

hyphens in port names must be backslash escaped (e.g. ‘ftp-data‘).

[email protected]:~# nc -nv -w 1 -z 192.168.1.134 1-100

(UNKNOWN) [192.168.1.134] 80 (http) open

(UNKNOWN) [192.168.1.134] 53 (domain) open

(UNKNOWN) [192.168.1.134] 25 (smtp) open

(UNKNOWN) [192.168.1.134] 23 (telnet) open

(UNKNOWN) [192.168.1.134] 22 (ssh) open

(UNKNOWN) [192.168.1.134] 21 (ftp) open

该笔记为安全牛课堂学员笔记,想看此课程或者信息安全类干货可以移步到安全牛课堂


Security+认证为什么是互联网+时代最火爆的认证?


      牛妹先给大家介绍一下Security+

        Security+ 认证是一种中立第三方认证,其发证机构为美国计算机行业协会CompTIA ;是和CISSP、ITIL 等共同包含在内的国际 IT 业 10 大热门认证之一,和CISSP偏重信息安全管理相比,Security+ 认证更偏重信息安全技术和操作。

       通过该认证证明了您具备网络安全,合规性和操作安全,威胁和漏洞,应用程序、数据和主机安全,访问控制和身份管理以及加密技术等方面的能力。因其考试难度不易,含金量较高,目前已被全球企业和安全专业人士所普遍采纳。

Security+认证如此火爆的原因?

        

       原因一:在所有信息安全认证当中,偏重信息安全技术的认证是空白的, Security+认证正好可以弥补信息安全技术领域的空白 。

      目前行业内受认可的信息安全认证主要有CISP和CISSP,但是无论CISP还是CISSP都是偏重信息安全管理的,技术知识讲的宽泛且浅显,考试都是一带而过。而且CISSP要求持证人员的信息安全工作经验都要5年以上,CISP也要求大专学历4年以上工作经验,这些要求无疑把有能力且上进的年轻人的持证之路堵住。在现实社会中,无论是找工作还是升职加薪,或是投标时候报人员,认证都是必不可少的,这给年轻人带来了很多不公平。而Security+的出现可以扫清这些年轻人职业发展中的障碍,由于Security+偏重信息安全技术,所以对工作经验没有特别的要求。只要你有IT相关背景,追求进步就可以学习和考试。


       原因二: IT运维人员工作与翻身的利器。

       在银行、证券、保险、信息通讯等行业,IT运维人员非常多,IT运维涉及的工作面也非常广。是一个集网络、系统、安全、应用架构、存储为一体的综合性技术岗。虽然没有程序猿们“生当做光棍,死亦写代码”的悲壮,但也有着“锄禾日当午,不如运维苦“的感慨。天天对着电脑和机器,时间长了难免有对于职业发展的迷茫和困惑。Security+国际认证的出现可以让有追求的IT运维人员学习网络安全知识,掌握网络安全实践。职业发展朝着网络安全的方向发展,解决国内信息安全人才的匮乏问题。另外,即使不转型,要做好运维工作,学习安全知识取得安全认证也是必不可少的。


        原因三:接地气、国际范儿、考试方便、费用适中!

CompTIA作为全球ICT领域最具影响力的全球领先机构,在信息安全人才认证方面是专业、公平、公正的。Security+认证偏重操作且和一线工程师的日常工作息息相关。适合银行、证券、保险、互联网公司等IT相关人员学习。作为国际认证在全球147个国家受到广泛的认可。

        在目前的信息安全大潮之下,人才是信息安全发展的关键。而目前国内的信息安全人才是非常匮乏的,相信Security+认证一定会成为最火爆的信息安全认证。

 近期,安全牛课堂在做此类线上培训,感兴趣可以了解

本文出自 “11662938” 博客,请务必保留此出处http://11672938.blog.51cto.com/11662938/1965021

安全牛学习笔记udp端口扫描

ICMPport-unreachablepython脚本: #!/usr/bin/pythonimportlogginglogging.getLogger("scapy.runtime").setLevel(logging.ERROR)fromscapy.allimport*importtimeimportsysiflen(sys.argv)!=4:print"Usage./udp_sc 查看详情

安全牛学习笔记服务扫描

1.简述   识别开放端口上的应用  识别目标操作系统  提高攻击效率 2.分类 Banner信息获取服务识别操作系统识别snmp分析防火墙识别 3.Banner(1).含义 在等定的时间或场景中显示... 查看详情

安全牛学习笔记漏洞扫描

一、安装在官网下载home版nussus,然后直接dpkg-i 启动服务/etc/init.d/nessusdstart前面不用加service 查看服务nessusstatus启动后有8834端口,登录后进入管理界面nessus6的默认账号密码在安装时会出现忘记密码可用... 查看详情

安全牛学习笔记smb扫描

SMB扫描╋━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╋┃SMB扫描                          查看详情

安全牛学习笔记漏洞概念

1.漏洞管理(信息维度)(1).信息收集 扫描发现网络IP、OS、服务、配置、漏洞能力需求:定义扫描方式内容和目标 (2).信息管理格式化信息,并进行筛选、分组、定义优先级   能力需求:资产分组、指定... 查看详情

安全牛学习笔记

 弱点扫描╋━━━━━━━━━━━━━━━━━━━━╋┃发现弱点                ┃┃发现漏洞          & 查看详情

安全牛学习笔记openvas+nessus

1.nmap弱点扫描400+扫描脚本 目录/usr/share/nmap/scripts/script.db实例 nmap-p445--script=smb-enum-shares.nse--script-args=smbuser=admin,smbpassword=pass1.1.1.1 nmap-sU-sS--script=sm 查看详情

安全牛学习笔记主动探测

arp协议不可路由桥接到物理网络arping  -c指定数量,-d出现两个相同ip地址的主机 (二层发现)arping-c11.1.1.1|grep"bytesfrom"|cut-d""-f5|cut-d"("-f2|cut-d")"-f1只显示ip地址通过脚本实现对大量主机扫描#!/bin/bashif[$#-ne1];thenecho"Usage:./... 查看详情

安全牛学习笔记缓冲区溢出

数据与代码边界不清,导致程序执行代码脚本:#!/bin/bashecho$1在终端中运行脚本,参数写;或|加上命令,会被系统执行源码审计 逆向工程 对编译后的文件反汇编模糊测试  安装包,对程序发送数值,监视反馈SLmail... 查看详情

安全牛学习笔记osi网络模型

OSI网络模型 物理层规定比特在物理介质中的传输方式,解决物理传输过程中的问题。代表设备:中继器,集线器(多端口中继器) 数据链路层 在不可靠的网络环境中进行可靠的数据传输。解决数据传输中可能出现的... 查看详情

安全牛学习笔记ssh远程端口转发和动态端口转发以及x协议转发

SSH远程端口转发                        由于ACL等原因,SSH与应用连接建立方向相反本地端口转发    查看详情

安全牛学习笔记搜索引擎

搜索引擎 shodan爬取banner信息。搜索联网设备。常用关键字: netcitycountryCNportoshostname实例:cisco200ok思科设备defaultpassword默认密码 google 语法: +-ORinurlallinurlintitleallintitlesitelink 实例: 查看详情

安全牛学习笔记fuzzing

FUZZING╋━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╋┃FUZZING                       &nb 查看详情

安全牛学习笔记提权

WindowsuserAdministratorSystemLinuxUserRootwindows提权将admin提权为systemnet user命令 查看账户Guest 用户,权限很小HelpAssistant用户,远程协助账号Windowssystem账号系统设置管理功能SysInternalSuite工具https://technet.microsoft.c 查看详情

安全牛学习笔记wpa安全系统

WAP安全系统                                & 查看详情

​安全牛学习笔记操作系统识别

该笔记为安全牛课堂学员笔记,想看此课程或者信息安全类干货可以移步到安全牛课堂Security+认证为什么是互联网+时代最火爆的认证?    牛妹先给大家介绍一下Security+    Security+认证是一种中立第... 查看详情

安全牛学习笔记windows系统域和工作组的区别

局域网(LocalAreaNetwork,LAN),又称内网,是指在某一区域内由多台计算机互联成的计算机组。    局域网可以实现文件管理、应用软件共享、打印机共享、扫描仪共享、工作组内的日程安排、电子邮件和传真通信服... 查看详情

安全牛学习笔记csrf

╋━━━━━━━━━━━━━━━━━━━━━━━╋┃CSRF                     ┃┃Cross-siterequestforgery    查看详情