Ejemplo n.º 1
0
def run(filename):
    f = file(filename)
    table = ''
    for eachLine in f:
        line = eachLine.strip().decode('utf-8')
        data = json.loads(line) 
        ws = Website()
        ws.parse(data)
        table += ws.to_tr()
        logging.debug(ws.dict)
    f.close

    html = toHTML(table)
    print(html)
Ejemplo n.º 2
0
def run(filename):
    f = file(filename)
    table = ''
    for eachLine in f:
        line = eachLine.strip().decode('utf-8')
        data = json.loads(line)
        ws = Website()
        ws.parse(data)
        table += ws.to_tr()
        logging.debug(ws.dict)
    f.close

    html = toHTML(table)
    print(html)
Ejemplo n.º 3
0
    def get_targets():
        """
        Retrieve and yield list of sites (targets) for testing.
        """
        for site in sites:
            _ = populate_site(site, args)
            if not _:
                continue
            target = Website(_, {"verbose": args.verbose})

            if not target.user_agent:
                target.user_agent = args.user_agent

            yield target
Ejemplo n.º 4
0
    def get_targets():
        """
        Retrieve and yield list of sites (targets) for testing.
        """
        for site in sites:
            _ = populate_site(site, args)
            if not _:
                continue
            target = Website(_, {"verbose": args.verbose})

            if not target.user_agent:
                target.user_agent = args.user_agent

            yield target
Ejemplo n.º 5
0
def list():
    f = file(filename)
    table = ''
    ws = Website()
    for eachLine in f:
        line = eachLine.strip().decode('utf-8')
        data = json.loads(line)
        ws.parse(data)
        table += ws.to_tr()
    f.close
    html = '<html><head><meta http-equiv="content-type" content="text/html;charset=utf-8"></head>'
    html += '<table border-spacing="0" border="1">\n<tr>'
    html += '<tr><th>Target</th><th>Status</th><th>Title</th><th>IP</th><th>Server</th>'
    html += '<th>Country</th><th>Password</th><th>Cookies</th><th>Email</th><th>Tags</th></tr>'
    html += table
    html += "\n</table></html>"
    return html
Ejemplo n.º 6
0
def list():
    f = file(filename)
    table = ''
    ws = Website()
    for eachLine in f:
        line = eachLine.strip().decode('utf-8')
        data = json.loads(line) 
        ws.parse(data)
        table += ws.to_tr()
    f.close
    html = '<html><head><meta http-equiv="content-type" content="text/html;charset=utf-8"></head>'
    html += '<table border-spacing="0" border="1">\n<tr>'
    html += '<tr><th>Target</th><th>Status</th><th>Title</th><th>IP</th><th>Server</th>'
    html += '<th>Country</th><th>Password</th><th>Cookies</th><th>Email</th><th>Tags</th></tr>'
    html += table
    html += "\n</table></html>"
    return html
Ejemplo n.º 7
0
def updateDB():
    global lastUpdated, website
    now = time.time()
    if now - lastUpdated >= 1800:
        # meaning 30 minutes have passed
        del website
        website = Website()
        # starts the parsing process again
        lastUpdated = now
Ejemplo n.º 8
0
def sort():
    f = file(filename)
    ws = Website()
    for eachLine in f:
        line = eachLine.strip().decode('utf-8')
        data = json.loads(line)
        ws.sort(data)
    f.close

    html = '<html><head><meta http-equiv="content-type" content="text/html;charset=utf-8"></head>'
    html += '<table border-spacing="0" border="1">\n<tr>'
    html += '<tr><th>Tags</th><th>Target</th></tr>'

    data = ws.to_sort()
    for i in data:
        html += '<tr><td>' + i + '</td><td>' + data[i] + '</td></tr>'

    html += "\n</table></html>"
    return html
Ejemplo n.º 9
0
def sort():
    f = file(filename)
    ws = Website()
    for eachLine in f:
        line = eachLine.strip().decode('utf-8')
        data = json.loads(line) 
        ws.sort(data)
    f.close

    html = '<html><head><meta http-equiv="content-type" content="text/html;charset=utf-8"></head>'
    html += '<table border-spacing="0" border="1">\n<tr>'
    html += '<tr><th>Tags</th><th>Target</th></tr>'

    data = ws.to_sort()
    for i in data:
        html += '<tr><td>'+i+'</td><td>'+ data[i] +'</td></tr>'

    html += "\n</table></html>"
    return html
Ejemplo n.º 10
0
from flask import Flask, jsonify
from flask import request
from lib.website import Website
import json
import time

app = Flask(__name__)

global website, lastUpdated
lastUpdated = time.time()
website = Website()


@app.route("/classinfo", methods=["POST"])
def classinfo():
    updateDB()
    subjcode = request.form['classname'].upper()
    result = website.getClassInfo(subjcode)

    if result == None:
        return jsonify({"count": 0})
    else:
        resultJson = {"count": 1, "result": [result.getDict()]}
        print(resultJson)
        return jsonify(resultJson)


@app.route("/roominfo", methods=["POST"])
def roominfo():
    updateDB()
    room = request.form['room'].upper()
Ejemplo n.º 11
0
def main():
    """
    Initializes and executes the program.
    """

    login_sucessful = []
    login_failed = []
    login_skipped = []

    version = check_revision(VERSION)

    print("%s\n\n%s %s (%s)\n" % (
        BANNER % tuple([color(_) for _ in BANNER_PASSWORDS]),
        NAME, version, URL))

    args = parse_args()

    if args.update:
        update()
        exit()

    if args.list:
        sites = list_sites()
        for _ in sites:
            print("- %s" % _)
        exit()

    if not args.password and not args.load_file:
        args.password = getpass("%s Please enter password:"******"(?P<type>[^:]+)://(?P<address>[^:]+)"
                          r":(?P<port>\d+)", args.proxy, re.I)
        if match:
            if match.group("type").upper() in ("HTTP", "HTTPS"):
                proxy_host = "%s:%s" % (match.group("address"),
                                        match.group("port"))
                proxy_handler = ProxyHandler({"http": proxy_host,
                                              "https": proxy_host})
            else:
                from thirdparty.socks import socks
                if match.group("type").upper() == "SOCKS4":
                    socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS4,
                                          match.group("address"),
                                          int(match.group("port")), True)
                elif match.group("type").upper() == "SOCKS5":
                    socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5,
                                          match.group("address"),
                                          int(match.group("port")), True)
                proxy_handler = None
        else:
            proxy_handler = ProxyHandler()
    else:
        proxy_handler = None

    opener = build_opener(HTTPHandler(), HTTPSHandler(),
                          HTTPCookieProcessor(cookie_handler))
    if proxy_handler:
        opener.add_handler(proxy_handler)

    install_opener(opener)

    with open(USER_AGENTS_FILE, 'r') as ua_file:
        args.user_agent = sample(ua_file.readlines(), 1)[0].strip()

    credentials = {"username": args.username, "email": args.email,
                   "password": quote(args.password)}
    sites = list_sites()

    if args.only:
        sites = [site for site in sites if site in args.only]
    elif args.exclude:
        sites = [site for site in sites if site not in args.exclude]

    print("%s Loaded %d %s to test." %
          (INFO, len(sites), "site" if len(sites) == 1 else "sites"))

    if args.load_file:
        if not isfile(args.load_file):
            print("%s could not find the file \"%s\"" %
                  (WARN, color(args.load_file)))
            exit()

        _ = sum(1 for line in open(args.load_file, "r"))
        if _ < 1:
            print("%s the file \"%s\" doesn't contain any valid credentials." %
                  (WARN, color(args.load_file)))
            exit()

        print("%s Loaded %d credential%s from \"%s\".\n" %
              (INFO, _, "s" if _ != 1 else "", color(args.load_file)))

    print("%s Starting tests at: \"%s\"\n" % (INFO, color(strftime("%X"), BW)))

    if not exists(OUTPUT_DIR):
        makedirs(OUTPUT_DIR)

    log = logger("%s/credmap" % OUTPUT_DIR)
    log.open()

    for site in sites:
        _ = populate_site(site, args)
        if not _:
            continue
        target = Website(_, {"verbose": args.verbose})

        if not target.user_agent:
            target.user_agent = args.user_agent

        def login():
            """
            Verify credentials for login and check if login was successful.
            """
            if(target.username_or_email == "email" and not
               credentials["email"] or
               target.username_or_email == "username" and not
               credentials["username"]):
                if args.verbose:
                    print("%s Skipping %s\"%s\" since "
                          "no \"%s\" was specified.\n" %
                          (INFO, "[%s:%s] on " %
                           (credentials["username"] or
                            credentials["email"], credentials["password"]) if
                           args.load_file else "", color(target.name),
                           color(target.username_or_email, BW)))
                    login_skipped.append(target.name)
                return

            print("%s Testing %s\"%s\"..." %
                  (TEST, "[%s:%s] on " % (credentials["username"] or
                                          credentials["email"],
                                          credentials["password"]) if
                   args.load_file else "", color(target.name, BW)))

            cookie_handler.clear()

            if target.perform_login(credentials, cookie_handler):
                log.write(">>> %s - %s:%s\n" %
                          (target.name, credentials["username"] or
                           credentials["email"], credentials["password"]))
                login_sucessful.append("%s%s" %
                                       (target.name, " [%s:%s]" %
                                        (credentials["username"] or
                                         credentials["email"],
                                         credentials["password"]) if
                                        args.load_file else ""))
            else:
                login_failed.append(target.name)

        if args.load_file:
            with open(args.load_file, "r") as load_list:
                for user in load_list:
                    user = user.rstrip().split(":", 1)
                    if not user[0]:
                        continue

                    match = re.match(r"^[A-Za-z0-9._%+-]+@(?:[A-Z"
                                     r"a-z0-9-]+\.)+[A-Za-z]{2,12}$", user[0])
                    credentials = {"email": user[0] if match else None,
                                   "username": None if match else user[0],
                                   "password": user[1]}

                    login()
        else:
            login()

    log.close()

    if not args.verbose:
        print()

    if len(login_sucessful) > 0 or len(login_failed) > 0:
        _ = "%s/%s" % (color(len(login_sucessful), BW),
                       color(len(login_sucessful) + len(login_failed), BW))
        sign = PLUS if len(login_sucessful) > (len(login_failed) +
                                               len(login_skipped)) else INFO
        print("%s Succesfully logged in%s." %
              (sign, " with %s credentials on the list." % _ if args.load_file
               else "to %s websites." % _),)
        print("%s An overall success rate of %s.\n" %
              (sign, color("%%%s" % (100 * len(login_sucessful) /
                                     (len(login_sucessful) +
                                      len(login_failed))), BW)))

    if len(login_sucessful) > 0:
        print("%s The provided credentials worked on the following website%s: "
              "%s\n" % (PLUS, "s" if len(login_sucessful) != 1 else "",
                        ", ".join(login_sucessful)))

    print("%s Finished tests at: \"%s\"\n" % (INFO, color(strftime("%X"), BW)))
Ejemplo n.º 12
0
def main():
    """
    Initializes and executes the program
    """

    login_sucessful = []
    login_failed = []

    version = check_revision(VERSION)

    print("%s\n\n%s %s (%s)\n" % (
        BANNER % tuple([color(_) for _ in BANNER_PASSWORDS]),
        NAME, version, URL))

    args = parse_args()

    if args.update:
        update()
        exit()

    if args.list:
        sites = list_sites()
        for _ in sites:
            print("- %s" % _)
        exit()

    if not args.password:
        args.password = getpass("%s Please enter password:"******"")

    if args.ignore_proxy:
        proxy_handler = ProxyHandler({})

    elif args.proxy:
        match = re.search(r"(?P<type>[^:]+)://(?P<address>[^:]+)"
                          r":(?P<port>\d+)", args.proxy, re.I)
        if match:
            if match.group("type").upper() in ("HTTP", "HTTPS"):
                proxy_host = "%s:%s" % (match.group("address"),
                                        match.group("port"))
                proxy_handler = ProxyHandler({"http": proxy_host,
                                              "https": proxy_host})
            else:
                from thirdparty.socks import socks
                if match.group("type").upper() == "SOCKS4":
                    socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS4,
                                          match.group("address"),
                                          int(match.group("port")), True)
                elif match.group("type").upper() == "SOCKS5":
                    socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5,
                                          match.group("address"),
                                          int(match.group("port")), True)
                proxy_handler = None
        else:
            proxy_handler = ProxyHandler()
    else:
        proxy_handler = None

    opener = build_opener(HTTPHandler(), HTTPSHandler(),
                          HTTPCookieProcessor(cookie_handler))
    if proxy_handler:
        opener.add_handler(proxy_handler)

    install_opener(opener)

    with open(USER_AGENTS_FILE, 'r') as ua_file:
        args.user_agent = sample(ua_file.readlines(), 1)[0].strip()

    credentials = {"username": args.username, "email": args.email,
                   "password": args.password}
    sites = list_sites()

    if args.only:
        sites = [site for site in sites if site in args.only]
    elif args.exclude:
        sites = [site for site in sites if site not in args.exclude]

    print("%s Loaded %d %s to test." % (INFO, len(sites),
                                        "site" if len(sites) == 1
                                        else "sites"))
    print("%s Starting tests at: \"%s\"\n" % (INFO, color(strftime("%X"), BW)))

    for site in sites:
        _ = populate_site(site, args)
        if not _:
            continue
        target = Website(_, {"verbose": args.verbose})

        if (target.username_or_email == "email" and not args.email or
                target.username_or_email == "username" and not args.username):
            if args.verbose:
                print("%s Skipping \"%s\" since no \"%s\" was specified.\n" %
                      (INFO, color(target.name),
                       color(target.username_or_email)))
            continue

        print("%s Testing \"%s\"" % (TEST, color(target.name, BW)))

        if not target.user_agent:
            target.user_agent = args.user_agent

        if target.perform_login(credentials, cookie_handler):
            login_sucessful.append(target.name)
        else:
            login_failed.append(target.name)

    if not args.verbose:
        print()

    if len(login_sucessful) > 0 or len(login_failed) > 0:
        print("%s Succesfully logged into %s/%s websites." %
              (INFO, color(len(login_sucessful), BW),
               color(len(login_sucessful) + len(login_failed), BW)))
        print("%s An overall success rate of %s.\n" %
              (INFO, color("%%%s" % (100 * len(login_sucessful) / len(sites)),
                           BW)))

    if len(login_sucessful) > 0:
        print("%s The provided credentials worked on the following website%s: "
              "%s\n" % (PLUS, "s" if len(login_sucessful) != 1 else "",
                        ", ".join(login_sucessful)))

    print("%s Finished tests at: \"%s\"\n" % (INFO, color(strftime("%X"), BW)))
Ejemplo n.º 13
0
def main():
    """
    Initializes and executes the program.
    """

    login_sucessful = []
    login_failed = []
    login_skipped = []

    version = check_revision(VERSION)

    print("%s\n\n%s %s (%s)\n" %
          (BANNER % tuple([color(_)
                           for _ in BANNER_PASSWORDS]), NAME, version, URL))

    args = parse_args()

    if args.update:
        update()
        exit()

    if args.list:
        sites = list_sites()
        for _ in sites:
            print("- %s" % _)
        exit()

    if not args.password and not args.load_file:
        args.password = getpass("%s Please enter password:"******"(?P<type>[^:]+)://(?P<address>[^:]+)"
            r":(?P<port>\d+)", args.proxy, re.I)
        if match:
            if match.group("type").upper() in ("HTTP", "HTTPS"):
                proxy_host = "%s:%s" % (match.group("address"),
                                        match.group("port"))
                proxy_handler = ProxyHandler({
                    "http": proxy_host,
                    "https": proxy_host
                })
            else:
                from thirdparty.socks import socks
                if match.group("type").upper() == "SOCKS4":
                    socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS4,
                                          match.group("address"),
                                          int(match.group("port")), True)
                elif match.group("type").upper() == "SOCKS5":
                    socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5,
                                          match.group("address"),
                                          int(match.group("port")), True)
                proxy_handler = None
        else:
            proxy_handler = ProxyHandler()
    else:
        proxy_handler = None

    opener = build_opener(HTTPHandler(), HTTPSHandler(),
                          HTTPCookieProcessor(cookie_handler))
    if proxy_handler:
        opener.add_handler(proxy_handler)

    install_opener(opener)

    with open(USER_AGENTS_FILE, 'r') as ua_file:
        args.user_agent = sample(ua_file.readlines(), 1)[0].strip()

    credentials = {
        "username": args.username,
        "email": args.email,
        "password": quote(args.password)
    }
    sites = list_sites()

    if args.only:
        sites = [site for site in sites if site in args.only]
    elif args.exclude:
        sites = [site for site in sites if site not in args.exclude]

    print("%s Loaded %d %s to test." %
          (INFO, len(sites), "site" if len(sites) == 1 else "sites"))

    if args.load_file:
        if not isfile(args.load_file):
            print("%s could not find the file \"%s\"" %
                  (WARN, color(args.load_file)))
            exit()

        _ = sum(1 for line in open(args.load_file, "r"))
        if _ < 1:
            print("%s the file \"%s\" doesn't contain any valid credentials." %
                  (WARN, color(args.load_file)))
            exit()

        print("%s Loaded %d credential%s from \"%s\".\n" %
              (INFO, _, "s" if _ != 1 else "", color(args.load_file)))

    print("%s Starting tests at: \"%s\"\n" % (INFO, color(strftime("%X"), BW)))

    if not exists(OUTPUT_DIR):
        makedirs(OUTPUT_DIR)

    log = logger("%s/credmap" % OUTPUT_DIR)
    log.open()

    for site in sites:
        _ = populate_site(site, args)
        if not _:
            continue
        target = Website(_, {"verbose": args.verbose})

        if not target.user_agent:
            target.user_agent = args.user_agent

        def login():
            """
            Verify credentials for login and check if login was successful.
            """
            if (target.username_or_email == "email"
                    and not credentials["email"]
                    or target.username_or_email == "username"
                    and not credentials["username"]):
                if args.verbose:
                    print("%s Skipping %s\"%s\" since "
                          "no \"%s\" was specified.\n" %
                          (INFO, "[%s:%s] on " %
                           (credentials["username"] or credentials["email"],
                            credentials["password"]) if args.load_file else "",
                           color(target.name),
                           color(target.username_or_email, BW)))
                    login_skipped.append(target.name)
                return

            print("%s Testing %s\"%s\"..." %
                  (TEST, "[%s:%s] on " %
                   (credentials["username"] or credentials["email"],
                    credentials["password"]) if args.load_file else "",
                   color(target.name, BW)))

            cookie_handler.clear()

            if target.perform_login(credentials, cookie_handler):
                log.write(">>> %s - %s:%s\n" %
                          (target.name, credentials["username"]
                           or credentials["email"], credentials["password"]))
                login_sucessful.append(
                    "%s%s" %
                    (target.name, " [%s:%s]" %
                     (credentials["username"] or credentials["email"],
                      credentials["password"]) if args.load_file else ""))
            else:
                login_failed.append(target.name)

        if args.load_file:
            with open(args.load_file, "r") as load_list:
                for user in load_list:
                    user = user.rstrip().split(":", 1)
                    if not user[0]:
                        continue

                    match = re.match(
                        r"^[A-Za-z0-9._%+-]+@(?:[A-Z"
                        r"a-z0-9-]+\.)+[A-Za-z]{2,12}$", user[0])
                    credentials = {
                        "email": user[0] if match else None,
                        "username": None if match else user[0],
                        "password": user[1]
                    }

                    login()
        else:
            login()

    log.close()

    if not args.verbose:
        print()

    if len(login_sucessful) > 0 or len(login_failed) > 0:
        _ = "%s/%s" % (color(len(login_sucessful), BW),
                       color(len(login_sucessful) + len(login_failed), BW))
        sign = PLUS if len(login_sucessful) > (len(login_failed) +
                                               len(login_skipped)) else INFO
        print(
            "%s Succesfully logged in%s." %
            (sign, " with %s credentials on the list." %
             _ if args.load_file else "to %s websites." % _), )
        print("%s An overall success rate of %s.\n" %
              (sign,
               color(
                   "%%%s" % (100 * len(login_sucessful) /
                             (len(login_sucessful) + len(login_failed))), BW)))

    if len(login_sucessful) > 0:
        print("%s The provided credentials worked on the following website%s: "
              "%s\n" % (PLUS, "s" if len(login_sucessful) != 1 else "",
                        ", ".join(login_sucessful)))

    print("%s Finished tests at: \"%s\"\n" % (INFO, color(strftime("%X"), BW)))