scan.py 文件源码

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

项目:CIDDS 作者: markusring 项目源码 文件源码
def main():

    echoC(__name__, "Starting a scan")

    # Determine subnets 
    ipRangeList = getIPRange()
    if ipRangeList == -1:
        return -1

    # Select a random subnet 
    rand = random.randint(0, len(ipRangeList)-1) 
    ipRange = ipRangeList[rand]

    # Define arguments 
    scanOptions = ["-sF", "-sA", "-sU", "-sS", "-n -sP -PE"]
    myArguments = random.choice(scanOptions) + " -T " + str(random.randint(1, 3))

    echoC(__name__, "Scanning " + str(ipRange) + " with arguments: " + myArguments)

    # Execute Scan 
    nm = nmap.PortScanner()
    nm.scan(hosts=ipRangeList[rand], arguments=myArguments)

    # Store the found IPs 
    # At first, delete old IPs 
    open(ipList, 'w').close()
    for i in nm.all_hosts():
        with open(ipList, 'a') as myfile:
            myfile.write(str(i) + '\n')

    echoC(__name__, "Done")

    returnval = "0,nmap args: " + myArguments
    return returnval
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号