@@ -0,0 +1,2643 @@
+import socket%0Afrom pymongo import MongoClient%0Aimport sys%0Aimport getpass%0A%0A__author__ = %22SREEJITH KOVILAKATHUVEETTIL CHANDRAN%22%0A__copyright__ = %22 Copyright 2015,SREEJITH KOVILAKATHUVEETTIL CHANDRAN%22%0A__email__ = %22sreeju_kc@hotmail.com%22%0A__license__ = %22Apache License 2.0%22%0A%0A%0Adef main():%0A    #for i in range(1,255):%0A%09#i = str(i)%0A%09#for k in range(1,255):%0A%09%09#k= str(k)%0A%09%09#for p in range(1,255):         # This will scan entire 10 network range(just need to replace ip with a digit) :)%0A%09%09%09#p = str(p)%0A%09%09%09#st = %22ip.%22+i+%22.%22+k+%22.%22+p%0A%09%09%09#print(st)%0A    for j in range(1,255):%0A        p = str(j)%0A        st = %22ip.ip.ip.%22+p # instead of word %22ip%22 you can replace an ip netwrok for ex: 192.168.1,that scan /24 network%0A        ports = %5B21,80,443,22,445,23,3389%5D #This way we can specipfy any number of ports want to look in%0A        for port in ports:%0A            #port = 21%0A            ip = st%0A            k = %22Open%22%0A            baner = bangrab(ip,port)%0A            if baner:%0A                baner = baner.strip('%5Cn')%0A                baner = baner.lstrip()%0A                baner = baner.rstrip()%0A                port = str(port)%0A                print('%5B+%5D' + ip + ' : ' + port+' : '+ baner.strip('%5Cn') + ' : '+k)            %0A                feedscan(ip,port,baner,k)%0Adef bangrab(ip,port):%0A    try:%0A        socket.setdefaulttimeout(2)%0A        s = socket.socket()%0A        k = s.connect((ip,port))%0A        baner = %22%22%0A        if k == None:%0A            try:%0A                if port == 80 or port == 443:%0A                    s.send('GET /index.htm HTTP/1.1')%0A                else:%0A                    s.send('Hello%5Cr%5Cn')%0A            except:%0A                pass%0A            try:%0A                baner = s.recv(1024)%0A            except:%0A                pass%0A            if baner == %22%22:%0A                baner =  %22No banner available%22%0A            s.close()%0A            return baner%0A    except:%0A        return    %0Adef feedscan(ip,port,baner,k):%0A    conn = MongoClient()%0A    conn = MongoClient('mongodb://ip.ip.ip.ip:27017/')#You need to setup a mongoDB server first and provide mongoDB server IP address%0A    db = conn.scan_db%0A    collection = db.scan_feed%0A    p = socket.gethostbyname(socket.gethostname())%0A    h = socket.getfqdn()%0A    u = getpass.getuser()%0A    post = %7B%22FromIP%22:p,%0A            %22HostnameScanned%22:h,%0A            %22UserScaned%22:u,%0A            %22IP%22: ip,%0A           %22Port%22: port,%0A           %22Version%22: baner,%0A            %22Status%22:k%7D%0A    pf = collection.find(%7B%22IP%22:ip,%22Port%22:port,%22Version%22: baner%7D).count()%0A    if pf %3E 0:  #avoid duplicate entries or you can create a primary key %0A        return%0A    collection.insert(post)%0Aif __name__ == %22__main__%22:%0A    main()%0A%0A

Create scanforme.py