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.pswp.cn/news/541315.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/541315.shtml
英文地址,請注明出處:http://en.pswp.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)函數…