Created
October 25, 2017 14:40
-
-
Save dcinzona/b66e545ee17614085be1ff59275be6ad to your computer and use it in GitHub Desktop.
ActiveX file download POC
This file contains hidden or 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
| <apex:page > | |
| <script type="text/javascript"> | |
| var sflogo = '/img/seasonLogos/Winter_18_yeti_175x65.png'; | |
| fso = new ActiveXObject("Scripting.FileSystemObject"); | |
| var currentDirectory="c:\\windows\\temp\\";//fso.GetAbsolutePathName("."); | |
| document.write(currentDirectory + "<br>"); | |
| var fp = currentDirectory+"logo198.png"; | |
| document.write(fp); | |
| function BinaryFile(filepath){ | |
| var adTypeBinary=1,adTypeText=2; | |
| var adSaveCreateNotExist=1,adSaveCreateOverWrite=2; | |
| var adReadAll=-1,adReadLine=-2; | |
| this.path=filepath; | |
| this.WriteAll = function(content){ | |
| var Stream = new ActiveXObject("ADODB.Stream"); | |
| Stream.Type = adTypeText; | |
| Stream.CharSet = "iso-8859-1"; | |
| Stream.Open(); | |
| Stream.WriteText(content); | |
| Stream.SaveToFile(this.path, adSaveCreateOverWrite); | |
| Stream.Close(); | |
| Stream = null; | |
| } | |
| this.ReadFromFile = function(){ | |
| var Stream = new ActiveXObject("ADODB.Stream"); | |
| Stream.Type = adTypeText; | |
| Stream.CharSet = "iso-8859-1"; | |
| Stream.Open(); | |
| Stream.LoadFromFile(this.path); | |
| var content = Stream.ReadText(adReadAll); | |
| Stream.Close(); | |
| Stream = null; | |
| return content; | |
| } | |
| this.ReadFromURL = function(){ | |
| var xmlHttp = new ActiveXObject("Microsoft.XMLHTTP") | |
| xmlHttp.open("GET", this.path, false); | |
| xmlHttp.send(); | |
| if (xmlHttp.status == 200) { | |
| return xmlHttp.ResponseBody; | |
| } else { | |
| return "error: " + xmlHttp.status; | |
| } | |
| } | |
| } | |
| var bf1 = new BinaryFile(sflogo); | |
| var bf2 = new BinaryFile(fp); | |
| bf2.WriteAll(bf1.ReadFromURL()); | |
| function getDataFromUrl(url, callback) { | |
| try { | |
| var xmlHttp = new ActiveXObject("MSXML2.XMLHTTP"); | |
| xmlHttp.open("GET", url, false); | |
| xmlHttp.send(); | |
| if (xmlHttp.status == 200) { | |
| return callback(xmlHttp.ResponseBody, false); | |
| } else { | |
| return callback(null, true); | |
| } | |
| } catch (error) { | |
| return callback(null, true); | |
| } | |
| } | |
| </script> | |
| </apex:page> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment