Ejemplo n.º 1
0
    def gethostbyaddr(self, ip_address):
        if ip_address in (u'127.0.0.1', u'::1',
                          b'127.0.0.1', b'::1',
                          'localhost'):
            return _socket.gethostbyaddr(ip_address)

        if not isinstance(ip_address, hostname_types):
            raise TypeError("argument 1 must be str, bytes or bytearray, not %s" % (type(ip_address),))

        return resolver._gethostbyaddr(ip_address)
Ejemplo n.º 2
0
def portScan(tgtHost, tgtPorts):
    try:
        tgtIP = gethostbyname(tgtHost)
    except:
        print ("[-] Cannot resovle '%s' : Unknown host"%tgtHost)
        return
    try:
        tgtName = gethostbyaddr(tgtIP)
        print ("\n[+] Scan Result for: " + tgtName[0])
    except:
        print ("\n[+] Scan Result for: " + tgtIP)
    setdefaulttimeout(1)
    for tgtPort in tgtPorts:
#         print ("Scanning Port " + tgtPort)
        t = Thread(target=nmapScan, args=(tgtHost, tgtPort))
        t.start()
Ejemplo n.º 3
0
def portScan(tgtHost, tgtPorts):
    try:
        tgtIP = gethostbyname(tgtHost)
    except:
        print("[-] Cannot resovle '%s' : Unknown host" % tgtHost)
        return
    try:
        tgtName = gethostbyaddr(tgtIP)
        print("\n[+] Scan Result for: " + tgtName[0])
    except:
        print("\n[+] Scan Result for: " + tgtIP)
    setdefaulttimeout(1)
    for tgtPort in tgtPorts:
        #         print ("Scanning Port " + tgtPort)
        t = Thread(target=nmapScan, args=(tgtHost, tgtPort))
        t.start()
 def test_gethostbyaddr(self):
     '''Tests _socket.gethostbyaddr'''
     _socket.gethostbyaddr("localhost")
     _socket.gethostbyaddr("127.0.0.1")
Ejemplo n.º 5
0
#this module uses gethostbyip function to get urls from the ip address
from _socket import gethostbyaddr
from scapy import all
from scapy.all import *
from scapy.layers.inet import TCP, IP

import getip
a = open("filepath.txt", "r")
#dta stored in file using test .py  can be accesed using filevar
filevar = a.read()
a.close()

packets = scapy.all.rdpcap(filevar)

print(packets)

for p in packets:
    if p.haslayer(IP):
        ipadress = p[IP].dst
        try:
            a = gethostbyaddr(str(ipadress))
            print(a)

        except socket.error:
            print('error in getting address')
Ejemplo n.º 6
0
import os
import _socket

for addr in range(33, 101):
    try:
        my_host = _socket.gethostbyaddr("192.168.0." + str(addr))
        print(my_host)
    except Exception as e:
        print(str(addr) + " not windows")
        try:
            my_host = os.uname("192.168.0." + str(addr))
        except Exception as e:
            print(e)
            print(str(addr) + " is not used")
Ejemplo n.º 7
0
    '199.7.189.173',
    '199.7.189.174',
    '199.7.189.175',
    '199.7.189.176',
    '199.7.189.177',
    '199.7.189.178',
    '199.7.189.179',
    '199.7.189.180',
    '199.7.189.181',
    '199.7.189.182',
    '199.7.189.183',
    '199.7.189.184',
    '199.7.189.185',
    '199.7.189.186',
    '199.7.189.187',
    '199.7.189.188',
    '199.7.189.189',
    '199.7.189.190',
]

_dict = {}
for i in IPS:
    try:
        if gethostbyaddr(i)[0] not in _dict:
            _dict[gethostbyaddr(i)[0]] = [i]
        else:
            _dict[gethostbyaddr(i)[0]].append(i)
    except:
        pass
print(_dict)
Ejemplo n.º 8
0
 def from_addr(cls, addr):
     """creates an Address instance from a host address"""
     try:
         name, aliases, addresses = _socket.gethostbyaddr(addr)
     except _socket.error, ex:
         raise AddressError(*ex.args)
Ejemplo n.º 9
0
 def from_addr(cls, addr):
     """creates an Address instance from a host address"""
     try:
         name, aliases, addresses = _socket.gethostbyaddr(addr)
     except _socket.error, ex:
         raise AddressError(*ex.args)
Ejemplo n.º 10
0
 def test_gethostbyaddr(self):
     '''Tests _socket.gethostbyaddr'''
     _socket.gethostbyaddr("localhost")
     _socket.gethostbyaddr("127.0.0.1")