guess_os 0.1.0 → 0.1.2

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.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +33 -3
  3. data/bin/guess_os +28 -0
  4. data/lib/guess_os/conn.rb +16 -17
  5. data/lib/guess_os/host.rb +6 -7
  6. data/lib/guess_os/nmap.rb +5 -0
  7. data/lib/guess_os/os.rb +12 -4
  8. data/lib/guess_os/type/all.rb +8 -0
  9. data/lib/guess_os/type/cygwin.rb +16 -0
  10. data/lib/guess_os/type/gnulinux.rb +22 -0
  11. data/lib/guess_os/type/macos.rb +26 -0
  12. data/lib/guess_os/type/minix.rb +16 -0
  13. data/lib/guess_os/type/windows.rb +22 -0
  14. data/lib/guess_os/type.rb +9 -77
  15. data/lib/guess_os/version.rb +2 -2
  16. data/lib/guess_os.rb +13 -1
  17. metadata +19 -42
  18. data/.standard.yml +0 -3
  19. data/CHANGELOG.md +0 -5
  20. data/Gemfile +0 -12
  21. data/Gemfile.lock +0 -48
  22. data/Rakefile +0 -19
  23. data/examples/demo-1-input.rb +0 -25
  24. data/examples/demo-2-input.rb +0 -40
  25. data/examples/demo-3-staticvalues.rb +0 -9
  26. data/examples/demo-4-staticvalues.rb +0 -28
  27. data/guess_os.gemspec +0 -38
  28. data/sig/guess_os.rbs +0 -4
  29. data/vagrant/.gitignore +0 -5
  30. data/vagrant/debian/.gitignore +0 -2
  31. data/vagrant/debian/Vagrantfile +0 -23
  32. data/vagrant/manjaro/.gitignore +0 -3
  33. data/vagrant/manjaro/Vagrantfile +0 -22
  34. data/vagrant/manjaro/Vagrantfile.1mv +0 -26
  35. data/vagrant/minix/.gitignore +0 -3
  36. data/vagrant/minix/README.md +0 -6
  37. data/vagrant/minix/Vagrantfile +0 -19
  38. data/vagrant/opensuse/.gitignore +0 -4
  39. data/vagrant/opensuse/Vagrantfile +0 -25
  40. data/vagrant/opensuse.kde/.gitignore +0 -1
  41. data/vagrant/opensuse.kde/Vagrantfile +0 -20
  42. data/vagrant/ubuntu/.gitignore +0 -2
  43. data/vagrant/ubuntu/02-install-software.rb +0 -27
  44. data/vagrant/ubuntu/Vagrantfile +0 -27
  45. data/vagrant/ubuntu/install-software.rb +0 -27
  46. data/vagrant/windows10/.gitignore +0 -1
  47. data/vagrant/windows10/Vagrantfile +0 -17
  48. data/vagrant/windows10/Vagrantfile.edge +0 -19
  49. data/vagrant/windows7/.gitignore +0 -2
  50. data/vagrant/windows7/Vagrantfile +0 -21
  51. data/vagrant/winserver/.gitignore +0 -3
  52. data/vagrant/winserver/Vagrantfile +0 -19
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c3c636ee0b15fd1c68aa6a2bb4c4272979cb73c89a6886855a683854d00d38d2
4
- data.tar.gz: da8e7869effe5ce9b00c46b7b706e6328ea494fd9f670308c5c893990694441d
3
+ metadata.gz: ecf71e8df8e1b41e517f61d77069fa346500793e9db520c50a62de2f78c082f3
4
+ data.tar.gz: b72dee2f0cc724848de83c9326b67b7936041b4056f83f88d5685d2d8d8437ad
5
5
  SHA512:
6
- metadata.gz: 1a2ae103136276617761854bf15943de46e1e69727da5030393e9a26e667a93ca766ff647e946832e7c1d967fd2938be2902d86ca6ebc40bfe65e7a73f25b386
7
- data.tar.gz: 1bca1bc1cee18330ac2dcbe78dd89dc2e3c45ebdc97ee58fb34ed19c4758eeeecf53400fb2df078425f129e3eac679f97ae3b730014773bf0f70a2f248bed099
6
+ metadata.gz: 00c044925a062129d54801c5ca32a0831deaf6296ca2500e134dd8930b3a54c188f951fa601f24defe1a0da1a03c1b36176931c87136d511f13011f84c950e92
7
+ data.tar.gz: a9c003559ecf48016ae68280816bd363c65747561bee46dcaeff5600fecfabf8273fad2267dc15d7005bb48dfd2ec29dbbaad01d76dfd7ffdd735a0d68998c09
data/README.md CHANGED
@@ -6,25 +6,55 @@ Try to guess the operating system installed on the host (local or remote)
6
6
  # Documentation
7
7
 
8
8
  1. Install Ruby on your system.
9
- 1. `gem install --user-install guess_os`, to install gem.
9
+ 1. `gem install --user-install guess_os`, to install gem as normal user.
10
10
 
11
- # Usage
11
+ > `sudo gem install --user-install guess_os`, to install gem as root user.
12
+
13
+ # Usage command
14
+
15
+ # Usage gem
16
+
17
+ **localhost example**: Guess local host OS.
18
+
19
+ ```ruby
20
+ require 'guess_os'
21
+
22
+ host = GuessOS::Host.new(ip: 'localhost')
23
+
24
+ puts host.os.type
25
+ puts host.os.name
26
+ ```
27
+
28
+ **Remote host example**: Guess remote host OS. The connection is established via SSH.
12
29
 
13
30
  ```ruby
14
31
  require 'guess_os'
15
32
 
16
33
  host = GuessOS::Host.new(
17
- ip: 'localhost',
34
+ ip: '192.168.1.42',
18
35
  port: 2241,
19
36
  username: 'vagrant',
20
37
  password: 'vagrant'
21
38
  )
22
39
 
40
+ puts host.os.type
23
41
  puts host.os.name
24
42
  ```
25
43
 
26
44
  > More [examples](examples)
27
45
 
46
+ Current OS list:
47
+
48
+ | OS type | OS name |
49
+ | --------- | -------- |
50
+ | :gnulinux | opensuse, debian, ubuntu, manjaro, mint |
51
+ | :windows | windows |
52
+ | :macos | macos |
53
+ | :cygwin | cygwin |
54
+ | :minix | minix |
55
+ | :unkown | unkown |
56
+
28
57
  # Contact
29
58
 
30
59
  * **Email**: `teuton.software@protonmail.com`
60
+
data/bin/guess_os ADDED
@@ -0,0 +1,28 @@
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 host.os.to_s
data/lib/guess_os/conn.rb CHANGED
@@ -1,5 +1,4 @@
1
-
2
- require 'net/ssh'
1
+ require "net/ssh"
3
2
 
4
3
  module GuessOS
5
4
  class Conn
@@ -10,7 +9,7 @@ module GuessOS
10
9
 
11
10
  def initialize(host)
12
11
  @host = host
13
- @last_output = ''
12
+ @last_output = ""
14
13
  @status = nil
15
14
  @ok = nil
16
15
  end
@@ -27,7 +26,7 @@ module GuessOS
27
26
  output = `#{command}`
28
27
  if $?.exitstatus.zero?
29
28
  @ok = true
30
- @status = 'Ok'
29
+ @status = "Ok"
31
30
  else
32
31
  @ok = false
33
32
  @status = "Exit status: #{$?.exitstatus}"
@@ -37,16 +36,16 @@ module GuessOS
37
36
  end
38
37
 
39
38
  def remote_exec(command)
40
- output = 'Error'
39
+ output = "Error"
41
40
  begin
42
41
  session = Net::SSH.start(@host.ip,
43
- @host.username,
44
- port: @host.port,
45
- password: @host.password,
46
- keepalive: true,
47
- timeout: 30,
48
- non_interactive: true)
49
- if session.class == Net::SSH::Connection::Session
42
+ @host.username,
43
+ port: @host.port,
44
+ password: @host.password,
45
+ keepalive: true,
46
+ timeout: 30,
47
+ non_interactive: true)
48
+ if session.instance_of?(Net::SSH::Connection::Session)
50
49
  output = session.exec!(command)
51
50
  @status = :ok
52
51
  @ok = true
@@ -54,19 +53,19 @@ module GuessOS
54
53
  rescue Errno::EHOSTUNREACH
55
54
  @status = "[ERROR] Host #{@host.ip} unreachable!"
56
55
  rescue Net::SSH::AuthenticationFailed
57
- @status = '[ERROR] SSH::AuthenticationFailed!'
56
+ @status = "[ERROR] SSH::AuthenticationFailed!"
58
57
  rescue Net::SSH::HostKeyMismatch
59
- @status = 'SSH::HostKeyMismatch!'
58
+ @status = "SSH::HostKeyMismatch!"
60
59
  puts("* The destination server's fingerprint is not matching " \
61
- 'what is in your local known_hosts file.')
62
- puts('* Remove the existing entry in your local known_hosts file')
60
+ "what is in your local known_hosts file.")
61
+ puts("* Remove the existing entry in your local known_hosts file")
63
62
  puts("* Try this => ssh-keygen -f '/home/USERNAME/.ssh/known_hosts' " \
64
63
  "-R #{@host.ip}")
65
64
  rescue SocketError
66
65
  @status = "[ERROR] SocketError with IP/port [#{@host.ip}:#{@host.port}]"
67
66
  rescue Errno::ECONNREFUSED
68
67
  @status = "[ERROR] ConnRefused: SSH on [#{@host.username}@#{@host.ip}:#{@host.port}]"
69
- rescue StandardError => e
68
+ rescue => e
70
69
  @status = "[#{e.class}] SSH on <#{@host.username}@#{@host.ip}:#{@host.port}>" \
71
70
  " exec: #{command}"
72
71
  end
data/lib/guess_os/host.rb CHANGED
@@ -1,5 +1,4 @@
1
-
2
- require_relative 'type'
1
+ require_relative "type"
3
2
 
4
3
  module GuessOS
5
4
  class Host
@@ -7,15 +6,15 @@ module GuessOS
7
6
  attr_reader :os
8
7
 
9
8
  def initialize(args = {})
10
- @ip = args[:ip] || 'localhost'
11
- @port = args[:port] || '22'
12
- @username = args[:username] || 'root'
13
- @password = args[:password] || 'vagrant'
9
+ @ip = args[:ip] || "localhost"
10
+ @port = args[:port] || "22"
11
+ @username = args[:username] || "vagrant"
12
+ @password = args[:password] || "vagrant"
14
13
  @os = GuessOS::Type.guess(self)
15
14
  end
16
15
 
17
16
  def local?
18
- return true if (ip == 'localhost') || (ip == '127.0.0.1')
17
+ return true if (ip == "localhost") || (ip == "127.0.0.1")
19
18
 
20
19
  false
21
20
  end
@@ -0,0 +1,5 @@
1
+ # ❯ sudo nmap -O 192.168.1.1 | grep -E 'Running|OS'
2
+ # Running: Linux 2.6.X|3.X
3
+ # OS CPE: cpe:/o:linux:linux_kernel:2.6 cpe:/o:linux:linux_kernel:3
4
+ # OS details: Linux 2.6.32 - 3.13
5
+ # OS detection performed. Please report any incorrect results at https://nmap.org/submit/ .
data/lib/guess_os/os.rb CHANGED
@@ -1,16 +1,24 @@
1
-
2
1
  module GuessOS
3
2
  class OS
4
3
  attr_reader :type, :name, :desc
5
4
 
6
5
  def initialize(type, name, desc)
7
6
  @type = type
8
- @name = name
9
- @desc = desc
7
+ @name = name.strip
8
+ @desc = clean(desc)
10
9
  end
11
10
 
12
11
  def to_s
13
- { type: @type, name: @name, desc: @desc }
12
+ {type: @type, name: @name, desc: @desc}
13
+ end
14
+
15
+ private
16
+
17
+ def clean(text)
18
+ output = text.clone
19
+ output.tr!("\t", " ")
20
+ output.tr!("\n", " ")
21
+ output.strip
14
22
  end
15
23
  end
16
24
  end
@@ -0,0 +1,8 @@
1
+ require_relative "../conn"
2
+ require_relative "../os"
3
+
4
+ require_relative "cygwin"
5
+ require_relative "gnulinux"
6
+ require_relative "macos"
7
+ require_relative "minix"
8
+ require_relative "windows"
@@ -0,0 +1,16 @@
1
+ class Cygwin
2
+ def self.guess(host)
3
+ conn = GuessOS::Conn.new(host)
4
+ command = "pwd"
5
+ conn.exec(command)
6
+
7
+ identified = conn.ok && conn.last_output.include?("/cygdrive")
8
+ return GuessOS::OS.new(:unkown, :unkown, conn.status) unless identified
9
+
10
+ output = conn.last_output
11
+ type = :cygwin
12
+ name = "cygwin"
13
+ desc = output.delete("\n")
14
+ GuessOS::OS.new(type, name, desc)
15
+ end
16
+ end
@@ -0,0 +1,22 @@
1
+ class GNULinux
2
+ def self.guess(host)
3
+ conn = GuessOS::Conn.new(host)
4
+ command = "lsb_release -d"
5
+
6
+ conn.exec(command)
7
+ return OS.new(:unkown, :unkown, conn.status) unless conn.ok
8
+
9
+ output = conn.last_output
10
+ items = output.split
11
+ type = :gnulinux
12
+ name = items[1]&.downcase
13
+ desc = output
14
+
15
+ list = %w[debian ubuntu opensuse manjaro mint arch]
16
+ unless list.include? name
17
+ return GuessOS::OS.new(:unkown, :unkown, "Unkown OS")
18
+ end
19
+
20
+ GuessOS::OS.new(type, name, desc)
21
+ end
22
+ end
@@ -0,0 +1,26 @@
1
+ class MacOS
2
+ def self.guess(host)
3
+ conn = GuessOS::Conn.new(host)
4
+ command = "sw_vers | grep ProductName"
5
+ conn.exec(command)
6
+ # 1.9.2 kevin-macbookpro:~ $ system_profiler SPSoftwareDataType
7
+ # System Version: Mac OS X 10.7.4 (11E53)
8
+ #
9
+ # 1.9.2 kevin-macbookpro:~ $ sw_vers
10
+ # ProductName: Mac OS X
11
+ # ProductVersion: 10.7.4
12
+
13
+ identified = conn.ok && conn.last_output.include?("Mac OS")
14
+ return GuesOS::OS.new(:unkown, :unkown, conn.status) unless identified
15
+
16
+ command = "sw_vers | grep ProductVersion"
17
+ conn.exec(command)
18
+ output = conn.last_output
19
+ items = output.split
20
+
21
+ type = :macos
22
+ name = "Mac OS #{items[2].split(".").first}"
23
+ desc = output
24
+ GuessSO::OS.new(type, name, desc)
25
+ end
26
+ end
@@ -0,0 +1,16 @@
1
+ class Minix
2
+ def self.guess(host)
3
+ conn = GuessOS::Conn.new(host)
4
+ command = "cat /etc/rc.d/minixrc |grep MINIX| head -n 1"
5
+ conn.exec(command)
6
+
7
+ identified = conn.ok && conn.last_output.include?("MINIX")
8
+ return GuessOS::OS.new(:unkown, :unkown, conn.status) unless identified
9
+
10
+ output = conn.last_output
11
+ type = :minix
12
+ name = "minix"
13
+ desc = output.delete("\n")
14
+ GuessOS::OS.new(type, name, desc)
15
+ end
16
+ end
@@ -0,0 +1,22 @@
1
+ class Windows
2
+ def self.guess(host)
3
+ conn = GuessOS::Conn.new(host)
4
+ command = "ver"
5
+ conn.exec(command)
6
+ # ver => Microsoft Windows [Version 10.0.20348.469]
7
+ # command = 'echo %windir%' => Windows
8
+
9
+ identified = conn.ok && conn.last_output.include?("Windows")
10
+ return GuessOS::OS.new(:unkown, :unkown, conn.status) unless identified
11
+
12
+ output = conn.last_output
13
+ output.delete!("\r")
14
+ output.delete!("\n")
15
+ items = output.split
16
+
17
+ type = :windows
18
+ name = "windows #{items[3].split(".").first}"
19
+ desc = output
20
+ GuessOS::OS.new(type, name, desc)
21
+ end
22
+ end
data/lib/guess_os/type.rb CHANGED
@@ -1,92 +1,24 @@
1
-
2
- require_relative 'conn'
3
- require_relative 'os'
1
+ require_relative "type/all"
4
2
 
5
3
  module GuessOS
6
- module Type
4
+ class Type
7
5
  def self.guess(host)
8
- os = guess_gnulinux(host)
6
+ os = GNULinux.guess(host)
9
7
  return os unless os.type == :unkown
10
8
 
11
- os = guess_cygwin(host)
9
+ os = guess_macos(host)
12
10
  return os unless os.type == :unkown
13
11
 
14
- os = guess_windows(host)
12
+ os = Windows.guess(host)
15
13
  return os unless os.type == :unkown
16
14
 
17
- os = guess_minix(host)
15
+ os = Cygwin.guess(host)
18
16
  return os unless os.type == :unkown
19
17
 
20
- os
21
- end
22
-
23
- def self.guess_gnulinux(host)
24
- conn = GuessOS::Conn.new(host)
25
- command = 'lsb_release -d'
26
-
27
- conn.exec(command)
28
- return OS.new(:unkown, :unkown, conn.status) unless conn.ok
29
-
30
- output = conn.last_output
31
- items = output.split
32
- type = 'gnu/linux'
33
- name = items[1]&.downcase
34
- desc = output
35
-
36
- list = %w(debian ubuntu opensuse manjaro)
37
- unless list.include? name
38
- return OS.new(:unkown, :unkown, 'Unkown OS')
39
- end
40
-
41
- OS.new(type, name, desc)
42
- end
43
-
44
- def self.guess_windows(host)
45
- conn = GuessOS::Conn.new(host)
46
- command = 'echo %windir%'
47
- conn.exec(command)
48
-
49
- identified = conn.ok && conn.last_output.include?('Windows')
50
- return OS.new(:unkown, :unkown, conn.status) unless identified
51
-
52
- output = conn.last_output
53
- type = 'windows'
54
- name = 'windows'
55
- desc = output.gsub("\r", '')
56
- desc.gsub!("\n", '')
57
- OS.new(type, name, desc)
58
- end
59
-
60
- def self.guess_cygwin(host)
61
- conn = GuessOS::Conn.new(host)
62
- command = 'pwd'
63
- conn.exec(command)
64
-
65
- identified = conn.ok && conn.last_output.include?('/cygdrive')
66
- return OS.new(:unkown, :unkown, conn.status) unless identified
67
-
68
- output = conn.last_output
69
- type = 'cygwin'
70
- name = 'cygwin'
71
- desc = output.gsub("\n", '')
72
- OS.new(type, name, desc)
73
- end
74
-
75
- def self.guess_minix(host)
76
- conn = GuessOS::Conn.new(host)
77
- command = 'cat /etc/rc.d/minixrc |grep MINIX| head -n 1'
78
-
79
- conn.exec(command)
80
-
81
- identified = conn.ok && conn.last_output.include?('MINIX')
82
- return OS.new(:unkown, :unkown, conn.status) unless identified
18
+ os = Minix.guess(host)
19
+ return os unless os.type == :unkown
83
20
 
84
- output = conn.last_output
85
- items = output.split
86
- type = 'minix'
87
- name = 'minix'
88
- desc = output.gsub("\n", '')
89
- OS.new(type, name, desc)
21
+ os
90
22
  end
91
23
  end
92
24
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GuessOS
4
- VERSION = "0.1.0"
5
- NAME = 'guess_os'
4
+ VERSION = "0.1.2"
5
+ NAME = "guess_os"
6
6
  end
data/lib/guess_os.rb CHANGED
@@ -1,7 +1,19 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "guess_os/version"
4
- require_relative 'guess_os/host'
4
+ require_relative "guess_os/host"
5
+
6
+ ##
7
+ # Usage:
8
+ #
9
+ # host = GuessOS::Host.new(
10
+ # ip: ip,
11
+ # port: port,
12
+ # username: username,
13
+ # password: password
14
+ # )
15
+ #
16
+ # => host.os
5
17
 
6
18
  module GuessOS
7
19
  end
metadata CHANGED
@@ -1,67 +1,44 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: guess_os
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Vargas
8
8
  autorequire:
9
- bindir: exe
9
+ bindir: bin
10
10
  cert_chain: []
11
- date: 2022-07-05 00:00:00.000000000 Z
11
+ date: 2023-02-16 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Guess local or remote OS.
14
14
  email:
15
15
  - dvarrui@protonmail.com
16
- executables: []
16
+ executables:
17
+ - guess_os
17
18
  extensions: []
18
- extra_rdoc_files: []
19
+ extra_rdoc_files:
20
+ - README.md
21
+ - LICENSE
19
22
  files:
20
- - ".standard.yml"
21
- - CHANGELOG.md
22
- - Gemfile
23
- - Gemfile.lock
24
23
  - LICENSE
25
24
  - README.md
26
- - Rakefile
27
- - examples/demo-1-input.rb
28
- - examples/demo-2-input.rb
29
- - examples/demo-3-staticvalues.rb
30
- - examples/demo-4-staticvalues.rb
31
- - guess_os.gemspec
25
+ - bin/guess_os
32
26
  - lib/guess_os.rb
33
27
  - lib/guess_os/conn.rb
34
28
  - lib/guess_os/host.rb
29
+ - lib/guess_os/nmap.rb
35
30
  - lib/guess_os/os.rb
36
31
  - lib/guess_os/type.rb
32
+ - lib/guess_os/type/all.rb
33
+ - lib/guess_os/type/cygwin.rb
34
+ - lib/guess_os/type/gnulinux.rb
35
+ - lib/guess_os/type/macos.rb
36
+ - lib/guess_os/type/minix.rb
37
+ - lib/guess_os/type/windows.rb
37
38
  - lib/guess_os/version.rb
38
- - sig/guess_os.rbs
39
- - vagrant/.gitignore
40
- - vagrant/debian/.gitignore
41
- - vagrant/debian/Vagrantfile
42
- - vagrant/manjaro/.gitignore
43
- - vagrant/manjaro/Vagrantfile
44
- - vagrant/manjaro/Vagrantfile.1mv
45
- - vagrant/minix/.gitignore
46
- - vagrant/minix/README.md
47
- - vagrant/minix/Vagrantfile
48
- - vagrant/opensuse.kde/.gitignore
49
- - vagrant/opensuse.kde/Vagrantfile
50
- - vagrant/opensuse/.gitignore
51
- - vagrant/opensuse/Vagrantfile
52
- - vagrant/ubuntu/.gitignore
53
- - vagrant/ubuntu/02-install-software.rb
54
- - vagrant/ubuntu/Vagrantfile
55
- - vagrant/ubuntu/install-software.rb
56
- - vagrant/windows10/.gitignore
57
- - vagrant/windows10/Vagrantfile
58
- - vagrant/windows10/Vagrantfile.edge
59
- - vagrant/windows7/.gitignore
60
- - vagrant/windows7/Vagrantfile
61
- - vagrant/winserver/.gitignore
62
- - vagrant/winserver/Vagrantfile
63
39
  homepage: https://github.com/dvarrui/guess_os
64
- licenses: []
40
+ licenses:
41
+ - GPL-3.0
65
42
  metadata:
66
43
  homepage_uri: https://github.com/dvarrui/guess_os
67
44
  source_code_uri: https://github.com/dvarrui/guess_os
@@ -81,7 +58,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
81
58
  - !ruby/object:Gem::Version
82
59
  version: '0'
83
60
  requirements: []
84
- rubygems_version: 3.1.6
61
+ rubygems_version: 3.2.33
85
62
  signing_key:
86
63
  specification_version: 4
87
64
  summary: Guess local or remote OS.
data/.standard.yml DELETED
@@ -1,3 +0,0 @@
1
- # For available configuration options, see:
2
- # https://github.com/testdouble/standard
3
- ruby_version: 2.6
data/CHANGELOG.md DELETED
@@ -1,5 +0,0 @@
1
- ## [Unreleased]
2
-
3
- ## [0.1.0] - 2022-07-03
4
-
5
- - Initial release
data/Gemfile DELETED
@@ -1,12 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source "https://rubygems.org"
4
-
5
- # Specify your gem's dependencies in guess_os.gemspec
6
- gemspec
7
-
8
- # gem "test-unit", "~> 3.0"
9
-
10
- gem 'bump'
11
- gem 'rake'
12
- gem "standard"
data/Gemfile.lock DELETED
@@ -1,48 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- guess_os (0.1.0)
5
-
6
- GEM
7
- remote: https://rubygems.org/
8
- specs:
9
- ast (2.4.2)
10
- bump (0.10.0)
11
- parallel (1.22.1)
12
- parser (3.1.2.0)
13
- ast (~> 2.4.1)
14
- rainbow (3.1.1)
15
- rake (13.0.6)
16
- regexp_parser (2.5.0)
17
- rexml (3.2.5)
18
- rubocop (1.29.1)
19
- parallel (~> 1.10)
20
- parser (>= 3.1.0.0)
21
- rainbow (>= 2.2.2, < 4.0)
22
- regexp_parser (>= 1.8, < 3.0)
23
- rexml (>= 3.2.5, < 4.0)
24
- rubocop-ast (>= 1.17.0, < 2.0)
25
- ruby-progressbar (~> 1.7)
26
- unicode-display_width (>= 1.4.0, < 3.0)
27
- rubocop-ast (1.18.0)
28
- parser (>= 3.1.1.0)
29
- rubocop-performance (1.13.3)
30
- rubocop (>= 1.7.0, < 2.0)
31
- rubocop-ast (>= 0.4.0)
32
- ruby-progressbar (1.11.0)
33
- standard (1.12.1)
34
- rubocop (= 1.29.1)
35
- rubocop-performance (= 1.13.3)
36
- unicode-display_width (2.2.0)
37
-
38
- PLATFORMS
39
- x86_64-linux
40
-
41
- DEPENDENCIES
42
- bump
43
- guess_os!
44
- rake
45
- standard
46
-
47
- BUNDLED WITH
48
- 2.3.11
data/Rakefile DELETED
@@ -1,19 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "bundler/gem_tasks"
4
- require "rake/testtask"
5
-
6
- Rake::TestTask.new(:test) do |t|
7
- t.libs << "test"
8
- t.libs << "lib"
9
- t.test_files = FileList["test/**/*_test.rb"]
10
- end
11
-
12
- require "standard/rake"
13
-
14
- task default: %i[test standard]
15
- #require "bundler/setup"
16
- #require "bump/tasks"
17
-
18
- #Bundler::GemHelper.install_tasks
19
-
@@ -1,25 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require_relative '../lib/guess_os/host'
4
-
5
- puts "[GuessOS] #{$0}"
6
-
7
- print ' ip? '; ip = gets.chomp
8
- print ' port? '; port = gets.chomp
9
- print 'username? '; username = gets.chomp
10
- print 'password? '; password = gets.chomp
11
-
12
- ip = 'localhost' if ip.empty?
13
- port = nil if port.empty?
14
- username = nil if username.empty?
15
- password = nil if password.empty?
16
-
17
- host = GuessOS::Host.new(
18
- ip: ip,
19
- port: port,
20
- username: username,
21
- password: password
22
- )
23
-
24
- puts '=' * 50 + "\n"
25
- puts host.os.to_s
@@ -1,40 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require_relative '../lib/guess_os/host'
4
-
5
- puts "[GuessOS] #{$0}"
6
-
7
- print ' ip? '; ip = gets.chomp
8
- print ' port? '; port = gets.chomp
9
- print 'username? '; username = gets.chomp
10
- print 'password? '; password = gets.chomp
11
-
12
- port = nil if port.empty?
13
- username = nil if username.empty?
14
- password = nil if password.empty?
15
-
16
- host = GuessOS::Host.new(
17
- ip: ip,
18
- port: port,
19
- username: username,
20
- password: password
21
- )
22
-
23
- puts "\n"
24
- puts "==> Show host info"
25
- puts " ip = #{host.ip}"
26
- puts " port = #{host.port}"
27
- puts " username = #{host.username}"
28
- puts " password = #{host.password}"
29
-
30
- conn = GuessOS::Conn.new(host)
31
-
32
- cmd = 'lsb_release -d'
33
- puts "\n==> Execute command: #{cmd}"
34
- puts " #{conn.exec(cmd)}"
35
-
36
- puts "\n"
37
- puts "==> Show Type info (#{host.ip}:#{host.port})"
38
- puts " type = #{host.os.type}"
39
- puts " name = #{host.os.name}"
40
- puts " desc = #{host.os.desc}"
@@ -1,9 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require_relative '../lib/guess_os/host'
4
-
5
- puts "[GuessOS] #{$0}"
6
- puts '-' * 50 + "\n"
7
-
8
- host = GuessOS::Host.new(ip: 'localhost')
9
- puts host.os.to_s
@@ -1,28 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require_relative '../lib/guess_os/host'
4
- require_relative '../lib/guess_os/conn'
5
-
6
- puts "[GuessOS] #{$0}"
7
- puts '-' * 50
8
-
9
- host = GuessOS::Host.new(ip: 'localhost')
10
-
11
- puts "\n"
12
- puts "==> Show host info"
13
- puts " ip = #{host.ip}"
14
- puts " port = #{host.port}"
15
- puts " username = #{host.username}"
16
- puts " password = #{host.password}"
17
-
18
- conn = GuessOS::Conn.new(host)
19
-
20
- cmd = 'lsb_release -d'
21
- puts "\n==> Execute command: #{cmd}"
22
- puts " #{conn.exec(cmd)}"
23
-
24
- puts "\n"
25
- puts "==> Show Type info (#{host.ip}:#{host.port})"
26
- puts " type = #{host.os.type}"
27
- puts " name = #{host.os.name}"
28
- puts " desc = #{host.os.desc}"
data/guess_os.gemspec DELETED
@@ -1,38 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "lib/guess_os/version"
4
-
5
- Gem::Specification.new do |spec|
6
- spec.name = "guess_os"
7
- spec.version = GuessOS::VERSION
8
- spec.authors = ["David Vargas"]
9
- spec.email = ["dvarrui@protonmail.com"]
10
-
11
- spec.summary = "Guess local or remote OS."
12
- spec.description = "Guess local or remote OS."
13
- spec.homepage = "https://github.com/dvarrui/guess_os"
14
- spec.required_ruby_version = ">= 2.6.0"
15
-
16
- # spec.metadata["allowed_push_host"] = "TODO: Set to your gem server 'https://example.com'"
17
-
18
- spec.metadata["homepage_uri"] = spec.homepage
19
- spec.metadata["source_code_uri"] = "https://github.com/dvarrui/guess_os"
20
- spec.metadata["changelog_uri"] = "https://github.com/dvarrui/guess_os/CHANGELOG.md"
21
-
22
- # Specify which files should be added to the gem when it is released.
23
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
24
- spec.files = Dir.chdir(__dir__) do
25
- `git ls-files -z`.split("\x0").reject do |f|
26
- (f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
27
- end
28
- end
29
- spec.bindir = "exe"
30
- spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
31
- spec.require_paths = ["lib"]
32
-
33
- # Uncomment to register a new dependency of your gem
34
- # spec.add_dependency "example-gem", "~> 1.0"
35
-
36
- # For more information and examples about making a new gem, check out our
37
- # guide at: https://bundler.io/guides/creating_gem.html
38
- end
data/sig/guess_os.rbs DELETED
@@ -1,4 +0,0 @@
1
- module GuessOs
2
- VERSION: String
3
- # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
- end
data/vagrant/.gitignore DELETED
@@ -1,5 +0,0 @@
1
- .vagrant
2
- .ruby-version
3
- *.gem
4
- *.sh
5
- teuton-*
@@ -1,2 +0,0 @@
1
- .vagrant
2
- *.log
@@ -1,23 +0,0 @@
1
- # -*- mode: ruby -*-
2
- # vi: set ft=ruby :
3
-
4
- Vagrant.configure("2") do |config|
5
- config.vm.define "vagrant-debian" do |i|
6
- # Configure BOX
7
- i.vm.box = "generic/debian11"
8
-
9
- # Configure VM
10
- i.vm.hostname = "vagrant-debian"
11
- #i.vm.network "public_network", bridge: [ "eth0" ]
12
- #i.vm.network "public_network", bridge: [ "wlp6s0" ]
13
- i.vm.network :forwarded_port, guest: 22, host: 2241
14
- i.vm.synced_folder "./", "/vagrant"
15
- i.vm.provision "shell", path: 'install-software.sh'
16
-
17
- # Configure VIRTUALBOX
18
- i.vm.provider "virtualbox" do |v|
19
- v.name = 'vagrant-debian'
20
- v.memory = 2048
21
- end
22
- end
23
- end
@@ -1,3 +0,0 @@
1
- .vagrant
2
- *.log
3
- private*
@@ -1,22 +0,0 @@
1
- # -*- mode: ruby -*-
2
- # vi: set ft=ruby :
3
-
4
- Vagrant.configure("2") do |config|
5
- config.vm.define "vagrant-manjaro" do |i|
6
- i.vm.box = "marashni/manjaro64"
7
- i.vm.box_version = "0.0.1"
8
- i.vm.hostname = "vagrant-manjaro"
9
- # i.vm.network "public_network", bridge: [ "eth0" ]
10
- # i.vm.network "public_network", bridge: [ "wlan0" ]
11
- i.vm.network :forwarded_port, guest: 22, host: 2251
12
- i.vm.synced_folder "./", "/vagrant"
13
- i.vm.provision "shell", inline: <<-SHELL
14
- lsb_release -d
15
- SHELL
16
- i.vm.provider "virtualbox" do |vm|
17
- vm.name = 'vagrant-manjaro'
18
- vm.memory = 2048
19
- end
20
- end
21
- end
22
-
@@ -1,26 +0,0 @@
1
- # -*- mode: ruby -*-
2
- # vi: set ft=ruby :
3
-
4
- Vagrant.configure("2") do |config|
5
- config.vm.box = "marashni/manjaro64"
6
- config.vm.box_version = "0.0.1"
7
-
8
- config.vm.hostname = "vagrant-manjaro"
9
- config.vm.synced_folder "./", "/vagrant"
10
-
11
- config.vm.provider "virtualbox" do |vm|
12
- vm.name = 'vagrant-manjaro'
13
- vm.memory = 2048
14
- end
15
-
16
- ##
17
- # config.vm.define "mv1" do |i|
18
- # i.vm.box = "marashni/manjaro64"
19
- # ...
20
- # end
21
- #
22
- # config.vm.define "mv2" do |i|
23
- # ...
24
- # end
25
- end
26
-
@@ -1,3 +0,0 @@
1
- .vagrant
2
- private*
3
- *.log
@@ -1,6 +0,0 @@
1
-
2
- # minix3
3
-
4
- * [Instalar paquetes](https://veopinguinos.wordpress.com/2015/03/02/minix-3-ii-configuracion-y-algo-de-administracion/)
5
- * [Configurar la red](https://wiki.minix3.org/doku.php?id=usersguide:networkconfiguration)
6
- * [SSH](https://wiki.minix3.org/doku.php?id=usersguide:settingupssh)
@@ -1,19 +0,0 @@
1
- Vagrant.configure("2") do |config|
2
- config.vm.define "vagrant-minix" do |i|
3
- i.vm.box = "mcandre/minix"
4
- i.vm.box_version = "0.0.1"
5
-
6
- i.vm.hostname = "vagrant-minix"
7
- #i.vm.network "public_network", bridge: [ "eth0" ]
8
- #i.vm.network "public_network", bridge: [ "wlan0" ]
9
- i.vm.network :forwarded_port, guest: 22, host: 2252
10
- i.vm.synced_folder "./", "/vagrant"
11
- i.vm.provision "shell", inline: <<-SHELL
12
- hostname
13
- SHELL
14
- i.vm.provider "virtualbox" do |v|
15
- v.name = 'vagrant-minix'
16
- v.memory = 2048
17
- end
18
- end
19
- end
@@ -1,4 +0,0 @@
1
- .vagrant
2
- *.log
3
- *.box
4
- private*
@@ -1,25 +0,0 @@
1
- # -*- mode: ruby -*-
2
- # vi: set ft=ruby :
3
-
4
- Vagrant.configure("2") do |config|
5
- config.vm.define "vagrant-opensuse" do |i|
6
- # Configure BOX
7
- i.vm.box = "generic/opensuse15"
8
-
9
- # Configure VM
10
- i.vm.hostname = "vagrant-opensuse"
11
- # i.vm.network "public_network", bridge: [ "eth0" ]
12
- # i.vm.network "public_network", bridge: [ "wlan0" ]
13
- i.vm.network :forwarded_port, guest: 22, host: 2222
14
- i.vm.network :forwarded_port, guest: 22, host: 2231
15
- i.vm.synced_folder "./", "/vagrant"
16
- i.vm.provision "shell", path: 'install-software.sh'
17
-
18
- # Configure VIRTUALBOX
19
- i.vm.provider "virtualbox" do |v|
20
- v.name = 'vagrant-opensuse'
21
- v.memory = 2048
22
- end
23
- end
24
- end
25
-
@@ -1 +0,0 @@
1
- .vagrant
@@ -1,20 +0,0 @@
1
- # -*- mode: ruby -*-
2
- # vi: set ft=ruby :
3
-
4
- Vagrant.configure("2") do |config|
5
- config.vm.define "opensuse-kde" do |i|
6
- i.vm.box = "microlinux/opensuse-15.3-kde"
7
- i.vm.hostname = "kde42"
8
- #i.vm.network "public_network", bridge: [ "eth1" ]
9
- i.vm.network :forwarded_port, guest: 22, host: 2232
10
- i.vm.synced_folder "./", "/vagrant"
11
- i.vm.provision "shell", inline: <<-SHELL
12
- zypper refresh
13
- zypper in -y vim tree nmap
14
- SHELL
15
- i.vm.provider "virtualbox" do |v|
16
- v.name = 'opensuse-kde'
17
- v.memory = 2048
18
- end
19
- end
20
- end
@@ -1,2 +0,0 @@
1
- .vagrant
2
- *.log
@@ -1,27 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- text = <<-TEXT
4
- apt install -y vim tree nmap
5
- apt install -y git
6
- apt install -y figlet
7
-
8
- figlet ubuntu > /etc/motd
9
- echo "" >> /etc/motd
10
- echo "David Vargas Ruiz" >> /etc/motd
11
- echo "https://github.com/dvarrui" >> /etc/motd
12
-
13
- echo "# Adding more alias" >> /home/vagrant/.bashrc
14
- echo "alias c='clear'" >> /home/vagrant/.bashrc
15
- echo "alias v='vdir'" >> /home/vagrant/.bashrc
16
-
17
- lsb_release -d
18
- TEXT
19
-
20
- lines = text.split("\n")
21
- total = lines.size
22
- lines.each_with_index do |line, index|
23
- print "=" * 10
24
- print " [ INFO ] Step #{index + 1}/#{total}"
25
- puts "=" * 10
26
- system(line)
27
- end
@@ -1,27 +0,0 @@
1
- # -*- mode: ruby -*-
2
- # vi: set ft=ruby :
3
-
4
- HOSTNAME = "vagrant-ubuntu"
5
- Vagrant.configure("2") do |config|
6
- config.vm.define HOSTNAME do |i|
7
- # Configure box
8
- i.vm.box = "ubuntu/focal64"
9
-
10
- # Configure VM
11
- i.vm.hostname = HOSTNAME
12
- # i.vm.network "public_network", bridge: [ "eth0" ]
13
- # i.vm.network "public_network", bridge: [ "wlan0" ]
14
- i.vm.network :forwarded_port, guest: 22, host: 2242
15
- i.vm.synced_folder "./", "/vagrant"
16
- # i.vm.provision "shell", path: 'install-software.sh'
17
- i.vm.provision "shell", inline: "apt-get update"
18
- i.vm.provision "shell", inline: "apt-get install -y ruby"
19
- i.vm.provision "shell", path: "install-software.rb"
20
-
21
- # Configure provider
22
- i.vm.provider "virtualbox" do |v|
23
- v.name = HOSTNAME
24
- v.memory = 2048
25
- end
26
- end
27
- end
@@ -1,27 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- text = <<-TEXT
4
- apt install -y vim tree nmap
5
- apt install -y git
6
- apt install -y figlet
7
-
8
- figlet ubuntu > /etc/motd
9
- echo "" >> /etc/motd
10
- echo "David Vargas Ruiz" >> /etc/motd
11
- echo "https://github.com/dvarrui" >> /etc/motd
12
-
13
- echo "# Adding more alias" >> /home/vagrant/.bashrc
14
- echo "alias c='clear'" >> /home/vagrant/.bashrc
15
- echo "alias v='vdir'" >> /home/vagrant/.bashrc
16
-
17
- lsb_release -d
18
- TEXT
19
-
20
- lines = text.split("\n")
21
- total = lines.size
22
- lines.each_with_index do |line, index|
23
- print "=" * 10
24
- print " [ INFO ] Step #{index + 1}/#{total}"
25
- puts "=" * 10
26
- system(line)
27
- end
@@ -1 +0,0 @@
1
- .vagrant
@@ -1,17 +0,0 @@
1
- # -*- mode: ruby -*-
2
- # vi: set ft=ruby :
3
-
4
- Vagrant.configure("2") do |config|
5
- config.vm.define "vagrant-windows10" do |i|
6
- i.vm.box = "senglin/win-10-enterprise-vs2015community"
7
- i.vm.box_version = "1.0.0"
8
- i.vm.hostname = "vagrant-windows10"
9
- # i.vm.network "public_network", bridge: [ "eth0" ]
10
- i.vm.network :forwarded_port, guest: 22, host: 2211
11
- i.vm.synced_folder "./", "/vagrant"
12
- i.vm.provider "virtualbox" do |v|
13
- v.name = "vagrant-windows10"
14
- v.memory = 2048
15
- end
16
- end
17
- end
@@ -1,19 +0,0 @@
1
- # -*- mode: ruby -*-
2
- # vi: set ft=ruby :
3
-
4
- Vagrant.configure("2") do |config|
5
- config.vm.define "windows10" do |i|
6
- i.vm.box = "Microsoft/EdgeOnWindows10"
7
- i.vm.box_version = "1.0"
8
- i.vm.hostname = "profesor42w10"
9
- i.vm.network "public_network", bridge: [ "eth0" ]
10
- i.vm.network :forwarded_port, guest: 80, host: 8081
11
- i.vm.provider "virtualbox" do |v|
12
- v.name = "windows10-edge"
13
- v.memory = 2048
14
- end
15
-
16
- i.ssh.username = "IEUser"
17
- i.ssh.password = "Passw0rd"
18
- end
19
- end
@@ -1,2 +0,0 @@
1
- .vagrant
2
- private*
@@ -1,21 +0,0 @@
1
- # -*- mode: ruby -*-
2
- # vi: set ft=ruby :
3
-
4
- HOSTNAME = "vagrant-windows7"
5
-
6
- Vagrant.configure("2") do |config|
7
- config.vm.define HOSTNAME do |i|
8
- i.vm.box = "gusztavvargadr/windows-server"
9
- i.vm.hostname = HOSTNAME
10
- # i.vm.network "public_network", bridge: [ "eth0" ]
11
- i.vm.network "public_network", bridge: ["wlan0"]
12
- # i.vm.network :forwarded_port, guest: 22, host: 1122
13
- i.vm.synced_folder "./", "/vagrant"
14
- # i.ssh.username = "IEUser"
15
- # i.ssh.password = "Passw0rd"
16
- i.vm.provider "virtualbox" do |v|
17
- v.name = HOSTNAME
18
- v.memory = 2048
19
- end
20
- end
21
- end
@@ -1,3 +0,0 @@
1
- .vagrant
2
- *.log
3
- private*
@@ -1,19 +0,0 @@
1
- # -*- mode: ruby -*-
2
- # vi: set ft=ruby :
3
-
4
- Vagrant.configure("2") do |config|
5
- config.vm.define "vagrant-winserver" do |i|
6
- i.vm.box = "gusztavvargadr/windows-server"
7
- i.vm.hostname = "vagrant-winserver"
8
- # i.vm.network "public_network", bridge: [ "eth0" ]
9
- # i.vm.network "public_network", bridge: [ "wlan0" ]
10
- i.vm.network :forwarded_port, guest: 22, host: 2221
11
- i.vm.synced_folder "./", "/vagrant"
12
- # i.ssh.username = "IEUser"
13
- # i.ssh.password = "Passw0rd"
14
- i.vm.provider "virtualbox" do |v|
15
- v.name = "vagrant-winserver"
16
- v.memory = 2048
17
- end
18
- end
19
- end