Ejemplo n.º 1
0
    def f_replace_secret_with_hashes(self, msg):
        replaced = msg.replace("secret", "######")

        if msg != replaced:
            return state.replace(replaced)

        return state.next(msg)
Ejemplo n.º 2
0
	def send(self, msg):
		"""
		Sends a message to client's server.

		@param msg: message to send
		@type msg: str
		@return: next state with the original message
		@rtype: state.next
		@raise socket.error: When sending fails
		"""
		try:
			self._socket.sendall(msg)
		except socket.error:
			print "[ERROR] ", "Remote logging attempt failed!", msg

		return state.next(msg)
Ejemplo n.º 3
0
	def enqueue(self, msg, original = None):
		"""
		Enqueues an URL into the input queue to be parsed.

		@param msg: message to be parsed
		@param original: original URL when being parsed recursively
		@return: next state with the original message
		@rtype: state.next
		"""
		url_pattern = "(http://)?(?P<server>[a-zA-Z0-9\-\.]+\.[a-z]{2,6})(?P<url>(/([a-zA-Z0-9]|\$|\&|\+|\,|\:|\;|\=|\?|\@|\#|\%|\.|\_|\~|\-)*)*)"
		match = re.search(url_pattern, msg)

		if match:
			self._queue.put({
				"original": original if original else match.group("server") + match.group("url"),
				"server": match.group("server"),
				"url": match.group("url")
			})
		return state.next(msg)
Ejemplo n.º 4
0
 def test_next(self):
     self.assertTrue(state.is_next(state.next(None)))
Ejemplo n.º 5
0
 def test_not_replace(self):
     self.assertFalse(state.is_replace(state.done(None)))
     self.assertFalse(state.is_replace(state.next(None)))
Ejemplo n.º 6
0
	def c_unknown(self, t):
		return state.next()
Ejemplo n.º 7
0
	def h_next(self, t):
		return state.next()