コード例 #1
0
ファイル: terminal_display.py プロジェクト: wangsz05/Graffiti
 def do_encode_payload(self, payload, script_type, encoder, description, execution_type):
     """
     encode a personal payload
     """
     prepared_payload = prepare_single_payload(
         payload, execution_type, exec_type=script_type, description=description
     )
     required_arguments = ("lhost", "lport", "url")
     args = {}
     for argument in required_arguments:
         args[argument] = raw_input("enter the {} (enter for None): ".format(argument.upper()))
     encoded = Encoder(
         prepared_payload, self.cursor,
         args["lhost"], args["lport"], args["url"], encoder
     ).encode()
     return encoded
コード例 #2
0
ファイル: settings.py プロジェクト: wangsz05/Graffiti
def get_encoders(is_view_all=False):
    """
    get the possible encoding techniques from the coders directory
    :return:
    """
    path = "{}/coders".format(CUR_DIR)
    bad = (".pyc", "__init__.py")
    retval = []
    for c in os.listdir(path):
        if not any(b in c for b in bad):
            retval.append(c.split("_")[-1].split(".")[0])
    if is_view_all:
        from coders import Encoder

        retval = Encoder(None, None, None, None, None, None, get_encoders=True)
    return retval
コード例 #3
0
ファイル: terminal_display.py プロジェクト: wangsz05/Graffiti
 def do_use_payload(self, selected, encoder):
     """
     use a selected payload, encode it, and stash it in a database for future use
     """
     encoders = get_encoders()
     selected_choice = False
     if encoder in encoders:
         choice = encoders.index(encoder)
     else:
         print("invalid encoding or no encoding given, defaulting to base64")
         choice = 0
     while not selected_choice:
         try:
             technique = encoders[int(choice)]
             payload_path = FINISH_PATH_TEMPLATE.format(CUR_DIR, selected)
             payload_data = get_single_payload(payload_path)
             if payload_data["data"]["information"]["type"].lower() == "dropper":
                 usable_data = {"url": raw_input("enter the URL to connect to: "), "lhost": None, "lport": None}
             elif payload_data["data"]["information"]["type"].lower() == "enum":
                 usable_data = {"url": raw_input("enter the domain to enumerate: "), "lhost": None, "lport": None}
             elif payload_data["data"]["information"]["type"].lower() in ("reverse", "bind"):
                 usable_data = {
                     "url": None, "lhost": raw_input("enter the LHOST: "), "lport": raw_input("enter the LPORT: ")
                 }
             else:
                 usable_data = {
                     "url": None,
                     "lhost": None,
                     "lport": None
                 }
             encoded = Encoder(
                 payload_data,
                 self.cursor,
                 usable_data["lhost"],
                 usable_data["lport"],
                 usable_data["url"],
                 technique
             ).encode()
             selected_choice = True
             return encoded
         except TypeError:
             print("invalid selection")
         except UnacceptableExecType as e:
             print(e.message)
             return None
コード例 #4
0
ファイル: arguments.py プロジェクト: Ro9ueAdmin/Graffiti
 def single_run_args(conf, cursor):
     """
     parses the configuration file and tells the program what needs to be done
     """
     # fetch the cached payloads out of the database
     cached_payloads = fetch_cached_payloads(cursor)
     if conf["graffiti"]["wipeData"]:
         print("wiping the database and the history files")
         secure_delete(DATABASE_PATH)
         history_files = get_history_files(HISTORY_FILES_PATH)
         for f in history_files:
             secure_delete(f)
         print("database and history files wiped")
         close()
     if conf["graffiti"]["useTerminal"]:
         print(BANNER)
         print(
             "no arguments have been passed, dropping into terminal type `help/?` to get help, "
             "all commands that sit inside of `/bin` are available in the terminal"
         )
         available_payloads = get_payload_paths()
         GraffitiTerminal(cached_payloads, available_payloads,
                          cursor).do_start(
                              conf["graffiti"]["saveCommandHistory"])
         exit()
     if conf["graffiti"]["listAvailablePayloads"]:
         available_payloads = get_payload_paths()
         print("total of {} payloads available\n".format(
             len(available_payloads)))
         for payload in available_payloads:
             print(payload)
         close()
     if conf["graffiti"]["viewCached"]:
         print("total of {} payloads present".format(len(cached_payloads)))
         for cache in cached_payloads:
             print("\nLanguage: {}\nPayload Type: {}\nPayload: {}".format(
                 cache[-1], cache[-2], str(repr(cache[1]))))
         close()
     if conf["graffiti"]["codecToUse"] != "":
         if conf["graffiti"]["userDefinedPayload"] != "":
             data = conf["graffiti"]["userDefinedPayload"]
             if len(data) < 2:
                 print(
                     "must provide at least the payload and the language type"
                 )
                 close(exit_code=1)
             else:
                 if len(data) == 4:
                     retval = prepare_single_payload(data[0],
                                                     data[2],
                                                     exec_type=data[1],
                                                     description=data[-1])
                 elif len(data) == 3:
                     retval = prepare_single_payload(data[0],
                                                     data[2],
                                                     exec_type=data[1],
                                                     description="N/A")
                 else:
                     retval = prepare_single_payload(data[0],
                                                     "N/A",
                                                     exec_type=data[1],
                                                     description="N/A")
                 checks = check_payload(data[0])
                 if len(checks) != 0:
                     print(
                         "seems you did not provide needed data to prepare your payload, you need to pass {}. "
                         "either pass the data using the host commands, add the data to the payload, "
                         "or remove the data from the payload all together".
                         format(",".join(checks)))
                     close(exit_code=1)
                 else:
                     if str(conf["graffiti"]["codecToUse"]) == "":
                         print("must specify a codec to use")
                         close(exit_code=1)
                     encoded = Encoder(
                         retval, cursor,
                         conf["graffiti"]["userDefinedLhost"],
                         conf["graffiti"]["userDefinedLport"],
                         conf["graffiti"]["userDefinedURL"],
                         conf["graffiti"]["codecToUse"]).encode()
                     print(encoded[0])
                     close()
         elif conf["graffiti"]["payloadPathToUse"] != "":
             useable_payload_paths = get_payload_paths()
             if conf["graffiti"][
                     "payloadPathToUse"] in useable_payload_paths:
                 full_path = FINISH_PATH_TEMPLATE.format(
                     CUR_DIR, conf["graffiti"]["payloadPathToUse"])
                 data_json = get_single_payload(full_path)
                 payload_type = data_json["data"]["information"]["type"]
                 if payload_type == "reverse":
                     if conf["graffiti"]["userDefinedLhost"] == "" or conf[
                             "graffiti"]["userDefinedLport"] == "":
                         print(
                             "no LHOST or LPORT given, specify and try again"
                         )
                         close()
                     else:
                         graph_data = (conf["graffiti"]["userDefinedLhost"],
                                       conf["graffiti"]["userDefinedLport"],
                                       None)
                 elif payload_type == "dropper":
                     if conf["graffiti"]["userDefinedURL"] == "":
                         print(
                             "no URL specified for the dropper, specify one and try again"
                         )
                         close()
                     else:
                         graph_data = (None, None,
                                       conf["graffiti"]["userDefinedURL"])
                 else:
                     graph_data = (None, None, None)
                 encoded_payload = Encoder(
                     data_json, cursor, graph_data[0], graph_data[1],
                     graph_data[2],
                     conf["graffiti"]["codecToUse"]).encode()
                 if encoded_payload is not None:
                     display_payload(encoded_payload[0],
                                     is_xor=True if
                                     conf["graffiti"]["codecToUse"].lower()
                                     == "xor" else False)
                 else:
                     print("dumping raw encoded payload")
                     display_payload(data_json["data"]["payload"])
                 close()
             else:
                 print(
                     "unknown payload path, do you want to make a payload?")
                 close()
     if conf["graffiti"]["createPayloadFile"] != "":
         acceptable_operating_systems = [
             "windows", "linux", "mac", "unix", "shared"
         ]
         if conf["graffiti"]["createPayloadFile"][
                 -1] in acceptable_operating_systems:
             target_system_type = conf["graffiti"]["createPayloadFile"][-1]
             description = conf["graffiti"]["createPayloadFile"][-2]
             payload_type = conf["graffiti"]["createPayloadFile"][-3]
             execution_type = conf["graffiti"]["createPayloadFile"][1]
             usable_payload = conf["graffiti"]["createPayloadFile"][0]
             data = (description, payload_type, execution_type,
                     usable_payload)
             json_data = tuple_to_json(data)
             path = write_to_file(json_data, target_system_type,
                                  execution_type, payload_type)
             database_info = tuple_to_json(data, sort_and_indent=False)
             insert_payload(database_info, payload_type, execution_type,
                            cursor)
             print("payload created and stored in {}".format(path))
             close()
         else:
             print(
                 "please choose an OS from the following and try again: {}".
                 format(",".join(acceptable_operating_systems)))
             close()