def add(self, name): if name not in cfgStore.store: cfgStore.store[name] = {} cfgStore.store[name] = self.loadConfigFromFile(name) default = self.loadConfigFromFile(name, True) for d in default: if d not in cfgStore.store[name]: cfgStore.store[name][d] = default[d] if name not in ['System', 'Project', 'Camera', 'Flir', 'Capture']: if 'frameIn' not in cfgStore.store[name]: # store the dict and then insert the new vars at the top of the list temp = cfgStore.store[name] cfgStore.store[name] = {} self.insertConfigVariable( name, 1, "Text", "frameIn", "default", "", "Frame source", "", "default~Mask~Color~Noise~FillGap") self.insertConfigVariable(name, 1, "Number", "channel", "0", "", "Source channel", "") for t in temp: cfgStore.store[name][t] = temp[t] if name in ['System']: if 'colors' not in cfgStore.store[name]: cfgStore.store[name]['colors'] = Colors().list if 'cindex' not in cfgStore.store[name]: cfgStore.store[name]['cindex'] = Colors().index self.saveConfigToFile(name) # after save to file - only change in memory # add the port here just in case we are serving multiple vision applications if name == 'Project': cfgStore.store[name]['visionServer'] = cfgStore.store[name][ 'visionServer'] + ':' + os.environ['PORT']
class Banner: r = Colors().red(1) y = Colors().yellow(9) ny = Colors().yellow(0) nw = Colors().white(0) e = Colors().end() def banner(self): print self.ny + " _____ _ _ _ _ " + self.e print self.ny + " | __|___ ___ ___| |_ ___| |_| |_|_|" + self.e print self.ny + " |__ | . | .'| . | | -_| _| _| |" + self.e print self.ny + " |_____| _|__,|_ |_|_|___|_| |_| |_|" + self.e print self.ny + " |_| |___| " + self.r + "v0.1.3\n" + self.e print self.nw + "~/#" + self.e + " Spaghetti - Web Application Security Scanner" + self.e print self.nw + "~/#" + self.e + " Codename - " + self.y + "MR.R0B0T" + self.e print self.nw + "~/#" + self.e + " Momo Outaadi (@M4ll0k)" + self.e print self.nw + "~/#" + self.e + " https://github.com/m4ll0k/Spaghetti\n" + self.e def usage(self, exit=False): name = os.path.basename(sys.argv[0]) self.banner() print "Usage:\n" print "\t-u --url\tTarget URL (eg: http://example.com)" print "\t-s --scan\tScan Options (default=0):\n" print "\t\t0:\tFull Scan" print "\t\t1:\tBruteforce (dirs,files,..)" print "\t\t2:\tDisclosure (ip,emails,..)" print "\t\t3:\tAttacks (sql,lfi,..)" print "\t\t4:\tOthers (webdav,..)" print "\t\t5:\tVulns (shellshock,..)" print "\t\t6:\tFingerprint only\n" print "\t--crawler\tDeep crawling (slow)" print "\t--agent\t\tUse the specified user-agent" print "\t--random-agent\tUse a random user-agent" print "\t--redirect\tRedirect target URL, default=True" print "\t--timeout\tSet timeout, default=None" print "\t--cookie\tSet cookie, default=None" print "\t--proxy\t\tSet proxy, (host:port)" print "\t--verbose\tVerbose output" print "\t--version\tShow version" print "\t--help\t\tShow this help and exit\n" print "Examples:\n" print "\t" + name + " --url http://example.com" print "\t" + name + " --url http://example.com --scan [0-6]" print "\t" + name + " --url http://example.com --scan 1 --crawler\n" if exit: sys.exit(0) def version(self, exit=False): self.banner() print "~/# Spaghetti - Web Application Security Scanner (v0.1.3\n" if exit: sys.exit(0)
def __init__(self, project='Untitled', source='.', ignored_paths=None, color=False, filter_obj=None, verbose=False, outfile=None, quiet=False): """ Constructor. :type project: str :param project: str :param ignored_paths: bool :param source: str :param color: bool :param filter_obj: lib.Filter() :param verbose: bool :param outfile: str :param quiet: bool """ self.project = project self.source = source self.color = False if color: self.color = Colors() self.filter = filter_obj self.verbose = verbose self.outfile = outfile self.fp = None self.html = '' self.quiet = quiet if ignored_paths: paths = ignored_paths.split(':') for path in paths: self.filter.ignored_paths.append(re.compile(path, self.filter.REGEX_FLAGS)) self.html = open('resources/output_template.html', 'r').read() self.fp = open(self.outfile, 'w') self.html = self.html.replace('###DIRECTORY###', self.source) self.html = self.html.replace('###PROJECT###', self.project)
def __init__(self, graphData): VdxRecord.__init__(self) self.graphData = graphData self.colors = Colors() # self.graphData = self.GraphDataImpl() """ up to the first 7 elements work, from then on the VDX cannot be imported! e.g., # self.edgeData = self.graphData.getEdgeData()[:6] # works # self.edgeData = self.graphData.getEdgeData()[:7] # does NOT work """ # self.edgeData = self.graphData.getEdgeData() self.edgeData = self.graphData.getEdgeData() if len(self.edgeData) == 0: self.addEmptyGraphNode() return self.layout = Layout (self.edgeData, **self.layout_args) if self.verbose: print self.layout self.addNodes(); self.addEdges();
def __init__(self, caption): """Инициализация основных параметров.""" self.caption = caption self.config = Config() self.color = Colors() # Заголовок экрана pygame.display.set_caption(self.caption) # Экран с заданным размером self.screen = pygame.display.set_mode(self.config.screen_size) # Создается группа Точек/список спрайтов self.dot_list = pygame.sprite.Group() # Создается группа Травинок/список спрайтов self.grass_list = pygame.sprite.Group() # Создается группа всех спрайтов self.all_sprites_list = pygame.sprite.Group() for i in range(10): # Создание Точки self.dot = Dot() # Выбор случайных координат размещения Точки self.dot.rect.x = random.randrange(self.config.screen_width) self.dot.rect.y = random.randrange(self.config.screen_height) # Добавить точки в список точек self.dot_list.add(self.dot) self.all_sprites_list.add(self.dot) for i in range(100): # Создание травинки self.grass = Grass() # Выбор случайных координат размещения травинки self.grass.rect.x = random.randrange(self.config.screen_width) self.grass.rect.y = random.randrange(self.config.screen_height) # Добавить травинку в список травинок self.grass_list.add(self.grass) self.all_sprites_list.add(self.grass)
def __init__(self, width, height, caption): pygame.init() # Размеры окна и заголовок self.width = width self.height = height self.size = (self.width, self.height) self.caption = caption pygame.display.set_caption(self.caption) # Экран с заданным размеров self.screen = pygame.display.set_mode(self.size) # Полноэкранный режим # self.screen = pygame.display.set_mode(self.size, pygame.FULLSCREEN) # Инициализация настроек self.config = Config() # Инициализация набора цветов self.colors = Colors() # Инициализация счетчика шагов self.step = 0 # Инициализация списков объектов (Точки и трав) self.dotsList = [] # Инициализация первой точки и добавление в список Точек self.firstDot = Dot() self.dotsList.append(self.firstDot) # Список координат трав self.grass = Grass() self.grassesCoords = self.grass.addGrass(self.width, self.height, self.grass.startQuantity) self.font = pygame.font.SysFont(None, 16) self.screen_rect = self.screen.get_rect() pygame.mouse.set_visible(False)
def __init__(self, extension, filetype, token): self.extension = extension self.token = token self.color = Colors() self.drive = dropbox.Dropbox(self.token) self.shareds = [] self.filetype = filetype
def __init__(self): # Класс точки наследует от встроенного класса Sprite super().__init__() # self.name = name # Создается экземпляр класса Config, где хранятся все настройки и цветов Colors self.config = Config() self.color = Colors() # Цвет Точки if self.config.dot_vel == 1: self.dot_color = self.color.BLUE elif self.config.dot_vel == 2: self.dot_color = self.color.FUCHSIA elif self.config.dot_vel == 3: self.dot_color = self.color.DARKKHAKI # Создаем спрайт Точки. Ширина и высота прямоугольника Точки равны диаметру Точки (два радиуса) self.image = pygame.Surface( [self.config.dot_radius * 2, self.config.dot_radius * 2]) self.image.fill(self.color.WHITE) # Создаем поверхность для Точек self.image.set_colorkey(self.color.WHITE) self.rect = self.image.get_rect() pygame.draw.circle(self.image, self.dot_color, (self.rect.x + self.config.dot_radius, self.rect.y + self.config.dot_radius), self.config.dot_radius)
def __init__(self): self.clock = pygame.time.Clock() # Создание экземпляра класса Colors self.color = Colors() # Характеристики экрана: # Цвет экрана self.screen_color = self.color.LAVENDER # Ширина и высота/размер экрана self.screen_size = self.screen_width, self.screen_height = 1280, 720 # Частота кадров self.FPS = 60 # Характеристики Точек: # Радиус точки self.dot_radius = 6 # Радиус обзора self.dot_scan_radius = 120 # Начальный уровень энергии self.dot_energy = 500 # Скорость self.dot_vel = random.randint(1, 3) # Характеристики Травинок: # Цвет Травинки self.grass_color = self.color.WHITE # Радиус точки self.grass_radius = 2 # Энергатическая ценность self.grass_energy = 120
def __init__(self, screen, pos=(0, 0)): self.screen = screen self.score = 0 self.color = Colors().white self.font = pygame.font.Font('fonts/Lumberjack-Regular.ttf', 32) self.prep_image() self.pos = pos self.position()
def __init__(self, screen, text, pos=(0, 0), size=50): super().__init__() self.screen = screen self.text = text self.color = Colors().white self.font = pygame.font.Font('fonts/PAC-FONT.TTF', size) self.pos = pos self.prep_image()
def prep_images(self): self.images.clear() for num, score in enumerate(self.score_controller.high_scores): image = self.font.render('#' + str(num + 1) + ' : ' + str(score), True, Colors().white) rect = image.get_rect() self.images.append([image, rect])
def __init__(self, params): self.width = params['width'] self.height = params['height'] self.playerPos = (0, 0) self.colors = Colors(params['colors']) self.npc = [] #not player unit self.cars = [] print(type(self.width))
def __init__(self, width, height, caption): pygame.init() # Размеры окна и заголовок self.width = width self.height = height self.size = (self.width, self.height) self.caption = caption pygame.display.set_caption(self.caption) # Экран с заданным размеров self.screen = pygame.display.set_mode(self.size) # Полноэкранный режим # self.screen = pygame.display.set_mode(self.size, pygame.FULLSCREEN) # Инициализация настроек self.config = Config() # Инициализация набора цветов self.colors = Colors() # Инициализация счетчика шагов self.step = 0 # Инициализация списков объектов (Точки и трав) self.dotsList = [] # Инициализация первой точки и добавление в список Точек self.firstDot = Dot() self.dotsList.append(self.firstDot) # Список координат трав self.grass = Grass() self.grassesCoords = self.grass.addGrass(self.width, self.height, self.grass.startQuantity) # Поверхность для создания графика статистики self.statsurf = pygame.Surface((240, 240)) self.font_legend = pygame.font.SysFont("Roboto", 24) self.screen_rect = self.statsurf.get_rect() # Поверхность для создания симуляции self.simsurf = pygame.Surface((1040, 720)) self.font_tooltip = pygame.font.SysFont("Roboto", 12) pygame.mouse.set_visible(False) self.filename = "stat.csv" self.frame = 0 self.data = [["Time", "Population", "Resources", "Slows", "Middles", "Fasts"]] # Группы по скорости self.slowDots = [] self.middleDots = [] self.fastDots = [] self.time = [] self.population = [] self.resources = [] self.slows = [] self.middles = [] self.fasts = []
def __init__(self, tokens_de_entrada): self.tokens = tokens_de_entrada if (self.programa()): print(Colors().sucess, "\n########SINTÁICO COM SUCESSO!!!##########\n", Colors().reset) print('Nada a Relatar aqui..') self.resultado = True else: print(Colors().danger, "\n\n########ERRO NO SINTÁTICO########") print("\nLinha", self.token[1], "Coluna", self.token[2], "Posição", self.linhaToken) if (self.pilha): print("\nToken esperado: \t", self.pilha[-1]) else: print("\nToken esperado: \t Nenhum") print("Token encontrado: \t", self.token[0]) self.resultado = False
def __init__(self): colors = Colors() green = colors.green() reset = colors.reset() print green + """ Simple Email Harvester This tools allows to scrape websites for emails Usage: ./email_harvester.py --url http://www.example.com --file example_emails.txt """ + reset
def __init__(self, metaData, buttonFilePaths, buttonHeight): self.metaData = metaData self.buttonHeight = buttonHeight self.backgroundColor = Colors().BLACK self.buttonsFilePaths = buttonFilePaths self.buttonObjects = self.createButtonObjectsFromFilePaths() self.buttonsPerScreen = ((self.metaData.height - 200) // self.buttonHeight) self.currentScreen = 0 self.numberOfScreens = (len(self.buttonObjects) // self.buttonsPerScreen) + 1
def __init__(self, screen, fonts=None, colors=None): self.screen = screen if fonts is None: self.fonts = Fonts() else: self.fonts = fonts if colors is None: self.colors = Colors() else: self.colors = colors
def __init__(self): Logger.__init__(self, 20) # self.scr: 'CursesScreen' = scr # the current colorscheme to use self.colorscheme = Colors() # a string describing the current situation self.status = '' # the next key to read from the user self.input_key = "" # the current room the player is in self.room = None self.turns = None # load the world self.world = world.parse_world(self) # the current Player instance self.player: Player = Player(self) self.player.pos = vec2(2, 4) # the state of the game # 'input' -> game is waiting for player input # 'running' -> time is progressing self.game_state = 'input' self.menu = MainMenu(self) # the state of the action menu # tells the game what actions to display self.menu_state = 'main' # holds an item previously selected through the menu self.menu_selected_item = None # holds the command string that is being typed by the user self.menu_cmd_buffer = '' # if true, try to quit the game self.quit = False # update the current room self.set_current_room() print('loaded a new game')
def __init__(self, tokens_de_entrada): self.tokens = tokens_de_entrada self.escopo.append(['0', 'livre']) if (self.programa()): self.resultado = True print(Colors().sucess, "\n########SEMÂNTICO COM SUCESSO!!!##########\n", Colors().reset) print("Tabela de simbolos:") for x in range(len(self.tabela)): msg = str(x) + ": ['" + str(self.tabela[x][0]) + "', " + str( self.tabela[x][1][-1]) + ", '" + str( self.tabela[x][2]) + "']" print(msg) else: print("\nPilha de erros:") for x in range(len(self.pilha)): print(x, self.pilha[x]) print(Colors().danger, "\n\n########ERRO NO SEMÂNTICO########") print(self.pilha[-1]) print(self.msg)
def __init__(self): # Класс Травки наследует от встроенного класса Sprite super().__init__() # Создается экземпляр класса Config, где хранятся все настройки и цветов Colors self.config = Config() self.color = Colors() # # Создаем спрайт Травки. Ширина и высота прямоугольника Точки равны диаметру Точки (два радиуса) self.image = pygame.Surface( [self.config.grass_radius * 2, self.config.grass_radius * 2]) self.image.fill(self.color.BLACK) # # Создаем поверхность для Точек self.image.set_colorkey(self.color.BLACK) self.rect = self.image.get_rect() pygame.draw.circle(self.image, self.config.grass_color, (self.rect.x + self.config.grass_radius, self.rect.y + self.config.grass_radius), self.config.grass_radius)
def update_screen(self): if not self.player.dead: self.screen.fill(Colors().black) self.check_player() self.maze.blit() self.player.update() for enemy in self.ghosts: enemy.update() enemy.blit() self.player.blit() self.score_keeper.blit() self.life_counter.blit() elif self.player.dead: self.player.update() self.player.blit() pygame.display.flip()
def setupGame(self): # set up pygame pygame.init() # set up the window width = 1920 height = 1080 __builtin__.windowSurface = pygame.display.set_mode((width, height), 0, 32) pygame.display.set_caption('Yet another PONG') # load colors __builtin__.colors = Colors() __builtin__.mygame = self __builtin__.sounds = Sound() self.player1 = 0 self.player2 = 0 # set up fonts basicFont = pygame.font.SysFont(None, height / 16) # set up the text text = basicFont.render('Yet another PONG!', False, colors.WHITE, colors.BLACK) textRect = text.get_rect() textRect.centerx = windowSurface.get_rect().centerx textRect.y = 12 #textRect.centery = windowSurface.get_rect().centery # draw the white background onto the surface windowSurface.fill(colors.BLACK) # draw the text's background rectangle onto the surface pygame.draw.rect(windowSurface, colors.WHITE, (textRect.left - 3, textRect.top - 3, textRect.width + 6, textRect.height + 6)) # draw the text onto the surface windowSurface.blit(text, textRect) #example of ball and bar class speed = 10 self.bar1 = Bar(width / 13, height / 2, (speed * height) / 768) self.bar2 = Bar(width * 803 / 884, height / 2, (speed * height) / 768) self.ball = Ball(width * 67 / 136, height * 37 / 76)
def __init__(self, screen, score_controller, size=26, background=Colors().black): self.screen = screen self.score_controller = score_controller self.back_button = Button(screen, 'Back', pos=(int(screen.get_width() * 0.25), int(screen.get_height() * 0.9))) self.font = pygame.font.Font('fonts/Lumberjack-Regular.ttf', size) self.images = [] self.active = False self.background = background self.prep_images() self.position()
def __init__(self, screen, msg, size=26, pos=(0, 0), text_color=Colors().white, alt_color=(0, 255, 0)): self.screen = screen self.screen_rect = screen.get_rect() self.text_color = text_color self.alt_color = alt_color self.font = pygame.font.Font('fonts/Lumberjack-Regular.ttf', size) self.pos = pos self.msg = msg self.msg_image, self.msg_image_rect = None, None self.prep_msg(self.text_color)
class Level(object): """Super class for levels""" #Each level has a list of walls and floors wall_list = None floor_list = None #Each level will have its own text and where the text will be located lvl_text = '' lvl_text_image = None text_location = (0, 0) font = pygame.font.SysFont(None, 64) color = Colors() has_blinding = False def __init__(self): """Constructor, create our lists""" self.wall_list = pygame.sprite.Group() self.floor_list = pygame.sprite.Group()
def calibrateBounds(): #_ Init c = Colors() bounds = {'lower_bounds': [], 'upper_bounds': []} #_ Get color from palette while True: try: color = c.getRGBfromPalette() color2 = np.uint8([[[color[2], color[1], color[0]]]]) hsv = cv2.cvtColor(color2, cv2.COLOR_BGR2HSV).squeeze() bounds['lower_bounds'].append((hsv[0] - 10, 100, 100)) bounds['upper_bounds'].append((hsv[0] + 10, 255, 255)) except: break #write in config file f = open(config.bounds_filename, 'w') b = json.dumps(bounds, f) f.write(b) f.close() print('File %s has been written', config.bounds_filename)
def __init__(self, program_name=None, log=True, pin=None, log_display_length=10): self.colors = Colors() self.program_name = program_name self.do_log = log self.log_dir = './logs' self.pin = pin self.log_display_length = log_display_length self.logs = [] # the log self.figlet = Figlet(font='ANSI_shadow') # define the clear screen function if platform.system() == "Windows": self.clear_screen = lambda cmnd="cls": os.system(cmnd) else: self.clear_screen = lambda cmnd="clear": os.system(cmnd) self.start()
class Output: r = Colors().red(0) g = Colors().green(0) y = Colors().yellow(0) b = Colors().blue(0) w = Colors().white(0) e = Colors().end() def plus(self,String): print ('{}[+]{} {}{}{}'.format( Output.g, Output.e, Output.w, String, Output.e) ) def less(self,String): print ('{}[-]{} {}{}{}'.format( Output.r, Output.e, Output.w, String, Output.e) ) def test(self,String): print ('{}[i]{} {}{}{}'.format( Output.b, Output.e, Output.w, String, Output.e) ) def info(self,String): print ('{}[i]{} {}{}{}'.format( Output.y, Output.e, Output.w, String, Output.e) )
def __init__(self, items=None, exit_msg=None): """ Initialize menu Usage: ------ >>> def some_function(param1=1, **kwargs): ... pass >>> mn = Menu(items=[{'label': 'sample 1', 'callback': some_function, 'params': {'param1': 'value', ...}}] :param items: menu items. list of dictionaries :type items: list :param exit_msg: exit message :type exit_msg: str :return: Nada :rtype: None """ self.colors = Colors() self.num_bg = '' self.num_bld = '' self.num_fg = '' self.label_bg = '' self.label_bld = '' self.label_fg = '' self.items = [] self.set_exit_item(msg=exit_msg) self.choose_msq = 'Select option: > ' self.exit_item = {'label': 'Exit', 'callback': sys.exit} if isinstance(items, list): for item in items: self.add_item(item) if isinstance(items, dict): self.add_item(items) else: self.items = []