lib/ronin/ui/cli/commands/net/proxy.rb in ronin-1.5.0 vs lib/ronin/ui/cli/commands/net/proxy.rb in ronin-1.5.1
- old
+ new
@@ -1,9 +1,9 @@
#
-# Copyright (c) 2006-2012 Hal Brodigan (postmodern.mod3 at gmail.com)
+# Copyright (c) 2006-2021 Hal Brodigan (postmodern.mod3 at gmail.com)
#
-# This file is part of Ronin.
+# This file is part of ronin.
#
# Ronin is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
@@ -12,11 +12,11 @@
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
-# along with Ronin. If not, see <http://www.gnu.org/licenses/>.
+# along with Ronin. If not, see <https://www.gnu.org/licenses/>.
#
require 'ronin/ui/cli/command'
require 'ronin/network/tcp/proxy'
require 'ronin/network/udp/proxy'
@@ -156,16 +156,26 @@
option :reset_server, :type => Set[Regexp],
:usage => '/REGEXP/ [...]',
:description => 'Server reset rules'
+ examples [
+ "ronin net:proxy --port 8080 --server google.com:80",
+ "ronin net:proxy --port 53 --server 4.2.2.1 --udp --hexdump"
+ ]
+
#
# Sets up the proxy command.
#
def setup
super
+ unless (tcp? || udp?)
+ print_error "Must specify --tcp or --udp"
+ exit -1
+ end
+
unless server?
print_error "Must specify the SERVER argument"
exit -1
end
@@ -187,11 +197,12 @@
:port => @port,
:host => @host,
:server => [@server_host, @server_port]
)
- if tcp?
+ case @proxy
+ when Network::TCP::Proxy
@proxy.on_client_connect do |client|
print_outgoing client, '[connecting]'
end
@proxy.on_client_disconnect do |client,server|
@@ -325,14 +336,12 @@
#
# @return [Network::TCP::Proxy, Network::UDP::Proxy]
# The proxy class.
#
def proxy_class
- if udp?
- Network::UDP::Proxy
- elsif tcp?
- Network::TCP::Proxy
+ if udp? then Network::UDP::Proxy
+ elsif tcp? then Network::TCP::Proxy
end
end
#
# Returns the address for the connection.
@@ -387,13 +396,11 @@
#
# @param [String] data
# The data from a message.
#
def print_data(data)
- if hexdump?
- @hexdumper.dump(data)
- else
- puts data
+ if hexdump? then @hexdumper.dump(data)
+ else puts data
end
end
end
end