{"id":13775434,"url":"https://github.com/c-bata/xpcap","last_synced_at":"2025-03-18T00:30:51.085Z","repository":{"id":76859755,"uuid":"154943531","full_name":"c-bata/xpcap","owner":"c-bata","description":"Cross-platform Packet Capture which supports Linux and macOS(BSD) in 1000 LOC without depending on libpcap.","archived":false,"fork":false,"pushed_at":"2019-06-25T15:18:44.000Z","size":31,"stargazers_count":25,"open_issues_count":4,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-02-28T05:57:51.034Z","etag":null,"topics":["bsd","linux","macos","network-programming","packet-capture","packet-sniffer"],"latest_commit_sha":null,"homepage":"https://c-bata.medium.com/how-to-write-cross-platform-packet-capture-using-raw-socket-and-bpf-bab3b614bc03","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/c-bata.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2018-10-27T08:41:25.000Z","updated_at":"2024-07-06T19:53:52.000Z","dependencies_parsed_at":"2024-01-07T01:18:21.824Z","dependency_job_id":"fed47183-f3ca-4396-8f76-dc8740f7005f","html_url":"https://github.com/c-bata/xpcap","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/c-bata%2Fxpcap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/c-bata%2Fxpcap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/c-bata%2Fxpcap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/c-bata%2Fxpcap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/c-bata","download_url":"https://codeload.github.com/c-bata/xpcap/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243893849,"owners_count":20364918,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bsd","linux","macos","network-programming","packet-capture","packet-sniffer"],"created_at":"2024-08-03T17:01:38.645Z","updated_at":"2025-03-18T00:30:50.721Z","avatar_url":"https://github.com/c-bata.png","language":"C","readme":"# XPCAP: cross(X)-platform Packet CAPture\n\nCross-platform packet capture, supports Linux, macOS(BSD) without depending on libpcap.\nSupported Protocols are ARP, IPv4, IPv6, TCP, UDP and ICMP.\n\n![xpcap](https://user-images.githubusercontent.com/5564044/47612189-e411a780-dab8-11e8-94ad-bac70e443e2e.gif)\n\nSee article: [How to write cross-platform packet capture using RAW Socket and BPF.](https://medium.com/@c_bata_/how-to-write-cross-platform-packet-capture-using-raw-socket-and-bpf-bab3b614bc03)\n\n## How to run\n\nAt first, please check your network interface devices using `ifconfig`:\n\n```\n$ ifconfig\nlo0: ...\n :\nen0: ...\n :\n```\n\nAfter that compiled xpcap via `build.sh` or `cmake` and run it:\n\n```\n$ ./build.sh\n$ ./xpcap en0 -v\ndevice = en0, verbose = 1, port = 0\n\n================================================================================\n[TCP6]\nether_header--------------------------------------------------------------------\nether_dhost = XX:XX:XX:XX:XX:XX\nether_shost = XX:XX:XX:XX:XX:XX\nether_type = 86DD(IPv6)\nip6-----------------------------------------------------------------------------\nip6_vfc = 96\nip6_flow = 2363892320\nip6_plen = 15104\n(TCP), ip6_hlim = 56\nip6_src = xxxx:xxxx:xxxx:x::xxxx:xxxx\nip6_dst = yyyy:yy:yyyy:yyyy:yyyy:yyyy:yyyy:yyyy\ntcphdr--------------------------------------------------------------------------\nsource: 47873\ndestination: 59083\nsequence number: 1148644729\nack number = 2897299570\ndata offset = 5, control flag = 24, window = 49152, checksum = 54057, urgent pointer = 0\ndata----------------------------------------------------------------------------\n00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ..something..data..\n================================================================================\n\n================================================================================\n[ARP]\nether_header--------------------------------------------------------------------\nether_dhost = XX:XX:XX:XX:XX:XX\nether_shost = XX:XX:XX:XX:XX:XX\nether_type = 806(Address resolution)\nether_arp-----------------------------------------------------------------------\narp_hrd = 1(Ethernet 10/100Mbps.), arp_pro = 2048(IP)\narp_hln = 6, arp_pln = 4, arp_op = 1(ARP request.)\narp_sha = 34:76:C5:77:5D:4C\narp_spa = 192.168.0.1\narp_tha = 00:00:00:00:00:00\narp_tpa = 192.168.0.8\n================================================================================\n\n================================================================================\n[UDP]\nether_header--------------------------------------------------------------------\nether_dhost = XX:XX:XX:XX:XX:XX\nether_shost = XX:XX:XX:XX:XX:XX\nether_type = 800(IP)\nip------------------------------------------------------------------------------\nip_v = 4, ip_hl = 5, ip_tos = 0, ip_len = 149\nip_id = 29282, ip_off = 0, 0\nip_ttl = 255, ip_p = 17(UDP), ip_sum = 42831\nip_src = yyy.yyy.yyy.yyy\nip_dst = xxx.xxx.xxx.xxx\nudphdr--------------------------------------------------------------------------\nsource = 5353, dest = 5353\nlen = 129, check = 38825\ndata----------------------------------------------------------------------------\n00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ..something..data..\n================================================================================\n```\n\nIf you are macOS user and want to test xpcap on Linux, please creating VM image from the Vagrantfile.\n\n\n## LICENSE\n\nMIT License.\n\n","funding_links":[],"categories":["\u003ca id=\"8bc2e181f74ba67ec93fd2a13d95cc0c\"\u003e\u003c/a\u003elibpcap"],"sub_categories":["\u003ca id=\"b239f12aca7aa942b45836032cbef99a\"\u003e\u003c/a\u003e转换"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fc-bata%2Fxpcap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fc-bata%2Fxpcap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fc-bata%2Fxpcap/lists"}