Created
September 18, 2017 11:31
-
-
Save tqkve/28bde8edeef4baebda460c6c8e8e646f to your computer and use it in GitHub Desktop.
This file contains hidden or 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 random | |
| visaPrefix = ["4539", "4556", "4916", "4532", "4929", "40240071", "4485", "4716", "4"] | |
| mcPrefix = ["51", "52", "53", "54", "55"] | |
| amexPrefix = ["34", "37"] | |
| disPrefix = ["6011"] | |
| dinnerPrefix = ["300", "301", "302", "303", "36", "38"] | |
| def get_last_digit(ccn): | |
| length = len(ccn) + 1 | |
| _sum = 0 | |
| pos = 0 | |
| r_ccn = [] | |
| r_ccn.extend(ccn) | |
| r_ccn.reverse() | |
| while pos < length - 1: | |
| odd = int(r_ccn[pos]) * 2 | |
| if odd > 9: | |
| odd -= 9 | |
| _sum += odd | |
| if pos != (length - 2): | |
| _sum += int(r_ccn[pos + 1]) | |
| pos += 2 | |
| return str(((_sum / 10 + 1) * 10 - _sum) % 10) | |
| def gen_card(_type): | |
| if _type == "visa": | |
| ccn = random.choice(visaPrefix) | |
| elif _type == "master": | |
| ccn = random.choice(mcPrefix) | |
| elif _type == "dis": | |
| ccn = random.choice(disPrefix) | |
| elif _type == "amex": | |
| ccn = random.choice(amexPrefix) | |
| elif _type == "dinner": | |
| ccn = random.choice(dinnerPrefix) | |
| else: | |
| ccn = _type | |
| if ccn.startswith("4"): | |
| length = 16 | |
| elif ccn.startswith("30") or ccn.startswith("36") or ccn.startswith("38"): | |
| length = 14 | |
| elif ccn.startswith("34") or ccn.startswith("37"): | |
| length = 15 | |
| elif ccn.startswith("5") or ccn.startswith("6011"): | |
| length = 16 | |
| else: | |
| length = 16 | |
| while len(ccn) < (length - 1): | |
| digit = str(random.choice(range(0, 10))) | |
| ccn += digit | |
| ccn += get_last_digit(ccn) | |
| return ccn | |
| import socket | |
| import re | |
| s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
| s.connect(("misc.chal.csaw.io", 8308)) | |
| while 1: | |
| need = s.recv(1024) | |
| print need | |
| if "MasterCard" in need: | |
| answer = gen_card("master") | |
| elif "Visa" in need: | |
| answer = gen_card("visa") | |
| elif "American" in need: | |
| answer = gen_card("amex") | |
| elif "Discover" in need: | |
| answer = gen_card("dis") | |
| elif "starts with" in need: | |
| answer = gen_card(re.findall("\d+", need)[0]) | |
| elif "ends with" in need: | |
| answer = "" | |
| while not answer.endswith(re.findall("\d+", need)[0]): | |
| answer = gen_card(random.choice(["3", "4", "5", "6"])) | |
| elif "Yes" in need: | |
| ccn = re.findall("\d{10,}", need)[0] | |
| if len(ccn) != 16: answer = "0" | |
| elif get_last_digit(ccn[:-1]) == ccn[-1]: answer = "1" | |
| else: answer = "0" | |
| else: | |
| print "hmmmm" | |
| break | |
| print "Sending %s" %answer | |
| s.send(answer + "\n") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment