guess_os 0.1.13 → 0.1.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/bin/guess_os +7 -4
- data/lib/guess_os/conn.rb +10 -2
- data/lib/guess_os/type/cygwin.rb +1 -1
- data/lib/guess_os/type/gnulinux.rb +2 -2
- data/lib/guess_os/type/macos.rb +1 -1
- data/lib/guess_os/type/minix.rb +1 -1
- data/lib/guess_os/type/windows.rb +2 -3
- data/lib/guess_os/version.rb +1 -1
- data/lib/guess_os.rb +0 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6be02cc5d51194fb7d36733bab782724a9b12db716a6a747202ddd0da441d3fd
|
4
|
+
data.tar.gz: e4564eb17497335e66a64e7588f98d9008e425b670ec8ce9e297c470aa4b60a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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
|
data/lib/guess_os/type/cygwin.rb
CHANGED
@@ -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.
|
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.
|
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.
|
17
|
+
return GuessOS::OS.unkown
|
18
18
|
end
|
19
19
|
|
20
20
|
GuessOS::OS.new(type, name, desc)
|
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 GuessOS::OS.
|
14
|
+
return GuessOS::OS.unkown unless identified
|
15
15
|
|
16
16
|
command = "sw_vers | grep ProductVersion"
|
17
17
|
conn.exec(command)
|
data/lib/guess_os/type/minix.rb
CHANGED
@@ -8,12 +8,11 @@ class Windows
|
|
8
8
|
os = try_with_ver(conn)
|
9
9
|
return os unless os.type == :unkown
|
10
10
|
|
11
|
-
|
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 =
|
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")
|
data/lib/guess_os/version.rb
CHANGED
data/lib/guess_os.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.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-
|
11
|
+
date: 2023-02-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: net-ssh
|