Created
December 29, 2022 00:07
-
-
Save exinmusic/659dba1c687edad0463f95c681e8a355 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import random | |
from pprint import pprint | |
import re | |
def get_cc_number(): | |
if len(sys.argv) < 2: | |
usage() | |
sys.exit(1) | |
return sys.argv[1] | |
def get_brand(number): | |
pattern = str(number) | |
if re.match("5[1-5][0-9]{14}", pattern): | |
return "MASTERCARD" | |
if re.match("4([0-9]{12}|[0-9]{15})", pattern): | |
return "VISA" | |
if re.match("3[47][0-9]{13}", pattern): | |
return "AMEX" | |
if re.match("3(0[0-5][0-9]{11}|[68][0-9]{12})", pattern): | |
return "DINERS" | |
if re.match("6011[0-9]{12}", pattern): | |
return "DISCOVER" | |
if re.match("(3[0-9]{15}|(2131|1800)[0-9]{11})", pattern): | |
return "JCB" | |
if re.match("2(014|149)[0-9]{11}", pattern): | |
return "ENROUTE" | |
return "UKNOWN" | |
def input_check(input_number): | |
if len(input_number) < 8: | |
print(f"[๐] Atleast the first octet is required. {input_number} is only {len(input_number)}.") | |
quit() | |
print(f"[๐ฐ] Input length: {len(input_number)}") | |
def validate(n): | |
r = [int(ch) for ch in str(n)][::-1] | |
return (sum(r[0::2]) + sum(sum(divmod(d*2,10)) for d in r[1::2])) % 10 == 0 | |
def create_card_numbers(first_octet): | |
# Initialize an empty list to store the valid numbers | |
valid_numbers = [] | |
all_second_octets = list(range(0, 99999999)) | |
while True: | |
# Generate a random 8-digit number as the second octet of the number | |
second_octet = all_second_octets.pop() | |
# Concatenate the first and second octets to form the 16-digit number | |
number = int(str(first_octet) + str(second_octet).rjust(8, '0')) | |
# Use the validate function to check if the number is valid | |
if validate(number): | |
# If the number is valid, append it to the list of valid numbers and print it along with its validation status | |
valid_numbers.append(number) | |
print(number, "[๐ฐ] Valid") | |
else: | |
# If the number is not valid, print it along with its validation status | |
print(number, "[๐] Not valid") | |
# If the list of valid numbers has 10 elements, return the list | |
if len(valid_numbers) == 10: | |
return set(valid_numbers) | |
def visualize_card(brand="????", number="????????????????"): | |
number=str(number)[:16].ljust(24) | |
brand=brand[:24].ljust(24) | |
print(f"""[๐ฐ] Card details generated. | |
โญ--------------------------โฎ | |
โ โ | |
โ {brand}โ | |
โ โ | |
โ {number}โ | |
โ โ | |
โ ??/?? โ | |
โฐ--------------------------โฏ""") | |
if __name__ == "__main__": | |
input_number = get_cc_number() | |
input_check(input_number) | |
validated = create_card_numbers(input_number) | |
for card in validated: | |
visualize_card(get_brand(card),card) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment