コード例 #1
0
    def compute(self, message, r_result=False):
        id, score = message.split()
        item = Item(id)
        content = item.get_content()
        all_cards = re.findall(self.regex, content)

        if len(all_cards) > 0:
            #self.redis_logger.debug(f'All matching {all_cards}')
            creditcard_set = set([])

            for card in all_cards:
                clean_card = re.sub('[^0-9]', '', card)
                if lib_refine.is_luhn_valid(clean_card):
                    self.redis_logger.debug(f'{clean_card} is valid')
                    creditcard_set.add(clean_card)

            #pprint.pprint(creditcard_set)
            to_print = f'CreditCard;{item.get_source()};{item.get_date()};{item.get_basename()};'
            if (len(creditcard_set) > 0):
                self.redis_logger.warning(
                    f'{to_print}Checked {len(creditcard_set)} valid number(s);{item.get_id()}'
                )

                #Send to duplicate
                self.send_message_to_queue(item.get_id(), 'Duplicate')

                msg = f'infoleak:automatic-detection="credit-card";{item.get_id()}'
                self.send_message_to_queue(msg, 'Tags')

                if r_result:
                    return creditcard_set
            else:
                self.redis_logger.info(
                    f'{to_print}CreditCard related;{item.get_id()}')
コード例 #2
0
ファイル: CreditCard.py プロジェクト: cs24/AIL-framework
    regex = re.compile('|'.join(cards))

    while True:
        message = p.get_from_set()
        if message is not None:
            filename, score = message.split()
            paste = Paste.Paste(filename)
            content = paste.get_p_content()
            all_cards = re.findall(regex, content)
            if len(all_cards) > 0:
                print 'All matching', all_cards
                creditcard_set = set([])

                for card in all_cards:
                    clean_card = re.sub('[^0-9]', '', card)
                    if lib_refine.is_luhn_valid(clean_card):
                        print clean_card, 'is valid'
                        creditcard_set.add(clean_card)

                paste.__setattr__(channel, creditcard_set)
                paste.save_attribute_redis(channel, creditcard_set)

                pprint.pprint(creditcard_set)
                to_print = 'CreditCard;{};{};{};'.format(
                    paste.p_source, paste.p_date, paste.p_name)
                if (len(creditcard_set) > 0):
                    publisher.warning('{}Checked {} valid number(s)'.format(
                        to_print, len(creditcard_set)))
                else:
                    publisher.info('{}CreditCard related'.format(to_print))
        else:
コード例 #3
0
    #                   [3-9]\d)|[2-8]\d\d|9(?:[01]\d|2[0-5])))\d{10}"
    # jcb_regex = "35(?:2[89]|[3-8]\d)([\ \-]?)\d{4}\1\d{4}\1\d{4}"
    # amex_regex = "3[47]\d\d([\ \-]?)\d{6}\1\d{5}"
    # chinaUP_regex = "62[0-5]\d{13,16}"
    # maestro_regex = "(?:5[0678]\d\d|6304|6390|67\d\d)\d{8,15}"

    while True:
        if message is not None:
            channel, filename, word, score = message.split()

            if prec_filename is None or filename != prec_filename:
                creditcard_set = set([])
                PST = Paste.Paste(filename)

                for x in PST.get_regex(creditcard_regex):
                    if lib_refine.is_luhn_valid(x):
                        creditcard_set.add(x)

                PST.__setattr__(channel, creditcard_set)
                PST.save_attribute_redis(channel, creditcard_set)

                pprint.pprint(creditcard_set)
                to_print = 'CreditCard;{};{};{};'.format(
                    PST.p_source, PST.p_date, PST.p_name)
                if (len(creditcard_set) > 0):
                    publisher.critical('{}Checked {} valid number(s)'.format(
                        to_print, len(creditcard_set)))
                else:
                    publisher.info('{}CreditCard related'.format(to_print))

            prec_filename = filename
コード例 #4
0
ファイル: CreditCards.py プロジェクト: Rafiot/AIL-framework
    regex = re.compile('|'.join(cards))

    while True:
        message = p.get_from_set()
        if message is not None:
            filename, score = message.split()
            paste = Paste.Paste(filename)
            content = paste.get_p_content()
            all_cards = re.findall(regex, content)
            if len(all_cards) > 0:
                print 'All matching', all_cards
                creditcard_set = set([])

                for card in all_cards:
                    clean_card = re.sub('[^0-9]', '', card)
                    if lib_refine.is_luhn_valid(clean_card):
                        print clean_card, 'is valid'
                        creditcard_set.add(clean_card)

                paste.__setattr__(channel, creditcard_set)
                paste.save_attribute_redis(channel, creditcard_set)

                pprint.pprint(creditcard_set)
                to_print = 'CreditCard;{};{};{};'.format(
                    paste.p_source, paste.p_date, paste.p_name)
                if (len(creditcard_set) > 0):
                    publisher.warning('{}Checked {} valid number(s)'.format(
                        to_print, len(creditcard_set)))
                    #Send to duplicate
                    p.populate_set_out(filename, 'Duplicate')
                    #send to Browse_warning_paste
コード例 #5
0
ファイル: CreditCard.py プロジェクト: jumojer/SAIL-framework
            filename = message
            try:
                paste = Paste.Paste(filename)
            except OSError:
                print "Paste is gone."
                Paste.Paste(filename, False).analysis_done()
                continue
            content = paste.get_p_content()
            all_cards = re.findall(regex, content)
            if len(all_cards) > 0:
                creditcard_set = set()
                contexts_set = set()

                for match_groups in all_cards:
                    clean_card = re.sub('[^0-9]', '', match_groups[1])
                    if clean_card is not "" and lib_refine.is_luhn_valid(clean_card):
                        positive = None
                        try:
                            while positive is None:
                                try:
                                    positive, bank = lib_refine.binlist_check(clean_card, banks_regex)
                                except EnvironmentError as e:
                                    print e
                                    print "Sleeping 15 min"
                                    time.sleep(900)
                                    positive = None
                                    continue
                            if positive:
                                creditcard_set.add(clean_card)
                                contexts_set.add(match_groups[0])
                        except RuntimeError as e:
コード例 #6
0
def main():
    """Main Function"""

    # CONFIG #
    cfg = ConfigParser.ConfigParser()
    cfg.read(configfile)

    # REDIS #
    r_serv = redis.StrictRedis(
        host = cfg.get("Redis_Queues", "host"),
        port = cfg.getint("Redis_Queues", "port"),
        db = cfg.getint("Redis_Queues", "db"))

    r_serv1 = redis.StrictRedis(
        host = cfg.get("Redis_Data_Merging", "host"),
        port = cfg.getint("Redis_Data_Merging", "port"),
        db = cfg.getint("Redis_Data_Merging", "db"))

    p_serv = r_serv.pipeline(False)

    # LOGGING #
    publisher.channel = "Script"

    # ZMQ #
    Sub = ZMQ_PubSub.ZMQSub(configfile, "PubSub_Categ", "creditcard_categ", "cards")

    # FUNCTIONS #
    publisher.info("Creditcard script subscribed to channel creditcard_categ")

    message = Sub.get_msg_from_queue(r_serv)
    prec_filename = None

    creditcard_regex = "4[0-9]{12}(?:[0-9]{3})?"

    mastercard_regex = "5[1-5]\d{2}([\ \-]?)\d{4}\1\d{4}\1\d{4}"
    visa_regex = "4\d{3}([\ \-]?)\d{4}\1\d{4}\1\d{4}"
    discover_regex = "6(?:011\d\d|5\d{4}|4[4-9]\d{3}|22(?:1(?:2[6-9]|[3-9]\d)|[2-8]\d\d|9(?:[01]\d|2[0-5])))\d{10}"
    jcb_regex = "35(?:2[89]|[3-8]\d)([\ \-]?)\d{4}\1\d{4}\1\d{4}"
    amex_regex = "3[47]\d\d([\ \-]?)\d{6}\1\d{5}"
    chinaUP_regex = "62[0-5]\d{13,16}"
    maestro_regex = "(?:5[0678]\d\d|6304|6390|67\d\d)\d{8,15}"

    while True:
        if message != None:
            channel, filename, word, score  = message.split()

            if prec_filename == None or filename != prec_filename:
                Creditcard_set = set([])
                PST = P.Paste(filename)

                for x in PST.get_regex(creditcard_regex):
                    if lib_refine.is_luhn_valid(x):
                        Creditcard_set.add(x)


                PST.__setattr__(channel, Creditcard_set)
                PST.save_attribute_redis(r_serv1, channel, Creditcard_set)

                pprint.pprint(Creditcard_set)
                if (len(Creditcard_set) > 0):
                    publisher.critical('{0};{1};{2};{3};{4}'.format("CreditCard", PST.p_source, PST.p_date, PST.p_name,"Checked " + str(len(Creditcard_set))+" valid number(s)" ))
                else:
                    publisher.info('{0};{1};{2};{3};{4}'.format("CreditCard", PST.p_source, PST.p_date, PST.p_name, "CreditCard related" ))

            prec_filename = filename

        else:
            if r_serv.sismember("SHUTDOWN_FLAGS", "Creditcards"):
                r_serv.srem("SHUTDOWN_FLAGS", "Creditcards")
                print "Shutdown Flag Up: Terminating"
                publisher.warning("Shutdown Flag Up: Terminating.")
                break
            publisher.debug("Script creditcard is idling 1m")
            time.sleep(60)

        message = Sub.get_msg_from_queue(r_serv)