#!/usr/bin/env ruby # frozen_string_literal: true require 'optparse' opts = {} OptionParser.new do |options| options.banner = "USAGE: #{File.basename($PROGRAM_NAME)} [opts] " options.on('-pSTRING', '--payload=STRING', '') do |p| opts[:payload] = p end end.parse! if opts.empty? puts `#{File.basename($PROGRAM_NAME)} --help` exit 1 end payload = opts[:payload].to_s.scrub payload.each_char do |char| print "\\x#{char.to_s.unpack1('H*')}" end print "\n"