{"id":13775227,"url":"https://github.com/hrbrmstr/crafter","last_synced_at":"2025-03-21T12:30:54.910Z","repository":{"id":36375633,"uuid":"40680487","full_name":"hrbrmstr/crafter","owner":"hrbrmstr","description":":microscope: An R package to work with PCAPs","archived":false,"fork":false,"pushed_at":"2018-03-27T10:39:13.000Z","size":4848,"stargazers_count":35,"open_issues_count":3,"forks_count":16,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-01T06:09:52.898Z","etag":null,"topics":["packet-capture","pcap","pcap-analyzer","pcap-files","r","r-cyber","rstats"],"latest_commit_sha":null,"homepage":"","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hrbrmstr.png","metadata":{"files":{"readme":"README.Rmd","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-08-13T20:34:02.000Z","updated_at":"2025-01-31T20:46:07.000Z","dependencies_parsed_at":"2022-08-29T14:00:29.337Z","dependency_job_id":null,"html_url":"https://github.com/hrbrmstr/crafter","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/hrbrmstr%2Fcrafter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hrbrmstr%2Fcrafter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hrbrmstr%2Fcrafter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hrbrmstr%2Fcrafter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hrbrmstr","download_url":"https://codeload.github.com/hrbrmstr/crafter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244135909,"owners_count":20403798,"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":["packet-capture","pcap","pcap-analyzer","pcap-files","r","r-cyber","rstats"],"created_at":"2024-08-03T17:01:35.593Z","updated_at":"2025-03-21T12:30:54.104Z","avatar_url":"https://github.com/hrbrmstr.png","language":"R","funding_links":[],"categories":["\u003ca id=\"f13469c9891173804423be4403b2c4ff\"\u003e\u003c/a\u003epcap"],"sub_categories":["\u003ca id=\"eb49514924c3f4bf2acf6f3a4436af13\"\u003e\u003c/a\u003e未分类"],"readme":"---\noutput: rmarkdown::github_document\neditor_options: \n  chunk_output_type: console\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r, echo = FALSE}\nknitr::opts_chunk$set(collapse=TRUE, comment=\"##\", fig.retina=2, fig.path = \"README_figs/README-\", message=FALSE, warning=FALSE)\noptions(width=120)\n```\n\n    __________________________oooo__oo____________________\n    _ooooo__oo_ooo___ooooo___oo_____oo_____ooooo__oo_ooo__\n    oo___oo_ooo___o_oo___oo_ooooo__oooo___oo____o_ooo___o_\n    oo______oo______oo___oo_oo______oo____ooooooo_oo______\n    oo______oo______oo___oo_oo______oo__o_oo______oo______\n    _ooooo__oo_______oooo_o_oo_______ooo___ooooo__oo______\n    ______________________________________________________\n  \n# crafter\n\nTools to Analyze and Visualize Network Packet Capture (PCAP) Files\n\n## Description\n\nLife's too short to export to CSV/XML. There's no reason R should not be able to read binary PCAP data.\n\n[What is a PCAP?](https://en.wikipedia.org/wiki/Pcap)\n\nYou need the [crafter C++ library](https://github.com/pellegre/libcrafter) installed and their site lists the other dependencies.\n\nIf there's any hope for this to run on Windows (`libcrafter` supports Windows) it will be due to a Windows + (prbly some infosec) + `#rstats` person tagging along on this project.\n\nYou can find some sample PCAP files:\n\n- [Netresec](http://www.netresec.com/?page=PcapFiles)\n- [Wireshark](https://wiki.wireshark.org/SampleCaptures)\n\n## What's Inside The Tin?\n\nThe following functions are implemented:\n\n- `read_pcap`:\tRead in a packet capture file\n- `seq_in`:\tFind a (the first) sequence in a vector\n- `summary.crafter`:\tPrint summary info about a packet capture\n\n(The `pcap` in the functions below is the return value from a call to `read_pcap`.)\n\n- `pcap$get_layer`: return a data.frame with the indicated protocol layer from the pcap packets\n- `pcap$packet_info`: retrieve a data frame of high level packet info\n- `pcap$get_payload`: retrieve payload (if any) from a given packet number\n- `pcap$get_ips`: retrieve a list (with counts) of src/dst/all ips in the capture\n- `pcap$summary`: summary info about the capture\n\n(There are actually more but they're inside the pcap object and I just need to get them exposed. See the example below for usage.)\n\n## Installation\n\n```{r eval=FALSE}\ndevtools::install_github(\"hrbrmstr/crafter\")\n```\n\n## Usage\n\n```{r}\nlibrary(crafter)\n\n# current verison\npackageVersion(\"crafter\")\n\nlibrary(crafter)\nlibrary(dplyr)\nlibrary(ggplot2)\nlibrary(igraph)\n\n# read in the \"honeybot\" packet capture from the \"Capture the hacker 2013\"\n# competition (by Dr. David Day of Sheffield Hallam University) http://www.snaketrap.co.uk/\nhbot \u003c- read_pcap(system.file(\"pcaps/hbot.pcap\", package=\"crafter\"))\n\n# high level statistics\nsummary(hbot)\n\n# look at general packet info\nhead(hbot$packet_info(), 15)\n\n# look at the IP layer packets\nhbot_ip \u003c- hbot$get_layer(\"IP\")\n\n# have some semi-useless fun!\npairs \u003c- count(hbot_ip, src, dst, protocol_name)\n\nnodes \u003c- unique(c(pairs$src, pairs$dst))\n\ng \u003c- graph_from_data_frame(pairs, directed=TRUE, vertices=nodes)\n```\n\n```{r fig.width=10, fig.height=10}\nplot(g, layout=layout.circle, vertex.size=sqrt(degree(g)), \n     vertex.label=NA, edge.width=0.5, edge.arrow.width=0.5, edge.arrow.size=0.5)\n```\n\n```{r}\n# look at the data\nhead(hbot_ip, 10)\n\n# look at the TCP layer packets\nhead(hbot$get_layer(\"TCP\"), 5)\n\n# this is probably a bit more useful\nhbot_tcp \u003c- hbot$get_layer(\"TCP\")\n\nsrc \u003c- \"192.168.0.200\"\ndst \u003c- \"91.199.212.171\"\n\nhbot_tcp %\u003e% \n  filter((src==src \u0026 dst==dst) |\n         (src==dst | dst == src)) %\u003e% \n  select(payload) -\u003e pays\n\ncat(paste0(pays$payload[1:25], collapse=\"\\n\"))\n\n# look at the ICMP layer packets\nhead(hbot$get_layer(\"ICMP\"), 20)\n\n# see the protocol distribution\nhbot$get_layer(\"IP\") %\u003e% \n  count(protocol_name) %\u003e% \n  ggplot(aes(x=protocol_name, y=n)) + \n  geom_bar(stat=\"identity\") + \n  labs(x=NULL, title=\"Honeybot IP Protocols\") + \n  theme_bw()\n\n```\n\n## Code of Conduct\n\nPlease note that this project is released with a [Contributor Code of Conduct](CONDUCT.md). \nBy participating in this project you agree to abide by its terms.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhrbrmstr%2Fcrafter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhrbrmstr%2Fcrafter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhrbrmstr%2Fcrafter/lists"}