guess_os 0.1.13 → 0.1.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2b22f8e27dbc05559cfd46b8d99bc5247a4e3db4f2216e6925c78361cf6aeca2
4
- data.tar.gz: 2f1a170576c87b283f38492279116c86e07ee7eb2011951042b3756598f2d88a
3
+ metadata.gz: 6be02cc5d51194fb7d36733bab782724a9b12db716a6a747202ddd0da441d3fd
4
+ data.tar.gz: e4564eb17497335e66a64e7588f98d9008e425b670ec8ce9e297c470aa4b60a2
5
5
  SHA512:
6
- metadata.gz: 701d63535c518e4adfeee98a296f27b515b524020c38ed389fd838f9f97e6c0f9685c3b43dfd549611bf0626323630a3f44a20c6328b225d0bda99b90f6de26c
7
- data.tar.gz: a5ba332a3b390040baa3705c7b4d3c73f9f0563eedc4b7834658b797afc6276cf8dea3f8bf0559ad0463688eeee9c826bed51c71da9b9d99771685c2bc030184
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,12 +8,11 @@ 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)
16
- command = 'run "reg query \"HKLM\\Software\\Microsoft\\Windows NT\\CurrentVersion\" /t REG_SZ'
15
+ command = "reg query \"HKLM\\Software\\Microsoft\\Windows NT\\CurrentVersion\" /t REG_SZ"
17
16
  conn.exec(command)
18
17
 
19
18
  identified = conn.ok && conn.last_output.include?("Windows")
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GuessOS
4
- VERSION = "0.1.13"
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.13
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