guess_os 0.1.9 → 0.1.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +17 -2
- data/bin/guess-os +1 -0
- data/bin/guess_os +35 -21
- data/lib/guess_os/type/macos.rb +2 -2
- data/lib/guess_os/type/windows.rb +6 -2
- data/lib/guess_os/type.rb +3 -3
- data/lib/guess_os/version.rb +1 -1
- metadata +4 -3
- data/bin/guess-os +0 -30
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 89004a256626a3a6a8275aa5caf484caf1463a1c3c1bdb1c32f64f52fdabdd4a
|
4
|
+
data.tar.gz: d2c9becce5271e407a582079de1b00d9da5a93fc8c6d7bd6292f989c918e511c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
❯
|
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
|
-
|
5
|
+
def get_input_options
|
6
|
+
puts "[GuessOS]"
|
6
7
|
|
7
|
-
print ' ip? '; ip = gets.chomp
|
8
|
-
if ip.empty?
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
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
|
-
|
16
|
-
|
17
|
-
|
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
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
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 "
|
29
|
-
puts "
|
30
|
-
puts "
|
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
|
data/lib/guess_os/type/macos.rb
CHANGED
@@ -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
|
14
|
+
return GuessOS::OS.new(:unkown, :unkown, conn.status) unless identified
|
15
15
|
|
16
16
|
command = "sw_vers | grep ProductVersion"
|
17
17
|
conn.exec(command)
|
@@ -21,6 +21,6 @@ class MacOS
|
|
21
21
|
type = :macos
|
22
22
|
name = "Mac OS #{items[2].split(".").first}"
|
23
23
|
desc = output
|
24
|
-
|
24
|
+
GuessOS::OS.new(type, name, desc)
|
25
25
|
end
|
26
26
|
end
|
@@ -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
|
-
|
14
|
-
|
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 =
|
6
|
+
os = Windows.guess(host)
|
7
7
|
return os unless os.type == :unkown
|
8
8
|
|
9
|
-
os =
|
9
|
+
os = GNULinux.guess(host)
|
10
10
|
return os unless os.type == :unkown
|
11
11
|
|
12
|
-
os =
|
12
|
+
os = MacOS.guess(host)
|
13
13
|
return os unless os.type == :unkown
|
14
14
|
|
15
15
|
os = Cygwin.guess(host)
|
data/lib/guess_os/version.rb
CHANGED
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.
|
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-
|
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:
|
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}"
|