日期:2014-05-16  浏览次数:20458 次

用一个js文件搞定中了u盘病毒被隐藏的文件夹

用一个js文件搞定中了u盘病毒被隐藏的文件夹,其实有专杀工具的,纯粹是好玩。

但也有些亮点,比如说文件(夹)的属性判断,稍微改写可以做成用户权限的判断。

好了废话少说,上代码:

/**
 * 处理当前文件夹中属性为隐藏、系统的文件夹
 * 结果是文件夹属性为正常!
 */


function alert(string) {
	var wsh = new ActiveXObject("WScript.shell");
	wsh.Popup(string);
}

var s = "";

function ClearAttrib(f) {
	var flag = f.attributes;
	var sFlag = "";
	sFlag = GetAttrib(f);
	switch (flag) {
		case 18:
		case 20:
		case 22:
			f.attributes = 16;
			s += "成功去除文件夹" + f.Path + "的" + sFlag + "属性!\n";
	}
}

function ListDir(folderspec) {
	var fso, f, fc;
	fso = new ActiveXObject("Scripting.FileSystemObject");
	f = fso.GetFolder(folderspec);

	fc = new Enumerator(f.SubFolders);

	for (; !fc.atEnd(); fc.moveNext()) {
		s += "文件夹:" + fc.item() + ",属性:" + GetAttrib(fc.item()) + "\n";
		ClearAttrib(fc.item());
		ListDir(fc.item());
	}
}

/**
 * 属性判断
 * fPurview = f.attributes
 * opt = 0 只读,1 隐藏,2 系统,3 驱动器卷标,
 *       4 文件夹,5 归档,6 快捷方式,7 压缩文件
 */
function checkPower(fPurview, opt) {
	var purviewValue = 0;
	purviewValue = Math.pow(2, opt);

	return(fPurview & purviewValue) == purviewValue;
}

function GetAttrib(f) {
	var att = "";
	var ary = {0:"只读",1:"隐藏",2:"系统",3:"驱动器卷标",4:"文件夹",5:"归档",6:"快捷方式",7:"压缩文件"};
	var flag = f.attributes;

	for (var i = 0; i <= 7; i++) {
		if (checkPower(flag, i)) {
			att += ary[i] + "+";
		}
	}
	
	return(att.substr(0, att.length - 1));
}

function ShowFolderFileList(folderspec) {
   var fso, f, fc, s;
   fso = new ActiveXObject("Scripting.FileSystemObject");
   f = fso.GetFolder(folderspec);
   fc = new Enumerator(f.files);
   s = "";
   for (; !fc.atEnd(); fc.moveNext()) {
      s += fc.item() + GetAttrib(fc.item()) + "\n";
   }
   return(s);
}


try {
	ListDir(".");
	//alert(ShowFolderFileList("."));
	alert(s);
} catch (e) {
	alert(e.name + ":" + e.message);
}

?欢迎大家拍砖!!!

?

本来是发在qq上的,但那dongdong上代码不能带格式,特丑!