网络协议与攻击模拟

网络协议与攻击模拟

一、协议

TCP/IP协议簇

1、协议

  • 网络接口层
    • 物理层
    • 数据链路层
  • 网络层:IP协议(v4/v6) ARP(地址解析) RARP ICMP(控制报文协议) IGMP
  • 传输层:TCP(传输控制协议) UDP(用户数据报协议)
  • 应用层:基于传输层端口 HTTP HTTPS
    • DHCP
    • DNS
    • HTTP
    • HTTPS
    • FTP
    • SMTP
    • POP3
    • IMAP

二、流量抓取工具(wireshark)

1、网卡

  • wireshark是对主机网卡上数据流量抓取

2、网卡的模式

  • 混杂模式:不管是否是自己目的,都抓取
  • 非混杂模式:默认情况下处于此模式,不会接受目的非自己的数

三、ARP攻击

概念:地址解析协议

1、查看ARP缓存

# 查看缓存
arp -a
# 清除缓存
arp -d
# 添加缓存
arp -s

2、攻击

# arp欺骗
arpspoof -i eth0 -t 目标ip 网关
# 开启转发
echo 1 > /proc/sys/net/ipv4/ip_forward
# 监听图片
driftnet 

四、ICMP协议及重定向攻击

概念:控制报文协议,用于在IP主机或路由器之间传递控制消息

网络是否通畅、主机是否可以到达,路由是否可用

1、ICMP协议

  • 网络层协议,封装在传输层和网络成之间

2、ICMP报文格式

  • 类型(type)
    • 8 请求
    • 0 应答
    • 3 不正常应答
    • 11 超时
    • 5 重定向

3、ICMP重定向

在某些特定情况下,路由器检测到主机使用非优化路由的时候,会向主机发送一个ICMP的重定向报文,使主机路由改变。

4、重定向攻击

  • ettercap

  • netwox

    netwox 86 -g 新网关
    

五、TCP协议

传输层的功能:定义应用层协议数据报文的端口号,流量控制。

对原始数据进行分段处理

1、传输层提供的服务

  • 传输连接服务
  • 数据传输服务:流量控制、差错校验、序列控制

2、传输层协议

  • 面向连接的传输协议(TCP)
    • 要求数据在传输之前必须建立连接
    • 数据传输完成后必须释放连接
    • 仅支持单播传输:两个终端之间的点对点连接
  • UDP(用户数据报协议)

3、TCP的报文字段

在这里插入图片描述

4、TCP的三次握手

在这里插入图片描述

5、TCP的四次挥手

在这里插入图片描述

6、TCP半关闭状态

7、TCP的半连接状态

8、常见的TCP端口号

21 ftp
22 ssh
23 telnet
25 smtp
53 dns    两台DNS服务器用到TCP  本身dns时udp
80 http
110 pop3
143 imap4
443 https
3306 mysql
3389 rdp

六、SYN flood

# kali开启网卡
ifup eth0
# kali关闭网卡
ifdown eth0
# linux查看路由
route -n

1、攻击

# hping3
hping3 -c 1000 -d 120 -S -w 64 -p 80 --flood --rand-source 192.168.1.100

2、防御

  • 使用TCP代理
  • TCP源探测

七、UDP协议

UDP:用户数据报协议

1、特点

  • 不需要连接,直接发送数据,不去重新排序,不需要确认

2、报文字段

  • 源端口
  • 目标端口
  • UDP长度
  • UDP校验和

3、常见UDP端口号

  • 53 DNS
  • 69 TFTP
  • 111 RPC
  • 123 NTP
  • 161 SNMP

4、工具

  • hping3

八、DHCP协议

用户动态获取IP地址(动态用户配置协议)

  • 应用层协议,基于UDP
    在这里插入图片描述

九、FTP协议

文件传输协议

由两部分组成:C/S架构

  • 服务端
  • 客户端

基于TCP协议,端口为20,21

  • 20传输协议
  • 21用于传输控制
  • 主动模式使用20号端口
  • 被动模式端口协商决定

1、主动模式

  • 建立连接(三次握手)使用21号端口,服务器从20号端口主动向客户机发动连接(三次握手)

2、被动模式

  • 建立连接(三次握手)使用21号端口,客户端向服务器发送命令,服务器随机打开一个高位端口,进行连接(三次握手)

3、传输文件模式

  • 文本模式:ASCII模式,以文本序列传输
  • 二进制模式:binary,非文本类(图片,视频,应用程序等等)

4、服务端程序

  • server-u
  • vsftp(开源)
  • filezilla server(Linux)
  • windows ftp服务器

5、客户端程序

  • 命令行

    ftp 192.168.0.1   访问
    
  • 资源管理器

    ftp://192.168.0.1   访问
    
  • 浏览器

    ftp://192.168.0.1
    
  • 第三方工具

    • flashFXP
    • filezilla client
    • xftp
    • cuteftp

5、FTP用户

  • 匿名用户
    • anonymous:固定名称
  • 普通用户

【注】注意防火墙

十、HTTP协议

1、概念

  • HTTP(超文本传输协议),万维网服务器上传输超文本HTML代码。服务器到本地浏览器的传输协议。
  • 基于TCP(HTML文本,文本等等)

2、万维网服务

  • 采用C/S架构
  • 客户机通过浏览器请求 浏览器对服务器架构(B/S)架构

3、万维网服务软件

  • Windows IIS(win)
  • apache (多平台)
  • tomcat (多平台)
  • nginx (多平台)

4、工作原理

客户端通过浏览器使用URL向HTTP服务器发送请求

  • URL:统一资源定位器,由三部分组成(协议+主机和端口+文件名和路径)

WEB服务器根据收到的请求直接向客户机响应信息

HTTP默认端口为80,默认端口可以更改

交互过程
在这里插入图片描述

  • 【注意】

    • http无连接:每次连接只处理一个请求

    • http独立:任何数据都可以处理,采用适合的MIME类型

    • http无状态:没有记忆能力,后续处理需要重传

十一、HTTPS协议

http+ssl/tls

1、基础

  • 在http通道上增加安全性,传输过程通过加密和身份认证来确保传输的安全性

2、TLS

  • 传输层安全协议,SSL/TLS是一个协议,ssl3.0更名为TLS,使用最为广泛的是TLS1.2版本
  • 设计目标
    • 保密性
    • 完整性
    • 认证:双方都配备证书,防止冒充
    • 互操作
    • 通用性
    • 可扩展
    • 高效率
  • 发展史
    • SSL 2.0 SSL3.0 TLS1.0 TLS1.1 TLS1.2 TLS1.3

3、http缺陷

  • 明文传输
  • 只对传输数据长度完整性校验,数据是否被篡改不做确认

4、https好处

  • 传输前,协商加密算法(非对称加密算法,密钥交换,RSA/DH),数据签名摘要算法(MD5/HASH),数据采用对称加密算法(DES/AES/3DES)
    在这里插入图片描述

5、加密算法

  • 对称加密

    • 加密解密密钥相同
    • DES
    • AES
    • RC
      在这里插入图片描述
  • 非对称加密

    • 加密和解密使用不同的密钥(公钥和私钥),每个用户都可以有自己的公钥和私钥,私钥是自己保存,使用一个密钥加密就需要另一个私钥解密。
    • 加密比较复杂,大规模数据,比较影响速率
    • DH
    • RSA
    • ECC
    • RABIN

6、PKI体系

公钥基础设施

使用公钥技术和数字签名来确保信息安全

公钥加密技术(非对称加密),数字证书,CA(证书颁发机构),RA(证书注册机构)组成

  • 实现功能
    • 身份验证
    • 数据完整性
    • 数据机密性
    • 操作不可否认性
  • 身份认证及完整性认证

在这里插入图片描述

  • 数字证书
    • 保证密钥的合法性
    • 证书的主体可以是任何一个对象
    • 包含信息
      • 使用者的公钥
      • 使用者的标识
      • 有效期
      • 颁发者的标识信息
      • 颁发者的数字签名
What’s in This Book? This book contains a mix of theoretical and practical chapters. For the practical chapters, I’ve developed and made available a networking library called Canape Core, which you can use to build your own tools for protocol analysis and exploitation. I’ve also provided an example networked application called SuperFunkyChat, which implements a userto-user chat protocol. By following the discussions in the chapters, you can use the example application to learn the skills of protocol analysis and attack the sample network protocols. Here is a brief breakdown of each chapter: Chapter 1: The Basics of Networking This chapter describes the basics of computer networking with a particular focus on TCP/IP, which forms the basis of application-level network protocols. Subsequent chapters assume that you have a good grasp of the network basics. This chapter also introduces the approach I use to model application protocols. The model breaks down the application protocol into flexible layers and abstracts complex technical detail, allowing you to focus on the bespoke parts of the protocol you’re analyzing. Chapter 2: Capturing Application Traffic This chapter introduces the concepts of passive and active capture of network traffic, and it’s the first chapter to use the Canape Core network libraries for practical tasks. Chapter 3: Network Protocol Structures Download from finelybook www.finelybook.com 24This chapter contains details of the internal structures that are common across network protocols, such as the representation of numbers or human-readable text. When you’re analyzing captured network traffic, you can use this knowledge to quickly identify common structures, speeding up your analysis. Chapter 4: Advanced Application Traffic Capture This chapter explores a number of more advanced capture techniques that complement the examples in Chapter 2. The advanced capture techniques include configuring Network Address Translation to redirect traffic of interest and spoofing the address resolution protocol. Chapter 5: Analysis from the Wire This chapter introduces methods for analyzing captured network traffic using the passive and active techniques described in Chapter 2. In this chapter, we begin using the SuperFunkyChat application to generate example traffic. Chapter 6: Application Reverse Engineering This chapter describes techniques for reverse engineering networkconnected programs. Reverse engineering allows you to analyze a protocol without needing to capture example traffic. These methods also help to identify how custom encryption or obfuscation is implemented so you can better analyze traffic you’ve captured. Chapter 7: Network Protocol Security This chapter provides background information on techniques and cryptographic algorithms used to secure network protocols. Protecting the contents of network traffic from disclosure or tampering as it travels over public networks is of the utmost importance for network protocol security. Chapter 8: Implementing the Network Protocol This chapter explains techniques for implementing the application Download from finelybook www.finelybook.com 25network protocol in your own code so you can test the protocol’s behavior to find security weaknesses. Chapter 9: The Root Causes of Vulnerabilities This chapter describes common security vulnerabilities you’ll encounter in a network protocol. When you understand the root causes of vulnerabilities, you can more easily identify them during analysis. Chapter 10: Finding and Exploiting Security Vulnerabilities This chapter describes processes for finding security vulnerabilities based on the root causes in Chapter 9 and demonstrates a number of ways of exploiting them, including developing your own shell code and bypassing exploit mitigations through return-oriented programming. Appendix: Network Protocol Analysis Toolkit In the appendix, you’ll find descriptions of some of the tools I commonly use when performing network protocol analysis. Many of the tools are described briefly in the main body of the text as well. How to Use This Book If you want to start with a refresher on the basics of networking, read Chapter 1 first. When you’re familiar with the basics, proceed to Chapters 2, 3, and 5 for practical experience in capturing network traffic and learning the network protocol analysis process. With the knowledge of the principles of network traffic capture and analysis, you can then move on to Chapters 7 through 10 for practical information on how to find and exploit security vulnerabilities in these protocols. Chapters 4 and 6 contain more advanced information about additional capture techniques and application reverse engineering, so you can read them after you’ve read the other chapters if you prefer. For the practical examples, you’ll need to install .NET Core Download from finelybook www.finelybook.com 26(https://www.microsoft.com/net/core/), which is a cross-platform version of the .NET runtime from Microsoft that works on Windows, Linux, and macOS. You can then download releases for Canape Core from https://github.com/tyranid/CANAPE.Core/releases/ and SuperFunkyChat from https://github.com/tyranid/ExampleChatApplication/releases/; both use .NET Core as the runtime. Links to each site are available with the book’s resources at https://www.nostarch.com/networkprotocols/. To execute the example Canape Core scripts, you’ll need to use the CANAPE.Cli application, which will be in the release package downloaded from the Canape Core Github repository. Execute the script with the following command line, replacing script.csx with the name of the script you want to execute.
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值