1. 程式人生 > >【安全牛學習筆記】 埠掃描

【安全牛學習筆記】 埠掃描

埠掃描

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

┃隱蔽埠掃描                                                    ┃

┃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"\n\n-- RECEIVED --"

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

response.display()

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

    print"\n\n-- SENT --"

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

    A.display()

    print"\n\n-- 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

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

 PortState

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 commandsas `-e'; use /bin/sh to exec [dangerous!!]

-e filenameprogram to exec after connect [dangerous!!]

-ballow broadcasts

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

-G numsource-routing pointer: 4, 8, 12, ...

-hthis cruft

-i secsdelay interval for lines sent, ports scanned

        -k                      set keepalive option on socket

-llisten mode, for inbound connects

-nnumeric-only IP addresses, no DNS

-o filehex dump of traffic

-p portlocal port number

-rrandomize local and remote ports

-q secsquit after EOF on stdin and delay of secs

-s addrlocal source address

-T tosset Type Of Service

-tanswer TELNET negotiation

-uUDP mode

-vverbose [use twice to be more verbose]

-w secstimeout for connects and final net reads

-CSend CRLF as line-ending

-zzero-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+認證一定會成為最火爆的資訊保安認證。

 近期,安全牛課堂在做此類線上培訓,感興趣可以瞭解

相關推薦

安全學習筆記 掃描

埠掃描 ╋━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╋ ┃隱蔽埠掃描                                                    ┃ ┃Syn-----syn/ack-----rst         

安全學習筆記服務掃描

安全、web、滲透、信息安全 1.簡述 識別開放端口上的應用 識別目標操作系統 提高攻擊效率 2.分類 Banner信息獲取 服務識別 操作系統識別snmp分析 防火墻識別 3.Banner (1).含義

安全學習筆記漏洞掃描

信息安全 漏洞掃描 security+ 一、安裝在官網下載home版nussus,然後直接dpkg -i 啟動服務 /etc/init.d/nessusd start 前面不用加service 查看服務 nessus status 啟動後

安全學習筆記UDP掃描

ICMP port-unreachable python指令碼:  #! /usr/bin/python import logging logging.getLogger("scapy.runtime").setLevel(logging.ERROR) from

安全學習筆記UDP端口掃描

security+ linux 信息安全 ICMP port-unreachablepython腳本: #! /usr/bin/pythonimport logginglogging.getLogger("scapy.runtime").setLevel(logging.ERROR)from sc

安全學習筆記掃描漏洞

security+ linux 信息安全 searchsploit 搜索服務的漏洞利用程序/usr/share/exploitdb/platforms 存放漏洞攻擊代碼sandi-gui工具主動掃描:黑盒探測Agent掃描:收平臺限制Nmap工具Cat 文件 | wc -l 計算行數s

安全學習筆記XSS的簡述

cookie 服務器 漏洞 安全 xss 1.Cross Site SCripting 攻擊者往Web頁面裏插入惡意Script代碼,當用戶瀏覽該頁時,嵌入其中Web裏面的Script代碼會被執行,從而達到惡意攻擊用戶的目的。

安全學習筆記XSS的利用

xss 惡意代碼 漏洞 反射型XSS1.概念 通過社會工程學等手段誘騙用戶點擊某個精心構造的鏈接,該鏈接會將惡意的js代碼提交給 有漏洞的服務器網站,並由服務器返回給受害者的客戶端執行。 2.POC -<scri

安全學習筆記Web掃描器(1)

安全 web 漏洞 1.偵察httrack可將目標網站的網頁全部爬取下來,減少偵察過程中與目標服務器發生的交互。 2.Nikto(1).檢測對象 掃描軟件版本 搜索存在安全隱患的文件 配置漏洞

安全學習筆記OSI網絡模型

http ssh stmp 安全 OSI網絡模型 物理層規定比特在物理介質中的傳輸方式,解決物理傳輸過程中的問題。 代表設備:中繼器,集線器(多端口中繼器) 數據鏈路層 在不可靠的網絡環境中進行可靠的數據傳輸。解決數據傳輸中可能出現的

安全學習筆記搜索引擎

安全、web、滲透、信息安全 搜索引擎 shodan爬取banner信息。搜索聯網設備。 常用關鍵字: netcity country CNport oshostname實例:cisco 200 ok 思科設備default password 默認密碼

安全學習筆記Kali Linux 安裝-持久加密USB安裝、熟悉環境、熟悉BASH命令

security+ linux 信息安全 持久加密USB安裝-1LUKS: linux UNified Key Setup 磁盤分區加密規範 不依賴於操作系統的磁盤級加密 Windows——DoxBox 後端:dm-crypt 前端:cryptsetup 微軟的bitlocker將鏡像

安全學習筆記網絡配置、更新升級、安裝軟件包、瀏覽器插件

信息安全;網絡配置[email protected]:~# dhclient eth0 //用來通過 dhcp 協議配置本機的網絡接口[email protected]:~# ifconfig 查看現在的ip地址[email protected]:~# ifc

安全學習筆記 Kali Linux安裝-熟悉環境

信息安全;security+;kali linux熟悉BASH命令 Ls、cd、pwd、cat、more、tail、cp、rm、top、ps、greg、ifconfig、netstat、awk、sort、route、mount、dmesg、find、whereis、Echo、vi 管道 shell腳本[

安全學習筆記基本工具-NETCAT(telnet/banner、傳輸文本信息)

信息安全;security+;kali linux滲透測試常用工具經常使用且功能強大安全從業者必不可少的幫手Nc / ncatWireshackTcpdumpNETCAT-----NC網絡工具中的瑞士軍刀——小身材、大智慧偵聽模式/傳輸模式telnet/獲取banner信息傳輸文本信息傳輸文件目錄加密傳輸文件

安全學習筆記實驗環境

信息安全;security+;kali linux滲透測試準備實驗環境 滲透非授權系統的弊端 搭建自己的實驗環境安裝虛擬機微軟最新版軟件 http://msdn .microsoft.com/en-ca/subscriptions/aa336858windows虛擬機 http://dev.mod

安全學習筆記TOR

信息安全;security+;kali linux滲透測試保護隱私防止被追蹤誌願者組成長期在天朝完全無法使用 感謝 雲暗網 互聯網搜索引擎無法發現 互聯網黑市下載和看視頻是不道德的行為互聯網黑市交易的貨幣是比特幣比特幣很難在互聯網復原下載http://www.torproject.org/d

安全學習筆記搜索引擎、SHODAN

信息安全 security+ 搜索引擎、SHODAN╋━━━━━━━━━━━━━━━━━━━━━━━━━━╋┃搜索引擎 ┃┃公司新聞動態 ┃┃重要雇員信息

安全學習筆記

信息安全;security+; 弱點掃描╋━━━━━━━━━━━━━━━━━━━━╋┃發現弱點 ┃┃發現漏洞 ┃┃ 基於端口五福掃描結果版本信息(速度慢)┃┃ 搜索已公開的漏洞數據庫

安全學習筆記​ NESSUS

信息安全;security+; NESSUS╋━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╋┃NESSUS ┃┃家庭版