guess_os 0.1.10 → 0.1.11

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: ba356d23160fed5e9c5140051e7730c5809d009c652abd46853602860f4ea95b
4
- data.tar.gz: 40cfd67eab46e8b660674485f376cef975bdc8c8750340250c08082d749d02e2
3
+ metadata.gz: 89004a256626a3a6a8275aa5caf484caf1463a1c3c1bdb1c32f64f52fdabdd4a
4
+ data.tar.gz: d2c9becce5271e407a582079de1b00d9da5a93fc8c6d7bd6292f989c918e511c
5
5
  SHA512:
6
- metadata.gz: ae9c0fdebc54324cc87354185cacd60c80e031c0e6a6a39600787b876736dfc17d4901c57711f0814133d571ce04309ddfa1363e9c7b230ee9ebeb870372c92f
7
- data.tar.gz: 0d781a88af5f58df23274f325fc1a61da06752bb6ec847e3607b5f65883aa58b7bc3092e59f699286c991792d7198964a83084b342262a08644665cf5e851888
6
+ metadata.gz: 0e5322b66cc4582261c064d9f3c2a1e1b0fbc4b91da37dc64274526df7f283ab7f15634021eb1aba49533127788d55efa8645723a0ca45c8025f0c3666854e52
7
+ data.tar.gz: 12cae8e6292a805ec368e0ccda51284d35072693166ba0da65088c9156f42925ec4f3050b1d68426a2bc31a7df767a5ed125ad7b2774ee37be4f7cefde0ab6fa
data/README.md CHANGED
@@ -1,7 +1,15 @@
1
1
 
2
2
  # GuessOS
3
3
 
4
- Try to guess the operating system installed on the host (local or remote)
4
+ Try to guess the operating system installed on the host (local or remote). Using SSH to connect remote host.
5
+
6
+ **But, What about nmap?**
7
+
8
+ It is true that nmap already performs the function of finding out the OS. We didn't want to repeat the work of nmap. The idea of the gem is:
9
+
10
+ * Work without nmap installed. Its posible some host have not installed.
11
+ * nmap is fine but slow to return results. We wanted to integrate this functionality into another application and were not completely satisfied with the nmap response times.
12
+ * In an extension of this gem we are thinking that it will use of nmap to obtain the results when it is a remote machine and we do not have SSH access to it.
5
13
 
6
14
  # Documentation
7
15
 
@@ -12,10 +20,17 @@ Try to guess the operating system installed on the host (local or remote)
12
20
 
13
21
  # Usage
14
22
 
23
+ > **WARNING**
24
+ >
25
+ > **guess_os** accepts several parameters (ip, username, password) to open an SSH connection to the remote host, and guess remote OS.
26
+ >
27
+ > In the case of writing IP="localhost" SSH is not used.
28
+
15
29
  ## Command
16
30
 
17
31
  ```console
18
- ./bin/guess_os
32
+ ❯ guess_os
33
+
19
34
  [GuessOS]
20
35
  ip? localhost
21
36
  port?
data/bin/guess-os ADDED
@@ -0,0 +1 @@
1
+ guess_os
data/bin/guess_os CHANGED
@@ -2,29 +2,43 @@
2
2
 
3
3
  require_relative '../lib/guess_os/host'
4
4
 
5
- puts "[GuessOS]"
5
+ def get_input_options
6
+ puts "[GuessOS]"
6
7
 
7
- print ' ip? '; ip = gets.chomp
8
- if ip.empty?
9
- ip = 'localhost' if ip.empty?
10
- else
11
- print ' port? '; port = gets.chomp
12
- print 'username? '; username = gets.chomp
13
- print 'password? '; password = gets.chomp
8
+ print ' ip? '; ip = gets.chomp
9
+ if ip.empty?
10
+ ip = "localhost"
11
+ elsif ip != "localhost"
12
+ print ' port? '; port = gets.chomp
13
+ print 'username? '; username = gets.chomp
14
+ print 'password? '; password = gets.chomp
14
15
 
15
- port = nil if port.empty?
16
- username = nil if username.empty?
17
- password = nil if password.empty?
16
+ port = nil if port.empty?
17
+ username = nil if username.empty?
18
+ password = nil if password.empty?
19
+ end
20
+ {
21
+ ip: ip,
22
+ port: port,
23
+ username: username,
24
+ password: password
25
+ }
18
26
  end
19
27
 
20
- host = GuessOS::Host.new(
21
- ip: ip,
22
- port: port,
23
- username: username,
24
- password: password
25
- )
28
+ def try_guess_with(options)
29
+ host = GuessOS::Host.new(
30
+ ip: options[:ip],
31
+ port: options[:port],
32
+ username: options[:username],
33
+ password: options[:password]
34
+ )
26
35
 
27
- puts "-" * 50 + "\n"
28
- puts " Type: #{host.os.type}"
29
- puts " Name: #{host.os.name}"
30
- puts " Desc: #{host.os.desc}"
36
+ puts "-" * 50 + "\n"
37
+ puts "[Results]"
38
+ puts " Type: #{host.os.type}"
39
+ puts " Name: #{host.os.name}"
40
+ puts " Desc: #{host.os.desc}"
41
+ end
42
+
43
+ options = get_input_options
44
+ try_guess_with options
@@ -10,8 +10,12 @@ class Windows
10
10
  return GuessOS::OS.new(:unkown, :unkown, conn.status) unless identified
11
11
 
12
12
  output = conn.last_output
13
- output.delete!("\r")
14
- output.delete!("\n")
13
+ begin
14
+ output.tr!("\r", ".")
15
+ output.tr!("\n", ".")
16
+ rescue
17
+ # nothing
18
+ end
15
19
  items = output.split
16
20
 
17
21
  type = :windows
data/lib/guess_os/type.rb CHANGED
@@ -3,13 +3,13 @@ require_relative "type/all"
3
3
  module GuessOS
4
4
  class Type
5
5
  def self.guess(host)
6
- os = GNULinux.guess(host)
6
+ os = Windows.guess(host)
7
7
  return os unless os.type == :unkown
8
8
 
9
- os = MacOS.guess(host)
9
+ os = GNULinux.guess(host)
10
10
  return os unless os.type == :unkown
11
11
 
12
- os = Windows.guess(host)
12
+ os = MacOS.guess(host)
13
13
  return os unless os.type == :unkown
14
14
 
15
15
  os = Cygwin.guess(host)
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GuessOS
4
- VERSION = "0.1.10"
4
+ VERSION = "0.1.11"
5
5
  NAME = "guess_os"
6
6
  end
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.10
4
+ version: 0.1.11
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-16 00:00:00.000000000 Z
11
+ date: 2023-02-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: net-ssh
@@ -24,7 +24,8 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '7.0'
27
- description: Guess local or remote OS.
27
+ description: Try to guess the operating system installed on the host (local or remote).
28
+ Using SSH to connect remote host.
28
29
  email:
29
30
  - dvarrui@protonmail.com
30
31
  executables:
data/bin/guess-os DELETED
@@ -1,30 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require_relative '../lib/guess_os/host'
4
-
5
- puts "[GuessOS]"
6
-
7
- print ' ip? '; ip = gets.chomp
8
- if ip.empty?
9
- ip = 'localhost' if ip.empty?
10
- else
11
- print ' port? '; port = gets.chomp
12
- print 'username? '; username = gets.chomp
13
- print 'password? '; password = gets.chomp
14
-
15
- port = nil if port.empty?
16
- username = nil if username.empty?
17
- password = nil if password.empty?
18
- end
19
-
20
- host = GuessOS::Host.new(
21
- ip: ip,
22
- port: port,
23
- username: username,
24
- password: password
25
- )
26
-
27
- puts "-" * 50 + "\n"
28
- puts " Type: #{host.os.type}"
29
- puts " Name: #{host.os.name}"
30
- puts " Desc: #{host.os.desc}"