Module: Ermir
- Includes:
- TransportConstants, Utils
- Defined in:
- lib/ermir.rb,
lib/ermir/utils.rb,
lib/ermir/errors.rb,
lib/ermir/version.rb,
lib/ermir/argv_parser.rb,
lib/ermir/evil_registry.rb,
lib/ermir/gadget_marshaller.rb,
lib/ermir/transport_constants.rb
Defined Under Namespace
Modules: ArgvParser, Errors, GadgetMarshaller, TransportConstants, Utils Classes: EvilRegistry
Constant Summary collapse
- VERSION =
"0.1.2"
Constants included from TransportConstants
TransportConstants::CALL, TransportConstants::DGC_ACK, TransportConstants::EXCEPTIONAL_RETURN, TransportConstants::INTERFACE_SKEL_HASH, TransportConstants::INTERFACE_STUB_HASH, TransportConstants::MAGIC, TransportConstants::MULTIPLEX_PROTOCOL, TransportConstants::NORMAL_RETURN, TransportConstants::OBJECT_STREAM_MAGIC, TransportConstants::OPS, TransportConstants::PING, TransportConstants::PING_ACK, TransportConstants::PROTOCOL_ACK, TransportConstants::PROTOCOL_NACK, TransportConstants::RETURN, TransportConstants::SC_BLOCK_DATA, TransportConstants::SC_ENUM, TransportConstants::SC_EXTERNALIZABLE, TransportConstants::SC_SERIALIZABLE, TransportConstants::SC_WRITE_METHOD, TransportConstants::SINGLE_OP_PROTOCOL, TransportConstants::STREAM_PROTOCOL, TransportConstants::TC_ARRAY, TransportConstants::TC_BLOCKDATA, TransportConstants::TC_BLOCKDATALONG, TransportConstants::TC_CLASS, TransportConstants::TC_CLASSDESC, TransportConstants::TC_ENDBLOCKDATA, TransportConstants::TC_EXCEPTION, TransportConstants::TC_LONGSTRING, TransportConstants::TC_NULL, TransportConstants::TC_OBJECT, TransportConstants::TC_PROXYCLASSDESC, TransportConstants::TC_REFERENCE, TransportConstants::TC_RESET, TransportConstants::TC_STRING
Class Method Summary collapse
Methods included from Utils
error_and_abort!, print_rmi_transport_msg, print_time_msg, stream_header_valid?
Class Method Details
.run ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/ermir.rb', line 13 def self.run host, port, gadget = ArgvParser.parse_argv! begin server = TCPServer.new(host, port) Utils.print_time_msg("Ermir started listening for RMI calls at #{server.addr[-1]}:#{server.addr[1]}.", :light_yellow) loop do Thread.fork(server.accept) do |socket| peer = [socket.peeraddr[-1], socket.peeraddr[1]] Utils.print_time_msg("connection received from #{peer[0]}:#{peer[1]}.") begin registry = EvilRegistry.new(socket, gadget) registry.handle_connection! registry.close_connection! rescue SystemCallError => e Utils.error_and_abort!(e.to_s, "RMI Registry") end Utils.print_time_msg("closed the connection to #{peer[0]}:#{peer[1]}.") end end rescue SystemCallError => e if Errno.const_defined?(e.class.to_s.split("::").last || e.class.name) Utils.error_and_abort!(e.to_s, "TCP Server Binding") else Utils.error_and_abort!("something went wrong.", "TCP Server Binding", e.to_s) end end end |