origami 1.2.1 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (121) hide show
  1. data/README +1 -1
  2. data/bin/gui/hexview.rb +1 -1
  3. data/bin/gui/menu.rb +4 -4
  4. data/bin/gui/textview.rb +6 -4
  5. data/bin/gui/treeview.rb +4 -4
  6. data/bin/gui/walker.rb +1 -1
  7. data/bin/pdf2graph +1 -1
  8. data/bin/pdf2pdfa +1 -1
  9. data/bin/pdf2ruby +1 -1
  10. data/bin/pdfcocoon +1 -1
  11. data/bin/pdfcop +1 -1
  12. data/bin/pdfdecompress +1 -1
  13. data/bin/pdfdecrypt +1 -1
  14. data/bin/pdfencrypt +1 -1
  15. data/bin/pdfextract +75 -14
  16. data/bin/pdfmetadata +1 -1
  17. data/bin/shell/.irbrc +1 -1
  18. data/{origami.rb → lib/origami.rb} +3 -3
  19. data/{origami → lib/origami}/3d.rb +0 -0
  20. data/{origami → lib/origami}/acroform.rb +2 -2
  21. data/{origami → lib/origami}/actions.rb +0 -0
  22. data/{origami → lib/origami}/annotations.rb +0 -0
  23. data/{origami → lib/origami}/array.rb +0 -0
  24. data/{origami → lib/origami}/boolean.rb +0 -0
  25. data/{origami → lib/origami}/catalog.rb +0 -0
  26. data/{origami → lib/origami}/destinations.rb +0 -0
  27. data/{origami → lib/origami}/dictionary.rb +0 -0
  28. data/{origami → lib/origami}/docmdp.rb +0 -0
  29. data/{origami → lib/origami}/encryption.rb +9 -7
  30. data/{origami → lib/origami}/export.rb +0 -0
  31. data/lib/origami/extensions/fdf.rb +257 -0
  32. data/{origami/adobe → lib/origami/extensions}/ppklite.rb +3 -1
  33. data/{origami → lib/origami}/file.rb +0 -0
  34. data/{origami → lib/origami}/filters.rb +0 -0
  35. data/{origami → lib/origami}/filters/ascii.rb +0 -0
  36. data/{origami → lib/origami}/filters/ccitt.rb +0 -1
  37. data/{origami → lib/origami}/filters/crypt.rb +0 -0
  38. data/{origami → lib/origami}/filters/dct.rb +0 -0
  39. data/{origami → lib/origami}/filters/flate.rb +0 -0
  40. data/{origami → lib/origami}/filters/jbig2.rb +0 -0
  41. data/{origami → lib/origami}/filters/jpx.rb +0 -0
  42. data/{origami → lib/origami}/filters/lzw.rb +0 -0
  43. data/{origami → lib/origami}/filters/predictors.rb +0 -0
  44. data/{origami → lib/origami}/filters/runlength.rb +0 -0
  45. data/{origami → lib/origami}/font.rb +0 -0
  46. data/{origami → lib/origami}/functions.rb +0 -0
  47. data/{origami → lib/origami}/graphics.rb +0 -0
  48. data/{origami → lib/origami}/graphics/colors.rb +45 -23
  49. data/{origami → lib/origami}/graphics/instruction.rb +0 -0
  50. data/{origami → lib/origami}/graphics/path.rb +0 -0
  51. data/{origami → lib/origami}/graphics/patterns.rb +0 -0
  52. data/{origami → lib/origami}/graphics/render.rb +0 -0
  53. data/{origami → lib/origami}/graphics/state.rb +2 -2
  54. data/{origami → lib/origami}/graphics/text.rb +0 -0
  55. data/{origami → lib/origami}/graphics/xobject.rb +219 -0
  56. data/{origami → lib/origami}/header.rb +0 -0
  57. data/{origami → lib/origami}/javascript.rb +0 -0
  58. data/{origami → lib/origami}/linearization.rb +0 -0
  59. data/{origami → lib/origami}/metadata.rb +0 -0
  60. data/{origami → lib/origami}/name.rb +0 -0
  61. data/{origami → lib/origami}/null.rb +0 -0
  62. data/{origami → lib/origami}/numeric.rb +0 -0
  63. data/{origami → lib/origami}/obfuscation.rb +0 -0
  64. data/{origami → lib/origami}/object.rb +7 -2
  65. data/{origami → lib/origami}/outline.rb +0 -0
  66. data/{origami → lib/origami}/outputintents.rb +0 -0
  67. data/{origami → lib/origami}/page.rb +0 -0
  68. data/{origami → lib/origami}/parser.rb +76 -51
  69. data/{origami → lib/origami}/parsers/fdf.rb +9 -6
  70. data/{origami/parsers/pdf/linear.rb → lib/origami/parsers/pdf.rb} +31 -39
  71. data/lib/origami/parsers/pdf/linear.rb +84 -0
  72. data/lib/origami/parsers/ppklite.rb +93 -0
  73. data/{origami → lib/origami}/pdf.rb +6 -3
  74. data/{origami → lib/origami}/reference.rb +0 -0
  75. data/{origami → lib/origami}/signature.rb +170 -19
  76. data/{origami → lib/origami}/stream.rb +9 -0
  77. data/{origami → lib/origami}/string.rb +0 -0
  78. data/{origami → lib/origami}/trailer.rb +0 -0
  79. data/{origami → lib/origami}/webcapture.rb +0 -0
  80. data/{origami → lib/origami}/xfa.rb +0 -0
  81. data/{origami → lib/origami}/xreftable.rb +3 -7
  82. data/samples/README.txt +45 -0
  83. data/samples/actions/launch/calc.rb +87 -0
  84. data/samples/actions/launch/winparams.rb +22 -0
  85. data/samples/actions/loop/loopgoto.rb +24 -0
  86. data/samples/actions/loop/loopnamed.rb +21 -0
  87. data/samples/actions/named/named.rb +31 -0
  88. data/samples/actions/samba/smbrelay.rb +26 -0
  89. data/samples/actions/triggerevents/trigger.rb +75 -0
  90. data/samples/actions/webbug/submitform.js +26 -0
  91. data/samples/actions/webbug/webbug-browser.rb +68 -0
  92. data/samples/actions/webbug/webbug-js.rb +67 -0
  93. data/samples/actions/webbug/webbug-reader.rb +90 -0
  94. data/samples/attachments/attach.rb +40 -0
  95. data/samples/attachments/attached.txt +1 -0
  96. data/samples/crypto/crypto.rb +28 -0
  97. data/samples/digsig/signed.rb +46 -0
  98. data/samples/exploits/cve-2008-2992-utilprintf.rb +87 -0
  99. data/samples/exploits/cve-2009-0927-geticon.rb +65 -0
  100. data/samples/exploits/exploit_customdictopen.rb +55 -0
  101. data/samples/exploits/getannots.rb +69 -0
  102. data/samples/flash/flash.rb +31 -0
  103. data/samples/flash/helloworld.swf +0 -0
  104. data/samples/javascript/attached.txt +1 -0
  105. data/samples/javascript/js.rb +52 -0
  106. data/{tests → test}/ts_pdf.rb +1 -1
  107. metadata +109 -95
  108. data/origami/adobe/fdf.rb +0 -259
  109. data/origami/parsers/pdf.rb +0 -27
  110. data/origami/parsers/ppklite.rb +0 -86
  111. data/tests/dataset/test.dummycrt +0 -28
  112. data/tests/dataset/test.dummykey +0 -27
  113. data/tests/tc_actions.rb +0 -32
  114. data/tests/tc_annotations.rb +0 -85
  115. data/tests/tc_pages.rb +0 -37
  116. data/tests/tc_pdfattach.rb +0 -24
  117. data/tests/tc_pdfencrypt.rb +0 -110
  118. data/tests/tc_pdfnew.rb +0 -32
  119. data/tests/tc_pdfparse.rb +0 -98
  120. data/tests/tc_pdfsig.rb +0 -37
  121. data/tests/tc_streams.rb +0 -129
data/tests/tc_pdfnew.rb DELETED
@@ -1,32 +0,0 @@
1
- require 'test/unit'
2
- require 'stringio'
3
-
4
- class TC_PdfNew < Test::Unit::TestCase
5
-
6
- def setup
7
- @output = StringIO.new
8
- end
9
-
10
- # def teardown
11
- # end
12
-
13
- def test_pdf_struct
14
-
15
- pdf = PDF.new
16
-
17
- null = Null.new
18
- assert_nothing_raised do
19
- pdf << null
20
- end
21
-
22
- assert_nothing_raised do
23
- pdf.save(@output)
24
- end
25
-
26
- assert null.is_indirect?
27
- assert pdf.objects.include?(null)
28
- assert_equal pdf.revisions.first.body[null.reference], null
29
- assert_equal null.reference.solve, null
30
- end
31
-
32
- end
data/tests/tc_pdfparse.rb DELETED
@@ -1,98 +0,0 @@
1
- require 'test/unit'
2
-
3
- class TC_PdfParse < Test::Unit::TestCase
4
- def setup
5
- @data =
6
- %w{
7
- tests/dataset/empty.pdf
8
- tests/dataset/calc.pdf
9
- tests/dataset/crypto.pdf
10
- }
11
-
12
- @dict = StringScanner.new "<</N 2 0 R/x1 null/Pi 3.14 /a <<>>>>"
13
-
14
- @bytestring = StringScanner.new "(\\122\\125by\\n)"
15
- @hexastring = StringScanner.new "<52 55 62 79 0A>"
16
- @true = StringScanner.new "true"
17
- @false = StringScanner.new "false"
18
- @real = StringScanner.new "-3.141592653"
19
- @int = StringScanner.new "00000000002000000000000"
20
- @name = StringScanner.new "/#52#55#62#79#0A"
21
- end
22
-
23
- # def teardown
24
- # end
25
-
26
- def test_parsepdf
27
- @data.each { |file|
28
- assert_nothing_raised do
29
- PDF.read(file, :ignore_errors => false, :verbosity => Parser::VERBOSE_QUIET)
30
- end
31
- }
32
- end
33
-
34
- def test_parsedictionary
35
-
36
- dict = nil
37
- assert_nothing_raised do
38
- dict = Dictionary.parse(@dict)
39
- end
40
-
41
- assert dict[:Pi] == 3.14
42
- assert dict[:a].is_a?(Dictionary)
43
-
44
- end
45
-
46
- def test_parsestring
47
- str = nil
48
- assert_nothing_raised do
49
- str = ByteString.parse(@bytestring)
50
- end
51
-
52
- assert str.value == "RUby\n"
53
-
54
- assert_nothing_raised do
55
- str = HexaString.parse(@hexastring)
56
- end
57
-
58
- assert str.value == "RUby\n"
59
- end
60
-
61
- def test_parsebool
62
- _true, _false = nil
63
- assert_nothing_raised do
64
- _true = Boolean.parse(@true)
65
- _false = Boolean.parse(@false)
66
- end
67
-
68
- assert _false.false?
69
- assert (not _true.false?)
70
- end
71
-
72
- def test_parsereal
73
- real = nil
74
- assert_nothing_raised do
75
- real = Real.parse(@real)
76
- end
77
-
78
- assert_equal real, -3.141592653
79
- end
80
-
81
- def test_parseint
82
- int = nil
83
- assert_nothing_raised do
84
- int = Origami::Integer.parse(@int)
85
- end
86
-
87
- assert_equal int, 2000000000000
88
- end
89
-
90
- def test_parsename
91
- name = nil
92
- assert_nothing_raised do
93
- name = Name.parse(@name)
94
- end
95
-
96
- assert_equal name.value, :"RUby\n"
97
- end
98
- end
data/tests/tc_pdfsig.rb DELETED
@@ -1,37 +0,0 @@
1
- require 'test/unit'
2
- require 'stringio'
3
-
4
- class TC_PdfSig < Test::Unit::TestCase
5
-
6
- def setup
7
- @target = PDF.read("tests/dataset/calc.pdf", :ignore_errors => false, :verbosity => Parser::VERBOSE_QUIET)
8
- @output = StringIO.new
9
-
10
- @cert = OpenSSL::X509::Certificate.new(File.open("tests/dataset/test.dummycrt").read)
11
- @key = OpenSSL::PKey::RSA.new(File.open("tests/dataset/test.dummykey").read)
12
- end
13
-
14
- # def teardown
15
- # end
16
-
17
- def test_sig
18
-
19
- sigannot = Annotation::Widget::Signature.new.set_indirect(true)
20
- sigannot.Rect = Rectangle[:llx => 89.0, :lly => 386.0, :urx => 190.0, :ury => 353.0]
21
-
22
- assert_nothing_raised do
23
- @target.append_page(page = Page.new)
24
- page.add_annot(sigannot)
25
-
26
- @target.sign(@cert, @key, [], sigannot, "France", "fred@security-labs.org", "Proof of Concept (owned)")
27
- end
28
-
29
- assert @target.frozen?
30
-
31
- assert_nothing_raised do
32
- @target.save(@output)
33
- end
34
-
35
- end
36
-
37
- end
data/tests/tc_streams.rb DELETED
@@ -1,129 +0,0 @@
1
- require 'test/unit'
2
- require 'stringio'
3
-
4
- class TC_Streams < Test::Unit::TestCase
5
- def setup
6
- @target = PDF.new
7
- @output = StringIO.new
8
- @data = "0123456789" * 1024
9
- end
10
-
11
- # def teardown
12
- # end
13
-
14
- def test_predictors
15
-
16
- stm = Stream.new(@data, :Filter => :FlateDecode)
17
- stm.set_predictor(Filter::Predictor::TIFF)
18
- raw = stm.rawdata
19
- stm.data = nil
20
- stm.rawdata = raw
21
-
22
- assert_equal @data, stm.data
23
-
24
- stm = Stream.new(@data, :Filter => :FlateDecode)
25
- stm.set_predictor(Filter::Predictor::PNG_SUB)
26
- raw = stm.rawdata
27
- stm.data = nil
28
- stm.rawdata = raw
29
-
30
- assert_equal @data, stm.data
31
-
32
- stm = Stream.new(@data, :Filter => :FlateDecode)
33
- stm.set_predictor(Filter::Predictor::PNG_UP)
34
- raw = stm.rawdata
35
- stm.data = nil
36
- stm.rawdata = raw
37
-
38
- assert_equal stm.data, @data
39
-
40
- stm = Stream.new(@data, :Filter => :FlateDecode)
41
- stm.set_predictor(Filter::Predictor::PNG_AVERAGE)
42
- raw = stm.rawdata
43
- stm.data = nil
44
- stm.rawdata = raw
45
-
46
- assert_equal stm.data, @data
47
-
48
- stm = Stream.new(@data, :Filter => :FlateDecode)
49
- stm.set_predictor(Filter::Predictor::PNG_PAETH)
50
- raw = stm.rawdata
51
- stm.data = nil
52
- stm.rawdata = raw
53
-
54
- assert_equal stm.data, @data
55
-
56
- end
57
-
58
- def test_filter_flate
59
-
60
- stm = Stream.new(@data, :Filter => :FlateDecode)
61
- raw = stm.rawdata
62
- stm.data = nil
63
- stm.rawdata = raw
64
-
65
- assert_equal stm.data, @data
66
- end
67
-
68
- def test_filter_asciihex
69
-
70
- stm = Stream.new(@data, :Filter => :ASCIIHexDecode)
71
- raw = stm.rawdata
72
- stm.data = nil
73
- stm.rawdata = raw
74
-
75
- assert_equal stm.data, @data
76
- end
77
-
78
- def test_filter_ascii85
79
-
80
- stm = Stream.new(@data, :Filter => :ASCII85Decode)
81
- raw = stm.rawdata
82
- stm.data = nil
83
- stm.rawdata = raw
84
-
85
- assert_equal stm.data, @data
86
- end
87
-
88
- def test_filter_rle
89
-
90
- stm = Stream.new(@data, :Filter => :RunLengthDecode)
91
- raw = stm.rawdata
92
- stm.data = nil
93
- stm.rawdata = raw
94
-
95
- assert_equal stm.data, @data
96
- end
97
-
98
- def test_filter_lzw
99
-
100
- stm = Stream.new(@data, :Filter => :LZWDecode)
101
- raw = stm.rawdata
102
- stm.data = nil
103
- stm.rawdata = raw
104
-
105
- assert_equal stm.data, @data
106
- end
107
-
108
- def test_filter_ccittfax
109
-
110
- stm = Stream.new(@data[0, 216], :Filter => :CCITTFaxDecode)
111
-
112
- raw = stm.rawdata
113
- stm.data = nil
114
- stm.rawdata = raw
115
-
116
- assert_equal stm.data, @data[0, 216]
117
- end
118
-
119
- def test_stream
120
- stm = Stream.new(@data, :Filter => :ASCIIHexDecode )
121
- @target << stm
122
-
123
- stm.pre_build
124
- assert stm.Length == stm.rawdata.length
125
-
126
- @target.save(@output)
127
- end
128
-
129
- end