Beispiel #1
0
 def connect(self):
     try:
         import paramiko
         try:
             close(rng_device)
         except Exception,e:
             pass
         from paramiko import rng_posix
         rng_device = rng_posix.open_rng_device()
         self.client = paramiko.SSHClient()
         self.client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
         paramiko.util.log_to_file('/var/log/ossim/ssh-remote.log',level=logging.DEBUG)
         self.client.connect(hostname=self.host, port=self.port, username=self.user, password=self.password, look_for_keys=False)
         logger.info("Connected remotely to %s " % self.host)
         self.connected = True
Beispiel #2
0
 def connect(self):
     try:
         import paramiko
         try:
             close(rng_device)
         except Exception, e:
             pass
         from paramiko import rng_posix
         rng_device = rng_posix.open_rng_device()
         self.client = paramiko.SSHClient()
         self.client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
         paramiko.util.log_to_file('/var/log/ossim/ssh-remote.log',
                                   level=logging.DEBUG)
         self.client.connect(hostname=self.host,
                             port=self.port,
                             username=self.user,
                             password=self.password,
                             look_for_keys=False)
         logger.info("Connected remotely to %s " % self.host)
         self.connected = True
Beispiel #3
0
## Crypto.Util.randpool.RandomPool as a fall-back.  RandomPool will happily run
## with very little entropy, thus _silently_ defeating any security that
## Paramiko attempts to provide.  (This is current as of PyCrypto 2.0.1).
## See http://www.lag.net/pipermail/paramiko/2008-January/000599.html
## and http://www.lag.net/pipermail/paramiko/2008-April/000678.html
##

if ((platform is not None and platform.system().lower() == 'windows') or
        sys.platform == 'win32'):
    # MS Windows
    from paramiko import rng_win32
    rng_device = rng_win32.open_rng_device()
else:
    # Assume POSIX (any system where /dev/urandom exists)
    from paramiko import rng_posix
    rng_device = rng_posix.open_rng_device()


class StrongLockingRandomPool(object):
    """Wrapper around RandomPool guaranteeing strong random numbers.
    
    Crypto.Util.randpool.RandomPool will silently operate even if it is seeded
    with little or no entropy, and it provides no prediction resistance if its
    state is ever compromised throughout its runtime.  It is also not thread-safe.

    This wrapper augments RandomPool by XORing its output with random bits from
    the operating system, and by controlling access to the underlying
    RandomPool using an exclusive lock.
    """

    def __init__(self, instance=None):
Beispiel #4
0
## Find a strong random entropy source, depending on the detected platform.
## WARNING TO DEVELOPERS: This will fail on some systems, but do NOT use
## Crypto.Util.randpool.RandomPool as a fall-back.  RandomPool will happily run
## with very little entropy, thus _silently_ defeating any security that
## Paramiko attempts to provide.  (This is current as of PyCrypto 2.0.1).

if ((platform is not None and platform.system().lower() == 'windows') or
        sys.platform == 'win32'):
    # MS Windows
    from paramiko import rng_win32
    rng_device = rng_win32.open_rng_device()
else:
    # Assume POSIX (any system where /dev/urandom exists)
    from paramiko import rng_posix
    rng_device = rng_posix.open_rng_device()


class StrongLockingRandomPool(object):
    """Wrapper around RandomPool guaranteeing strong random numbers.
    
    Crypto.Util.randpool.RandomPool will silently operate even if it is seeded
    with little or no entropy, and it provides no prediction resistance if its
    state is ever compromised throughout its runtime.  It is also not thread-safe.

    This wrapper augments RandomPool by XORing its output with random bits from
    the operating system, and by controlling access to the underlying
    RandomPool using an exclusive lock.
    """

    def __init__(self, instance=None):