Exemplo n.º 1
0
 def validate_authentication(self, username, password, handler):
   hash = md5(b(password)).hexdigest()
   try:
     if self.user_table[username]['pwd'] != hash:
       raise KeyError 
   except KeyError:
       raise AuthenticationFailed
Exemplo n.º 2
0
 def validate_authentication(self, username, password, handler):
     hash = md5(b(password)).hexdigest()
     try:
         if self.user_table[username]['pwd'] != hash:
             raise KeyError
     except KeyError:
         raise AuthenticationFailed
Exemplo n.º 3
0
 def test_unforseen_ssl_shutdown(self):
     self.client.login()
     try:
         sock = self.client.sock.unwrap()
     except socket.error:
         err = sys.exc_info()[1]
         if err.errno == 0:
             return
         raise
     sock.settimeout(TIMEOUT)
     sock.sendall(b('noop'))
     try:
         chunk = sock.recv(1024)
     except socket.error:
         pass
     else:
         self.assertEqual(chunk, b(""))
Exemplo n.º 4
0
 def recv(self, buffer_size):
     try:
         data = self.socket.recv(buffer_size)
         if not data:
             # a closed connection is indicated by signaling
             # a read condition, and having recv() return 0.
             self.handle_close()
             return b('')
         else:
             return data
     except socket.error:
         why = sys.exc_info()[1]
         if why.args[0] in _DISCONNECTED:
             self.handle_close()
             return b('')
         else:
             raise
Exemplo n.º 5
0
 def test_unforseen_ssl_shutdown(self):
     self.client.login()
     try:
         sock = self.client.sock.unwrap()
     except socket.error:
         err = sys.exc_info()[1]
         if err.errno == 0:
             return
         raise
     sock.settimeout(TIMEOUT)
     sock.sendall(b('noop'))
     try:
         chunk = sock.recv(1024)
     except socket.error:
         pass
     else:
         self.assertEqual(chunk, b(""))
Exemplo n.º 6
0
 def recv(self, buffer_size):
     try:
         data = self.socket.recv(buffer_size)
         if not data:
             # a closed connection is indicated by signaling
             # a read condition, and having recv() return 0.
             self.handle_close()
             return b('')
         else:
             return data
     except socket.error:
         why = sys.exc_info()[1]
         if why.args[0] in _DISCONNECTED:
             self.handle_close()
             return b('')
         else:
             raise
Exemplo n.º 7
0
def main():
    # get a hash digest from a clear-text password
    hash = md5(b('12345')).hexdigest()
    authorizer = DummyMD5Authorizer()
    authorizer.add_user('user', hash, os.getcwd(), perm='elradfmw')
    authorizer.add_anonymous(os.getcwd())
    handler = FTPHandler
    handler.authorizer = authorizer
    server = FTPServer(('', 2121), handler)
    server.serve_forever()
Exemplo n.º 8
0
def main():
    # get a hash digest from a clear-text password
    hash = md5(b('12345')).hexdigest()
    authorizer = DummyMD5Authorizer()
    authorizer.add_user('user', hash, os.getcwd(), perm='elradfmw')
    authorizer.add_anonymous(os.getcwd())
    handler = FTPHandler
    handler.authorizer = authorizer
    server = FTPServer(('', 2121), handler)
    server.serve_forever()
Exemplo n.º 9
0
def main():
  # auth to managing users
  authorizer = DummyMD5Authorizer()

  # add users
  hash = md5(b('12345')).hexdigest()
  authorizer.add_user('user', hash, '/home/leo/FTPRoot', perm='elradfmwM')

  handler = SimpleHandler 
  handler.authorizer = authorizer

  # loggin setting
  
  handler.banner = "Hello , my friend"
  address = ('', 2200)
  server = FTPServer(address, handler)
  server.max_cons = 256
  server.max_cons_pre_ip = 5
  server.serve_forever()