一个开源的Asp.net2.0博客系统
用法:
1、追加文件:jpgexe.js jpg1.jpg + exe1.exe jpgout.jpg
程序exe1已经到图片jpgout.jpg 中了。
2.、分离:jpgexe.js jpgout.jpg exe2.exe
程序exe2已经分离出来了。
脚本:
- function existsArg(args,argValue)
- {
- for(var i = 0;i<args.length; ++i)
- {
- if(args.item(i) == argValue)
- {
- return true;
- }
- }
- return false;
- }
- Number.prototype.toBytes = function()
- {
- var n = this;
- var s = new ActiveXObject("adodb.stream");
- s.Charset = "ASCII";
- s.Type = 2;
- s.Open();
- s.Position = 0;
- s.WriteText(String.fromCharCode(n & 0xff));
- s.WriteText(String.fromCharCode((n >> 8) & 0xff));
- s.WriteText(String.fromCharCode((n >> 16) & 0xff));
- s.WriteText(String.fromCharCode((n >> 24) & 0xff));
- s.Position = 0;
- s.Type = 1;
- var buf = s.Read(4);
- s.Close();
- return buf;
- }
- Number.fromBytes = function(buf)
- {
- var s = new ActiveXObject("adodb.stream");
- s.Type = 1;
- s.Open();
- s.Write(buf);
- if(s.Size != 4)
- throw 'Number.fromByte函数中,buf长度不对';
- s.Position = 0;
- s.Type = 2;
- s.Charset = "ASCII";
- var str = s.ReadText(4);
- var n = str.charCodeAt(0);
- n |= (str.charCodeAt(1) << 8);
- n |= (str.charCodeAt(2) << 16);
- n |= (str.charCodeAt(3) << 24);
- s.Close();
- return n;
- }
- function bindFile(picFile,exeFile,outFile)
- {
- var streamPic = new ActiveXObject("adodb.stream");
- streamPic.Type = 1;
- streamPic.Open();
- streamPic.LoadFromFile(picFile);
- streamPic.Position = streamPic.Size;
- var streamExe = new ActiveXObject("adodb.stream");
- streamExe.Type = 1;
- streamExe.Open();
- streamExe.LoadFromFile(exeFile);
- streamExe.Position = 0;
- streamExe.CopyTo(streamPic,streamExe.Size);
- streamPic.Write(streamExe.Size.toBytes());
- streamExe.Close();
- streamPic.SaveToFile(outFile);
- streamPic.Close();
- }
- function exportExe(picFile,outFile)
- {
- var bRet = false;
- var s = new ActiveXObject("adodb.stream");
- s.Type = 1;
- s.Open();
- s.LoadFromFile(picFile);
- s.Position = s.Size - 4;
- var buf = s.Read(4);
- var size = Number.fromBytes(buf);
- if(size > 0)
- {
- var pos = s.Size - 4 - size;
- if(pos >= 0)
- {
- s.Position = pos;
- var exeData = s.Read(size);
- s.Close();
- s.Open();
- s.Write(exeData);
- s.SaveToFile(outFile);
- bRet = true;
- }
- }
- s.Close();
- return bRet;
- }
- function main(args)
- {
- if(existsArg(args,"+"))
- {
- var picFile = args.item(0).toString();
- var exeFile = args.item(2).toString();
- var outFile = args.item(3).toString();
- bindFile(picFile,exeFile,outFile);
- }
- else
- {
- var picFile = args.item(0).toString();
- var outFile = args.item(1).toString();
- exportExe(picFile, outFile);
- }
- }
- main(WScript.Arguments);