第十一至第十三天(网安篇)

一、NMAP命令

Nmap(Network Mapper)是一个开源的网络探测和安全审核工具。它被广泛用于网络发现和安全扫描。Nmap使用原始IP数据包来确定网络上的哪些主机可用、这些主机提供哪些服务(应用程序名和版本)、这些主机运行的操作系统(包括版本信息和可能的硬件类型)、这些主机使用的包过滤器/防火墙类型以及各种其他特性。

参数解释示例
-p [port(s)]扫描指定的端口或端口范围nmap -p 80,443 [target]
-F快速扫描,只检查常用端口nmap -F [target]
-O启用操作系统检测nmap -O [target]
-sV探测服务版本信息nmap -sV [target]
-n禁止DNS解析nmap -n [target]
-sS使用TCP SYN扫描,不完全建立TCP连接nmap -sS [target]
-sT使用TCP Connect扫描,完全建立TCP连接nmap -sT [target]
–script使用指定的Nmap脚本进行扫描nmap --script=[script-name] [target]
-A综合扫描,包括操作系统检测、版本检测、脚本扫描和traceroutenmap -A [target]
-T[0-5]设置扫描速度,0是最慢,5是最快nmap -T4 [target]
-v增加输出的详细程度nmap -v [target]
-Pn跳过主机发现,直接扫描端口nmap -Pn [target]
基本端口扫描
例子:
扫描端口: nmap 192.168.75.225
扫描特定端口: nmap -p 22,80,443 192.168.75.225
快速扫描: nmap -F 192.168.75.225
┌──(newrain㉿kali)-[~/Desktop]
└─$ sudo nmap 192.168.75.225                                                
[sudo] newrain 的密码:
Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-01-14 14:21 CST
Nmap scan report for 192.168.75.225
Host is up (0.000031s latency).
Not shown: 997 closed tcp ports (reset)
PORT     STATE SERVICE
22/tcp   open  ssh
80/tcp   open  http
3306/tcp open  mysql
MAC Address: 00:0C:29:A4:C1:3C (VMware)

Nmap done: 1 IP address (1 host up) scanned in 2.26 seconds
多地址扫描
扫描多个目标:nmap 192.168.75.225 192.168.75.226 192.168.75.227
扫描整个子网:nmap 192.168.75.0/24
# 多地址扫描
┌──(newrain㉿kali)-[~/Desktop]
└─$ sudo nmap 192.168.75.225 192.168.75.226 192.168.75.227
Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-01-14 14:24 CST
Nmap scan report for 192.168.75.225
Host is up (0.00026s latency).
Not shown: 997 closed tcp ports (conn-refused)
PORT     STATE SERVICE
22/tcp   open  ssh
80/tcp   open  http
3306/tcp open  mysql

Nmap done: 3 IP addresses (1 host up) scanned in 3.34 seconds

# 扫描整个网段
┌──(newrain㉿kali)-[~/Desktop]
└─$ sudo nmap 192.168.75.0/24
Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-01-14 14:25 CST
Nmap scan report for 192.168.75.1
Host is up (0.00013s latency).
Not shown: 993 closed tcp ports (conn-refused)
PORT     STATE SERVICE
135/tcp  open  msrpc
139/tcp  open  netbios-ssn
443/tcp  open  https
445/tcp  open  microsoft-ds
902/tcp  open  iss-realsecure
912/tcp  open  apex-mesh
7000/tcp open  afs3-fileserver

Nmap scan report for 192.168.75.2
Host is up (0.00024s latency).
Not shown: 999 closed tcp ports (conn-refused)
PORT   STATE SERVICE
53/tcp open  domain

Nmap scan report for 192.168.75.225
Host is up (0.00052s latency).
Not shown: 997 closed tcp ports (conn-refused)
PORT     STATE SERVICE
22/tcp   open  ssh
80/tcp   open  http
3306/tcp open  mysql

Nmap scan report for 192.168.75.231
Host is up (0.000091s latency).
All 1000 scanned ports on 192.168.75.231 are in ignored states.
Not shown: 1000 closed tcp ports (conn-refused)

Nmap done: 256 IP addresses (4 hosts up) scanned in 7.19 seconds

平台检测
操作系统检测:nmap -O 192.168.75.225
服务版本检测:nmap -sV 192.168.75.225
# 检测操作系统
┌──(newrain㉿kali)-[~/Desktop]
└─$ sudo nmap -O 192.168.75.225
Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-01-14 14:27 CST
Nmap scan report for 192.168.75.225
Host is up (0.00044s latency).
Not shown: 997 closed tcp ports (reset)
PORT     STATE SERVICE
22/tcp   open  ssh
80/tcp   open  http
3306/tcp open  mysql
MAC Address: 00:0C:29:A4:C1:3C (VMware)
Device type: general purpose
Running: Linux 3.X|4.X
OS CPE: cpe:/o:linux:linux_kernel:3 cpe:/o:linux:linux_kernel:4
OS details: Linux 3.2 - 4.9
Network Distance: 1 hop

OS detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 3.65 seconds

# 检查版本
┌──(newrain㉿kali)-[~/Desktop]
└─$ sudo nmap -sV 192.168.75.225
Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-01-14 14:29 CST
Nmap scan report for 192.168.75.225
Host is up (0.000070s latency).
Not shown: 997 closed tcp ports (reset)
PORT     STATE SERVICE VERSION
22/tcp   open  ssh     OpenSSH 7.4 (protocol 2.0)
80/tcp   open  http    nginx 1.20.1
3306/tcp open  mysql   MySQL 5.7.44
MAC Address: 00:0C:29:A4:C1:3C (VMware)

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 8.94 seconds

基于特殊脚本扫描
nmap --script=default 192.168.106.134
执行默认的脚本集,这通常包括针对最常见的漏洞和问题的检测。
nmap --script=auth 192.168.106.214
运行与认证相关的脚本,通常用于发现目标上的认证漏洞。
nmap --script=brute 192.168.106.134
执行暴力破解攻击的脚本,用于尝试破解目标上的各种服务(如FTP、SSH等)的密码。
nmap --script=vuln 192.168.106.134
运行检测已知漏洞的脚本,用于识别目标上可能存在的漏洞。
nmap --script=broadcast 192.168.106.134
使用广播脚本,这通常用于发现局域网内的主机和服务。
nmap --script=smb-brute.nse 192.168.106.134
执行针对SMB服务的暴力破解脚本,尝试猜测SMB协议上的用户名和密码。
nmap --script=smb-check-vulns.nse --script-args=unsafe=1 192.168.106.134
运行SMB漏洞检查脚本,unsafe=1参数允许脚本执行可能会对目标系统造成影响的检测。
nmap --script=smb-vuln-conficker.nse --script-args=unsafe=1 192.168.106.134
执行检测Conficker蠕虫的脚本,这是一种在Windows系统上广泛传播的恶意软件。
nmap -p3306 --script=mysql-empty-password.nse 192.168.106.134
在端口3306(MySQL的默认端口)上运行检查空密码的MySQL账户的脚本。

二、nikto命令

站点扫描

执行对目标服务器的基本扫描,只需输入以下命令:

nikto -h [目标主机]
例如:nikto -h http://www.example.com
┌──(newrain㉿kali)-[~]
└─$ nikto -h http://192.168.75.225
- Nikto v2.5.0
---------------------------------------------------------------------------
+ Target IP:          192.168.75.225
+ Target Hostname:    192.168.75.225
+ Target Port:        80
+ Start Time:         2024-01-14 16:07:36 (GMT8)
---------------------------------------------------------------------------
+ Server: nginx/1.20.1
+ /: Retrieved x-powered-by header: PHP/8.0.30.
+ /: The anti-clickjacking X-Frame-Options header is not present. See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options
+ /: Drupal Link header found with value: <http://192.168.75.225/index.php?rest_route=/>; rel="https://api.w.org/". See: https://www.drupal.org/
+ /: The X-Content-Type-Options header is not set. This could allow the user agent to render the content of the site in a different fashion to the MIME type. See: https://www.netsparker.com/web-vulnerability-scanner/vulnerabilities/missing-content-type-header/
+ /index.php?: Uncommon header 'x-redirect-by' found, with contents: WordPress.
+ No CGI Directories found (use '-C all' to force check all possible dirs)
+ /wp-content/plugins/akismet/readme.txt: The WordPress Akismet plugin 'Tested up to' version usually matches the WordPress version.
+ /wp-links-opml.php: This WordPress script reveals the installed version.
+ /license.txt: License file found may identify site software.
+ /: A Wordpress installation was found.
+ /wp-login.php?action=register: Cookie wordpress_test_cookie created without the httponly flag. See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies
+ 8102 requests: 0 error(s) and 10 item(s) reported on remote host
+ End Time:           2024-01-14 16:08:27 (GMT8) (51 seconds)
---------------------------------------------------------------------------
+ 1 host(s) tested

报告内容

报告内容:
针对IP地址192.168.75.225上运行的Web服务器(端口80)的一些关键发现。这台服务器运行着nginx/1.20.1,并且部署了WordPress和Drupal。以下是一些重要的安全隐患和信息泄露点:

  1. PHP版本公开
    • 扫描发现了x-powered-by头部,显示PHP版本为8.0.30。公开版本信息可能增加被攻击的风险。
  2. 缺少X-Frame-Options头
    • 没有X-Frame-Options头可能使网站容易受到点击劫持攻击。更多信息可参考:X-Frame-Options
  3. Drupal API链接
    • 发现了Drupal的API链接,这可能是信息泄露。
  4. 缺少X-Content-Type-Options头
    • 缺少这个头部可能允许浏览器基于内容推断MIME类型,可能导致安全漏洞。详情见:[Missing Content-Type Header](https://www

.netsparker.com/web-vulnerability-scanner/vulnerabilities/missing-content-type-header/).

  1. WordPress的非常见头部 ‘x-redirect-by’
    • 发现了指向WordPress的非常见头部,这可能是信息泄露。
  2. 未找到CGI目录
    • 未发现CGI目录,但可以使用**-C all**参数强制检查所有可能的目录。
  3. WordPress Akismet插件信息
    • 通过**/wp-content/plugins/akismet/readme.txt**文件,泄露了WordPress Akismet插件的版本信息。
  4. WordPress版本泄露
    • /wp-links-opml.php脚本泄露了WordPress的安装版本。
  5. 可能泄露的许可证文件
    • 通过**/license.txt**文件可能泄露了站点软件的信息。
  6. WordPress安装确认
    • 确认了站点上安装了WordPress。
  7. Cookie缺少HttpOnly标志
    • 在**/wp-login.php?action=register发现了未设置HttpOnly标志的wordpress_test_cookie**。这可能使cookie容易受到跨站脚本攻击。

解决建议:

  • 更新和打补丁:确保所有服务(如PHP, WordPress, Drupal, nginx)都是最新版本,并应用了所有安全补丁。
  • 隐藏版本信息:配置Web服务器和应用,以避免泄露版本信息。
  • 设置安全头部:添加X-Frame-Options、X-Content-Type-Options等安全头部,以增强浏览器安全性。
  • 安全配置WordPress:确保WordPress配置正确,不泄露不必要的信息。
  • 检查插件版本:确保所有WordPress插件是最新的,避免使用过时的插件。
  • 配置Cookie安全:对所有敏感Cookie设置HttpOnly标志。
参数解释
参数解释示例
-h [host]指定要扫描的主机或IP地址nikto -h www.example.com
-p [port]指定要扫描的端口nikto -h www.example.com -p 8080
-ssl使用SSL连接到主机nikto -h www.example.com -ssl
-id [id:pass]使用HTTP认证nikto -h www.example.com -id user:pass
-o [file]将扫描结果保存到指定文件nikto -h www.example.com -o result.txt
-nolookup不进行DNS或WHOIS查找nikto -h 192.168.1.1 -nolookup
-C [dir]强制检查指定目录nikto -h www.example.com -C all
-T [test]选择特定测试类型执行nikto -h www.example.com -T xss
-useproxy [host]通过指定的HTTP/HTTPS代理进行扫描nikto -h www.example.com -useproxy http://localhost:8080
-timeout [time]设置请求超时时间(秒)nikto -h www.example.com -timeout 30
-evasion [num]使用指定的逃避技术nikto -h www.example.com -evasion 1
-useragent [ua]设置自定义的User-Agent字符串nikto -h www.example.com -useragent “MyUserAgent”
-update更新Nikto插件和数据库nikto -update
-list-plugins列出所有可用的Nikto插件nikto -list-plugins

1. 信息收集概述

  • Web信息搜集(探测)即Web踩点,是掌握目标Web服务的各方面信息,是实现Web渗透入侵前的准备工作。
  • Web踩点内容包括操作系统、服务器类型、数据库类型、Web容器、Web语言、域名信息、网站目录等。
  • Web信息搜集涉及搜索引擎、网站扫描、域名遍历、指纹识别等工作。

2. 项目实验环境

  • 测试渗透机:Kali。

3. Google Hacking

3.1 site

  • 功能:搜索指定的域名的网页内容,用于搜索子域名、与此域名相关的内容。
  • 示例
    • site:zhihu.com:搜索与zhihu.com相关的网页。
    • “web安全” site:zhihu.com:搜索zhihu.com与web安全相关的网页。
    • “sql注入” site:csdn.net:在csdn.net搜索与sql注入相关的内容。
    • “教程” site:pan.baidu.com:在百度盘中搜索教程。

3.2 filetype

  • 功能:搜索指定文件类型。
  • 示例
    • “web安全” filetype:pdf:搜索与安全书籍相关的pdf文件。
    • nmap filetype:ppt:搜索与nmap相关的ppt文件。
    • site:csdn.net filetype:pdf:搜索csdn网站中的pdf文件。
    • filetype:pdf site:www.51cto.com:搜索51cto的pdf文件。

3.3 inurl

  • 功能:搜索url网址中存在特定关键字的网页,可以用来搜寻有注入点的网站。
  • 示例
    • inurl:.php?id=:搜索网址中有"php?id"的网页。
    • inurl:view.php=?
    • inurl:.jsp?id=
    • inurl:.asp?id=
    • inurl:/admin/login.php
    • inurl:login

3.4 intitle

  • 功能:搜索标题存在特定关键字的网页。
  • 示例
    • intitle:后台登录:搜索网页标题是“后台登录”的相关网页。
    • intitle:后台管理 filetype:php:搜索网页标题是“后台管理”的php页面。
    • intitle:index of “keyword”
    • intitle:index of “parent directory”
    • intitle:index of “password”
    • intitle:index of “login”
    • intitle:index of “admin”

3.5 intext

  • 功能:搜索正文存在特定关键字的网页。
  • 示例
    • intext:Powered by Discuz:搜索Discuz论坛相关的页面。
    • intext:powered by wordpress:搜索wordpress制作的博客网址。
    • *intext:Powered by CMS
    • intext:powered by xxx inurl:login

3.6 实例

  • 搜索美女/电影等相关网站:
    • inurl:php?id= intitle:美剧
    • inurl:php?id= intitle:动漫
    • inurl:php?id intitle:动漫图片 intext:powered by discuz

3.7 谷歌信息搜集

搜索语法解释示例
“关键词”精确短语搜索“machine learning”
关键词 -排除词排除包含特定词的搜索结果apple -phone
关键词 * 关键词使用星号作为通配符artificial * applications
site:网站地址限制搜索结果只来自指定的网站site:nytimes.com
intitle:关键词只搜索在网页标题中包含特定关键词的页面intitle:global warming
inurl:关键词搜索URL中包含特定关键词的网页inurl:blog
filetype:文件类型搜索特定格式的文件filetype:pdf climate change
OR搜索包含至少一个关键词的结果education OR training
cache:网址显示谷歌缓存的页面内容cache:www.example.com
related:网址查找与指定网址内容相关的网页related:www.example.com
define:关键词查找关键词的定义define:philosophy
allintitle:多个关键词搜索标题中同时包含多个关键词的页面allintitle:global warming consequences
allinurl:多个关键词搜索URL中同时包含多个关键词的页面allin

4. 撒旦搜索引擎

点击跳转官网

4.1 基于ip

139.198.125.244

image.png

4.2 服务/协议

http
http country:"DE"
http country:"DE" product:"Apache httpd"
http product:"Apache httpd"

ssh
ssh default password
ssh default password country:"JP"

image.png

4.3 关键字

"default password" country:"TH"
FTP anon successful

4.4 国家

country:cn
country:us
country:jp

4.5 产品

product:"Microsoft IIS httpd"
product:"nginx"
product:"Apache httpd"
product:MySQL

4.6 版本

product:MySQL version:"5.1.73"
product:"Microsoft IIS httpd" version:"7.5"

4.7 域名/主机名

hostname:.org
hostname:.edu

4.8 操作系统

os:"Windows Server 2008 R2"
os:"Windows 7 or 8"
os:"Linux 2.6.x"

4.9 网络

net:110.180.13.0/24
200 ok net:110.180.13.0/24
200 ok country:JP net:110.180.13.0/24

4.10 端口

port:3389
port:445
port:22
port:80
port:443

4.11 案例

搜索日本区开启80端口的设备:
country:jp port:"80"
country:jp port:"80" product:"Apache httpd"
country:jp port:"80" product:"Apache httpd" city:"Tokyo"
country:jp port:"80" product:"Apache httpd" city:"Tokyo" os:"Linux 3.x"
搜索日本区使用Linux2.6.x系统的设备:
country:jp os:"Linux 2.6.x"
country:jp os:"Linux 2.6.x" port:"80"
country:jp os:"Linux 2.6.x" port:"80" product:"Apache httpd"
搜索日本区使用Windows Server 系统的设备:
country:jp os:"Windows Server 2008 R2"
country:jp os:"Windows Server 2003" port:"445"
country:jp os:"Windows Server 2003" port:"80"
搜索日本区使用Microsoft IIS的设备:
country:jp product:"Microsoft IIS httpd" version:"7.5"

Server: Hikvision-Webs country:"CN"
Server: SQ-WEBCAM

钟馗之眼
点击跳转

5. 脚本调用shodan

# 安装模块
┌──(newrain㉿kali)-[~/Desktop]
└─$ sudo pip install shodan
或
┌──(newrain㉿kali)-[~/Desktop]
└─$ git clone https://github.com/achillean/shodan-python.git && cd shodan-python && sudo python setup.py install
┌──(newrain㉿kali)-[~/Desktop]
└─$ shodan -h
Usage: shodan [OPTIONS] COMMAND [ARGS]...
Options:
  -h, --help  Show this message and exit.
Commands:
  alert       Manage the network alerts for your account  # 管理账户的网络提示
  convert     Convert the given input data file into a...  # 转换输入文件
  count       Returns the number of results for a search  # 返回查询结果数量
  download    Download search results and save them in a...  # 下载查询结果到文件
  honeyscore  Check whether the IP is a honeypot or not.  # 检查 IP 是否为蜜罐
  host        View all available information for an IP...  # 显示一个 IP 所有可用的详细信息
  info        Shows general information about your account  # 显示账户的一般信息
  init        Initialize the Shodan command-line  # 初始化命令行
  myip        Print your external IP address  # 输出用户当前公网IP
  parse       Extract information out of compressed JSON...  # 解析提取压缩的JSON信息,即使用download下载的数据
  scan        Scan an IP/ netblock using Shodan.  # 使用 Shodan 扫描一个IP或者网段
  search      Search the Shodan database  # 查询 Shodan 数据库
  stats       Provide summary information about a search...  # 提供搜索结果的概要信息
  stream      Stream data in real-time.  # 实时显示流数据

┌──(newrain㉿kali)-[~/Desktop]
└─$ shodan init yKr2vkS7zjvWTQVBpBlwl5bRXXXXXXX # 使用自己的api-key
Successfully initialized

Ettercap 是一个综合的网络监控和嗅探工具,专门用于局域网(LAN)中。它支持活动和被动的多种嗅探方式,并包括对加密通信的一些攻击,如SSL中间人攻击。Ettercap 还支持网络协议分析和实时内容过滤。由于其强大的功能,Ettercap 通常用于网络安全测试和黑客攻击。
使用 Ettercap 时,用户可以执行多种操作,包括但不限于:

  1. ARP 欺骗:通过伪装成网络中的另一台机器来拦截流向该机器的数据。
  2. 中间人攻击:截获和修改两台通信设备之间的数据传输。
  3. 密码嗅探:捕获网络中传输的密码,例如HTTP、FTP、SSH密码。
  4. 连接断开攻击:断开网络中的设备连接。

Ettercap 的使用涉及复杂的网络知识和技术,通常通过命令行界面执行。它的一些基本命令包括:

  • ettercap -T:启动Ettercap的文本模式。
  • ettercap -G:启动Ettercap的图形用户界面(如果可用)。
  • ettercap -i [interface]:指定要使用的网络接口。
  • ettercap -M arp /target1/ /target2/:启动针对特定目标的ARP中间人攻击。

实验:

kali 网卡尽量选择桥接网卡

1、在终端执行ettercap -G,如果使用普通用户,记得sudo
2、在弹出的ui界面中选择如图所示
3、点击ui界面有上角的√

image.png
image.png
image.png
image.png

测试网站,文明访问

image.png

结果:在日常访问网站时,谨记注意当前的网络环境是否安全,并访问https的加密网站。

仅供交流学习使用,勿用于其他用途,务必遵纪守法!!!

  • 41
    点赞
  • 34
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值