ronin-php 0.0.9

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.
data/tasks/helpers.rb ADDED
@@ -0,0 +1 @@
1
+ require './tasks/helpers/minify.rb'
@@ -0,0 +1,54 @@
1
+ require 'hpricot'
2
+ require 'cssmin'
3
+ require 'jsmin'
4
+
5
+ module Ronin
6
+ module PHP
7
+ #
8
+ # Inlines and minifies any Javascript or CSS within the PHP file
9
+ # at the specified _path_. The resulting minified PHP file will be saved
10
+ # to the _output_ path.
11
+ #
12
+ def PHP.minify(path,output=nil)
13
+ path = File.expand_path(path)
14
+ dir = File.dirname(path)
15
+
16
+ php_inline = lambda { |text|
17
+ text.gsub(/<\?/,'<\?').gsub(/\?>/,'?\>')
18
+ }
19
+
20
+ doc = Hpricot(open(path))
21
+
22
+ doc.search('//script[@type *= "javascript"]') do |script|
23
+ js = ''
24
+
25
+ if script.has_attribute?('src')
26
+ js = File.open(File.join(dir,script.get_attribute('src')))
27
+ else
28
+ js = script.inner_text
29
+ end
30
+
31
+ script.swap("<script type=\"text/javascript\">" +
32
+ php_inline.call(JSMin.minify(js)) +
33
+ "</script>")
34
+ end
35
+
36
+ doc.search('//link[@rel="stylesheet"][@type="text/css"][@href]') do |link|
37
+ css = File.read(File.join(dir,link.get_attribute('href')))
38
+
39
+ link.swap("<style type=\"text/css\">" +
40
+ php_inline.call(CSSMin.minify(css)) +
41
+ "</style>")
42
+ end
43
+
44
+ ext = File.extname(path)
45
+ output ||= path.gsub(/#{ext}$/,".min#{ext}")
46
+
47
+ File.open(output,'w') do |min|
48
+ min.write(doc.to_html)
49
+ end
50
+
51
+ return output
52
+ end
53
+ end
54
+ end
data/tasks/spec.rb ADDED
@@ -0,0 +1,7 @@
1
+ require 'spec/rake/spectask'
2
+
3
+ desc "Run all specifications"
4
+ Spec::Rake::SpecTask.new(:spec) do |t|
5
+ t.libs += ['lib', 'spec']
6
+ t.spec_opts = ['--colour', '--format', 'specdoc']
7
+ end
data/tasks/static.rb ADDED
@@ -0,0 +1,34 @@
1
+ require './tasks/helpers/minify.rb'
2
+
3
+ require 'fileutils'
4
+
5
+ namespace :static do
6
+ STATIC_DIR = File.expand_path(File.join(File.dirname(__FILE__),'..','static'))
7
+
8
+ MINIFY = [
9
+ {
10
+ :path => File.join('rpc','server.php'),
11
+ :output => File.join('rpc','server.min.php')
12
+ }
13
+ ]
14
+
15
+ desc 'Creates minified versions of all static files'
16
+ task :minify do
17
+ MINIFY.each do |pair|
18
+ path = File.join(STATIC_DIR,pair[:path])
19
+ output = File.join(STATIC_DIR,pair[:output])
20
+
21
+ Ronin::PHP.minify(path,output)
22
+ end
23
+ end
24
+
25
+ desc 'Cleans all minified static files'
26
+ task :clean do
27
+ MINIFY.each do |pair|
28
+ FileUtils.rm(File.join(STATIC_DIR,pair[:output]))
29
+ end
30
+ end
31
+ end
32
+
33
+ desc 'Creates minified versions of all static files'
34
+ task :static => ['static:minify']
metadata ADDED
@@ -0,0 +1,132 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ronin-php
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.9
5
+ platform: ruby
6
+ authors:
7
+ - Postmodern Modulus III
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-08-20 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: ronin
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 0.0.9
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: cssmin
27
+ type: :runtime
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: "0"
34
+ version:
35
+ - !ruby/object:Gem::Dependency
36
+ name: jsmin
37
+ type: :runtime
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: "0"
44
+ version:
45
+ - !ruby/object:Gem::Dependency
46
+ name: hoe
47
+ type: :development
48
+ version_requirement:
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: 1.7.0
54
+ version:
55
+ description: Ronin PHP is a Ruby library for Ronin that provides support for PHP related security tasks. Ronin is a Ruby platform designed for information security and data exploration tasks. Ronin allows for the rapid development and distribution of code over many of the common Source-Code-Management (SCM) systems.
56
+ email:
57
+ - postmodern.mod3@gmail.com
58
+ executables: []
59
+
60
+ extensions: []
61
+
62
+ extra_rdoc_files:
63
+ - History.txt
64
+ - COPYING.txt
65
+ - Manifest.txt
66
+ - README.txt
67
+ files:
68
+ - History.txt
69
+ - COPYING.txt
70
+ - Manifest.txt
71
+ - README.txt
72
+ - Rakefile
73
+ - lib/ronin/php.rb
74
+ - lib/ronin/php/extensions.rb
75
+ - lib/ronin/php/extensions/string.rb
76
+ - lib/ronin/php/lfi.rb
77
+ - lib/ronin/php/lfi/exceptions.rb
78
+ - lib/ronin/php/lfi/exceptions/unknown_target.rb
79
+ - lib/ronin/php/lfi/extensions.rb
80
+ - lib/ronin/php/lfi/extensions/uri.rb
81
+ - lib/ronin/php/lfi/extensions/uri/http.rb
82
+ - lib/ronin/php/lfi/target.rb
83
+ - lib/ronin/php/lfi/file.rb
84
+ - lib/ronin/php/lfi/lfi.rb
85
+ - lib/ronin/php/rfi.rb
86
+ - lib/ronin/php/rfi/extensions.rb
87
+ - lib/ronin/php/rfi/extensions/uri.rb
88
+ - lib/ronin/php/rfi/extensions/uri/http.rb
89
+ - lib/ronin/php/rfi/rfi.rb
90
+ - lib/ronin/rpc/php.rb
91
+ - lib/ronin/rpc/php/call.rb
92
+ - lib/ronin/rpc/php/response.rb
93
+ - lib/ronin/rpc/php/client.rb
94
+ - lib/ronin/rpc/php/console.rb
95
+ - lib/ronin/rpc/php/shell.rb
96
+ - lib/ronin/rpc/php/rfi.rb
97
+ - tasks/spec.rb
98
+ - tasks/static.rb
99
+ - tasks/helpers.rb
100
+ - tasks/helpers/minify.rb
101
+ - spec/spec_helper.rb
102
+ - static/rfi/test.php
103
+ - static/rpc/server.php
104
+ has_rdoc: true
105
+ homepage: http://ronin.rubyforge.org/php/
106
+ post_install_message:
107
+ rdoc_options:
108
+ - --main
109
+ - README.txt
110
+ require_paths:
111
+ - lib
112
+ required_ruby_version: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: "0"
117
+ version:
118
+ required_rubygems_version: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ version: "0"
123
+ version:
124
+ requirements: []
125
+
126
+ rubyforge_project: ronin
127
+ rubygems_version: 1.2.0
128
+ signing_key:
129
+ specification_version: 2
130
+ summary: Ronin PHP is a Ruby library for Ronin that provides support for PHP related security tasks
131
+ test_files: []
132
+