waliedassar

Decode_njRat_GZipVersion

Apr 18th, 2015
284
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # A script to decode embedded executable inside some njRat samples
  2.  
  3. import sys,os,time,base64,io,gzip
  4.  
  5.  
  6.  
  7.  
  8.  
  9. def DecodeX(input_file):
  10.     if os.path.exists(input_file)==False:
  11.         print "File does not exist\r\n"
  12.         return
  13.     fIn = open(input_file,"r")
  14.     Content64 = fIn.read()
  15.     fIn.close
  16.     GzipContent = base64.b64decode(Content64)
  17.     compressed_file = io.BytesIO(GzipContent)
  18.     Decompressed = gzip.GzipFile(fileobj=compressed_file)
  19.     ContentFinal = Decompressed.read()
  20.     FileName, FileExt = os.path.splitext(input_file)
  21.     fGz = open(FileName + ".exe","wb")
  22.     fGz.write(ContentFinal)
  23.     fGz.close()
  24.  
  25.    
  26.    
  27.  
  28.  
  29. def main():
  30.     if len(sys.argv)!=2:
  31.         print "Usage: Decode.py input.txt\r\n"
  32.         sys.exit(-1)
  33.     else:
  34.         DecodeX(sys.argv[1])
  35.         sys.exit(0)
  36.  
  37.  
  38. if __name__ == "__main__":
  39.     main();
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×