Module: PWN::Plugins::ScannableCodes
- Defined in:
- lib/pwn/plugins/scannable_codes.rb
Overview
This plugin is used to Create Scannable BarCodes and QR Codes
Class Method Summary collapse
-
.authors ⇒ Object
- Author(s)
-
0day Inc.
-
.generate(opts = {}) ⇒ Object
- Supported Method Parameters
-
response = PWN::Plugins::ScannableCodes.generate( data: ‘required - data to encode’, type: ‘optional - :barcode || :qrcode (defaults to :qrcode)’, size: ‘optional - size of the image when type is :qrcode (defaults to 200)’, path: ‘optional - path to save image (defaults to “./#data.png”)’ return_type: ‘optional - :base64 || :file (defaults to :file)’ ).
-
.help ⇒ Object
Display Usage for this Module.
Class Method Details
.authors ⇒ Object
- Author(s)
-
0day Inc. <[email protected]>
65 66 67 68 69 |
# File 'lib/pwn/plugins/scannable_codes.rb', line 65 public_class_method def self. "AUTHOR(S): 0day Inc. <[email protected]> " end |
.generate(opts = {}) ⇒ Object
- Supported Method Parameters
-
response = PWN::Plugins::ScannableCodes.generate(
data: 'required - data to encode', type: 'optional - :barcode || :qrcode (defaults to :qrcode)', size: 'optional - size of the image when type is :qrcode (defaults to 200)', path: 'optional - path to save image (defaults to "./#{data}.png")' return_type: 'optional - :base64 || :file (defaults to :file)'
)
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/pwn/plugins/scannable_codes.rb', line 22 public_class_method def self.generate(opts = {}) data = opts[:data] raise 'ERROR: option data is required.' unless data type = opts[:type] type ||= :qrcode size = opts[:size] raise 'ERROR: size is only applicable when type is :qrcode.' if size && type != :qrcode path = opts[:path] path ||= "./#{data}.png" return_type = opts[:return_type] ||= :file case type when :barcode = Barby::Code128B.new(data) .to_png.save(path) when :qrcode size ||= 200 qrcode = RQRCode::QRCode.new(data) png = qrcode.as_png png.resize(size, size).save(path) else raise 'ERROR: type must be :barcode or :qrcode.' end data = "Saved #{type} to #{path}" if return_type == :base64 data = Base64.strict_encode64(File.binread(path)) FileUtils.rm_f(path) end data rescue Interrupt puts "\nGoodbye." rescue StandardError => e raise e end |
.help ⇒ Object
Display Usage for this Module
73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/pwn/plugins/scannable_codes.rb', line 73 public_class_method def self.help puts "USAGE: #{self}.generate( data: 'required - data to encode', type: 'optional - :barcode || :qrcode (defaults to :qrcode)', size: 'optional - size of the image when type is :qrcode (defaults to 200)', path: 'optional - path to save image (defaults to \"./\#{data}.png\")' ) #{self}.authors " end |