guess_os 0.1.14 → 0.1.15

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9775402b676531ba769ce92a92584091d3626e59ce26b8e0d9eba97aff6f2035
4
- data.tar.gz: 0342af311861c841af1969419ffc06828f70a2682d35d8cc8f9d53dbb949f9fc
3
+ metadata.gz: 6be02cc5d51194fb7d36733bab782724a9b12db716a6a747202ddd0da441d3fd
4
+ data.tar.gz: e4564eb17497335e66a64e7588f98d9008e425b670ec8ce9e297c470aa4b60a2
5
5
  SHA512:
6
- metadata.gz: 3ab22ebbe3034f5935dcb4a3d8af2ed949f777445aaff617c98f645048174aee492199518057714e08ba0ec59a7b70b109d9db461554f7fe364898a36127d5d8
7
- data.tar.gz: 1d763b88e2e8ce07b411e77291fc8ce2075bfe2b862a5249441ba868897abe0e23800942ed7b9ca679812ff302cb0245ea1785c8497a317998097510ade1aa55
6
+ metadata.gz: 53e0769faa0b0e578455e42c368f01dbdede40a103791f8b1d97b620442c6431e6837013941d9f9fa8b0433ef1c144042011e85dea11fee1de9898a0f59b7120
7
+ data.tar.gz: 9fe1af03a37b1eeb214bf153a13aee616dabdf4fca9fabe70b1e0f8dcb51affc8f2335f34d4581ce6e0d2abfcefc351c6b3c796530ca68b1b386da19bd821a41
data/README.md CHANGED
@@ -16,7 +16,7 @@ It is true that nmap already performs the function of finding out the OS. We did
16
16
  1. Install Ruby on your system.
17
17
  1. `gem install --user-install guess_os`, to install gem as normal user.
18
18
 
19
- > `sudo gem install --user-install guess_os`, to install gem as root user.
19
+ > `sudo gem install guess_os`, to install gem as root user.
20
20
 
21
21
  # Usage
22
22
 
data/bin/guess_os CHANGED
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require_relative '../lib/guess_os/host'
4
+ require "debug"
4
5
 
5
6
  def get_input_options
6
7
  puts "[GuessOS]"
@@ -18,14 +19,16 @@ def get_input_options
18
19
  password = nil if password.empty?
19
20
  end
20
21
  {
21
- ip: ip,
22
- port: port,
23
- username: username,
24
- password: password
22
+ ip: ip || "localhost",
23
+ port: port || "",
24
+ username: username || "",
25
+ password: password || ""
25
26
  }
26
27
  end
27
28
 
28
29
  def try_guess_with(options)
30
+ puts "-" * 50 + "\n"
31
+ puts "[Trying]"
29
32
  host = GuessOS::Host.new(
30
33
  ip: options[:ip],
31
34
  port: options[:port],
data/lib/guess_os/conn.rb CHANGED
@@ -40,7 +40,11 @@ module GuessOS
40
40
  @status = "Exit status: #{$?.exitstatus}"
41
41
  end
42
42
 
43
- @last_output = output
43
+ @last_output = if output.nil?
44
+ ""
45
+ else
46
+ output.encode(Encoding::UTF_8, invalid: :replace)
47
+ end
44
48
  end
45
49
 
46
50
  def remote_exec(command)
@@ -77,7 +81,11 @@ module GuessOS
77
81
  @status = "[#{e.class}] SSH on <#{@host.username}@#{@host.ip}:#{@host.port}>" \
78
82
  " exec: #{command}"
79
83
  end
80
- @last_output = output
84
+ @last_output = if output.nil?
85
+ ""
86
+ else
87
+ output.encode(Encoding::UTF_8, invalid: :replace)
88
+ end
81
89
  end
82
90
  end
83
91
  end
@@ -5,7 +5,7 @@ class Cygwin
5
5
  conn.exec(command)
6
6
 
7
7
  identified = conn.ok && conn.last_output.include?("/cygdrive")
8
- return GuessOS::OS.new(:unkown, :unkown, conn.status) unless identified
8
+ return GuessOS::OS.unkown unless identified
9
9
 
10
10
  output = conn.last_output
11
11
  type = :cygwin
@@ -4,7 +4,7 @@ class GNULinux
4
4
  command = "lsb_release -d"
5
5
 
6
6
  conn.exec(command)
7
- return GuessOS::OS.new(:unkown, :unkown, conn.status) unless conn.ok
7
+ return GuessOS::OS.unkown unless conn.ok
8
8
 
9
9
  output = conn.last_output
10
10
  items = output.split
@@ -14,7 +14,7 @@ class GNULinux
14
14
 
15
15
  list = %w[debian ubuntu opensuse manjaro mint arch]
16
16
  unless list.include? name
17
- return GuessOS::OS.new(:unkown, :unkown, "Unkown OS")
17
+ return GuessOS::OS.unkown
18
18
  end
19
19
 
20
20
  GuessOS::OS.new(type, name, desc)
@@ -11,7 +11,7 @@ class MacOS
11
11
  # ProductVersion: 10.7.4
12
12
 
13
13
  identified = conn.ok && conn.last_output.include?("Mac OS")
14
- return GuessOS::OS.new(:unkown, :unkown, conn.status) unless identified
14
+ return GuessOS::OS.unkown unless identified
15
15
 
16
16
  command = "sw_vers | grep ProductVersion"
17
17
  conn.exec(command)
@@ -5,7 +5,7 @@ class Minix
5
5
  conn.exec(command)
6
6
 
7
7
  identified = conn.ok && conn.last_output.include?("MINIX")
8
- return GuessOS::OS.new(:unkown, :unkown, conn.status) unless identified
8
+ return GuessOS::OS.unkown unless identified
9
9
 
10
10
  output = conn.last_output
11
11
  type = :minix
@@ -8,8 +8,7 @@ class Windows
8
8
  os = try_with_ver(conn)
9
9
  return os unless os.type == :unkown
10
10
 
11
- os = try_with_folder(conn)
12
- return os unless os.type == :unkown
11
+ try_with_folder(conn)
13
12
  end
14
13
 
15
14
  def self.try_with_regedit(conn)
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GuessOS
4
- VERSION = "0.1.14"
4
+ VERSION = "0.1.15"
5
5
  NAME = "guess_os"
6
6
  end
data/lib/guess_os.rb CHANGED
@@ -2,7 +2,6 @@
2
2
 
3
3
  require_relative "guess_os/version"
4
4
  require_relative "guess_os/host"
5
-
6
5
  ##
7
6
  # Usage:
8
7
  #
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: guess_os
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.14
4
+ version: 0.1.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Vargas
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-02-22 00:00:00.000000000 Z
11
+ date: 2023-02-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: net-ssh