From c8d8f71e03c1a61ffcea0a1a967e007f6ca314bf Mon Sep 17 00:00:00 2001 From: evilsocket Date: Tue, 21 Jul 2015 11:16:18 +0200 Subject: [PATCH] Ensuring english localization when executing ifconfig --- lib/monkey/packetfu/utils.rb | 4 ++-- lib/shell.rb | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/monkey/packetfu/utils.rb b/lib/monkey/packetfu/utils.rb index d1a9ecd7..82a2de81 100644 --- a/lib/monkey/packetfu/utils.rb +++ b/lib/monkey/packetfu/utils.rb @@ -25,9 +25,10 @@ def self.ifconfig(iface='eth0') Logger.debug "ifconfig #{iface}" + ifconfig_data = Shell.ifconfig(iface) + case RUBY_PLATFORM when /linux/i - ifconfig_data = %x[ifconfig #{iface}] Logger.debug "Linux ifconfig #{iface}:\n#{ifconfig_data}" if ifconfig_data =~ /#{iface}/i @@ -59,7 +60,6 @@ def self.ifconfig(iface='eth0') end end # linux when /darwin/i - ifconfig_data = %x[ifconfig #{iface}] Logger.debug "OSX ifconfig #{iface}:\n#{ifconfig_data}" if ifconfig_data =~ /#{iface}/i diff --git a/lib/shell.rb b/lib/shell.rb index 9ff557ac..0784b967 100644 --- a/lib/shell.rb +++ b/lib/shell.rb @@ -16,6 +16,11 @@ def execute(command) end return r end + + def ifconfig(iface) + # ensure default en language, see https://github.com/evilsocket/bettercap/issues/6 + self.execute( "LANG=en ifconfig #{iface}" ) + end end end