mirror of
https://github.com/cliffe/SecGen.git
synced 2026-02-20 13:50:45 +00:00
generator/credit_card_data: outputs credit card type and number
This commit is contained in:
1
Gemfile
1
Gemfile
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
31
modules/generators/content/credit_card/secgen_local/local.rb
Normal file
31
modules/generators/content/credit_card/secgen_local/local.rb
Normal 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
|
||||
19
modules/generators/content/credit_card/secgen_metadata.xml
Normal file
19
modules/generators/content/credit_card/secgen_metadata.xml
Normal 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>
|
||||
Reference in New Issue
Block a user