Sangjun 개발 블로그
    • 카테고리
    • Algorithm
    • apple
    • AWS
    • boto3
    • cron
    • crontab
    • DB
    • Django
    • Docker
    • facebook
    • fcm
    • Go
    • google
    • Gopacket
    • Gui
    • Guide
    • kakao
    • Learning
    • LeetCode
    • Linux
    • logging
    • mariaDB
    • Models
    • MSSQL
    • naver
    • NFS
    • Numpy
    • oauth
    • Opencv
    • PostgreDB
    • pytest
    • Python
    • Sniff
    • Swagger
    • Windows
    • Windows10
    • WSL
    Hero Image
    pyshark 라이브러리 사용법 (pyshark Library Guide)

    설치환경 : Windows 10, python 3.7 1. 설치 와이어샤크 프로그램에 포함된 npcap 설치 필요 https://www.wireshark.org/download.html pip install pyshark 2. 사용법 캡쳐파일 읽기 capture = pyshark.FileCapture('./test.pcapng') 실시간 패킷캡처 interface capture = pyshark.LiveCapture(interface='이더넷', bpf_filter='ether src host 11:22:33:44:55:66', use_json=True, include_raw=True) 패킷 캡처 패킷 1개 캡처하거나 10ms 경과하면 캡처 결과 반환 capture.sniff(packet_count=1, timeout=10) 패킷 10개 캡처하거나 10ms 경과하면 캡처 결과 반환 capture.sniff(packet_count=10, timeout=10) 패킷 bytes 형태로 반환 print(capture[0].get_raw_packet()) 모든 패킷을 실행하고 읽은대로 각 패킷과 함께 주어진 콜백(함수) 호출

    February 10, 2021 Read
    Hero Image
    scapy 라이브러리 사용법 (Scapy Library Guide)

    설치환경 : Windows 10 1. 설치 와이어샤크 프로그램에 포함된 npcap 설치 필요 https://www.wireshark.org/download.html pip install --pre scapy[basic] 2. Client 예제 from scapy.all import * from scapy.utils import rdpcap import datetime as dt # PCAP 파일 읽기 # could be used like this rdpcap("filename",500) fetches first 500 pkts pkts = rdpcap("./pcap/test.pcapng", -1) pkts = pkts[21:100] cnt = 0 repeat = 10 s_time = dt.datetime.now() for _ in range(repeat): for pkt in pkts: # print(f"hexdump(pkt) = {hexdump(pkt)}") # Send one or more packets at 2 layer sendp(pkt, inter=0, loop=0, count=1, iface=None) # Send one or more packets at 3 layer # send(pkt, inter=0, loop=0, count=1, iface=None) cnt += 1 print(cnt) sendp(b'', inter=0, loop=0, count=1, iface=None) time.

    February 9, 2021 Read
    바로가기
    • About
    • Recent Posts
    Contact me:
    • sangjuncha.dev@gmail.com

    Toha Theme Logo Toha
    Copyright 2020. SangjunCha all rights reserved.
    Powered by Hugo Logo