netblock.py 文件源码

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

项目:pentestly 作者: praetorian-inc 项目源码 文件源码
def strtoip(ipstr):
    """convert an IP address in string form to numeric."""
    res = 0L
    count = 0
    n = string.split(ipstr, '.')
    for i in n:
        res = res << 8L
        ot = string.atoi(i)
        if ot < 0 or ot > 255:
            raise ValueError, "invalid IP octet"
        res = res + ot
        count = count + 1
    # could be incomplete (short); make it complete.
    while count < 4:
        res = res << 8L
        count = count + 1
    return res
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号