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


Python Client.registerCallbackOnConnectChange方法代码示例

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


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

示例1: P4wnP1

# 需要导入模块: import Client [as 别名]
# 或者: from Client import registerCallbackOnConnectChange [as 别名]
class P4wnP1(cmd.Cmd):
	"""
	Maybe this is the class implementing P4wnP1 HID channel user prompt
	... maybe not, who knows ?!
	"""

	DEBUG = False

	CLIENT_TIMEOUT_MS = 1000 # if this value is reached, the client is regarded as disconnected

	# message types from CLIENT (powershell) to server (python)
	CTRL_MSG_FROM_CLIENT_RESERVED = 0
	CTRL_MSG_FROM_CLIENT_REQ_STAGE2 = 1
	CTRL_MSG_FROM_CLIENT_RCVD_STAGE2 = 2
	CTRL_MSG_FROM_CLIENT_STAGE2_RUNNING = 3
	CTRL_MSG_FROM_CLIENT_RUN_METHOD_RESPONSE = 4 # response from a method ran on client
	#CTRL_MSG_FROM_CLIENT_ADD_CHANNEL = 5
	CTRL_MSG_FROM_CLIENT_RUN_METHOD = 6 # client tasks server to run a method
	CTRL_MSG_FROM_CLIENT_DESTROY_RESPONSE = 7
	CTRL_MSG_FROM_CLIENT_PROCESS_EXITED = 8
	CTRL_MSG_FROM_CLIENT_CHANNEL_SHOULD_CLOSE = 9
	CTRL_MSG_FROM_CLIENT_CHANNEL_CLOSED = 10

	# message types from server (python) to client (powershell)
	CTRL_MSG_FROM_SERVER_STAGE2_RESPONSE = 1000
	#CTRL_MSG_FROM_SERVER_SEND_OS_INFO = 1001
	#CTRL_MSG_FROM_SERVER_SEND_PS_VERSION = 1002
	CTRL_MSG_FROM_SERVER_RUN_METHOD = 1003 # server tasks client to run a method
	#CTRL_MSG_FROM_SERVER_ADD_CHANNEL_RESPONSE = 1004
	CTRL_MSG_FROM_SERVER_RUN_METHOD_RESPONSE = 1005 # response from a method ran on server
	CTRL_MSG_FROM_SERVER_DESTROY = 1006 # response from a method ran on server
	CTRL_MSG_FROM_SERVER_CLOSE_CHANNEL = 1007

	def __init__(self, linklayer, transportlayer, config,  stage2 = "", duckencoder = None):
		# state value to inform sub threads of running state
		self.running = False	
		self.stage2=stage2
		self.config =  config

		self.client = Client() # object to monitor state of remote client
		self.client.registerCallbackOnConnectChange(self.onClientConnectStateChange)

		#self.control_sysinfo_response = BlockingQueue("CONTROL_SERVER_SYSINFO_RESPONSE")

		self.server_thread_in = Thread(target = self.__input_handler, name = "P4wnP1 Server Input Loop", args = ( ))
		self.server_thread_out = Thread(target = self.__output_handler, name = "P4wnP1 Server Output Loop", args = ( ))

		self._next_client_method_id = 1

		self.tl = transportlayer
		self.ll = linklayer

		self.__pending_server_methods = {}

		self.duckencoder = duckencoder
		self.mousescriptparser = MouseScriptParser()
		
		# register Listener for LinkLayer signals to upper layers (to receive LinkLayer connection events)
		dispatcher.connect(self.signal_handler_transport_layer, sender="TransportLayerUp")
		
		self.client_connected_commands = ["ls", "pwd", "cd", "shell", "CreateProc", "interact", "download", "upload", "echotest", "GetClientProcs", "KillClient", "KillProc"]
		self.setPrompt(False, False)
		cmd.Cmd.__init__(self)
		
		
		self.intro = '''=================================
P4wnP1 HID backdoor shell
Author: MaMe82
Web: https://github.com/mame82/P4wnP1
State: Experimental (maybe forever ;-))

Enter "help" for help
Enter "FireStage1" to run stage 1 against the current target.
Use "help FireStage1" to get more details.
=================================
'''
		
	def precmd(self, line):
		cmd, args, remain = self.parseline(line)
		if not cmd:
			return line
		if cmd in self.client_connected_commands:
			if not self.client.isConnected():
				print ""
				print "Command '{0}' could only be called with a client connected.".format(cmd)
				print "--------------------------------------------------------------"
				print ""
				print "Use 'SetKeyboardLanguage' to switch to your targtes keyboard"
				print "layout and run 'FireStage1' to connect via HID covert channel."
				print "--------------------------------------------------------------"
				print ""
				return ""		
		return line

	def setPrompt(self, connectState,  reprint = True):
		if connectState:
			self.prompt = "P4wnP1 shell (client connected) > "
		else:
			self.prompt = "P4wnP1 shell (client not connected) > "
		if reprint:
#.........这里部分代码省略.........
开发者ID:advisor25,项目名称:P4wnP1,代码行数:103,代码来源:P4wnP1.py


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