In [1]:
import pyping
import nmap
import dominate
from dominate.tags import *
import paramiko
import base64

In [2]:
nm = nmap.PortScanner()


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-2-596b1b54ffb8> in <module>()
----> 1 nm = nmap.PortScanner()

NameError: name 'nmap' is not defined

In [3]:
allscan = nm.scan('192.168.1.*')

In [ ]:
allhosts = nm.all_hosts()

In [5]:
pinglis = []
nplis = []

In [6]:
for hosts in allhosts:
    print(hosts)
    pinglis.append(pyping.ping(hosts))


192.168.1.0
---------------------------------------------------------------------------
error                                     Traceback (most recent call last)
<ipython-input-6-51050c0ffa12> in <module>()
      1 for hosts in allhosts:
      2     print(hosts)
----> 3     pinglis.append(pyping.ping(hosts))

/usr/local/lib/python2.7/dist-packages/pyping/core.pyc in ping(hostname, timeout, count, packet_size, *args, **kwargs)
    416 def ping(hostname, timeout=1000, count=3, packet_size=55, *args, **kwargs):
    417         p = Ping(hostname, timeout, packet_size, *args, **kwargs)
--> 418         return p.run(count)

/usr/local/lib/python2.7/dist-packages/pyping/core.pyc in run(self, count, deadline)
    269 
    270                 while True:
--> 271                         delay = self.do()
    272 
    273                         self.seq_number += 1

/usr/local/lib/python2.7/dist-packages/pyping/core.pyc in do(self)
    296                                 current_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.getprotobyname("icmp"))
    297                         else:
--> 298                                 current_socket = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.getprotobyname("icmp"))
    299                 except socket.error, (errno, msg):
    300                         if errno == 1:

/usr/lib/python2.7/socket.pyc in __init__(self, family, type, proto, _sock)
    185     def __init__(self, family=AF_INET, type=SOCK_STREAM, proto=0, _sock=None):
    186         if _sock is None:
--> 187             _sock = _realsocket(family, type, proto)
    188         self._sock = _sock
    189         for method in _delegate_methods:

error: [Errno 1] Operation not permitted - Note that ICMP messages can only be send from processes running as root.

In [7]:
for pls in pinglis:
    print pls.output[0]
    nplis.append(pls.output[0])

In [ ]:
nplis

In [ ]:
nmapdoc = dominate.document(title='nmap scan')

In [ ]:
doc = dominate.document(title='nmap ping')

with doc.head:
    link(rel='stylesheet', href='style.css')
    script(type='text/javascript', src='script.js')

with doc:
    #with div(id='header').add(ol()):
    #    for i in pinglis:
    #        li(a(i(), href='/%s.html' % i))

    with div():
        attr(cls='body')
        p(nplis)

print doc

In [ ]:
key = paramiko.RSAKey(data=base64.decodestring('AAA...'))

In [104]:
key = paramiko.RSAKey(data=base64.decodestring('AAA...'))


---------------------------------------------------------------------------
Error                                     Traceback (most recent call last)
<ipython-input-104-469024d16871> in <module>()
----> 1 key = paramiko.RSAKey(data=base64.decodestring('AAA...'))

/usr/lib/python2.7/base64.pyc in decodestring(s)
    319 def decodestring(s):
    320     """Decode a string."""
--> 321     return binascii.a2b_base64(s)
    322 
    323 

Error: Incorrect padding

In [105]:
client = paramiko.SSHClient()

In [107]:
clientkey = client.get_host_keys()

In [110]:
clientkey


Out[110]:
<paramiko.hostkeys.HostKeys at 0x2584f50>

In [114]:
client.connect('192.168.1.6', username='deb', password='deb')


---------------------------------------------------------------------------
SSHException                              Traceback (most recent call last)
<ipython-input-114-bae6c0cb7787> in <module>()
----> 1 client.connect('192.168.1.6', username='deb', password='deb')

/usr/local/lib/python2.7/dist-packages/paramiko/client.pyc in connect(self, hostname, port, username, password, pkey, key_filename, timeout, allow_agent, look_for_keys, compress, sock, gss_auth, gss_kex, gss_deleg_creds, gss_host, banner_timeout)
    286                 # will raise exception if the key is rejected; let that fall out
    287                 self._policy.missing_host_key(self, server_hostkey_name,
--> 288                                               server_key)
    289                 # if the callback returns, assume the key is ok
    290                 our_server_key = server_key

/usr/local/lib/python2.7/dist-packages/paramiko/client.pyc in missing_host_key(self, client, hostname, key)
    568         client._log(DEBUG, 'Rejecting %s host key for %s: %s' %
    569                     (key.get_name(), hostname, hexlify(key.get_fingerprint())))
--> 570         raise SSHException('Server %r not found in known_hosts' % hostname)
    571 
    572 

SSHException: Server '192.168.1.6' not found in known_hosts