示例#1
0
def single_search(ioc):
    os.chdir('../intel')
    dirs = os.listdir('.')

    if len(dirs) == 0:
        sys.stderr.write("[!] Cannot complete search, no files in intel directory. Exiting..\n")
        sys.exit(0)

    total = float(len(dirs))
    print 'There are %d files in Intel dir' % total

    frac = 1.0/total
    prog = 0.0
    matched = open('../matches.txt', 'w+')
    matches = 0

    for i_file in dirs:
        f2 = open(i_file, 'r')
        contents = f2.readlines()
        for line in contents:
            if ioc in line:
                info = line.rstrip('\n') + ' --> ' + i_file + '\n'
                matched.write(info)
                matches += 1
            else:
                pass
            f2.close()

        prog += frac
        tools.update_progress(prog)


    print '[+] Search complete.'
    print '%d matches found and stored in matches.txt' % matches
示例#2
0
def single_search(ioc):
    os.chdir('../intel')
    dirs = os.listdir('.')

    if len(dirs) == 0:
        sys.stderr.write(
            "[!] Cannot complete search, no files in intel directory. Exiting..\n"
        )
        sys.exit(0)

    total = float(len(dirs))
    print 'There are %d files in Intel dir' % total

    frac = 1.0 / total
    prog = 0.0
    matched = open('../matches.txt', 'w+')
    matches = 0

    for i_file in dirs:
        f2 = open(i_file, 'r')
        contents = f2.readlines()
        for line in contents:
            if ioc in line:
                info = line.rstrip('\n') + ' --> ' + i_file + '\n'
                matched.write(info)
                matches += 1
            else:
                pass
            f2.close()

        prog += frac
        tools.update_progress(prog)

    print '[+] Search complete.'
    print '%d matches found and stored in matches.txt' % matches
示例#3
0
def main():


    PythonGranadaBot = bot_library.MasterBot('104245233:AAERxkRshykPM6LH8JFACjYBHRCkpOXmwvk')

    while True:
        logger.debug('Awaiting for new imput')
        PythonGranadaBot.echo()

        for second in range(3):
            tools.update_progress((second+1)/3.0, 3.0-second)
            time.sleep(1)
示例#4
0
 def updateStocks(self, data):
     step = 1
     total = len(data)
     error_stocks = []
     for d in data:
         update_progress(step / total)
         if not d.empty:
             symbol = d['code'].iloc[0]
             try:
                 self.data.saveStock(symbol, d)
             except sqlalchemy.exc.OperationalError:
                 error_stocks.append(symbol)
         step += 1
     return error_stocks
示例#5
0
def search_file(ioc):
    os.chdir('../')
    patt = tools.regex('ip')

    if ioc[-3:] == 'csv':
        print '[*] Pulling indicators as CSV values'
    else:
        print '[*] Assuming new-line formatted file'
    try:
        f = open(ioc, 'r').readlines()
    except:
        sys.stderr.write("[!] Cannot locate file: %s.\
        Please provide the full path." % ioc)
        exit(0)

    ioc_list = []
    for line in f:
        for match in patt.findall(line):
            ioc_list.append(match)

    sleep(2)
    os.chdir('intel')
    dir = os.listdir('.')

    total = float(len(ioc_list))
    print '[*] Found %d indicators in %s' % (total, ioc)
    frac = 1.0 / total
    prog = 0.0

    matched = open('../matches.txt', 'w+')

    for item in ioc_list:
        for i in dir:
            f2 = open(i, 'r')
            contents = f2.readlines()
            for line in contents:
                if item in line:
                    info = item + ' --> ' + i + '\n'
                    matched.write(info)
                    matches += 1
            else:
                pass
            f2.close()

        prog += frac
        tools.update_progress(prog)

    print '[+] Search complete.'
    print '%d matches found and stored in matches.txt' % matches
示例#6
0
def search_file(ioc):
    os.chdir('../')
    patt = tools.regex('ip')

    if ioc[-3:] == 'csv':
        print '[*] Pulling indicators as CSV values'
    else:
        print '[*] Assuming new-line formatted file'
    try:
        f = open(ioc, 'r').readlines()
    except:
        sys.stderr.write("[!] Cannot locate file: %s.\
        Please provide the full path." % ioc)
        exit(0)

    ioc_list = []
    for line in f:
        for match in patt.findall(line):
            ioc_list.append(match)

    sleep(2)
    os.chdir('intel')
    dir = os.listdir('.')

    total = float(len(ioc_list))
    print '[*] Found %d indicators in %s' % (total, ioc)
    frac = 1.0/total
    prog = 0.0

    matched = open('../matches.txt', 'w+')

    for item in ioc_list:
        for i in dir:
            f2 = open(i, 'r')
            contents = f2.readlines()
            for line in contents:
                if item in line:
                    info = item + ' --> ' + i + '\n'
                    matched.write(info)
                    matches += 1
            else:
                pass
            f2.close()

        prog += frac
        tools.update_progress(prog)

    print '[+] Search complete.'
    print '%d matches found and stored in matches.txt' % matches
示例#7
0
 def getUpdatedStockData(self, symbol):
     data = self.data.getUpdatedStockData(symbol)
     update_progress(self.step / self.total)
     self.step += 1
     return data