How can I use RAW sockets in Ruby?

I am trying to create a raw socket using Ruby.

The problem is that there is nothing called a "raw socket", and on the other hand, the Socket class itself is not fully documented.

Does anyone have code samples for this kind of socket in Ruby or maybe some documentation for this?

By the way, I already know how to work with the TCPSocket and TCPServer classes, and what I need is, in particular, a raw socket.

+3
source share
3 answers

Google returns the following result: http://www.ruby-forum.com/topic/90408

Short version:

require 'socket'

rsock = Socket.open(Socket::PF_INET, Socket::SOCK_RAW, Socket::IPPROTO_RAW)

rsock.send(string, flags)

rsock.recv(1024)

Socket: http://www.rubycentral.com/pickaxe/lib_network.html

( , root-. . , , IPSocket)

+2

PacketFu. Metasploit.

+2

(https://rubygems.org/gems/racket). , , 2009 , metasploit.

+1

Source: https://habr.com/ru/post/1716263/


All Articles