当前位置: 首页>>代码示例>>Python>>正文


Python Box.by_ip_address方法代码示例

本文整理汇总了Python中models.Box.by_ip_address方法的典型用法代码示例。如果您正苦于以下问题:Python Box.by_ip_address方法的具体用法?Python Box.by_ip_address怎么用?Python Box.by_ip_address使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Box的用法示例。


在下文中一共展示了Box.by_ip_address方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: edit_ipv6

# 需要导入模块: from models import Box [as 别名]
# 或者: from models.Box import by_ip_address [as 别名]
 def edit_ipv6(self):
     ''' Add ipv6 addresses to a box (sorta edits the box object) '''
     form = Form(box_uuid="Select a box", ipv6="Please provide a list of IPv6 addresses")
     if form.validate(self.request.arguments):
         errors = []
         box = Box.by_uuid(self.get_argument('box_uuid'))
         if box is not None:
             ips_string = self.get_argument('ipv6').replace('\n', ',').lower()
             ips = filter(lambda char: char in "1234567890abcdef:,", ips_string).split(",")
             for ip in filter(lambda ip: 0 < len(ip), ips):
                 try:
                     box = Box.by_ip_address(ip)
                     if box is None:
                         addr = IpAddress(box_id=box.id, v6=ip)
                         dbsession.add(addr)
                     else:
                         errors.append(
                             "%s has already been assigned to %s." % (ip, box.name,)
                         )
                 except ValueError:
                     errors.append(
                         "'%s' is not a valid IPv6 address" % str(ip[:39])
                     )
             dbsession.flush()
         else:
             errors.append("Box does not exist")
         self.render("admin/view/game_objects.html", errors=errors)
     else:
         self.render("admin/view/game_objects.html", errors=form.errors)
开发者ID:mach327,项目名称:RootTheBox,代码行数:31,代码来源:AdminHandlers.py

示例2: open

# 需要导入模块: from models import Box [as 别名]
# 或者: from models.Box import by_ip_address [as 别名]
 def open(self):
     ''' When we receive a new websocket connect '''
     box = Box.by_ip_address(self.request.remote_ip)
     if box is not None:
         self.box = box
         self.remote_ip = self.request.remote_ip
         self.write_message("box ok")
     else:
         self.close()
开发者ID:brutalhonesty,项目名称:RootTheBox,代码行数:11,代码来源:BotHandlers.py

示例3: open

# 需要导入模块: from models import Box [as 别名]
# 或者: from models.Box import by_ip_address [as 别名]
 def open(self, *args):
     """ Steps 1 and 2; called when a new bot connects """
     box = Box.by_ip_address(self.request.remote_ip)
     self.remote_ip = self.request.remote_ip
     if box is None and self.config.whitelist_box_ips:
         logging.debug("Rejected bot from '%s' (not a box)" % self.request.remote_ip)
         self.write_message({"opcode": "error", "message": "Invalid IP address."})
         self.close()
     else:
         logging.debug("Interrogating bot on %s" % self.request.remote_ip)
         self.write_message({"opcode": "interrogate", "xid": self.xid})
开发者ID:harite,项目名称:RootTheBox,代码行数:13,代码来源:BotnetHandlers.py

示例4: open

# 需要导入模块: from models import Box [as 别名]
# 或者: from models.Box import by_ip_address [as 别名]
 def open(self, *args):
     ''' Steps 1 and 2; called when a new bot connects '''
     box = Box.by_ip_address(self.request.remote_ip)
     self.remote_ip = self.request.remote_ip
     if box is None and self.config.whitelist_box_ips:
         logging.debug("Rejected bot from '%s' (not a box)" % self.request.remote_ip)
         self.write_message({
             'opcode': 'error',
             'message': 'Invalid IP address.'
         })
         self.close()
     else:
         logging.debug("Interrogating bot on %s" % self.request.remote_ip)
         self.write_message({'opcode': 'interrogate', 'xid': self.xid})
开发者ID:moloch--,项目名称:RootTheBox,代码行数:16,代码来源:BotnetHandlers.py

示例5: open

# 需要导入模块: from models import Box [as 别名]
# 或者: from models.Box import by_ip_address [as 别名]
 def open(self, *args):
     ''' When we receive a new websocket connect '''
     box = Box.by_ip_address(self.request.remote_ip)
     if box is not None:
         self.box_uuid = box.uuid
         self.box_name = box.name
         self.remote_ip = self.request.remote_ip
         self.write_message({
             'opcode': 'get_user',
         })
     else:
         logging.debug("Rejected bot from '%s' (not a box)" % self.request.remote_ip)
         self.write_message({
             'opcode': 'error',
             'message': 'Invalid IP address.'
         })
         self.close()
开发者ID:lavalamp-,项目名称:RootTheBox,代码行数:19,代码来源:BotnetHandlers.py

示例6: get

# 需要导入模块: from models import Box [as 别名]
# 或者: from models.Box import by_ip_address [as 别名]
	def get(self, *args, **kwargs):
		''' Registers a reporting service on a remote box '''
		box = Box.by_ip_address(self.request.remote_ip)
		if box != None:
			try:
				display_name = self.get_argument("handle")
				user = User.by_display_name(display_name)
				if user != None and not user.team.is_controlling(box):
					user.give_control(box)
					self.dbsession.add(user)
					self.dbsession.flush()
					self.notify(user, box)
					self.write(unicode(user.team.listen_port))
				else:
					self.write("Invalid handle")
			except:
				self.write("Missing parameter")
		else:
			self.write("Invalid ip address")
		self.finish()
开发者ID:xaelek,项目名称:RootTheBox,代码行数:22,代码来源:ReporterHandlers.py

示例7: get

# 需要导入模块: from models import Box [as 别名]
# 或者: from models.Box import by_ip_address [as 别名]
 def get(self, *args, **kwargs):
     """ Registers a reporting service on a remote box """
     box = Box.by_ip_address(self.request.remote_ip)
     if box is not None:
         try:
             handle = self.get_argument("handle")
             user = User.by_handle(handle)
             if user is not None:
                 if not box in user.team.boxes:
                     user.team.boxes.append(box)
                     dbsession.add(user.team)
                     dbsession.flush()
                 self.write(unicode(user.team.listen_port))
             else:
                 self.write("Invalid handle")
         except:
             self.write("Missing parameter")
     else:
         self.write("Invalid ip address")
     self.finish()
开发者ID:brutalhonesty,项目名称:RootTheBox,代码行数:22,代码来源:ReporterHandlers.py


注:本文中的models.Box.by_ip_address方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。