bobbystacksmash / Construct

A cross-platform Windows Script Host emulator for dynamically analysing malicious JScript programs.
GNU General Public License v3.0
8 stars 2 forks source link

Add VFS method to support expanding relative to absolute paths. #3

Open bobbystacksmash opened 6 years ago

bobbystacksmash commented 6 years ago

Lots of methods which accept a path first test if the path is relative, and if it is, they clean it up and convert it to an abspath. This should be a standard VFS method. The pattern that's being used at the moment is something like:

if (this.vfs.PathIsRelative(filepath)) {
  filepath = path.replace(/^C:/i, "");
  // get_env("path") returns the process CWD.
  filepath = win32path.join(this.ctx.get_env("path"), filepath);
}

To find examples, search for any method calls to vfs.PathIsRelative().