buby 1.1.6-java
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +67 -0
- data/README.rdoc +289 -0
- data/Rakefile +34 -0
- data/bin/buby +108 -0
- data/buby.gemspec +37 -0
- data/java/buby.jar +0 -0
- data/java/src/BurpExtender.java +295 -0
- data/java/src/burp/IBurpExtender.java +136 -0
- data/java/src/burp/IBurpExtenderCallbacks.java +211 -0
- data/java/src/burp/IHttpRequestResponse.java +32 -0
- data/java/src/burp/IScanIssue.java +32 -0
- data/java/src/burp/IScanQueueItem.java +20 -0
- data/lib/buby.rb +772 -0
- data/lib/buby/extends.rb +4 -0
- data/lib/buby/extends/buby_array_wrapper.rb +41 -0
- data/lib/buby/extends/http_request_response.rb +95 -0
- data/lib/buby/extends/scan_issue.rb +36 -0
- data/samples/drb_buby.rb +31 -0
- data/samples/drb_sample_cli.rb +14 -0
- data/samples/mechanize_burp.rb +57 -0
- data/samples/poc_generator.rb +124 -0
- data/samples/verb_tamperer.rb +25 -0
- data/samples/watch_scan.rb +21 -0
- data/spec/buby_spec.rb +7 -0
- data/spec/spec_helper.rb +16 -0
- data/tasks/ann.rake +80 -0
- data/tasks/bones.rake +20 -0
- data/tasks/gem.rake +201 -0
- data/tasks/git.rake +40 -0
- data/tasks/notes.rake +27 -0
- data/tasks/post_load.rake +34 -0
- data/tasks/rdoc.rake +51 -0
- data/tasks/rubyforge.rake +55 -0
- data/tasks/setup.rb +292 -0
- data/tasks/spec.rake +54 -0
- data/tasks/svn.rake +47 -0
- data/tasks/test.rake +40 -0
- data/tasks/zentest.rake +36 -0
- data/test/test_buby.rb +0 -0
- metadata +106 -0
data/History.txt
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
== 1.1.6 / 2009-11-19
|
2
|
+
* fix
|
3
|
+
* poc_generator.rb example fixed to properly parse port in Host header
|
4
|
+
* fix evt_proxy_message bridge to deal correctly with binary content data
|
5
|
+
|
6
|
+
== 1.1.5 / 2009-10-15
|
7
|
+
* enhancements
|
8
|
+
* added support for exitSuite in burp v 1.2.17+
|
9
|
+
* added samples/poc_generator.rb
|
10
|
+
|
11
|
+
== 1.1.4.1 / 2009-09-22
|
12
|
+
* fix
|
13
|
+
* Buby.harvest_cookies_from_history() was broken.
|
14
|
+
It now implements select() block semantics and always returns an array.
|
15
|
+
|
16
|
+
== 1.1.4 / 2009-09-14
|
17
|
+
* enhancements
|
18
|
+
* buby got implants! (har har)
|
19
|
+
* Ruby wrapper classes added for proxy_history, site_map, and scan_issues
|
20
|
+
* Extensions module for IHttpRequestResponse burp's class implementation
|
21
|
+
* Extensions module for IScanIssue burp's class implementation
|
22
|
+
* Added -s/--state, -r/--require, -e/--extend to buby cmd-line executable
|
23
|
+
* Added -v/--version buby cmd-line flag
|
24
|
+
* Modified samples for use as modules with -r/-e as well as run standalone
|
25
|
+
* Added drb client and server sample
|
26
|
+
|
27
|
+
== 1.1.3.1 / 2009-09-09
|
28
|
+
* fix
|
29
|
+
* fixed a typo in the String type-check for Buby.getParameters()
|
30
|
+
|
31
|
+
== 1.1.3 / 2009-08-25
|
32
|
+
* 1 enhancement
|
33
|
+
* new convenience methods added for iterating and searching through
|
34
|
+
proxy history, scan history, etc.
|
35
|
+
* 1 fix
|
36
|
+
* The gem now includes a buby.jar which should be usable with Java 1.5+
|
37
|
+
(previously the jar had been compiled only for Java 1.6)
|
38
|
+
|
39
|
+
== 1.1.2 / 2009-08-20
|
40
|
+
* 1 enhancement
|
41
|
+
* Support added for the new getScanIssues extender method exposed in v1.2.15
|
42
|
+
See http://releases.portswigger.net/2009/08/v1215.html
|
43
|
+
|
44
|
+
== 1.1.1 / 2009-06-24
|
45
|
+
* Fix
|
46
|
+
* fixed getSiteMap callback front-end so that it takes the urlprefix argument
|
47
|
+
|
48
|
+
== 1.1.0 / 2009-06-18
|
49
|
+
* 1 major enhancement
|
50
|
+
* Support added for the new Burp API features added in Burp 1.2.09.
|
51
|
+
See http://releases.portswigger.net/2009/05/v1209.html
|
52
|
+
* 1 minor enhancement
|
53
|
+
* buby command-line tool exposes arguments for debugging and IRB
|
54
|
+
|
55
|
+
== 1.0.2 / 2009-06-02
|
56
|
+
* Enhancements
|
57
|
+
* Added a sample illustrating synching cookies with Mechanize
|
58
|
+
|
59
|
+
== 1.0.1 / 2009-05-10
|
60
|
+
* Enhancements
|
61
|
+
* Added some sugar to make swapping Burp event handlers easier.
|
62
|
+
* Fixed documentation errors
|
63
|
+
|
64
|
+
== 1.0.0 / 2009-05-08
|
65
|
+
|
66
|
+
* 1 major enhancement
|
67
|
+
* Birthday!
|
data/README.rdoc
ADDED
@@ -0,0 +1,289 @@
|
|
1
|
+
buby
|
2
|
+
by Eric Monti
|
3
|
+
http://emonti.github.com/buby
|
4
|
+
|
5
|
+
== DESCRIPTION:
|
6
|
+
|
7
|
+
Buby is a mashup of JRuby with the popular commercial web security testing tool Burp Suite from PortSwigger. Burp is driven from and tied to JRuby with a Java extension using the BurpExtender API. This extension aims to add Ruby scriptability to Burp Suite with an interface comparable to the Burp's pure Java extension interface.
|
8
|
+
|
9
|
+
== FEATURES/PROBLEMS:
|
10
|
+
|
11
|
+
* Intercept and log proxied requests and responses via Burp into Ruby and
|
12
|
+
perform arbitrary processing on them.
|
13
|
+
|
14
|
+
* Modify requests and responses in-line using Ruby scripts.
|
15
|
+
|
16
|
+
* Pass requests and other information from JRuby to various sub-interfaces in
|
17
|
+
Burp
|
18
|
+
|
19
|
+
* Use the Burp framework for active and passive scanning using arbitrary
|
20
|
+
requests and responses.
|
21
|
+
|
22
|
+
* Use the Burp framework for making arbitrary HTTP requests
|
23
|
+
|
24
|
+
|
25
|
+
Buby is implemented using an abstract Ruby event handler and interface class. The Buby Ruby class is back-ended with a minimal BurpExtender class implemented in Java. The java code is required to conform to nuances in the Burp extension interface and while it's in the pure Java runtime, it acts as 'glue' where deemed appropriate, but otherwise tries to stay out of the way.
|
26
|
+
|
27
|
+
The java BurpExtender included with Buby is an implementation of IBurpExtender which is the interface API supplied by PortSwigger for writing extensions to Burp Suite. It mostly acts as a method proxy between Ruby and Java, doing very little except event handler proxying between the java and ruby runtimes with run-time type conversion as needed.
|
28
|
+
|
29
|
+
|
30
|
+
== REQUIREMENTS:
|
31
|
+
|
32
|
+
* JRuby - http://jruby.org
|
33
|
+
Burp is Java based and the extension is developed specifically around JRuby.
|
34
|
+
The C version of ruby will not work.
|
35
|
+
|
36
|
+
* Burp (pro or free version): Buby is useless without a copy of Burp.
|
37
|
+
Buby has been tested successfully with Burp 1.2.x.
|
38
|
+
|
39
|
+
|
40
|
+
== BUILD/INSTALL:
|
41
|
+
|
42
|
+
=== Gem
|
43
|
+
You should be able to get up and running with just the gem and a copy of Burp.
|
44
|
+
I've packaged up a pre-built buby.jar file containing the required classes
|
45
|
+
minus ofcourse, Burp itself.
|
46
|
+
|
47
|
+
jruby -S gem sources -a http://gems.github.com # only have to do this once
|
48
|
+
jruby -S gem install emonti-buby
|
49
|
+
|
50
|
+
* IMPORTANT: The buby gem doesn't include a copy of Burp! See manual step #5
|
51
|
+
below. For best results, you'll still want to make your burp.jar available
|
52
|
+
in the ruby runtime library path.
|
53
|
+
|
54
|
+
|
55
|
+
=== Manual
|
56
|
+
Here are manual instructions if you want or need to build things yourself:
|
57
|
+
|
58
|
+
==== Step 1. Download buby from github
|
59
|
+
git clone git://github.com/emonti/buby.git
|
60
|
+
|
61
|
+
==== Step 2. Compile BurpExtender.java. Include jruby.jar in the classpath:
|
62
|
+
|
63
|
+
cd buby/java/src
|
64
|
+
javac -classpath (.../jruby/root)/lib/jruby.jar:. BurpExtender.java
|
65
|
+
|
66
|
+
==== Step 3. Create a new java/buby.jar
|
67
|
+
|
68
|
+
jar cvf ../buby.jar .
|
69
|
+
|
70
|
+
==== Step 4. Build a local gem and install it
|
71
|
+
|
72
|
+
cd ../../
|
73
|
+
jruby -S gem build buby.gemspec
|
74
|
+
jruby -S gem install --local buby-*.gem
|
75
|
+
|
76
|
+
==== Step 5.
|
77
|
+
|
78
|
+
The last part is a bit tricky. Burp Suite itself is obviously not included
|
79
|
+
with buby. You'll want to somehow put your 'burp.jar' in a place where it
|
80
|
+
is visible in the JRuby RUBY-LIB paths. There are a few other ways of pulling
|
81
|
+
in Burp during runtime, but this method probably involves the least amount of
|
82
|
+
hassle in the long run.
|
83
|
+
|
84
|
+
JRuby usually gives you a 'java' lib directory for this kind of thing. Here's
|
85
|
+
a quick way to see jruby's runtime lib-path:
|
86
|
+
|
87
|
+
jruby -e 'puts $:'
|
88
|
+
|
89
|
+
There is usually a '.../jruby/lib/1.8/java' directory reference in there,
|
90
|
+
though the actual directory may need to be created.
|
91
|
+
|
92
|
+
Here's how I do it. I have my jruby installation under my home directory.
|
93
|
+
Your configuration details can be substituted below.
|
94
|
+
|
95
|
+
mkdir ~/jruby-1.1.5/lib/ruby/1.8/java
|
96
|
+
ln -s ~/tools/burp.jar ~/jruby-1.1.5/lib/ruby/1.8/java/burp.jar
|
97
|
+
|
98
|
+
Now everything should be ready to go. Try at least the first few parts of the
|
99
|
+
test below to confirm everything is set up.
|
100
|
+
|
101
|
+
== TEST AND USAGE EXAMPLE:
|
102
|
+
|
103
|
+
The gem includes a command-line executable called 'buby'. You can use this to
|
104
|
+
test your Buby set-up and try out a few features.
|
105
|
+
|
106
|
+
$ buby -h
|
107
|
+
Usage: buby [options]
|
108
|
+
-i, --interactive Start IRB
|
109
|
+
-d, --debug Debug info
|
110
|
+
-B, --load-burp=PATH Load Burp Jar from PATH
|
111
|
+
-s, --state=FILE Restore burp state file on startup
|
112
|
+
-r, --require=LIB load a ruby lib (or jar) after Burp loads
|
113
|
+
-e, --extend=MOD Extend Buby with a module (loaded via -r?)
|
114
|
+
-h, --help Show this help message
|
115
|
+
|
116
|
+
$ buby -i -d
|
117
|
+
[:got_extender, #<Java::Default::BurpExtender:0x80 ...>]
|
118
|
+
Global $burp is set to #<Buby:0x78de07 @burp_callbacks=#<#<Class:...>
|
119
|
+
[:got_callbacks, #<#<Class:01x38ba04>:0x90 ...>]
|
120
|
+
irb(main):001:0>
|
121
|
+
|
122
|
+
|
123
|
+
Once Burp is running, click on the alerts tab.
|
124
|
+
|
125
|
+
You should see now something like the following in alerts:
|
126
|
+
|
127
|
+
2:46:01 PM suite method BurpExtender.processProxyMessage() found
|
128
|
+
2:46:01 PM suite method BurpExtender.registerExtenderCallbacks() found
|
129
|
+
2:46:01 PM suite method BurpExtender.setCommandLineArgs() found
|
130
|
+
2:46:01 PM suite method BurpExtender.applicationClosing() found
|
131
|
+
2:46:01 PM proxy proxy service started on port 8080
|
132
|
+
2:46:01 PM suite [BurpExtender] registering JRuby handler callbacks
|
133
|
+
2:46:01 PM suite [JRuby::Buby] registered callback
|
134
|
+
|
135
|
+
Here are some simple test examples using Buby through the IRB shell:
|
136
|
+
|
137
|
+
To confirm you are connected back to Burp in IRB, you can try writing to the
|
138
|
+
alerts panel with something like the following:
|
139
|
+
|
140
|
+
$burp.alert("hello Burp!")
|
141
|
+
|
142
|
+
Which should produce a new alert:
|
143
|
+
|
144
|
+
2:47:00 PM suite hello Burp!
|
145
|
+
|
146
|
+
|
147
|
+
Next, try making an HTTP request through the proxy. We'll use Net:HTTP right
|
148
|
+
in IRB for illustration purposes. However, you can just as easily perform this
|
149
|
+
test through a browser configured to use Burp as its proxy.
|
150
|
+
|
151
|
+
require 'net/http'
|
152
|
+
p = Net::HTTP::Proxy("localhost", 8080).start("www.example.com")
|
153
|
+
p.get("/")
|
154
|
+
|
155
|
+
|
156
|
+
With $DEBUG = true, you should see the debugging output from Ruby as the proxy
|
157
|
+
passes your request back to your HTTP client/browser.
|
158
|
+
|
159
|
+
It will look something like the following in IRB:
|
160
|
+
|
161
|
+
>> p.get("/")
|
162
|
+
[:got_proxy_request,
|
163
|
+
[:msg_ref, 1],
|
164
|
+
[:is_req, true],
|
165
|
+
[:rhost, "www.example.com"],
|
166
|
+
[:rport, 80],
|
167
|
+
[:is_https, false],
|
168
|
+
[:http_meth, "GET"],
|
169
|
+
[:url, "/"],
|
170
|
+
[:resourceType, nil],
|
171
|
+
[:status, nil],
|
172
|
+
[:req_content_type, nil],
|
173
|
+
[:message, "GET / HTTP/1.1\r\nAccept:..."],
|
174
|
+
[:action, 0]]
|
175
|
+
|
176
|
+
You may also see the response right away depending on your intercept settings
|
177
|
+
in Burp. Back the in Burp proxy's intercept window, turn off interception if
|
178
|
+
it hasn't already been disabled. Now you should definitely see the response
|
179
|
+
in IRB as it passes back through the Burp proxy.
|
180
|
+
|
181
|
+
[:got_proxy_response,
|
182
|
+
[:msg_ref, 1],
|
183
|
+
[:is_req, false],
|
184
|
+
[:rhost, "www.example.com"],
|
185
|
+
[:rport, 80],
|
186
|
+
[:is_https, false],
|
187
|
+
[:http_meth, "GET"],
|
188
|
+
[:url, "/"],
|
189
|
+
[:resourceType, nil],
|
190
|
+
[:status, "200"],
|
191
|
+
[:req_content_type, "text/html; charset=utf-8"],
|
192
|
+
[:message, "HTTP/1.1 200 OK\r\n..."],
|
193
|
+
[:action, 0]]
|
194
|
+
=> #<Net::HTTPOK 200 OK readbody=true>
|
195
|
+
>>
|
196
|
+
|
197
|
+
Note also, the Net::HTTP request should have returned the same result as shown in the proxy.
|
198
|
+
|
199
|
+
Now, lets try something mildly interesting with the proxy. This contrived example will implement a proxy request manipulator to do HTTP request verb tampering on every GET request that goes through the proxy.
|
200
|
+
|
201
|
+
# Note: I'm using 'instance_eval' here only to stay with the flow of the
|
202
|
+
# existing IRB session. Normally, you'd probably want to implement this as
|
203
|
+
# an override in your Buby-derived class.
|
204
|
+
|
205
|
+
$burp.instance_eval do
|
206
|
+
|
207
|
+
def evt_proxy_message(*param)
|
208
|
+
msg_ref, is_req, rhost, rport, is_https, http_meth, url, resourceType,
|
209
|
+
status, req_content_type, message, action = param
|
210
|
+
|
211
|
+
if is_req and http_meth=="GET"
|
212
|
+
# Change the HTTP request verb to something silly
|
213
|
+
message[0,3] = "PET"
|
214
|
+
|
215
|
+
# Forcibly disable interception in the Burp UI
|
216
|
+
action[0] = Buby::ACTION_DONT_INTERCEPT
|
217
|
+
|
218
|
+
# Return a new instance and still get $DEBUG info
|
219
|
+
return super(*param).dup
|
220
|
+
else
|
221
|
+
# Just get $DEBUG info for all other requests
|
222
|
+
return super(*param)
|
223
|
+
end
|
224
|
+
end
|
225
|
+
|
226
|
+
end
|
227
|
+
|
228
|
+
# Now, make another request using the Net::HTTP client
|
229
|
+
p.get("/")
|
230
|
+
|
231
|
+
|
232
|
+
This should produce a request that looks like the following in IRB:
|
233
|
+
|
234
|
+
[:got_proxy_request,
|
235
|
+
...
|
236
|
+
[:message,
|
237
|
+
"PET / HTTP/1.1\r\nAccept: */*\r\nUser-Agent: Ruby..."],
|
238
|
+
[:action, 2]]
|
239
|
+
|
240
|
+
And, assuming 'www.example.com' checks for valid request verbs, you should see something like the following response:
|
241
|
+
|
242
|
+
[:got_proxy_response,
|
243
|
+
...
|
244
|
+
[:http_meth, "PET"],
|
245
|
+
[:url, "/"],
|
246
|
+
[:resourceType, nil],
|
247
|
+
[:status, "400"],
|
248
|
+
...
|
249
|
+
[:message,
|
250
|
+
"HTTP/1.1 400 Bad Request\r\nContent-Type:..."],
|
251
|
+
[:action, 0]]
|
252
|
+
=> #<Net::HTTPBadRequest 400 Bad Request readbody=true>
|
253
|
+
|
254
|
+
|
255
|
+
== CREDIT:
|
256
|
+
* Burp and Burp Suite are trademarks of PortSwigger(ltd)
|
257
|
+
Copyright 2008 PortSwigger Ltd. All rights reserved.
|
258
|
+
See http://portswigger.net for license terms.
|
259
|
+
|
260
|
+
* This ruby library and the accompanying BurpExtender.java implementation are
|
261
|
+
written by Eric Monti @ Matasano Security. Matasano Security claims no
|
262
|
+
professional or legal affiliation with PortSwigger LTD.
|
263
|
+
|
264
|
+
However, the author would like to express his personal and professional
|
265
|
+
respect and admiration to Burp's authors and appreciation to PortSwigger for
|
266
|
+
the availability of the IBurpExtender extension API.
|
267
|
+
|
268
|
+
The availability of this interface goes a long way to helping make Burp Suite
|
269
|
+
a truly first-class application.
|
270
|
+
|
271
|
+
== LICENSE:
|
272
|
+
|
273
|
+
* Burp and Burp Suite are trademarks of PortSwigger Ltd.
|
274
|
+
Copyright 2008 PortSwigger Ltd. All rights reserved.
|
275
|
+
See http://portswigger.net for license terms.
|
276
|
+
|
277
|
+
* The Buby Ruby library and its accompanying BurpExtender implementation are
|
278
|
+
both freely available under the terms of the MIT public license:
|
279
|
+
|
280
|
+
(The MIT License)
|
281
|
+
|
282
|
+
Copyright (C) 2009 Eric Monti, Matasano Security
|
283
|
+
|
284
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
285
|
+
|
286
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
287
|
+
|
288
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
289
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# Look in the tasks/setup.rb file for the various options that can be
|
2
|
+
# configured in this Rakefile. The .rake files in the tasks directory
|
3
|
+
# are where the options are used.
|
4
|
+
|
5
|
+
begin
|
6
|
+
require 'bones'
|
7
|
+
Bones.setup
|
8
|
+
rescue LoadError
|
9
|
+
begin
|
10
|
+
load 'tasks/setup.rb'
|
11
|
+
rescue LoadError
|
12
|
+
raise RuntimeError, '### please install the "bones" gem ###'
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
ensure_in_path 'lib'
|
17
|
+
ensure_in_path 'java'
|
18
|
+
require 'buby'
|
19
|
+
|
20
|
+
task :default => 'spec:run'
|
21
|
+
|
22
|
+
PROJ.name = 'buby'
|
23
|
+
PROJ.authors = 'Eric Monti - Matasano Security'
|
24
|
+
PROJ.email = 'emonti@matasano.com'
|
25
|
+
PROJ.url = 'http://emonti.github.com/buby'
|
26
|
+
PROJ.version = Buby::VERSION
|
27
|
+
PROJ.rubyforge.name = 'buby'
|
28
|
+
PROJ.readme_file = 'README.rdoc'
|
29
|
+
PROJ.libs << "java"
|
30
|
+
PROJ.platform = 'java'
|
31
|
+
|
32
|
+
PROJ.spec.opts << '--color'
|
33
|
+
|
34
|
+
# EOF
|
data/bin/buby
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
#!/usr/bin/env jruby
|
2
|
+
|
3
|
+
require File.expand_path(File.join(File.dirname(__FILE__), %w[.. lib buby]))
|
4
|
+
require 'irb'
|
5
|
+
require 'optparse'
|
6
|
+
|
7
|
+
args = {}
|
8
|
+
|
9
|
+
begin
|
10
|
+
opts = OptionParser.new do |o|
|
11
|
+
o.banner = "Usage: #{File.basename $0} [options]"
|
12
|
+
|
13
|
+
o.on_tail("-h", "--help", "Show this help message") do
|
14
|
+
raise opts.to_s
|
15
|
+
end
|
16
|
+
|
17
|
+
o.on("-i", "--interactive", "Start IRB") { args[:irb] = true }
|
18
|
+
|
19
|
+
o.on("-d", "--debug", "Debug info") { args[:debug] = true }
|
20
|
+
|
21
|
+
o.on("-B", "--load-burp=PATH", "Load Burp Jar from PATH") do |b|
|
22
|
+
args[:load_burp] = b
|
23
|
+
end
|
24
|
+
|
25
|
+
o.on('-s', '--state=FILE', "Restore burp state file on startup") do |r|
|
26
|
+
args[:restore] = r
|
27
|
+
end
|
28
|
+
|
29
|
+
o.on('-r', '--require=LIB',
|
30
|
+
'load a ruby lib (or jar) after Burp loads') do |i|
|
31
|
+
(args[:requires] ||= []).push(i)
|
32
|
+
end
|
33
|
+
|
34
|
+
o.on('-e', '--extend=MOD',
|
35
|
+
'Extend Buby with a module (loaded via -r?)') do |m|
|
36
|
+
(args[:extensions] ||= []).push(m)
|
37
|
+
end
|
38
|
+
|
39
|
+
o.on('-v', '--version', 'Prints version and exits.') do
|
40
|
+
puts "#{File.basename $0} v#{Buby::VERSION}"
|
41
|
+
exit 0
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
opts.parse!(ARGV)
|
46
|
+
|
47
|
+
if jar=args[:load_burp]
|
48
|
+
raise "Load Burp Error: #{jar} did not provide burp.StartBurp" unless Buby.load_burp(jar)
|
49
|
+
end
|
50
|
+
|
51
|
+
raise "Load Burp Error: Specify a path to your burp.jar with -B" unless Buby.burp_loaded?
|
52
|
+
|
53
|
+
rescue
|
54
|
+
STDERR.puts $!
|
55
|
+
exit 1
|
56
|
+
end
|
57
|
+
|
58
|
+
$DEBUG=true if args[:debug]
|
59
|
+
|
60
|
+
$burp = Buby.start_burp()
|
61
|
+
|
62
|
+
if libs=args[:requires]
|
63
|
+
libs.each {|lib| STDERR.puts "Loading: #{lib.inspect}"; require(lib)}
|
64
|
+
end
|
65
|
+
|
66
|
+
def resolve_const(str)
|
67
|
+
raise "can't resolve empty name #{str.inspect}" if str.empty?
|
68
|
+
names = str.split('::')
|
69
|
+
obj = ::Object
|
70
|
+
names.each do |name|
|
71
|
+
raise "#{name.inspect} is not defined" unless obj.const_defined?(name)
|
72
|
+
obj = obj.const_get(name)
|
73
|
+
end
|
74
|
+
return obj if obj != ::Object
|
75
|
+
end
|
76
|
+
|
77
|
+
if mods=args[:extensions]
|
78
|
+
mods.each do |mod|
|
79
|
+
obj = resolve_const(mod)
|
80
|
+
raise "#{obj.name} is not a module" unless obj.kind_of? Module
|
81
|
+
STDERR.puts "Extending $burp with: #{obj.name}"
|
82
|
+
$burp.extend(obj)
|
83
|
+
if $burp.respond_to?(imeth=:"init_#{mod.split('::').last}")
|
84
|
+
$burp.__send__ imeth
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
if f=args[:restore]
|
90
|
+
raise "no such file #{f.inspect}" unless File.exists?(f)
|
91
|
+
STDERR.puts "Restoring burp state from: #{f.inspect}"
|
92
|
+
$burp.restore_state(f)
|
93
|
+
end
|
94
|
+
|
95
|
+
if args[:irb]
|
96
|
+
# yucky hack...
|
97
|
+
IRB.setup(nil)
|
98
|
+
IRB.conf[:IRB_NAME] = File.basename($0, ".rb")
|
99
|
+
module IRB
|
100
|
+
class <<self
|
101
|
+
def setup(*args); end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
puts "Global $burp is set to #{$burp.inspect}",
|
105
|
+
" Important Note: exit with $burp.close"
|
106
|
+
IRB.start()
|
107
|
+
end
|
108
|
+
|