コード例 #1
0
	def onSend(self, data):
		sockConnect.onSend(self, data)
		if self.connectHost:
			analysis.incrementData(self.address[0], domainAnalysisType.outgoing, self.connectHost, len(data))
		if self.mode == "http" and not self.requestSend():
			if self.messageParse.connection() != "keep-alive":
				self.close()
			else:
				self.messageParse.clear()
コード例 #2
0
	def onRecv(self, data):
		sockConnect.onRecv(self, data)
		self.recvCache += data
		if self.mode == "proxy":
			if self.remoteConnect and self.recvCache:
				if self.connectHost:
					analysis.incrementData(self.address[0], domainAnalysisType.incoming, self.connectHost, len(self.recvCache))
				self.remoteConnect.sendData(self.fileno(), self.recvCache)
				self.recvCache = ""
			return
		if self.messageParse.appendData(data):
			method = self.messageParse.method()
			path = self.messageParse.path()
			self.connectName = self.filenoStr() + "	" + method + "	" + path
			if not path.startswith("http://") and method in ["GET", "POST"]:
				path = path.split("?")
				self.onHTTP(self.messageParse.headers,
						method,
						path[0],
						path[1] if len(path) > 1 else "",
						self.messageParse.getBody() if method == "POST" else "")
				self.mode = "http"
			else:
				
				self.mode = "proxy"
				
				connect = remoteConnectManger.getConnect()
				if path.find("status.dddproxy.com")>0:
					try:
						connect = None
						jsonMessage = self.messageParse.getBody()
						jsonBody = json.loads(jsonMessage)
						connectList = remoteConnectManger.getConnectHost(jsonBody["host"],jsonBody["port"])
						if connectList:
							for _,v in connectList.items():
								connect = v
					except:
						pass
				
				if connect:
					connect.addAuthCallback(self.onRemoteConnectAuth)
					connect.setConnectCloseCallBack(self.fileno(), self.onRemoteConnectClose)
				else:
					self.close()
				
				self.connectHost = parserUrlAddrPort("https://" + path if method == "CONNECT" else path)[0]
				analysis.incrementData(self.address[0], domainAnalysisType.connect, self.connectHost, 1)
		else:
			pass