generator/credit_card_data: outputs credit card type and number

This commit is contained in:
thomashaw
2017-09-05 17:41:50 +01:00
parent 489eb76e47
commit 02f191104d
6 changed files with 54 additions and 0 deletions

View File

@@ -12,6 +12,7 @@ gem 'mini_exiftool_vendored'
gem 'rmagick'
gem 'sshkey'
gem 'zipruby'
gem 'credy'
#development only gems go here
group :test, :development do

View File

@@ -3,6 +3,8 @@ GEM
specs:
CFPropertyList (2.2.8)
chunky_png (1.3.8)
credy (0.2.1)
thor (~> 0.19.1)
facter (2.4.6)
CFPropertyList (~> 2.2.6)
faker (1.6.6)
@@ -66,6 +68,7 @@ PLATFORMS
ruby
DEPENDENCIES
credy
faker
forgery
librarian-puppet

View File

@@ -0,0 +1,31 @@
#!/usr/bin/ruby
require_relative '../../../../../lib/objects/local_string_generator.rb'
require 'credy'
class CreditCardGenerator < StringGenerator
def initialize
super
self.module_name = 'Credit Card Number Generator'
end
def generate
selected_type = [['americanexpress', 'American Express'],
['diners-club-international', 'Diners Club International'],
['china-unionpay', 'China UnionPay'],
['laser', 'Laser'],
['maestro', 'Maestro'],
['mastercard', 'Mastercard'],
['solo', 'Solo'],
['switch', 'Switch'],
['visa', 'Visa'],
['visa-electron', 'Visa Electron']].sample
card_data = Credy::CreditCard.generate(:type => selected_type[0])
card_data_formatted = card_data[:number].scan(/.{1,4}/).join(' ') # add a space every 4 characters
card_string = "#{selected_type[1]}\t#{card_data_formatted}"
self.outputs << card_string
end
end
CreditCardGenerator.new.run

View File

@@ -0,0 +1,19 @@
<?xml version="1.0"?>
<generator xmlns="http://www.github/cliffe/SecGen/generator"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.github/cliffe/SecGen/generator">
<name>Industry Generator</name>
<author>Thomas Shaw</author>
<module_license>MIT</module_license>
<description>Industry generator using the Forgery ruby gem.</description>
<type>credit_card</type>
<type>local_calculation</type>
<platform>linux</platform>
<platform>windows</platform>
<reference>https://github.com/TimPetricola/Credy</reference>
<output_type>industry</output_type>
</generator>