netblock.py 文件源码

python
阅读 30 收藏 0 点赞 0 评论 0

项目:pentestly 作者: praetorian-inc 项目源码 文件源码
def cidrstrerr(str):
    """Check an IP address or CIDR netblock for validity.

    Returns None if it is and otherwise an error string."""
    if not cvalid.match(str):
        return 'Not a syntatically valid IP address or netblock'
    rng = 32
    pos = string.find(str, '/')
    ips = str
    if not pos == -1:
        rng = string.atoi(ips[pos+1:])
        ips = str[:pos]
    if rng < 0 or rng > 32:
        return 'CIDR length out of range'
    n = string.split(ips, '.')
    for i in n:
        ip = string.atoi(i)
        if (ip < 0 or ip > 255):
            return 'an IP octet is out of range'
    # could check to see if it is 'proper', but.
    return None
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号