Example #1
0
def callback(ch, method, properties, body):
    print(" [x] Received %r" % body)
    proxies = {
        "http": "http://%s"%(body)
    }
    try:
        response = requests.get(home_url, proxies=proxies, timeout=timeout)
        mq = RabbitMQ(queue="proxy")
        mq.publish(body)
        print "%s is good" % (body)
    except requests.exceptions.ConnectTimeout:
        pass
    except requests.exceptions.ReadTimeout:
        pass
    except requests.exceptions.ConnectionError:
        pass
Example #2
0
 def __init__(self):
     handlers = [
         (r"/", MainHandler),
         (r"/vin/v1/(\w+)", VinCodeHandler),
         (r"/wmi/v1/(\w+)", WmiCodeHandler),
         (r"/vin/v1/checksum/(\w+)", VinChecksumHandler),
     ]
     self.mongo = MongoDB(host=settings.mongodb["host"])
     self.rabbitmq = RabbitMQ(host=settings.rabbitmq["host"])
     tornado.web.Application.__init__(self, handlers, debug=True)
def parse_html(html):
    soup = BeautifulSoup(html, "html.parser")
    tables = soup.findAll('table')
    table = tables[0]
    mq = RabbitMQ(queue="cybersyndrome")
    for tr in table.findAll('tr')[1:]:
        tds = tr.findAll('td')
        if len(tds) > 0:
            content = tds[1].string
            ip, port = content.split(":")
            print content
            try:
                ip_tmp = ipaddress.IPv4Address(ip.decode("utf-8"))
                if ip_tmp.is_private or ip_tmp.is_reserved or ip_tmp.is_multicast:
                    print "private,reserved,multicast is not valid"
                    continue
            except ipaddress.AddressValueError, msg:
                print msg
                continue
            mq.publish(content)
Example #4
0
def parse_html(html):
    soup = BeautifulSoup(html, "html.parser")
    tables = soup.findAll('table', id="ip_list")
    table = tables[0]
    mq = RabbitMQ(queue="xicidaili")
    for tr in table.findAll('tr'):
        tds = tr.findAll('td')
        if len(tds) > 0:
            ip = tds[1].string
            port = tds[2].string
            content = "%s:%s" %(ip, port)
            print content
            try:
                ip_tmp = ipaddress.IPv4Address(ip.decode("utf-8"))
                if ip_tmp.is_private or ip_tmp.is_reserved or ip_tmp.is_multicast:
                    print "private,reserved,multicast is not valid"
                    continue
            except ipaddress.AddressValueError, msg:
                print msg
                continue
            mq.publish(content)
Example #5
0
def parse_html(html):
    soup = BeautifulSoup(html, "html.parser")
    tables = soup.findAll('table')
    table = tables[0]
    mq = RabbitMQ(queue="httpsdaili")
    for row in table.findAll('tr'):
        ips = row.findAll('td', attrs={"class": "style1"})
        ports = row.findAll('td', attrs={"class": "style2"})
        if not ips or not ports:
            continue
        ip = ips[0].string
        port = ports[0].string
        content = "%s:%s" % (ip, port)
        print content
        try:
            ip_tmp = ipaddress.IPv4Address(ip.decode("utf-8"))
            if ip_tmp.is_private or ip_tmp.is_reserved or ip_tmp.is_multicast:
                print "private,reserved,multicast is not valid"
                continue
        except ipaddress.AddressValueError, msg:
            print msg
            continue
        mq.publish(content)
Example #6
0
from django.http import HttpResponse
from rabbitmq.rabbitmq import RabbitMQ
import json

mq = RabbitMQ()
chan = mq.get_mq_channel()
exchange = 'topic_logs'


# Create your views here.
def topics(request):
    chan.exchange_declare(exchange=exchange, exchange_type='topic')
    if request.method == 'GET':
        chan.basic_publish(exchange=exchange,
                           routing_key='anonymous.info',
                           body='Hello World!')
    else:
        body = json.loads(request.body)
        chan.basic_publish(exchange=exchange,
                           routing_key=body['routing'],
                           body=body['body'])
    return HttpResponse()
Example #7
0
def main():
    queue = "kuaidaili"
    if len(sys.argv) >= 2:
        queue = sys.argv[1]
    mq = RabbitMQ(queue=queue)
    mq.start_consuming(callback)
Example #8
0
def requeue_server(server):
    mq = RabbitMQ(queue="proxy")
    mq.publish(server)
Example #9
0
def next_server():
    mq = RabbitMQ(queue="proxy")
    return mq.basic_get()