Templates
templates.build_filepath(mission, generic_ok=False)
Builds a safe filepath for the template to exist at.
Arguments Type Description missiondict A mission dict returned from the Synack API generic_okbool Return the default mission template if the specified template doesn't exist (Default: False) Examples
>>> msn = { ... "taskType": "SV2M", ... "assetTypes": ["host"], ... "title": "More Realistic Name: CVE-1970-1" ... } >>> h.templates.build_filepath(msn) '/home/user/Templates/sv2m/host/more_realistic_name_cve_1970_1.txt' >>> msn = { ... "taskType": "MISSION", ... "assetTypes": ["web"], ... "title": "SoME HoRR!bl3 M!$$!0N" ... } >>> h.templates.build_filepath(msn) '/home/user/Templates/mission/web/some_horr_bl3_m_0n.txt' >>> msn["title"] = "Mission Without A Template" >>> h.templates.build_filepath(msn, generic_ok=True) '/home/user/Templates/mission/web/generic.txt' >>> h.templates.build_filepath(msn, generic_ok=False) '/home/user/Templates/mission/web/mission_without_a_template.txt'
templates.build_replace_variables(text, target=None, **kwargs)
Replaces some variables within a given piece of text based on the target provided
Arguments Type Description textstr String to replace variables within targetdb.models.Target Target to use for variables kwargskwargs Key word arguments to use for finding a target (codename, slug, etc.) Examples
>>> target = h.db.find_targets(slug='2oh3ui')[0] >>> h.templates.build_replace_variables("This mission is for {{ TARGET_CODENAME }}", target=target) This mission is for TRANSFORMERTURKEY
templates.build_safe_name(name)
Takes a name and converts it into something that is definitely safe for a filepath
Arguments Type Description namestr Some string to convert into a standardized string that if definitely safe to use as a filepath Examples
>>> h.build_safe_name('R@ND0M G@RB@G3!!!!!') 'r_nd0m_g_rb_ge_'
templates.build_sections(path)
Take the text from a local template file and prepare it to be sent to the Synack API
Arguments Description pathpathlib.PosixPath Examples
>>> h.templates.build_sections(Path('/home/user/Templates/mission/web/mission.txt')) { "introduction": "This is the intro", "testing_methodology": "This is how I tested", "conclusion": "This is the conclusion", "structuredResponse": "no" }
templates.get_file(mission)
Pulls in a local template file to upload to a given mission
Arguments Type Description missiondict A mission dict from the Synack API Examples
>>> msns = h.missions.get_claimed() >>> h.templates.get_file(msns[0]) {"introduction": "This is the intro",...}
templates.set_file(evidences)
Writes evidences pulled from
missions.get_evidences()to a local template fileNote that if the file already exists, it will not be overwritten
Arguments Type Description evidencesdict Evidences from missions.get_evidences()Examples
>>> msns = h.missions.get_approved() >>> evidences = h.missions.get_evidences(msns[0]) >>> h.templates.set_file(evidences) '/home/user/Templates/mission/web/some_new_mission.txt'