Exemplo n.º 1
0
	async def PASS(self):
		""" Ftp command PASS """
		self.password = self.path[1:]
		if User.check(self.user, self.password):
			await self.sendResponse(230, b"Logged in.")
		else:
			await self.sendResponse(430, b"Invalid username or password")
Exemplo n.º 2
0
 def login(request, response, duration):
     """ Login page """
     User.init()
     if Sessions.check(request.getCookie(b"session")) == False:
         if User.check(request.params.get(b"loginuser", b""),
                       request.params.get(b"loginpassword", b"")):
             response.setCookie(b"session", Sessions.create(duration),
                                duration)
         else:
             return PasswordPage.loginPage(
                 None if request.params.get(b"loginpassword", None) ==
                 None else b"Wrong user or password")
     return None
Exemplo n.º 3
0
	async def treatCommand(self):
		""" Treat ftp command """
		if self.quit == False:
			try:
				command = useful.tostrings(self.command)
				if hasattr(self, command):
					callback = getattr(self, command)
					
					if not self.command in [b"USER",b"PASS"]:
						if User.check(self.user, self.password):
							await callback()
						else:
							await self.sendResponse(430, b"Invalid username or password")
					else:
						await callback() 
				else:
					await self.unsupportedCommand()
			except Exception as err:
				await self.sendError(err)
Exemplo n.º 4
0
	def getlogin(self, b=None):
		result = b
		if self.state == 0:
			self.socket.write(b"%s\r\nTelnet connected to %s\r\n%s\r\n"%(b"*"*30, useful.tobytes(sys.platform), b"*"*30))
			if User.isEmpty():
				self.state = 3
			else:
				self.socket.write(b"Username:"******"\r\nPassword:"******""
					self.login = b""
					self.socket.write(b" Logging success\r\n%s\r\n"%(b"*"*30))
				else:
					self.state = 1
					self.socket.write(b" Logging failed\r\n\r\nUsername:"******""
					self.login = b""
			elif b[0] == 0x7F:
				if len(self.password) >= 1:
					self.password = self.password[:-1]
			else:
				self.password += bytes([b[0]])
		return result