# Path: lib/redisopt.py
# def get_hash(host, uri, postdata):
# def content_deal(headers, host, method, postdata, uri, packet):
# 
# Path: lib/out.py
# def windows_out(color, msg):
# def good(msg):
# def warning(msg):
# def error(msg):
# def jump(url):
# def alert(content, url):
#     STD_OUTPUT_HANDLE = -11
# 
# Path: lib/scan.py
# def thread_filled():
# def time_requests(method, url, headers, postdata=""):
# def request_payload(request, payload, param, postdata=False, time_check=False):
# def query_collect(query, url):
# def requests_convert(request):
# def scan_start():
# def new_scan(reqhash, request, rules):
# def common_scan(request, config_level, re_test, scan_type):
# def sqlireflect_scan(request, level):
# def ldap_scan(request, level):
# def lfi_scan(request, level):
# def xpath_scan(request, level):
# def xss_scan(request, config_level):
# def sqlibool_scan(request, config_level):
# def sqlitime_scan(request, config_level):
# def sqlmap_scan(request, level):
#                         VAR = '500000'
#                         VAR = '500000'
# 
# Path: lib/secure.py
# def clear(s):
# def kill(addr, port, data):
# def check_requirements():
# def check_redis():
# 
# Path: lib/config.py
# def load():
# def update(conf):
# def load_rule():
# def update_rule(rule):
# def rule_read(name, get_file_handle=None):
# def rule_write(name, rule):
# 
# Path: lib/session.py
# def new(ip):
# def check(session):
# def update(session):
# def destroy(session):
# def size_control():
# 
# Path: proxy/pyscapy.py
# def extract(data, out):
# def print_request(method, host, url):
# def capture(x):
# def main():
#     NIC = config.load()["scapy_network_card"]  # network adapter name
# 
# Path: proxy/mix_proxy.py
# def https_things(sock):
# def get_str(res):
# def get_res(data, connstream, https):
# def client_conn(connstream, https=False):
# def main():
# 
# Path: proxy/proxy_io.py
# def get_proxy(url):
# def parse_proxy(proxy):
# def fetch_request(url, callback, **kwargs):
#     def deal(method):
#         def wrapper(self, *args, **kwargs):
#     def compute_etag(self):
#     def extract_request(self, url, headers, method, body):
#     def get(self):
#             def handle_response(response):
#     def post(self):
#     def connect(self):
#         def read_from_client(data):
#         def read_from_upstream(data):
#         def client_close(data=None):
#         def upstream_close(data=None):
#         def start_tunnel():
#         def on_proxy_response(data=None):
#         def start_proxy_tunnel():
# def run_proxy(port, address):
# def main():
# class ProxyHandler(tornado.web.RequestHandler):
# 
# Path: web/handlers/base.py
# class BaseHandler(tornado.web.RequestHandler):
# 
#     """
#     All the function need to login
#     """
# 
#     def initialize(self):
#         cookie = self.get_cookie("ysrc_token")
#         if cookie == "" or not session.check(cookie):
#             self.login = False
#         else:
#             self.login = True
# 
# def authenticated(method):
#     def wrapper(self, *args, **kwargs):
#         if not self.login:
#             self.set_header("Location", "/login")
#             self.set_status(302)
#             return
#         else:
#             return method(self, *args, **kwargs)
#     return wrapper


import json
import base64
import urllib
import threading
import tornado.web
from lib.redisopt import conn
from lib import out
from lib import scan
from lib import secure
from lib import config
from lib import session
from proxy import pyscapy, mix_proxy, proxy_io
from web.handlers.base import BaseHandler, authenticated

    @authenticated
    def post(self):
        conf_all = config.load()
        for i in self.request.body.split("&"):
            para = secure.clear(urllib.unquote(i.split("=", 1)[0]))
            value = secure.clear(urllib.unquote(i.split("=", 1)[1]))
            if para in conf_all.keys():
                conf_all[para] = value
        config.update(conf_all)
        return self.render("config.html", config=config.load())


class ScanConfigHandler(BaseHandler):

    @authenticated
    def get(self):
        start = {}
        rule = ["sqlireflect", "sqlitime", "sqlmap", "xpath", "xss", "lfi", "ldap", "sqlibool"]
        for i in rule:
            start[i + "_true"] = ""
            start[i + "_false"] = "checked"
        for i in config.load_rule()["scan_type"]:
            start[i + "_true"] = "checked"
            start[i + "_false"] = ""
        rules = {}
        for i in rule:
            rules[i] = config.rule_read(i)
        return self.render("scan_config.html", config=config.load(), start=start, rules=rules, scan_stat=config.load()['scan_stat'], sqlmap_api=config.load_rule()['sqlmap_api'])


# Path: lib/redisopt.py
# def get_hash(host, uri, postdata):
# def content_deal(headers, host, method, postdata, uri, packet):
# 
# Path: lib/out.py
# def windows_out(color, msg):
# def good(msg):
# def warning(msg):
# def error(msg):
# def jump(url):
# def alert(content, url):
#     STD_OUTPUT_HANDLE = -11
# 
# Path: lib/scan.py
# def thread_filled():
# def time_requests(method, url, headers, postdata=""):
# def request_payload(request, payload, param, postdata=False, time_check=False):
# def query_collect(query, url):
# def requests_convert(request):
# def scan_start():
# def new_scan(reqhash, request, rules):
# def common_scan(request, config_level, re_test, scan_type):
# def sqlireflect_scan(request, level):
# def ldap_scan(request, level):
# def lfi_scan(request, level):
# def xpath_scan(request, level):
# def xss_scan(request, config_level):
# def sqlibool_scan(request, config_level):
# def sqlitime_scan(request, config_level):
# def sqlmap_scan(request, level):
#                         VAR = '500000'
#                         VAR = '500000'
# 
# Path: lib/secure.py
# def clear(s):
# def kill(addr, port, data):
# def check_requirements():
# def check_redis():
# 
# Path: lib/config.py
# def load():
# def update(conf):
# def load_rule():
# def update_rule(rule):
# def rule_read(name, get_file_handle=None):
# def rule_write(name, rule):
# 
# Path: lib/session.py
# def new(ip):
# def check(session):
# def update(session):
# def destroy(session):
# def size_control():
# 
# Path: proxy/pyscapy.py
# def extract(data, out):
# def print_request(method, host, url):
# def capture(x):
# def main():
#     NIC = config.load()["scapy_network_card"]  # network adapter name
# 
# Path: proxy/mix_proxy.py
# def https_things(sock):
# def get_str(res):
# def get_res(data, connstream, https):
# def client_conn(connstream, https=False):
# def main():
# 
# Path: proxy/proxy_io.py
# def get_proxy(url):
# def parse_proxy(proxy):
# def fetch_request(url, callback, **kwargs):
#     def deal(method):
#         def wrapper(self, *args, **kwargs):
#     def compute_etag(self):
#     def extract_request(self, url, headers, method, body):
#     def get(self):
#             def handle_response(response):
#     def post(self):
#     def connect(self):
#         def read_from_client(data):
#         def read_from_upstream(data):
#         def client_close(data=None):
#         def upstream_close(data=None):
#         def start_tunnel():
#         def on_proxy_response(data=None):
#         def start_proxy_tunnel():
# def run_proxy(port, address):
# def main():
# class ProxyHandler(tornado.web.RequestHandler):
# 
# Path: web/handlers/base.py
# class BaseHandler(tornado.web.RequestHandler):
# 
#     """
#     All the function need to login
#     """
# 
#     def initialize(self):
#         cookie = self.get_cookie("ysrc_token")
#         if cookie == "" or not session.check(cookie):
#             self.login = False
#         else:
#             self.login = True
# 
# def authenticated(method):
#     def wrapper(self, *args, **kwargs):
#         if not self.login:
#             self.set_header("Location", "/login")
#             self.set_status(302)
#             return
#         else:
#             return method(self, *args, **kwargs)
#     return wrapper


# Path: web/handlers/main.py
import json
import base64
import urllib
import threading
import tornado.web
from lib.redisopt import conn
from lib import out
from lib import scan
from lib import secure
from lib import config
from lib import session
from proxy import pyscapy, mix_proxy, proxy_io
from web.handlers.base import BaseHandler, authenticated


    @authenticated
    def post(self):
        conf_all = config.load()
        for i in self.request.body.split("&"):
            para = secure.clear(urllib.unquote(i.split("=", 1)[0]))
            value = secure.clear(urllib.unquote(i.split("=", 1)[1]))
            if para in conf_all.keys():
                conf_all[para] = value
        config.update(conf_all)
        return self.render("config.html", config=config.load())


class ScanConfigHandler(BaseHandler):

    @authenticated
    def get(self):
        start = {}
        rule = ["sqlireflect", "sqlitime", "sqlmap", "xpath", "xss", "lfi", "ldap", "sqlibool"]
        for i in rule:
            start[i + "_true"] = ""
            start[i + "_false"] = "checked"
        for i in config.load_rule()["scan_type"]:
            start[i + "_true"] = "checked"
            start[i + "_false"] = ""
        rules = {}
        for i in rule:
            rules[i] = config.rule_read(i)
        return self.render("scan_config.html", config=config.load(), start=start, rules=rules, scan_stat=config.load()['scan_stat'], sqlmap_api=config.load_rule()['sqlmap_api'])


    @authenticated