Exemplo n.º 1
0
import socket
import sys
from gevent import monkey
monkey.patch_all(aggressive=False)
import gevent_openssl
gevent_openssl.monkey_patch()
from code import InteractiveConsole
from nylas.logging import get_logger

log = get_logger()

doc = """
This is the Inbox console - you can use it to interact with mailsync and track memory leaks.

Guppy is installed. To start tracking leaks, you probably want to setup guppy like this:
>>> from guppy import hpy
>>> global hp # put this in the global space so it persists between connections
>>> hp = hpy()
>>> hp.setrelheap()

and then inspect the heap, like this:
>>> hp.heap()

Happy hacking!

"""  # noqa


class RemoteConsole(InteractiveConsole):

    def __init__(self, socket, locals=None):
Exemplo n.º 2
0
def bruteforce_interface(portScan_result_list, timeout, no_default_dict,
                         proto_list, pool):
    password_total = Password_total()
    password_total.init(no_default_dict)
    try:
        import psycopg2
        tasksQueue = Queue.Queue()
        postgreSQL_login = PostgreSQL_login()
        for one_portscan_result in portScan_result_list:
            service = one_portscan_result.get("service").lower()
            ipaddress = one_portscan_result.get("ipaddress")
            port = one_portscan_result.get("port")
            if "postgresql" in service and "postgresql" in proto_list:
                tasksQueue.put(
                    (postgreSQL_login.login,
                     (ipaddress, port,
                      password_total.PostgreSQL_user_passwd_pair_list)))

        runner = Runer(100)
        runner.taskQueue = tasksQueue
        runner.start()
    except Exception as E:
        logger.warning("Can not import OpenSSL,PostgreSQL pass")

    # 协程扫描
    patch_all()
    try:
        import gevent_openssl
        gevent_openssl.monkey_patch()
        from bruteforce.rdp_check import check_rdp
        SSL_FLAG = True
    except Exception as E:
        logger.error("Can not import OpenSSL,RDP pass")
        SSL_FLAG = False

    if SSL_FLAG:
        rdp_login = RDP_login(timeout)  # 1.07500004768

    smb_login = SMB_login(timeout)  # 1.08800005913
    ssh_login = SSH_login(timeout)  # 30.617000103
    ftp_login = FTP_login(timeout)  # 9.10599994659
    mysql_login = MySQL_login(timeout)  # 15.7749998569
    mssql_login = MSSQL_login(timeout)  # 1.04799985886
    redis_login = Redis_login(timeout)  # 12.3710000515
    mongo_login = MongoDB_login(timeout)  # 12.9830000401
    memcached_login = Memcached_login(timeout)  # 2.07899999619
    vnc_login = VNC_login(timeout)  # 6.06700015068
    pool = pool
    tasks = []
    for one_portscan_result in portScan_result_list:
        service = one_portscan_result.get("service").lower()
        ipaddress = one_portscan_result.get("ipaddress")
        port = one_portscan_result.get("port")

        # 快的扫描
        if SSL_FLAG:
            if ("ms-wbt-server" in service
                    or "rdp" in service) and "rdp" in proto_list and SSL_FLAG:
                task = pool.spawn(rdp_login.login, ipaddress, port,
                                  password_total.RDP_user_passwd_pair_list)
                tasks.append(task)

        if "ssh" in service and "ssh" in proto_list:  # 原生支持协程,直接扫描
            ssh_login.login_with_pool(ipaddress, port,
                                      password_total.SSH_user_passwd_pair_list,
                                      pool.size)

        if "mongodb" in service and "mongodb" in proto_list:
            task = pool.spawn(mongo_login.login, ipaddress, port,
                              password_total.MongoDB_user_passwd_pair_list)
            tasks.append(task)
        if "ftp" in service and "ftp" in proto_list:
            task = pool.spawn(ftp_login.login, ipaddress, port,
                              password_total.FTP_user_passwd_pair_list)
            tasks.append(task)
        if "microsoft-ds" in service and "smb" in proto_list:
            task = pool.spawn(smb_login.login, ipaddress, port,
                              password_total.SMB_user_passwd_pair_list)
            tasks.append(task)
        if "mysql" in service and "mysql" in proto_list:
            task = pool.spawn(mysql_login.login, ipaddress, port,
                              password_total.MYSQL_user_passwd_pair_list)
            tasks.append(task)
        if "ms-sql-s" in service and "mssql" in proto_list:
            task = pool.spawn(mssql_login.login, ipaddress, port,
                              password_total.MSSQL_user_passwd_pair_list)
            tasks.append(task)
        if "redis" in service and "redis" in proto_list:
            task = pool.spawn(redis_login.login, ipaddress, port,
                              password_total.Redis_user_passwd_pair_list)
            tasks.append(task)
        if "memcached" in service and "memcached" in proto_list:
            task = pool.spawn(memcached_login.login, ipaddress, port,
                              password_total.Memcached_user_passwd_pair_list)
            tasks.append(task)
        if "vnc" in service and "vnc" in proto_list:
            task = pool.spawn(vnc_login.login, ipaddress, port,
                              password_total.VNC_user_passwd_pair_list)
            tasks.append(task)
    gevent.joinall(tasks)
Exemplo n.º 3
0
""" Fixtures don't go here; see util/base.py and friends. """
# Monkeypatch first, to prevent "AttributeError: 'module' object has no
# attribute 'poll'" errors when tests import socket, then monkeypatch.
from gevent import monkey
monkey.patch_all(aggressive=False)

import gevent_openssl
gevent_openssl.monkey_patch()

from inbox.test.util.base import *  # noqa
from inbox.util.testutils import (
    mock_imapclient,  # noqa
    mock_smtp_get_connection,  # noqa
    mock_dns_resolver,  # noqa
    dump_dns_queries,  # noqa
    files,  # noqa
    uploaded_file_ids)  # noqa
Exemplo n.º 4
0
from gevent import monkey; monkey.patch_all()
import gevent_openssl; gevent_openssl.monkey_patch()

import re
import random
import string
import pytz
import email
import email.header
import json
import time
import traceback
import smtplib
from email.mime.text import MIMEText
from imapclient import IMAPClient
from datetime import datetime, timedelta
from operator import itemgetter
import gevent
from gevent import Greenlet
from gevent.queue import Queue
from gevent.lock import Semaphore
from flask import Flask, render_template, Response, request
from flask_sockets import Sockets
from bs4 import BeautifulSoup

app = Flask(__name__)
sockets = Sockets(app)
spawn = gevent.Greenlet.spawn

CONFIG = json.load(file("config.json"))