miko 0.0.3 → 0.0.4
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 +4 -4
- data/README.md +8 -6
- data/bin/miko +45 -19
- data/lib/miko/version.rb +1 -1
- data/lib/miko.rb +193 -208
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5c505ce9bb9e9dfbfb265dada89ff4b1f6bb606a
|
4
|
+
data.tar.gz: a52570ad304b1e4bf6153629a1fae11ea7f32759
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dd195c05462e324c690fc37fd4af164c8c776c259e9a97bfd592096be7e08234b8acf6c03b7b0e6c91b43c2259bebb3f43d0f92773000d64d2d0cc635eaad2c8
|
7
|
+
data.tar.gz: 529f50254dfc9df9e53415b752119f353789e3b0e923b8ef5f6b27ba2e3823990b1c4e18a8a7ab5dc63d4c6623e64b27c39218e6b30efddfe207796d9fe7c5fe
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
# Miko
|
1
|
+
# Miko 0.0.4
|
2
2
|
|
3
|
-
Search for script installations under a
|
3
|
+
Search for script installations versions under a account.
|
4
4
|
|
5
5
|
Supported scripts ( so far ):
|
6
6
|
- Wordpress
|
@@ -11,14 +11,16 @@ Supported scripts ( so far ):
|
|
11
11
|
- SMF Forum
|
12
12
|
- MyBB
|
13
13
|
- Moodle
|
14
|
-
- Prestashop
|
15
14
|
|
16
15
|
## Installation
|
17
|
-
|
18
|
-
gem install miko
|
16
|
+
`` gem install miko ``
|
19
17
|
|
20
18
|
## Usage
|
21
|
-
|
19
|
+
You can try to scan for the user accoutn using the "-u"/"--user" flag which translates to /home/USER/ or use "-d"/"--directory" flag to specify an exact directoy you want to scan.
|
20
|
+
Usage: miko [OPTIONS]
|
21
|
+
-u, --user USER Username - translates into /home/USER/
|
22
|
+
-d, --directory DIRECTORY Specify directory instead username
|
23
|
+
-h, --help Display Help
|
22
24
|
|
23
25
|
## Contributing
|
24
26
|
|
data/bin/miko
CHANGED
@@ -1,26 +1,52 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
$LOAD_PATH << File.join(File.dirname(__FILE__), '../lib')
|
4
|
-
require
|
5
|
-
require
|
4
|
+
require 'find'
|
5
|
+
require 'fileutils'
|
6
6
|
require 'miko'
|
7
|
+
require 'optparse'
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
end
|
9
|
+
options = {}
|
10
|
+
optparse = OptionParser.new do |opts|
|
11
|
+
opts.banner = "Usage: miko [OPTIONS]"
|
12
|
+
|
13
|
+
opts.on( "-u user", "--user USER", "Username - translates into /home/USER/") do |user|
|
14
|
+
options[:user] = user
|
15
|
+
end
|
16
|
+
|
17
|
+
opts.on( "-d dir", "--directory DIRECTORY", "Specify directory instead username") do |dir|
|
18
|
+
options[:directory] = dir
|
19
|
+
end
|
20
|
+
|
21
|
+
opts.on( "-h", "--help", "Display Help") do
|
22
|
+
puts opts
|
23
|
+
exit
|
24
|
+
end
|
25
25
|
end
|
26
26
|
|
27
|
+
|
28
|
+
begin
|
29
|
+
optparse.parse!
|
30
|
+
if options[:user].nil? and options[:directory].nil?
|
31
|
+
puts optparse
|
32
|
+
exit
|
33
|
+
end
|
34
|
+
|
35
|
+
c = Miko.new( options )
|
36
|
+
|
37
|
+
begin
|
38
|
+
c.run
|
39
|
+
if c.found.empty?
|
40
|
+
puts "No scripts detected"
|
41
|
+
else
|
42
|
+
puts "Scrips detected"
|
43
|
+
c.found.sort.each{ | script| puts script }
|
44
|
+
end
|
45
|
+
rescue Exception => e
|
46
|
+
puts e
|
47
|
+
end
|
48
|
+
rescue OptionParser::InvalidOption, OptionParser::MissingArgument
|
49
|
+
puts $!.to_s
|
50
|
+
puts optparse
|
51
|
+
exit
|
52
|
+
end
|
data/lib/miko/version.rb
CHANGED
data/lib/miko.rb
CHANGED
@@ -1,211 +1,196 @@
|
|
1
1
|
|
2
2
|
class Miko
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
acct_home = ""
|
197
|
-
script = ""
|
198
|
-
version = ""
|
199
|
-
|
200
|
-
File.open(@path, "r").each_line do |line|
|
201
|
-
if ( line["$release "] )
|
202
|
-
version = line.split("=")[1].gsub("'", "").split(";")[0]
|
203
|
-
acct_home = path.gsub("version.php", "")
|
204
|
-
script = "Moodle"
|
205
|
-
end
|
206
|
-
|
207
|
-
end
|
208
|
-
|
209
|
-
output( acct_home, version, script)
|
210
|
-
end
|
3
|
+
attr_accessor :user
|
4
|
+
attr_accessor :directory
|
5
|
+
attr_accessor :found
|
6
|
+
attr_accessor :path
|
7
|
+
|
8
|
+
def initialize( option )
|
9
|
+
unless option[:user].nil?
|
10
|
+
@user = option[:user]
|
11
|
+
@directory = "/home/#{option[:user]}/public_html"
|
12
|
+
end
|
13
|
+
|
14
|
+
unless option[:directory].nil?
|
15
|
+
@directory = option[:directory]
|
16
|
+
end
|
17
|
+
@found = []
|
18
|
+
end
|
19
|
+
|
20
|
+
def run
|
21
|
+
if File.directory?(@directory )
|
22
|
+
find_installs
|
23
|
+
else
|
24
|
+
raise "Directory doesn't exist"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
def find_installs
|
30
|
+
Find.find( @directory ) do |path|
|
31
|
+
@path = path
|
32
|
+
if File.readable?(path)
|
33
|
+
if path =~ /.*\/version\.php$/
|
34
|
+
find_wordpress_joomla
|
35
|
+
find_moodle
|
36
|
+
elsif path =~ /.*\/bootstrap.inc$/
|
37
|
+
find_drupal
|
38
|
+
elsif path =~ /.*\/modules\/system\/system.module$/
|
39
|
+
find_drupal
|
40
|
+
elsif path =~ /.*\/index.php$/
|
41
|
+
find_smf_version
|
42
|
+
elsif path =~ /.*\/app\/Mage.php$/
|
43
|
+
find_magento_version
|
44
|
+
elsif path =~ /.*\/styles\/prosilver\/template\/template.cfg$/
|
45
|
+
find_phpbb_version
|
46
|
+
elsif path =~/.*\/inc\/class_core.php$/
|
47
|
+
find_mybb_version
|
48
|
+
end
|
49
|
+
else
|
50
|
+
puts "Problem accessing #{path}"
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
def output( acct_home, version,script )
|
57
|
+
unless version.nil? or version.empty?
|
58
|
+
@found << "#{script} #{version}\t=>\t#{acct_home}"
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
##
|
63
|
+
## Wp and Joomla share the same filename for its version file
|
64
|
+
def find_wordpress_joomla
|
65
|
+
File.open( @path, "r" ).each_line do |line|
|
66
|
+
if ( line["wp_version ="] )
|
67
|
+
version = line.split(" ")[2][/([\d.]+)/]
|
68
|
+
acct_home = path.gsub("/wp-includes/version.php", "")
|
69
|
+
script = "Wordpress"
|
70
|
+
elsif ( line["public $RELEASE"] )
|
71
|
+
version = line.split(" ")[3][/([\d.]+)/]
|
72
|
+
acct_home = path.gsub("libraries/cms/version/version.php", "")
|
73
|
+
script = "Joomla"
|
74
|
+
elsif (line["var $RELEASE"] )
|
75
|
+
version = line.split(" ")[3][/([\d.]+)/]
|
76
|
+
acct_home = path.gsub("libraries/joomla/version.php", "")
|
77
|
+
script = "Joomla"
|
78
|
+
elsif (line["public $DEV_LEVEL" ])
|
79
|
+
elsif (line["var $DEV_LEVEL"] )
|
80
|
+
version << "." << line.split(" ")[3][/[0-9]/].to_s
|
81
|
+
end
|
82
|
+
# Output ony when we has a defined variable
|
83
|
+
unless defined?(version).nil?
|
84
|
+
output( acct_home, version, script )
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
## Find Drupal version
|
90
|
+
def find_drupal
|
91
|
+
File.open( @path, "r").each_line do |line|
|
92
|
+
if (line["define('VERSION"] )
|
93
|
+
version = line.split(" ")[1][/([\d.]+)/]
|
94
|
+
## Drupal 6 / Drupal7 compatability
|
95
|
+
if path =~ /.*\/modules\/system\/system.module$/
|
96
|
+
acct_home = path.gsub("modules/system/system.module", "")
|
97
|
+
else
|
98
|
+
acct_home = path.gsub("includes/bootstrap.inc", "")
|
99
|
+
end
|
100
|
+
script = "Drupal"
|
101
|
+
end
|
102
|
+
unless defined?(version).nil?
|
103
|
+
output( acct_home, version, script)
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
def find_smf_version
|
109
|
+
File.open( @path, "r").each_line do |line|
|
110
|
+
if ( line["$forum_version"] )
|
111
|
+
version = line.split("=")[1][/([\d.]+)/]
|
112
|
+
acct_home = path.gsub("index.php", "")
|
113
|
+
script = "SMF Forum"
|
114
|
+
end
|
115
|
+
unless defined?(version).nil?
|
116
|
+
output( acct_home, version, script)
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
def find_magento_version
|
122
|
+
File.open( @path, "r").each_line do |line|
|
123
|
+
if ( line[/'major'.*=>.*/])
|
124
|
+
major = line[/[0-9]/]
|
125
|
+
script = "Magento"
|
126
|
+
acct_home = path.gsub("app/Mage.php", "")
|
127
|
+
|
128
|
+
sec = File.read(@path)
|
129
|
+
minor = sec[/'minor'.*=>.*/][/\d/]
|
130
|
+
revision = sec[/'revision'.*=>.*/][/\d/]
|
131
|
+
patch = sec[/'patch'.*=>.*/][/\d/]
|
132
|
+
stability = sec[/'stability'.*=>.*/].split("=>")[1][/[a-z]+/]
|
133
|
+
number = sec[/'number'.*=>.*/][/\d/]
|
134
|
+
|
135
|
+
if stability.nil?
|
136
|
+
version = "#{major}.#{minor}.#{revision}.#{patch}"
|
137
|
+
else
|
138
|
+
version = "#{major}.#{minor}.#{revision}.#{patch}-#{stability}#{number}"
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
## Ship it
|
143
|
+
unless defined?(version).nil?
|
144
|
+
output( acct_home, version, script)
|
145
|
+
end
|
146
|
+
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
##
|
151
|
+
## phpBB version
|
152
|
+
## Versions are inside the CHANGELOG or the subsilver template
|
153
|
+
def find_phpbb_version
|
154
|
+
File.open( @path, "r").each_line do |line|
|
155
|
+
if ( line["version ="] )
|
156
|
+
version = line.split("=")[1][/([\d.]+)/]
|
157
|
+
acct_home = path.gsub("styles/prosilver/template/template.cfg", "")
|
158
|
+
script = "phpBB"
|
159
|
+
end
|
160
|
+
|
161
|
+
unless defined?(version).nil?
|
162
|
+
output( acct_home, version, script)
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
end
|
167
|
+
|
168
|
+
def find_mybb_version
|
169
|
+
File.open( @path, "r").each_line do |line|
|
170
|
+
if ( line["public $version ="] )
|
171
|
+
version = line.split("=")[1][/([\d.]+)/]
|
172
|
+
acct_home = path.gsub("inc/class_core.php", "")
|
173
|
+
script = "MyBB"
|
174
|
+
end
|
175
|
+
|
176
|
+
unless defined?(version).nil?
|
177
|
+
output( acct_home, version, script)
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
end
|
182
|
+
|
183
|
+
|
184
|
+
def find_moodle
|
185
|
+
File.open(@path, "r").each_line do |line|
|
186
|
+
if ( line["$release "] )
|
187
|
+
version = line.split("=")[1].gsub("'", "").split(";")[0]
|
188
|
+
acct_home = @path.gsub("version.php", "")
|
189
|
+
script = "Moodle"
|
190
|
+
end
|
191
|
+
unless defined?(version).nil?
|
192
|
+
output( acct_home, version, script)
|
193
|
+
end
|
194
|
+
end
|
195
|
+
end
|
211
196
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: miko
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Antun Krasic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-06-
|
11
|
+
date: 2013-06-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -75,7 +75,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
75
75
|
version: '0'
|
76
76
|
requirements: []
|
77
77
|
rubyforge_project:
|
78
|
-
rubygems_version: 2.0.
|
78
|
+
rubygems_version: 2.0.2
|
79
79
|
signing_key:
|
80
80
|
specification_version: 4
|
81
81
|
summary: Locates popular script installations under account
|