#!/usr/bin/env python # -*- coding: utf-8 -*- # @Author : TideSec # @Time : 18-5-17 # @File : nmap_scanner.py # @Desc : "" import nmap from mars.views.lib.mongo_db import connectiondb, db_name_conf port_db = db_name_conf()['port_db'] class NmapScanner: def __init__(self, target, arguments, scan_id): self.target = target self.arguments = arguments self.scan_id = scan_id self.ports = [] self.result = [] def scan(self): port_scanner = nmap.PortScanner() try: port_scanner.scan(self.target, arguments=self.arguments) except Exception as e: print self.target, e return port_scanner def port_result(self): self.result.append(self.scan().command_line())
# @Author : TideSec # @Time : 18-6-19 # @File : auth_scanner.py # @Desc : "" import time from threading import Thread from datetime import datetime from multiprocessing import Pool from mars.views.lib.mongo_db import connectiondb, db_name_conf from mars.views.modules.auth_tester.hydra_plugin import HydraScanner, ServiceCheck from mars.views.lib.parse_target import parse_target from apscheduler.schedulers.blocking import BlockingScheduler from instance import config_name config_db = db_name_conf()['config_db'] weekpasswd_db = db_name_conf()['weekpasswd_db'] auth_db = db_name_conf()['auth_db'] def hydra_scanner(target_list, service, username_list, password_list, args): start = HydraScanner(target_list, service, username_list, password_list, args) result = start.scanner() return result def service_check(target_list, service, args): start = ServiceCheck(target_list, service, args) result = start.service_check() return result
# @Author : TideSec # @Time : 18-5-19 # @File : domain_brute.py # @Desc : "" import dns.resolver from multiprocessing import Pool, Lock from datetime import datetime from random import sample from string import digits, ascii_lowercase from mars.views.lib.mongo_db import connectiondb, db_name_conf from mars.views.lib.get_title import get_title from instance import config_name lock = Lock() domain_db = db_name_conf()['domain_db'] config_db = db_name_conf()['config_db'] subdomain_db = db_name_conf()['subdomain_db'] def resolution(domain): _result = {} record_a = [] record_cname = [] try: respond = dns.resolver.query(domain.strip()) for record in respond.response.answer: for i in record.items: if i.rdtype == dns.rdatatype.from_text('A'): record_a.append(str(i)) _result[domain] = record_a
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Author : TideSec # @Time : 18-5-30 # @File : asset_discovery.py # @Desc : "" import nmap import time from multiprocessing import Pool from apscheduler.schedulers.blocking import BlockingScheduler from mars.views.lib.mongo_db import connectiondb, db_name_conf from mars.views.lib.parse_target import parse_target from instance import config_name config_db = db_name_conf()['config_db'] asset_db = db_name_conf()['asset_db'] server_db = db_name_conf()['server_db'] class AssetDiscovery: def __init__(self, asset_id): self.asset_id = asset_id self.result_tmp = [] self.result = [] self.port_list = connectiondb(config_db).find_one({"config_name": config_name})['port_list'] self.processes = connectiondb(config_db).find_one({"config_name": config_name})['discovery_thread'] self.asset_name = connectiondb(asset_db).find_one({"_id": self.asset_id})['asset_name'] self.host_list = parse_target(connectiondb(asset_db).find_one({"_id": self.asset_id})['asset_host']) def set_discovery(self):
# -*- coding: utf-8 -*- # @Author : TideSec # @Time : 18-5-22 # @File : vul_scanner.py # @Desc : "" import time from bson import ObjectId from flask import Blueprint, render_template, request, jsonify from mars.views.lib.parse_target import parse_target from mars.views.lib.mongo_db import connectiondb, db_name_conf from mars.views.authenticate import login_check from mars.views.modules.vul_scanner.awvs_api import AcunetixScanner vul_scanner = Blueprint('vul_scanner', __name__) vul_db = db_name_conf()['vulscan_db'] @vul_scanner.route('/vul-scanner', methods=['GET', 'POST']) #@login_check def vul_view(): # scanner view if request.method == "GET": vul_task = connectiondb(vul_db).find() return render_template('vul-scanner.html', vul_task=vul_task) else: if request.form.get('source') == "new_scan": target_id = [] task_name = request.form.get('task_name') target_list = request.form.get('target_addr').split("\n") scan_type = request.form.get('scan_type')
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Author : TideSec # @Time : 18-5-14 # @File : parse_plugin.py # @Desc : "" import os import re from mars.views.lib.mongo_db import connectiondb, db_name_conf from flask import Flask app = Flask(__name__) plugin_db = db_name_conf()['plugin_db'] def parse_plugin(plugin_filename): name_pattern = re.compile(r'name\s*=\s*[\'\"\[](.*)[\'\"\]]') author_pattern = re.compile(r'author\s*=\s*[\'\"\[](.*)[\'\"\]]') date_pattern = re.compile(r'vulDate\s*=\s*[\'\"\[](.*)[\'\"\]]') app_pattern = re.compile(r'appName\s*=\s*[\'\"\[](.*)[\'\"\]]') type_pattern = re.compile(r'vulType\s*=\s*[\'\"\[](.*)[\'\"\]]') version_pattern = re.compile(r'appVersion\s*=\s*[\'\"\[](.*)[\'\"\]]') plugin_data = open(plugin_filename, 'r').read() try: plugin_name = name_pattern.findall(plugin_data) plugin_author = author_pattern.findall(plugin_data) plugin_date = date_pattern.findall(plugin_data) plugin_app = app_pattern.findall(plugin_data) plugin_type = type_pattern.findall(plugin_data) plugin_version = version_pattern.findall(plugin_data)
# @File : poc_scanner.py # @Desc : =_=!! import sched import time, hashlib import datetime from multiprocessing import Pool, Lock from threading import RLock from pocsuite.api.cannon import Cannon from apscheduler.schedulers.blocking import BlockingScheduler from bson.objectid import ObjectId from mars.views.lib.mongo_db import connectiondb, db_name_conf from mars.views.lib.parse_target import parse_target from instance import config_name config_db = db_name_conf()['config_db'] tasks_db = db_name_conf()['tasks_db'] vul_db = db_name_conf()['vul_db'] plugin_db = db_name_conf()['plugin_db'] server_db = db_name_conf()['server_db'] schedule = sched.scheduler(time.time, time.sleep) lock = Lock() thread_lock = RLock() def md5hash(ip): md5 = hashlib.md5() md5.update(ip) return md5.hexdigest()