def main():
    check_python()
    banner()

    parser = optparse.OptionParser(usage="usage: %prog [options]", version="%prog 1.0")

    front_page = optparse.OptionGroup(parser,"Frontpage:")
    share_point = optparse.OptionGroup(parser,"Sharepoint:")
    mandatory = optparse.OptionGroup(parser,"Mandatory:")
    exploit = optparse.OptionGroup(parser,"Information Gathering and Exploit:")
    authentication = optparse.OptionGroup(parser,"Authentication [devalias.net]")
    general = optparse.OptionGroup(parser,"General:")

    mandatory.add_option("-u","--url", type="string" , help="target url to scan with proper structure", dest="url")
    front_page.add_option("-f", "--frontpage", type="choice", choices=['pvt' ,'bin'], help="<FRONTPAGE = pvt | bin> -- to check access permissions on frontpage standard files in vti or bin directory!", dest="frontpage")
    share_point.add_option("-s","--sharepoint", type="choice", choices=['forms','layouts','catalog'], help="<SHAREPOINT = forms | layouts | catalog> -- to check access permissions on sharepoint standard files in forms or layouts or catalog directory!", dest="sharepoint")

    exploit.add_option("-v","--http_fingerprint", type="choice", choices=['ms_sharepoint','ms_frontpage'], help="<FINGERPRINT = ms_sharepoint | ms_frontpage> -- fingerprint sharepoint or frontpage based on HTTP headers!" , dest="fingerprint")
    exploit.add_option("-d","--dump", type="choice", choices=['dump', 'extract'] , help="<DUMP = dump | extract> -- dump credentials from default sharepoint and frontpage files (configuration errors and exposed entries)!", dest="dump")
    exploit.add_option("-l","--list", type="choice", choices=['list','index'], help="<DIRECTORY = list | index> -- check directory listing and permissions!", dest="directory")
    exploit.add_option("-e","--exploit", type="choice", choices=['rpc_version_check','rpc_service_listing', 'author_config_check','rpc_file_upload','author_remove_folder'], help="EXPLOIT = <rpc_version_check | rpc_service_listing | rpc_file_upload | author_config_check | author_remove_folder> -- exploit vulnerable installations by checking RPC querying, service listing and file uploading", dest="exploit")
    exploit.add_option("-i","--services", type="choice", choices=['serv','services'], help="SERVICES = <serv | services> -- checking exposed services !", dest="services")

    authentication.add_option("-a","--auth-type", type="choice", choices=['ntlm'], help="AUTHENTICATION = <ntlm> -- Authenticate with NTLM user/pass !", dest="authentication")

    general.add_option("-x","--examples", type="string",help="running usage examples !", dest="examples")

    parser.add_option_group(front_page)
    parser.add_option_group(share_point)
    parser.add_option_group(mandatory)
    parser.add_option_group(exploit)
    parser.add_option_group(authentication)
    parser.add_option_group(general)

    options, arguments = parser.parse_args()

    try:
        target = options.url

        # devalias.net - Authentication
        if options.authentication == "ntlm":
            enable_ntlm_authentication("", "", target) # Leave user/pass blank to prompt user
            # TODO: Enable commandline user/pass?

        if target is not None:
            target_information(target)
        else:
            print "[-] specify the options. use (-h) for more help!"
            sys.exit(0)

        if options.dump=="dump" or options.dump == "extract":
                        print "\n[+]------------------------------------------------------------------------------------------------!"
                        print "[+] dumping (service.pwd | authors.pwd | administrators.pwd | ws_ftp.log) files if possible!"
                        print "[+]--------------------------------------------------------------------------------------------------!\n"
                        dump_credentials(target)
                        module_success("password dumping")
                        return

        elif options.exploit == "rpc_version_check":
                        print "\n[+]-----------------------------------------------------------------------!"
                        print "[+] auditing frontpage RPC service                                          !"
                        print "[+]-------------------------------------------------------------------------!\n"
                        frontpage_rpc_check(target)
                        module_success("module RPC version check")
                        return

        elif options.exploit == "rpc_service_listing":
                        print "\n[+]-----------------------------------------------------------------------!"
                        print "[+] auditing frontpage RPC service for fetching listing                     !"
                        print "[+]-------------------------------------------------------------------------!\n"
                        frontpage_service_listing(target)
                        module_success("module RPC service listing check")
                        return

        elif options.exploit == "author_config_check":
                        print "\n[+]-----------------------------------------------------------------------!"
                        print "[+] auditing frontpage configuration settings                               !"
                        print "[+]-------------------------------------------------------------------------!\n"
                        frontpage_config_check(target)
                        module_success("module RPC check")
                        return

        elif options.exploit == "author_remove_folder":
                        print "\n[+]-----------------------------------------------------------------------!"
                        print "[+] trying to remove folder from web server                                 !"
                        print "[+]-------------------------------------------------------------------------!\n"
                        frontpage_remove_folder(target)
                        module_success("module remove folder check")
                        return


        elif options.exploit == "rpc_file_upload":
                print "\n[+]-----------------------------------------------------------------------!"
                print "[+] auditing file uploading misconfiguration                                !"
                print "[+]-------------------------------------------------------------------------!\n"
                file_upload_check(target)
                module_success("module file upload check")
                return


        elif options.examples == "examples":
                sparty_usage(target)
                return

        elif options.directory == "list" or options.directory == "index":
            build_target(target,directory_check,dir_target)
            print "\n[+]-----------------------------------------------------------------------!"
            print "[+] auditing frontpage directory permissions (forbidden | index | not exist)!"
            print "[+]-------------------------------------------------------------------------!\n"
            audit(dir_target)
            module_success("directory check")
            return

        elif options.frontpage == "bin":
            build_target(target,front_bin,refine_target)
            print "\n[+]----------------------------------------!"
            print "[+] auditing frontpage '/_vti_bin/' directory!"
            print "[+]------------------------------------------!\n"
            audit(refine_target)
            module_success("bin file access")

        elif options.frontpage == "pvt":
            build_target(target,front_pvt,pvt_target)
            print "\n[+]---------------------------------------------------------!"
            print "[+] auditing '/_vti_pvt/' directory for sensitive information !"
            print "[+]-----------------------------------------------------------!\n"
            audit(pvt_target)
            module_success("pvt file access")
            return

        elif options.fingerprint == "ms_sharepoint":
            dump_sharepoint_headers(target)
            print "\n[+] sharepoint fingerprinting module completed !\n"
            return


        elif options.fingerprint == "ms_frontpage":
            fingerprint_frontpage(target)
            print "\n[+] frontpage fingerprinting module completed !\n"
            return

        elif options.sharepoint == "layouts":
            build_target(target,sharepoint_check_layout,sharepoint_target_layout)
            print "\n[+]-----------------------------------------------------------------!"
            print "[+] auditing sharepoint '/_layouts/' directory for access permissions !"
            print "[+]-------------------------------------------------------------------!\n"
            audit(sharepoint_target_layout)
            module_success("layout file access")
            return

        elif options.sharepoint == "forms":
            build_target(target,sharepoint_check_forms,sharepoint_target_forms)
            print "\n[+]--------------------------------------------------------------!"
            print "[+] auditing sharepoint '/forms/' directory for access permissions !"
            print "[+]----------------------------------------------------------------!\n"
            audit(sharepoint_target_forms)
            module_success("forms file access")
            return

        elif options.sharepoint == "catalog":
            build_target(target,sharepoint_check_catalog,sharepoint_target_catalog)
            print "\n[+]--------------------------------------------------------------!"
            print "[+] auditing sharepoint '/catalog/' directory for access permissions !"
            print "[+]----------------------------------------------------------------!\n"
            audit(sharepoint_target_catalog)
            module_success("catalogs file access")
            return

        elif options.services == "serv" or options.services == "services":
            build_target(target,front_services,refine_target)
            print "\n[+]---------------------------------------------------------------!"
            print "[+] checking exposed services in the frontpage/sharepoint  directory!"
            print "[+]-----------------------------------------------------------------!\n"
            audit(refine_target)
            module_success("exposed services check")


        else:
            print "[-] please provide the proper scanning options!"
            print "[+] check help (-h) for arguments and url specification!"
            sys.exit(0)

    except ValueError as v:
        print "[-] ValueError occurred. Improper option argument or url!"
        print "[+] check for help (-h) for more details!"
        sys.exit(0)

    except TypeError as t:
        print "[-] TypeError occcured. Missing option argument or url!"
        print "[+] check for help (-h) for more details!"
        sys.exit(0)

    except IndexError as e:
        sparty_usage()
        sys.exit(0)

    except urllib2.HTTPError as h:
        print h.code %"[-] HTTPError : %s"
        print "[+] please specify the target with protocol handlers as http | https"
        sys.exit(0)

    except urllib2.URLError as u:
        print "[-] URLError : %s" %u.args
        print "[+] please specify the target with protocol handlers as http | https"
        sys.exit(0)

    except KeyboardInterrupt:
        print "[-] halt signal detected, exiting the program !\n"
        sys.exit(0)


    except None:
        print "[] Hey"
        sys.exit(0)
# calling main
dataset/ETHPy150Open alias1/sparty/sparty_v_0.1.py/main/swapped operands of `%`