def main():
    dir = os.path.dirname(os.path.realpath(__file__))
    parser = argparse.ArgumentParser(description='Search Alienvault OTX for a given artifact')
    parser.add_argument('artifact', help='the artifact represented in JSON format')
    parser.add_argument('-c', '--config', metavar="CONFIG_FILE", default=dir + "/otx.yaml", help='optional config file to use instead of the default config file')

    args = parser.parse_args()
    if args.artifact:
        results = analyze(helpers.loadConfig(args.config), args.artifact)
        print(json.dumps(results))
 def test_loadConfig(self):
     dir = os.path.dirname(os.path.realpath(__file__))
     data = helpers.loadConfig(dir + "/virustotal/virustotal.yaml")
     self.assertEqual(data["base_url"],
                      "https://www.virustotal.com/api/v3/search?query=")
Beispiel #3
0
from PythonDNS.InterceptResolver import InterceptResolver
from dnslib.server import DNSLogger, DNSServer
import argparse, time
from helpers import loadConfig

p = argparse.ArgumentParser(prog="DNSInterceptor")

p.add_argument("config_file",
    type=str,
    metavar="configuration file",
    help="Path to DNSInterceptor configuration file")

args = p.parse_args()
config = loadConfig(args.config_file)

print("Starting DNSInterceptor on %s:%d, forwarding to %s:%d" % (
    config['local']['address'], int(config['local']['port']),
    config['upstream']['address'], int(config['upstream']['port'])
))

resolver = InterceptResolver(
    config['upstream']['address'],
    int(config['upstream']['port']),
    config['filters']['cloakfile'],
    config['filters']['blacklistfile'],
    int(config['upstream']['timeout'])
)

print("<%d CloakRules Imported>" % len(resolver.cloakrules))
print("<%d BlacklistRules Imported>" % len(resolver.blacklistrules))
Beispiel #4
0
def main():
    #grab params
    solutionFilePath, logFilePath, height, width, pillDensity, wallDensity, fruitProbability, fruitScore, timeMultiplier, randomSeed, runs, evals = helpers.loadConfig(
    )
    bestSolution = []
    bestScore = 0
    logger = Logger(solutionFilePath, logFilePath)
    logger.recordInitParams(randomSeed, height, width, pillDensity,
                            wallDensity, fruitProbability, fruitScore,
                            timeMultiplier)

    if randomSeed == "-1":
        seed = datetime.now()
    else:
        seed = datetime.strptime(randomSeed, '%Y-%m-%d %H:%M:%S.%f')

    seedInt = int(time.mktime(seed.timetuple()))

    for i in range(1, runs + 1):
        logger.recordNewRun(i, seed)  #record current run
        tempSolution = []
        tempScore = 0
        for k in range(1, evals + 1):
            print(k)
            seedInt += 1
            seed = datetime.fromtimestamp(seedInt)
            random.seed(seed)  #set new seed for a new board
            board = Board(solutionFilePath, logFilePath, height, width,
                          pillDensity, wallDensity, fruitProbability,
                          fruitScore, timeMultiplier)
            board.initializeBoard()
            board.runGame()
            if board.pacman1.score > tempScore:  #keep track of best score/solution for current run
                tempScore = board.pacman1.score
                tempSolution = board.solution
                logger.recordChangeInScore(k, tempScore)
        if tempScore > bestScore:  #keep track of best score/solution across all runs
            bestScore = tempScore
            bestSolution = tempSolution
    print(bestScore)
    logger.recordBestSolution(bestSolution)