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
data/origami/parsers/pdf.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
=begin
|
2
|
-
|
3
|
-
= File
|
4
|
-
parsers/pdf.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/parsers/pdf/linear'
|
27
|
-
|
data/origami/parsers/ppklite.rb
DELETED
@@ -1,86 +0,0 @@
|
|
1
|
-
=begin
|
2
|
-
|
3
|
-
= File
|
4
|
-
parsers/ppklite.rb
|
5
|
-
|
6
|
-
= Info
|
7
|
-
Origami is free software: you can redistribute it and/or modify
|
8
|
-
it under the terms of the GNU Lesser General Public License as published by
|
9
|
-
the Free Software Foundation, either version 3 of the License, or
|
10
|
-
(at your option) any later version.
|
11
|
-
|
12
|
-
Origami is distributed in the hope that it will be useful,
|
13
|
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
-
GNU Lesser General Public License for more details.
|
16
|
-
|
17
|
-
You should have received a copy of the GNU Lesser General Public License
|
18
|
-
along with Origami. If not, see <http://www.gnu.org/licenses/>.
|
19
|
-
|
20
|
-
=end
|
21
|
-
|
22
|
-
require 'origami/parser'
|
23
|
-
require 'origami/adobe/ppklite'
|
24
|
-
|
25
|
-
module Origami
|
26
|
-
|
27
|
-
class Adobe::PPKLite
|
28
|
-
class Parser < Origami::Parser
|
29
|
-
def parse(stream) #:nodoc:
|
30
|
-
super
|
31
|
-
|
32
|
-
addrbk = Adobe::PPKLite.new
|
33
|
-
addrbk.header = Adobe::PPKLite::Header.parse(stream)
|
34
|
-
@options[:callback].call(addrbk.header)
|
35
|
-
|
36
|
-
parse_objects(addrbk)
|
37
|
-
parse_xreftable(addrbk)
|
38
|
-
parse_trailer(addrbk)
|
39
|
-
book_specialize_entries(addrbk)
|
40
|
-
|
41
|
-
addrbk
|
42
|
-
end
|
43
|
-
|
44
|
-
def book_specialize_entries(addrbk) #:nodoc:
|
45
|
-
addrbk.revisions.first.body.each_pair do |ref, obj|
|
46
|
-
|
47
|
-
if obj.is_a?(Dictionary)
|
48
|
-
|
49
|
-
if obj[:Type] == :Catalog
|
50
|
-
|
51
|
-
o = Adobe::PPKLite::Catalog.new(obj)
|
52
|
-
o.generation, o.no, o.file_offset = obj.generation, obj.no, obj.file_offset
|
53
|
-
|
54
|
-
if o.PPK.is_a?(Dictionary) and o.PPK[:Type] == :PPK
|
55
|
-
o.PPK = Adobe::PPKLite::PPK.new(o.PPK)
|
56
|
-
|
57
|
-
if o.PPK.User.is_a?(Dictionary) and o.PPK.User[:Type] == :User
|
58
|
-
o.PPK.User = Adobe::PPKLite::UserList.new(o.PPK.User)
|
59
|
-
end
|
60
|
-
|
61
|
-
if o.PPK.AddressBook.is_a?(Dictionary) and o.PPK.AddressBook[:Type] == :AddressBook
|
62
|
-
o.PPK.AddressBook = Adobe::PPKLite::AddressList.new(o.PPK.AddressBook)
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
addrbk.revisions.first.body[ref] = o
|
67
|
-
|
68
|
-
elsif obj[:ABEType] == Adobe::PPKLite::Descriptor::USER
|
69
|
-
o = Adobe::PPKLite::User.new(obj)
|
70
|
-
o.generation, o.no, o.file_offset = obj.generation, obj.no, obj.file_offset
|
71
|
-
|
72
|
-
addrbk.revisions.first.body[ref] = o
|
73
|
-
elsif obj[:ABEType] == Adobe::PPKLite::Descriptor::CERTIFICATE
|
74
|
-
o = Adobe::PPKLite::Certificate.new(obj)
|
75
|
-
o.generation, o.no, o.file_offset = obj.generation, obj.no, obj.file_offset
|
76
|
-
|
77
|
-
addrbk.revisions.first.body[ref] = o
|
78
|
-
end
|
79
|
-
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
data/tests/dataset/test.dummycrt
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
-----BEGIN CERTIFICATE-----
|
2
|
-
MIIE0zCCA7ugAwIBAgIJAPsOg8mXiWmIMA0GCSqGSIb3DQEBBQUAMIGhMQswCQYD
|
3
|
-
VQQGEwJGUjEWMBQGA1UECBMNSWxlLWRlLUZyYW5jZTEOMAwGA1UEBxMFUGFyaXMx
|
4
|
-
DzANBgNVBAoTBlNvZ2V0aTENMAsGA1UECxMERVNFQzEaMBgGA1UEAxQRR3VpbGxh
|
5
|
-
dW1lIERlbHVncoIxLjAsBgkqhkiG9w0BCQEWH2RhcmtwaG9lbml4QGJpbmFyeS1y
|
6
|
-
ZXZlcnNlci5vcmcwHhcNMDgwODIwMTIyMTMxWhcNMTgwODE4MTIyMTMxWjCBoTEL
|
7
|
-
MAkGA1UEBhMCRlIxFjAUBgNVBAgTDUlsZS1kZS1GcmFuY2UxDjAMBgNVBAcTBVBh
|
8
|
-
cmlzMQ8wDQYDVQQKEwZTb2dldGkxDTALBgNVBAsTBEVTRUMxGjAYBgNVBAMUEUd1
|
9
|
-
aWxsYXVtZSBEZWx1Z3KCMS4wLAYJKoZIhvcNAQkBFh9kYXJrcGhvZW5peEBiaW5h
|
10
|
-
cnktcmV2ZXJzZXIub3JnMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA
|
11
|
-
pU1Hrr0RnHsh0dP5V8BPX+Q/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
|
-
|
3
|
-
class TC_Actions < Test::Unit::TestCase
|
4
|
-
def setup
|
5
|
-
@target = PDF.new
|
6
|
-
@page = Page.new
|
7
|
-
@action = Action::JavaScript.new "app.alert(null);"
|
8
|
-
end
|
9
|
-
|
10
|
-
# def teardown
|
11
|
-
# end
|
12
|
-
|
13
|
-
def test_pdf_actions
|
14
|
-
@target.onDocumentOpen @action
|
15
|
-
@target.onDocumentClose @action
|
16
|
-
@target.onDocumentPrint @action
|
17
|
-
|
18
|
-
assert_equal @target.Catalog.OpenAction, @action
|
19
|
-
assert_equal @target.Catalog.AA.WC, @action
|
20
|
-
assert_equal @target.Catalog.AA.WP, @action
|
21
|
-
end
|
22
|
-
|
23
|
-
def test_page_actions
|
24
|
-
|
25
|
-
@page.onOpen @action
|
26
|
-
@page.onClose @action
|
27
|
-
|
28
|
-
assert_equal @page.AA.O, @action
|
29
|
-
assert_equal @page.AA.C, @action
|
30
|
-
end
|
31
|
-
|
32
|
-
end
|
data/tests/tc_annotations.rb
DELETED
@@ -1,85 +0,0 @@
|
|
1
|
-
require 'test/unit'
|
2
|
-
require 'stringio'
|
3
|
-
|
4
|
-
class TC_Annotations< Test::Unit::TestCase
|
5
|
-
def setup
|
6
|
-
@target = PDF.new
|
7
|
-
@page = Page.new
|
8
|
-
@action = Action::JavaScript.new "app.alert(null);"
|
9
|
-
@output = StringIO.new
|
10
|
-
end
|
11
|
-
|
12
|
-
# def teardown
|
13
|
-
# end
|
14
|
-
|
15
|
-
def test_annotations
|
16
|
-
|
17
|
-
circle = Annotation::Circle.new
|
18
|
-
square = Annotation::Square.new
|
19
|
-
text = Annotation::Text.new
|
20
|
-
link = Annotation::Link.new
|
21
|
-
file = Annotation::FileAttachment.new
|
22
|
-
screen = Annotation::Screen.new
|
23
|
-
sound = Annotation::Sound.new
|
24
|
-
pushbutton = Annotation::Widget::PushButton.new
|
25
|
-
checkbox = Annotation::Widget::CheckBox.new
|
26
|
-
radio = Annotation::Widget::Radio.new
|
27
|
-
edit = Annotation::Widget::Text.new
|
28
|
-
combo = Annotation::Widget::ComboBox.new
|
29
|
-
list = Annotation::Widget::ListBox.new
|
30
|
-
sig = Annotation::Widget::Signature.new
|
31
|
-
|
32
|
-
@target.append_page @page
|
33
|
-
|
34
|
-
assert_nothing_raised do
|
35
|
-
@page.add_annot circle
|
36
|
-
@page.add_annot square
|
37
|
-
@page.add_annot text
|
38
|
-
@page.add_annot link
|
39
|
-
@page.add_annot file
|
40
|
-
@page.add_annot screen
|
41
|
-
@page.add_annot sound
|
42
|
-
@page.add_annot pushbutton
|
43
|
-
@page.add_annot checkbox
|
44
|
-
@page.add_annot radio
|
45
|
-
@page.add_annot edit
|
46
|
-
@page.add_annot combo
|
47
|
-
@page.add_annot list
|
48
|
-
@page.add_annot sig
|
49
|
-
end
|
50
|
-
|
51
|
-
assert_nothing_raised do
|
52
|
-
@target.save(@output)
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
def test_annotation_actions
|
57
|
-
|
58
|
-
screen = Annotation::Screen.new
|
59
|
-
|
60
|
-
@page.add_annot screen
|
61
|
-
|
62
|
-
screen.onMouseOver @action
|
63
|
-
screen.onMouseOut @action
|
64
|
-
screen.onMouseDown @action
|
65
|
-
screen.onMouseUp @action
|
66
|
-
screen.onFocus @action
|
67
|
-
screen.onBlur @action
|
68
|
-
screen.onPageOpen @action
|
69
|
-
screen.onPageClose @action
|
70
|
-
screen.onPageVisible @action
|
71
|
-
screen.onPageInvisible @action
|
72
|
-
|
73
|
-
assert_equal screen.AA.E, @action
|
74
|
-
assert_equal screen.AA.X, @action
|
75
|
-
assert_equal screen.AA.D, @action
|
76
|
-
assert_equal screen.AA.U, @action
|
77
|
-
assert_equal screen.AA.Fo, @action
|
78
|
-
assert_equal screen.AA.Bl, @action
|
79
|
-
assert_equal screen.AA.PO, @action
|
80
|
-
assert_equal screen.AA.PC, @action
|
81
|
-
assert_equal screen.AA.PV, @action
|
82
|
-
assert_equal screen.AA.PI, @action
|
83
|
-
end
|
84
|
-
|
85
|
-
end
|
data/tests/tc_pages.rb
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
require 'test/unit'
|
2
|
-
require 'stringio'
|
3
|
-
|
4
|
-
class TC_Pages < Test::Unit::TestCase
|
5
|
-
def setup
|
6
|
-
@target = PDF.new
|
7
|
-
@output = StringIO.new
|
8
|
-
end
|
9
|
-
|
10
|
-
# def teardown
|
11
|
-
# end
|
12
|
-
|
13
|
-
def test_appendpage
|
14
|
-
p1, p2, p3 = Page.new, Page.new, Page.new
|
15
|
-
|
16
|
-
assert_nothing_raised do
|
17
|
-
@target.append_page p1, p2, p3
|
18
|
-
end
|
19
|
-
|
20
|
-
assert_equal @target.pages.size, 3
|
21
|
-
|
22
|
-
assert_equal @target.pages[0], p1
|
23
|
-
assert_equal @target.pages[1], p2
|
24
|
-
assert_equal @target.pages[2], p3
|
25
|
-
|
26
|
-
assert_equal @target.Catalog.Pages, p1.Parent
|
27
|
-
assert_equal @target.Catalog.Pages, p2.Parent
|
28
|
-
assert_equal @target.Catalog.Pages, p3.Parent
|
29
|
-
|
30
|
-
assert_nothing_raised do
|
31
|
-
@target.save(@output)
|
32
|
-
end
|
33
|
-
|
34
|
-
assert_equal @target.Catalog.Pages.Count, 3
|
35
|
-
end
|
36
|
-
|
37
|
-
end
|
data/tests/tc_pdfattach.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
require 'test/unit'
|
2
|
-
require 'stringio'
|
3
|
-
|
4
|
-
class TC_PdfAttach < Test::Unit::TestCase
|
5
|
-
def setup
|
6
|
-
@target = PDF.new
|
7
|
-
@attachment = "tests/dataset/test.dummycrt"
|
8
|
-
@output = StringIO.new
|
9
|
-
end
|
10
|
-
|
11
|
-
# def teardown
|
12
|
-
# end
|
13
|
-
|
14
|
-
def test_attachfile
|
15
|
-
assert_nothing_raised do
|
16
|
-
fspec = @target.attach_file(@attachment, :EmbeddedName => "foo.bar")
|
17
|
-
end
|
18
|
-
|
19
|
-
assert_nothing_raised do
|
20
|
-
@target.save(@output)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
end
|
data/tests/tc_pdfencrypt.rb
DELETED
@@ -1,110 +0,0 @@
|
|
1
|
-
require 'test/unit'
|
2
|
-
require 'stringio'
|
3
|
-
|
4
|
-
class TC_PdfEncrypt < Test::Unit::TestCase
|
5
|
-
def setup
|
6
|
-
@target = PDF.read("tests/dataset/calc.pdf", :ignore_errors => false, :verbosity => Parser::VERBOSE_QUIET)
|
7
|
-
@output = StringIO.new
|
8
|
-
end
|
9
|
-
|
10
|
-
# def teardown
|
11
|
-
# end
|
12
|
-
|
13
|
-
def test_encrypt_rc4_40b
|
14
|
-
@output.string = ""
|
15
|
-
assert_nothing_raised do
|
16
|
-
@target.encrypt(:cipher => 'rc4', :key_size => 40).save(@output);
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
def test_encrypt_rc4_128b
|
21
|
-
@output.string = ""
|
22
|
-
assert_nothing_raised do
|
23
|
-
@target.encrypt(:cipher => 'rc4').save(@output);
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
def test_encrypt_aes_128b
|
28
|
-
@output.string = ""
|
29
|
-
assert_nothing_raised do
|
30
|
-
@target.encrypt(:cipher => 'aes').save(@output);
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
def test_decrypt_rc4_40b
|
35
|
-
pdf = nil
|
36
|
-
@output.string = ""
|
37
|
-
assert_nothing_raised do
|
38
|
-
pdf = PDF.new.encrypt(:cipher => 'rc4', :key_size => 40)
|
39
|
-
pdf.Catalog[:Test] = "test"
|
40
|
-
pdf.save(@output)
|
41
|
-
end
|
42
|
-
|
43
|
-
assert_not_equal pdf.Catalog[:Test], "test"
|
44
|
-
|
45
|
-
assert_nothing_raised do
|
46
|
-
@output = @output.reopen(@output.string, "r")
|
47
|
-
pdf = PDF.read(@output, :ignore_errors => false, :verbosity => Parser::VERBOSE_QUIET)
|
48
|
-
end
|
49
|
-
|
50
|
-
assert_equal pdf.Catalog[:Test], "test"
|
51
|
-
end
|
52
|
-
|
53
|
-
def test_decrypt_rc4_128b
|
54
|
-
pdf = nil
|
55
|
-
@output.string = ""
|
56
|
-
assert_nothing_raised do
|
57
|
-
pdf = PDF.new.encrypt(:cipher => 'rc4')
|
58
|
-
pdf.Catalog[:Test] = "test"
|
59
|
-
pdf.save(@output)
|
60
|
-
end
|
61
|
-
|
62
|
-
assert_not_equal pdf.Catalog[:Test], "test"
|
63
|
-
|
64
|
-
assert_nothing_raised do
|
65
|
-
@output.reopen(@output.string, "r")
|
66
|
-
pdf = PDF.read(@output, :ignore_errors => false, :verbosity => Parser::VERBOSE_QUIET)
|
67
|
-
end
|
68
|
-
|
69
|
-
assert_equal pdf.Catalog[:Test], "test"
|
70
|
-
end
|
71
|
-
|
72
|
-
def test_decrypt_aes_128b
|
73
|
-
pdf = nil
|
74
|
-
@output.string = ""
|
75
|
-
assert_nothing_raised do
|
76
|
-
pdf = PDF.new.encrypt(:cipher => 'aes')
|
77
|
-
pdf.Catalog[:Test] = "test"
|
78
|
-
pdf.save(@output)
|
79
|
-
end
|
80
|
-
|
81
|
-
assert_not_equal pdf.Catalog[:Test], "test"
|
82
|
-
|
83
|
-
assert_nothing_raised do
|
84
|
-
@output = @output.reopen(@output.string, "r")
|
85
|
-
pdf = PDF.read(@output, :ignore_errors => false, :verbosity => Parser::VERBOSE_QUIET)
|
86
|
-
end
|
87
|
-
|
88
|
-
assert_equal pdf.Catalog[:Test], "test"
|
89
|
-
end
|
90
|
-
|
91
|
-
def test_decrypt_aes_256b
|
92
|
-
pdf = nil
|
93
|
-
@output.string = ""
|
94
|
-
assert_nothing_raised do
|
95
|
-
pdf = PDF.new.encrypt(:cipher => 'aes', :key_size => 256)
|
96
|
-
pdf.Catalog[:Test] = "test"
|
97
|
-
pdf.save(@output)
|
98
|
-
end
|
99
|
-
|
100
|
-
assert_not_equal pdf.Catalog[:Test], "test"
|
101
|
-
|
102
|
-
assert_nothing_raised do
|
103
|
-
@output = @output.reopen(@output.string, "r")
|
104
|
-
pdf = PDF.read(@output, :ignore_errors => false, :verbosity => Parser::VERBOSE_QUIET)
|
105
|
-
end
|
106
|
-
|
107
|
-
assert_equal pdf.Catalog[:Test], "test"
|
108
|
-
end
|
109
|
-
|
110
|
-
end
|