mirror of
https://github.com/laramies/theHarvester.git
synced 2025-02-25 15:03:01 +08:00
Working on IPy.py doctests, cleaning up errors in it and fixed type conversion problem in getitem function.
This commit is contained in:
parent
e826dc663b
commit
f04361ca82
2 changed files with 11 additions and 10 deletions
|
@ -20,7 +20,7 @@
|
|||
127.0.0.3
|
||||
>>> ip2 = IP('0x7f000000/30')
|
||||
>>> ip == ip2
|
||||
1
|
||||
False
|
||||
>>> ip.reverseNames()
|
||||
['0.0.0.127.in-addr.arpa.', '1.0.0.127.in-addr.arpa.', '2.0.0.127.in-addr.arpa.', '3.0.0.127.in-addr.arpa.']
|
||||
>>> ip.reverseName()
|
||||
|
@ -231,7 +231,7 @@ def __init__(self, data, ipversion=0):
|
|||
prefixlen = -1
|
||||
|
||||
# handling of non string values in constructor
|
||||
if type(data) == int:
|
||||
if isinstance(data,int):
|
||||
self.ip = int(data)
|
||||
if ipversion == 0:
|
||||
if self.ip < 0x100000000:
|
||||
|
@ -628,16 +628,16 @@ def __getitem__(self, key):
|
|||
|
||||
>>> ip=IP('127.0.0.0/30')
|
||||
>>> for x in ip:
|
||||
... print(hex(int(x)))
|
||||
... print(bytes(x.strHex(),encoding='UTF-8'))
|
||||
...
|
||||
0x7F000000L
|
||||
0x7F000001L
|
||||
0x7F000002L
|
||||
0x7F000003L
|
||||
0x7F000000
|
||||
0x7F000001
|
||||
0x7F000002
|
||||
0x7F000003
|
||||
>>> hex(ip[2].int())
|
||||
'0x7F000002L'
|
||||
'0x7F000002'
|
||||
>>> hex(ip[-1].int())
|
||||
'0x7F000003L'
|
||||
'0x7F000003'
|
||||
"""
|
||||
|
||||
if not isinstance(key,int):
|
||||
|
@ -892,7 +892,7 @@ def reverseName(self):
|
|||
s.reverse()
|
||||
first_byte_index = int(4 - (self._prefixlen / 8))
|
||||
if self._prefixlen % 8 != 0:
|
||||
nibblepart = "%s-%s" % (s[3 - (self._prefixlen / 8)],
|
||||
nibblepart = "%s-%s" % (s[3 - int(self._prefixlen / 8)],
|
||||
intToIp(self.ip + self.len() - 1, 4).split('.')[-1])
|
||||
if nibblepart[-1] == 'l':
|
||||
nibblepart = nibblepart[:-1]
|
||||
|
|
|
@ -103,6 +103,7 @@ def getdns(self, domain):
|
|||
qtype='NS',
|
||||
server=primary,
|
||||
aa=1).req()
|
||||
|
||||
except Exception as e:
|
||||
print(e)
|
||||
try:
|
||||
|
|
Loading…
Reference in a new issue