linux udp 端口 抓包,tcpdump之UDP抓包

摘要

使用tcpdump抓UDP包,过滤过滤IP和port,并且自动拆分片段。

安装tcpdump

yum install -y tcpdump

使用方法

tcpdump -i bond0 udp port xxxx and host xxx.x.xx.xxx -s0 -G 600 -w %Y_%m%d_%H%M_%S.pcap

参数说明

-i 指定监听的网卡

udp 监听UDP协议

port 指定过滤的端口

host 指定过滤的ip

-s *表示*从一个包中截取的字节数,*0表示*包不截断

-G 按照固定的时间间隔切割输出的文件(单位:秒)

-w 直接将包写入文件中,并不分析和打印出来;

取非运算是 ‘not ’ ‘! ‘,与运算是’and’,’&&;或运算 是’or’ ,‘||’

定时抓包(python)

#!/usr/bin/env python

# -*- coding: UTF-8 -*-

#

# @author 张文兵

# @blog https://zhangwenbing.com/

# @datetime 2020-12-18 14:56:01

# @description

#

import os

import time

from apscheduler.schedulers.blocking import BlockingScheduler

def system(cmd):

t = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time()))

print('{} 执行 {}'.format(t, cmd))

stat = os.system(cmd)

if stat != 0:

print('{} 执行 {} 失败'.format(t, cmd))

scheduler = BlockingScheduler()

# 星期1-5的17点40分执行抓包任务

scheduler.add_job(system, 'cron', day_of_week="mon,tue,wed,thu,fri,sat",

hour=17, minute=30, args=['/sbin/tcpdump -i bond0 udp port xxxx and host xxx.x.xx.xxx -s0 -G 3600 -w /your_path/%Y_%m%d_%H%M_%S.pcap &>/dev/null'])

# 星期1-5的20点01分执行kill

scheduler.add_job(system, 'cron', day_of_week="mon,tue,wed,thu,fri,sat",

hour=20, minute=1, args=['pkill -9 tcpdump &>/dev/null'])

scheduler.start()

# 星期1-5的23点59分执行自动清理7天之前的抓包文件

scheduler.add_job(system, 'cron', day_of_week="mon,tue,wed,thu,fri,sat",

hour=23, minute=59, args=['/usr/bin/find /your_path/ -type f -ctime +7 -exec rm -f {} \; &>/dev/null'])

scheduler.start()

切分抓包文件

tcpdump -r old_file -w new_files -C 10

-r 指定需要切分的文件

-w 指定新的文件名前缀

-C 指定切分的文件大小(单位:M)

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/541315.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Vue版本过渡变化

到了2.0以后&#xff0c;有哪些变化&#xff1a; 在每个组件模板&#xff0c;不在支持片段代码之前: <template id”aaa”><h3>我是组件</h3><strong>我是加粗标签</strong></template> 现在: 必须有根元素&#xff0c;包裹住所有的代码 …

NABARD的完整形式是什么?

NABARD&#xff1a;国家农业和农村发展银行 (NABARD: National Bank for Agriculture and Rural Development) NABARD is an abbreviation of National Bank for Agriculture and Rural Development. NABARD是国家农业和农村发展银行的缩写 。 On 12 July 1982, it was establ…

基于opencv+Dlib的面部合成(Face Morph)

引自&#xff1a;http://blog.csdn.net/wangxing233/article/details/51549880 零、前言 前段时间看到文章【1】和【2】&#xff0c;大概了解了面部合成的基本原理。这两天空下来了&#xff0c;于是参考【3】自己实现了下。虽然【1】和【2】已经讲的很清楚了&#xff0c;但是有…

大脑应对危机的模式_危机的完整形式是什么?

大脑应对危机的模式危机&#xff1a;印度信用评级信息服务有限公司 (CRISIL: Credit Rating Information Services of India Limited) CRISIL is an abbreviation of Credit Rating Information Services of India Limited. It is an international analytic company which off…

linux网络延迟命令,2. Linux使用ping命令查看网络延迟

ping命令持续发送少量互联网流量到远程地址并报告收到回应的总时间。如果流量因为网络故障或者错误配置而被丢弃&#xff0c;它也会报告。ping命令是最基本和初级的诊断网络问题的工具之一。ping常被用来测试网络延迟&#xff0c;但是有时ping的延迟并不是网络引起的&#xff0…

一、简单工厂模式

# public class Operation //基类{private double _numberA 0;private double _numberB 0;public double NumberA{get{ return _numberA; }set{_numberA value;}}public double NumberB{get{ return _numberB; }set{_numberB value;}}public virtual double GetResult(){d…

软件生命周期模型及其类型

A life cycle model is also known as a process model. As the name suggests, the software life cycle model (or the software process model) gives us a pictorial representation of the entire software development process. 生命周期模型也称为过程模型 。 顾名思义&…

linux查看磁盘io带宽,[Linux] 磁盘IO性能查看和优化以及iostat命令

iostat命令:%user&#xff1a;CPU处在用户模式下的时间百分比。%nice&#xff1a;CPU处在带NICE值的用户模式下的时间百分比。%system&#xff1a;CPU处在系统模式下的时间百分比。%iowait&#xff1a;CPU等待输入输出完成时间的百分比。%steal&#xff1a;管理程序维护另一个虚…

Jsoup 数据修改

2019独角兽企业重金招聘Python工程师标准>>> 1 设置属性的值 在解析一个Document之后可能想修改其中的某些属性值&#xff0c;然后再保存到磁盘或都输出到前台页面。 可以使用属性设置方法 Element.attr(String key, String value), 和 Elements.attr(String key, S…

软件静态架构 软件组件图_组件图| 软件工程

软件静态架构 软件组件图什么是组件图&#xff1f; (What is Component Diagram?) A Component Diagram breaks down the real system under development into different heights of working. Every component is reactive for the main aim in the entire system and only re…

如何卸载非linux系统分区,如何卸载Linux系统分区?卸载Linux系统分区的方法-站长资讯中心...

系统为windows xp sp2和redhat as 5双系统&#xff0c;其中linux系统后安装的在D盘&#xff0c;华彩软件站www.huacolor.com小编今天发现硬盘不够用了&#xff0c;想干掉linux分区&#xff0c;在虚拟机中用linux。就在windows的磁盘管理(命令为:diskmgmt)下删除linux分区&#…

顺序结构复习

复习一些易错知识点还有习题 目录 可能不熟悉的知识点 逻辑表达式的求解 if,else的配队 条件运算符 运算符优先级的问题 switch的使用 goto和if构成的循环 例题讲解 1 2 3 4 ​编辑 5 ​编辑 6赋值 ​编辑 7 可能不熟悉的知识点 逻辑表达式的求解 如果…

模板模式(部分方法延迟到子类实现)

项目中&#xff0c;用到了抽象类作为父类&#xff0c;有部分实现。 提供了了模板方法作为子类公共方法&#xff0c;模板方法中调用了抽象类的抽象方法和部分非抽象方法。 执行代码时&#xff0c;发现模板方法调用了抽象类的抽象方法&#xff0c;当时比较好奇&#xff0c;后来发…

ruby 集合 分组_在Ruby中找到两个集合之间的区别

ruby 集合 分组Finding differences simply means that finding elements that are uncommon between two sets as well as are only present in the first set. We can find this, with the help of a – operator. You can also consider the objective as to find the uniqu…

怎样在linux卸载java,卸载linux自带java,linux自带java

卸载linux自带java&#xff0c;linux自带java第一步&#xff1a;rpm查询java安装包名称[rootlocalhost java]# rpm -qa | grep javajava-1.7.0-openjdk-headless-1.7.0.51-2.4.5.5.el7.x86_64tzdata-java-2014b-1.el7.noarchpython-javapackages-3.4.1-5.el7.noarchjava-1.7.0-…

Swift iOS : 内存管理

Swift是自动管理内存的。这意味着&#xff0c;你不需要主动释放内存。 比如Foo内包含的Bar&#xff0c;可以随同Foo一起被释放&#xff1a; import UIKit UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate {var window : UIWindow?func application(…

python实现接口_Python | 使用类实现接口

python实现接口In this program, we are implementing the concept of Interface using class. Here, Class Shape worked as Interface. In Interface all methods must be non-implemented it must be implemented in child class unlike abstract class, where we can have …

linux lp 打印中文,Linux基础命令---lp打印文件

lplp指令用来打印文件&#xff0c;也可以修改存在的打印任务。使用该指令可以指定打印的页码、副本等。此命令的适用范围&#xff1a;RedHat、RHEL、Ubuntu、CentOS、Fedora、openSUSE、SUSE。1、语法lp [ -E ] [ -U username ] [ -c ] [ -d destination[/instance] ] [ -h…

【转载】浏览器缓存详解:expires cache-control last-modified

下面的内容展示了一个常见的 Response Headers&#xff0c;这些 Headers 要求客户端最多缓存 3600 秒&#xff0c;也给出了一个 pub1259380237;gz 的校验值。 HTTP/1.x 200 OK Transfer-Encoding: chunked Date: Sat, 28 Nov 2009 04:36:25 GMT Server: LiteSpeed Connection: …

ctype函数_PHP ctype_xdigit()函数与示例

ctype函数PHP ctype_xdigit()函数 (PHP ctype_xdigit() function) ctype_xdigit() function is a character type (CType) function in PHP, it is used to check whether a given string contains hexadecimal digits or not. ctype_xdigit()函数是PHP中的字符类型(CType)函数…