Zmap Scan MongoDB with multi-threaded verification scripts

Source: Internet
Author: User
Tags mongodb git clone
Installation Environment:
sudo apt-get install build-essential cmake libgmp3-dev libpcap-dev gengetopt byacc flex git dwarfdump
Download Zmap:
git clone git://github.com/zmap/zmap.git
Install Zmap:
Cmake-denable_hardening=on
Make && make install
(Kali installation Zmap also require additional installation of json-c)
Individuals prefer to scan with profiles.
Zmap-c/etc/zmap/zmap.conf-o Output.txt
A script that uses Python to write a batch validation Zmap scan results for unauthorized access.
The beginning of the code does not set a timeout, the results found just ran off a while, check the official documents of a Half-day Pymongo, found the CONNECTTIMEOUTMS, Sockettimeoutms these two parameters.
Set the connection timeout Connecttimeoutms, do not know why did not work, and changed to set the socket timeout time SOCKETTIMEOUTMS only valid.
Pymongo the default number of connections is 100, so the number of threads in the code is 99, you can adjust.
Attached is a multithreaded verification script written by the practitioner:

#/usr/bin/python
#coding:utf8
import sys
import pymongo
import urllib2,threading,time
import sys
from Queue import Queue
 
def conn(addr,output):
        try:
                w = open(output,'a')
                conn = pymongo.MongoClient(addr,27017,socketTimeoutMS=3000)
                dbname = conn.database_names()
                wr = "Ip: "+addr+"\r\n"
                wr += "dbs:\r\n"
                wr += str(dbname)+"\r\n"
                w.write(wr)
                print wr
                conn.close()
                w.close()
        except:
                print addr+" connection was failed\r\n"
class MyThread(threading.Thread):
        def __init__(self):
                threading.Thread.__init__(self)
        def run(self):
                global queue
                while not queue.empty():
                        ip = queue.get()
                        conn(ip,sys.argv[1]+".txt")
 
if __name__ == "__main__":
        queue = Queue()
        a = open(sys.argv[1],'r')
        for ip in a.readlines():
                ip = ip.strip('\n')
                queue.put(ip)
        for i in range(99):
                c = MyThread()
                c.start()

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.