evil-proxy 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +1 -0
- data/Gemfile +5 -0
- data/lib/evil-proxy/httpproxy.rb +25 -1
- data/lib/evil-proxy/version.rb +1 -1
- data/spec/evil-proxy/httpproxy_spec.rb +62 -0
- data/spec/spec_helper.rb +11 -0
- data/spec/support/http_client.rb +33 -0
- metadata +11 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 23d4b1c477355c5e5aa6227ace67738b2e240c65
|
4
|
+
data.tar.gz: e19472748b61a71cc38ad8a91971bec1d47e6b4f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eeaf5bc18b460032b99cad92e4761a665b0eecc1056d57d0ce4abc8e66744b90e072aebd411616a5b16446a7182322785870592056e7fd31405e2dc5bc7f273d
|
7
|
+
data.tar.gz: fd73c75fb5e53bcd188bacdf1f03a92f4d8743ed3254e0cc237a7aac3800bc7c8c9d3ee7fcfd27d25cb86879ce433c29d6e854a1977c992317effaf47d61b229
|
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--require spec_helper
|
data/Gemfile
CHANGED
data/lib/evil-proxy/httpproxy.rb
CHANGED
@@ -6,6 +6,8 @@ class EvilProxy::HTTPProxyServer < WEBrick::HTTPProxyServer
|
|
6
6
|
|
7
7
|
DEFAULT_CALLBACKS = Hash.new
|
8
8
|
|
9
|
+
SUPPORTED_METHODS = %w(GET HEAD POST PUT PATCH DELETE OPTIONS CONNECT).freeze
|
10
|
+
|
9
11
|
def initialize config = {}, default = WEBrick::Config::HTTP
|
10
12
|
initialize_callbacks config
|
11
13
|
fire :when_initialize, config, default
|
@@ -66,13 +68,35 @@ class EvilProxy::HTTPProxyServer < WEBrick::HTTPProxyServer
|
|
66
68
|
end
|
67
69
|
end
|
68
70
|
|
71
|
+
def do_PUT(req, res)
|
72
|
+
perform_proxy_request(req, res) do |http, path, header|
|
73
|
+
http.put(path, req.body || '', header)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def do_DELETE(req, res)
|
78
|
+
perform_proxy_request(req, res) do |http, path, header|
|
79
|
+
http.delete(path, header)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def do_PATCH(req, res)
|
84
|
+
perform_proxy_request(req, res) do |http, path, header|
|
85
|
+
http.patch(path, req.body || '', header)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
def do_OPTIONS(_req, res)
|
90
|
+
res['allow'] = SUPPORTED_METHODS.join(',')
|
91
|
+
end
|
92
|
+
|
69
93
|
define_callback_methods :when_initialize
|
70
94
|
define_callback_methods :when_start
|
71
95
|
define_callback_methods :when_shutdown
|
72
96
|
define_callback_methods :before_request
|
73
97
|
define_callback_methods :before_response
|
74
98
|
|
75
|
-
|
99
|
+
SUPPORTED_METHODS.each do |method|
|
76
100
|
do_method = "do_#{method}".to_sym
|
77
101
|
do_method_without_callbacks = "#{do_method}_without_callbacks".to_sym
|
78
102
|
before_method = "before_#{method.downcase}".to_sym
|
data/lib/evil-proxy/version.rb
CHANGED
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe EvilProxy::HTTPProxyServer do
|
4
|
+
before :all do
|
5
|
+
@server = EvilProxy::MITMProxyServer.new Port: 3128, Quiet: true
|
6
|
+
@server.start
|
7
|
+
end
|
8
|
+
|
9
|
+
after :all do
|
10
|
+
@server.shutdown
|
11
|
+
end
|
12
|
+
|
13
|
+
let(:proxy) { 'http://127.0.0.1:3128' }
|
14
|
+
|
15
|
+
it 'proxy GET requests' do
|
16
|
+
content = HTTPClient.get('http://httpbin.org/get', proxy)
|
17
|
+
|
18
|
+
expect(content).not_to be_nil
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'proxy HEAD requests' do
|
22
|
+
content = HTTPClient.head('https://httpbin.org/get', proxy)
|
23
|
+
|
24
|
+
expect(content).not_to be_nil
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'proxy POST requests' do
|
28
|
+
content = HTTPClient.post('https://httpbin.org/post', { param: 'value' }, proxy)
|
29
|
+
|
30
|
+
expect(content).not_to be_nil
|
31
|
+
|
32
|
+
json = JSON.parse(content)
|
33
|
+
|
34
|
+
expect(json['form']['param']).to eq('value')
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'proxy PUT requests' do
|
38
|
+
content = HTTPClient.put('https://httpbin.org/put', { param: 'value' }, proxy)
|
39
|
+
|
40
|
+
expect(content).not_to be_nil
|
41
|
+
|
42
|
+
json = JSON.parse(content)
|
43
|
+
|
44
|
+
expect(json['form']['param']).to eq('value')
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'proxy PATCH requests' do
|
48
|
+
content = HTTPClient.patch('https://httpbin.org/patch', { param: 'value' }, proxy)
|
49
|
+
|
50
|
+
expect(content).not_to be_nil
|
51
|
+
|
52
|
+
json = JSON.parse(content)
|
53
|
+
|
54
|
+
expect(json['form']['param']).to eq('value')
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'proxy DELETE requests' do
|
58
|
+
content = HTTPClient.delete('https://httpbin.org/delete', proxy)
|
59
|
+
|
60
|
+
expect(content).not_to be_nil
|
61
|
+
end
|
62
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
class HTTPClient
|
2
|
+
class << self
|
3
|
+
def get(url, proxy)
|
4
|
+
RestClient::Request.execute(method: :get, url: url, proxy: proxy,
|
5
|
+
verify_ssl: OpenSSL::SSL::VERIFY_NONE)
|
6
|
+
end
|
7
|
+
|
8
|
+
def head(url, proxy)
|
9
|
+
RestClient::Request.execute(method: :head, url: url, proxy: proxy,
|
10
|
+
verify_ssl: OpenSSL::SSL::VERIFY_NONE)
|
11
|
+
end
|
12
|
+
|
13
|
+
def post(url, payload, proxy)
|
14
|
+
RestClient::Request.execute(method: :post, url: url, payload: payload,
|
15
|
+
proxy: proxy, verify_ssl: OpenSSL::SSL::VERIFY_NONE)
|
16
|
+
end
|
17
|
+
|
18
|
+
def put(url, payload, proxy)
|
19
|
+
RestClient::Request.execute(method: :put, url: url, payload: payload,
|
20
|
+
proxy: proxy, verify_ssl: OpenSSL::SSL::VERIFY_NONE)
|
21
|
+
end
|
22
|
+
|
23
|
+
def patch(url, payload, proxy)
|
24
|
+
RestClient::Request.execute(method: :patch, url: url, payload: payload,
|
25
|
+
proxy: proxy, verify_ssl: OpenSSL::SSL::VERIFY_NONE)
|
26
|
+
end
|
27
|
+
|
28
|
+
def delete(url, proxy)
|
29
|
+
RestClient::Request.execute(method: :delete, url: url, proxy: proxy,
|
30
|
+
verify_ssl: OpenSSL::SSL::VERIFY_NONE)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: evil-proxy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Theo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-09-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -48,6 +48,7 @@ extensions: []
|
|
48
48
|
extra_rdoc_files: []
|
49
49
|
files:
|
50
50
|
- ".gitignore"
|
51
|
+
- ".rspec"
|
51
52
|
- Gemfile
|
52
53
|
- LICENSE.txt
|
53
54
|
- README.md
|
@@ -65,6 +66,9 @@ files:
|
|
65
66
|
- lib/evil-proxy/selenium.rb
|
66
67
|
- lib/evil-proxy/store.rb
|
67
68
|
- lib/evil-proxy/version.rb
|
69
|
+
- spec/evil-proxy/httpproxy_spec.rb
|
70
|
+
- spec/spec_helper.rb
|
71
|
+
- spec/support/http_client.rb
|
68
72
|
homepage: https://github.com/bbtfr/evil-proxy
|
69
73
|
licenses:
|
70
74
|
- MIT
|
@@ -85,8 +89,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
85
89
|
version: '0'
|
86
90
|
requirements: []
|
87
91
|
rubyforge_project:
|
88
|
-
rubygems_version: 2.
|
92
|
+
rubygems_version: 2.5.1
|
89
93
|
signing_key:
|
90
94
|
specification_version: 4
|
91
95
|
summary: A ruby http/https proxy to do EVIL things.
|
92
|
-
test_files:
|
96
|
+
test_files:
|
97
|
+
- spec/evil-proxy/httpproxy_spec.rb
|
98
|
+
- spec/spec_helper.rb
|
99
|
+
- spec/support/http_client.rb
|