{"id":13994833,"url":"https://github.com/axsh/racket","last_synced_at":"2025-07-15T21:31:55.982Z","repository":{"id":2005817,"uuid":"2939628","full_name":"axsh/racket","owner":"axsh","description":"Ruby Raw Packet library, originally written by Jon Hart, http://spoofed.org/files/racket/doc/","archived":false,"fork":false,"pushed_at":"2012-03-19T08:52:43.000Z","size":436,"stargazers_count":18,"open_issues_count":0,"forks_count":11,"subscribers_count":19,"default_branch":"master","last_synced_at":"2024-08-10T14:17:07.608Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"d3/d3-ease","license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/axsh.png","metadata":{"files":{"readme":"README","changelog":null,"contributing":null,"funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2011-12-08T11:29:01.000Z","updated_at":"2017-02-13T20:46:06.000Z","dependencies_parsed_at":"2022-08-20T12:51:19.870Z","dependency_job_id":null,"html_url":"https://github.com/axsh/racket","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/axsh%2Fracket","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/axsh%2Fracket/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/axsh%2Fracket/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/axsh%2Fracket/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/axsh","download_url":"https://codeload.github.com/axsh/racket/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226072240,"owners_count":17569311,"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":[],"created_at":"2024-08-09T14:03:07.859Z","updated_at":"2024-11-23T17:20:15.798Z","avatar_url":"https://github.com/axsh.png","language":"Ruby","readme":"#  $Id$\n\nRacket -- Ruby Raw Packet library.  \n\nComments, concerns, bugs, money, food, libations to:\n\n  Jon Hart \u003cjhart@spoofed.org\u003e\n\nInstallation is simple:\n\n  gem install --source http://spoofed.org/files/racket/ racket\n\nIf you desire the source:\n\n  svn co http://spoofed.org/racket/svn racket     \n\nIncludes support for reading and writing most major layer 2, 3, 4 and\n5 protocols.\n\nBasic packet construction and writing is as simple (!) as walking\nthe stack:\n\n  require 'rubygems'\n  require 'racket'\n\n  include Racket\n  unless (ARGV.size == 4)\n    puts \"Usage: #{$0} \u003csrcip\u003e \u003cdstip\u003e \u003cdst_port\u003e \u003csize\u003e\"\n    exit\n  end\n\n  # create a new Racket object and pick an interface\n  n = Racket::Racket.new\n  n.iface = \"eth0\"\n\n  # skip right to layer3, layer2 will be done automatically\n  # build a new IPv4 layer, and assign src and dst ip from the command line\n  n.l3 = IPv4.new\n  n.l3.src_ip = ARGV[0]\n  n.l3.dst_ip = ARGV[1]\n  n.l3.protocol = 0x11\n\n  # tack on UDP \n  n.l4 = UDP.new\n  # randomize source port\n  n.l4.src_port = 1024 + rand(65535-1024)\n  # take destination port from the commandline\n  n.l4.dst_port = ARGV[2].to_i\n  # build a random amount of garbage for the payload\n  n.l4.payload = Misc.randstring(ARGV[3].to_i)\n\n  # fix 'er  up (checksum, length) prior to sending\n  n.l4.fix!(n.l3.src_ip, n.l3.dst_ip)\n\n  # off you go\n  f = n.sendpacket\n\n  # print out what we built\n  n.layers.compact.each do |l|\n    puts l.pretty\n  end\n  puts \"Sent #{f}\"\n\nPacket reading, done through something like Pcap, is pretty straight forward too:\n\n  require 'rubygems'\n  require 'racket'\n\n  # Get the raw capture data from somewhere.  In this case, I've hardcoded it\n  binary = \"\\x45\\x10\\x00\\x3c\\x2f\\xdf\\x40\\x00\\x40\\x06\\x89\\x17\\xc0\\xa8\\x00\\x64\\xc0\\xa8\\x00\\x01\\x99\\xb7\\x00\\x35\\x29\\x39\\x28\\x66\\x00\\x00\\x00\\x00\\xa0\\x02\\x16\\xd0\\xbc\\x04\\x00\\x00\\x02\\x04\\x05\\xb4\\x04\\x02\\x08\\x0a\\x00\\x31\\x07\\xb9\\x00\\x00\\x00\\x00\\x01\\x03\\x03\\x07\"\n  i = Racket::IPv4.new(binary)\n\n  # this will print it out all pretty like, and should show a 60 byte TCP packet from 192.168.0.100 to 192.168.0.1\n  puts i.pretty\n\n\n","funding_links":[],"categories":["Ruby"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faxsh%2Fracket","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faxsh%2Fracket","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faxsh%2Fracket/lists"}