vbs 加解密 for ms script encode
來源:易賢網(wǎng) 閱讀:1045 次 日期:2016-06-30 08:55:17
溫馨提示:易賢網(wǎng)小編為您整理了“vbs 加解密 for ms script encode”,方便廣大網(wǎng)友查閱!

一、加密

代碼如下:

dim objectfso

if (lcase(right(wscript.fullname,11))=wscript.exe) then

wscript.quit(0)

end if

if wscript.arguments.count<2 then

wscript.echo vbs code encoder v1.0 powered by enun. http://www.enun.net/

wscript.echo notes: dfilename must be '*.vbe'!

wscript.echo usage: cscript.exe //nologo sfilename dfilename

wscript.echo eg: cscript.exe //nologo test.vbs enc.vbe

wscript.quit(0)

end if

sfilename = wscript.arguments(0)

dfilename = wscript.arguments(1)

set objectfso = createobject(scripting.filesystemobject)

set readdata = objectfso.opentextfile(sfilename, 1)

objectfso.opentextfile(dfilename, 8, true).write(encoder(readdata.readall))

function encoder(data)

encoder = createobject(scripting.encoder).encodescriptfile(.vbs, data, 0, vbscript)

end function

二、解密

代碼如下:

option explicit

dim oargs, nomfichier

'optional argument : the encoded filename

nomfichier=

set oargs = wscript.arguments

select case oargs.count

case 0 'no arg, popup a dialog box to choose the file

nomfichier=browseforfolder(choose an encoded file, &h4031, &h0011)

case 1

if instr(oargs(0),?)=0 then '-? ou /? => aide

nomfichier=oargs(0)

end if

case else

wscript.echo too many parameters

end select

set oargs = nothing

if nomfichier<> then

dim fso

set fso=wscript.createobject(scripting.filesystemobject)

if fso.fileexists(nomfichier) then

dim fic,contenu

set fic = fso.opentextfile(nomfichier, 1)

contenu=fic.readall

fic.close

set fic=nothing

const taginit=#@~^ ==

const tagfin===^#~@ '& chr(0)

dim debutcode, fincode

do

fincode=0

debutcode=instr(contenu,taginit)

if debutcode>0 then

if (instr(debutcode,contenu,==)-debutcode)=10 then 'if == follows the tag

fincode=instr(debutcode,contenu,tagfin)

if fincode>0 then

contenu=left(contenu,debutcode-1) & _

decode(mid(contenu,debutcode+12,fincode-debutcode-12-6)) & _

mid(contenu,fincode+6)

end if

end if

end if

loop until fincode=0

wscript.echo contenu

else

wscript.echo nomfichier & not found

end if

set fso=nothing

else

wscript.echo please give a filename

wscript.echo usage : & wscript.fullname & & wscript.scriptfullname & <filename>

end if

function decode(chaine)

dim se,i,c,j,index,chainetemp

dim tdecode(127)

const combinaison=1231232332321323132311233213233211323231311231321323112331123132

set se=wscript.createobject(scripting.encoder)

for i=9 to 127

tdecode(i)=jla

next

for i=9 to 127

chainetemp=mid(se.encodescriptfile(.vbs,string(3,i),0,),13,3)

for j=1 to 3

c=asc(mid(chainetemp,j,1))

tdecode(c)=left(tdecode(c),j-1) & chr(i) & mid(tdecode(c),j+1)

next

next

'next line we correct a bug, otherwise a ) could be decoded to a >

tdecode(42)=left(tdecode(42),1) & ) & right(tdecode(42),1)

set se=nothing

chaine=replace(replace(chaine,@&,chr(10)),@#,chr(13))

chaine=replace(replace(chaine,@*,>),@!,<)

chaine=replace(chaine,@$,@)

index=-1

for i=1 to len(chaine)

c=asc(mid(chaine,i,1))

if c<128 then index=index+1

if (c=9) or ((c>31) and (c<128)) then

if (c<>60) and (c<>62) and (c<>64) then

chaine=left(chaine,i-1) & mid(tdecode(c),mid(combinaison,(index mod 64)+1,1),1) & mid(chaine,i+1)

end if

end if

next

decode=chaine

end function

function browseforfolder(byval pstrprompt, byval pintbrowsetype, byval pintlocation)

dim shellobject, pstrtempfolder, x

set shellobject=wscript.createobject(shell.application)

on error resume next

set pstrtempfolder=shellobject.browseforfolder(&h0,pstrprompt,pintbrowsetype,pintlocation)

browseforfolder=pstrtempfolder.parentfolder.parsename(pstrtempfolder.title).path

if err.number<>0 then browseforfolder=

set pstrtempfolder=nothing

set shellobject=nothing

end function

更多信息請查看腳本欄目
易賢網(wǎng)手機網(wǎng)站地址:vbs 加解密 for ms script encode
由于各方面情況的不斷調(diào)整與變化,易賢網(wǎng)提供的所有考試信息和咨詢回復(fù)僅供參考,敬請考生以權(quán)威部門公布的正式信息和咨詢?yōu)闇?zhǔn)!

2025國考·省考課程試聽報名

  • 報班類型
  • 姓名
  • 手機號
  • 驗證碼
關(guān)于我們 | 聯(lián)系我們 | 人才招聘 | 網(wǎng)站聲明 | 網(wǎng)站幫助 | 非正式的簡要咨詢 | 簡要咨詢須知 | 加入群交流 | 手機站點 | 投訴建議
工業(yè)和信息化部備案號:滇ICP備2023014141號-1 云南省教育廳備案號:云教ICP備0901021 滇公網(wǎng)安備53010202001879號 人力資源服務(wù)許可證:(云)人服證字(2023)第0102001523號
云南網(wǎng)警備案專用圖標(biāo)
聯(lián)系電話:0871-65099533/13759567129 獲取招聘考試信息及咨詢關(guān)注公眾號:hfpxwx
咨詢QQ:526150442(9:00—18:00)版權(quán)所有:易賢網(wǎng)
云南網(wǎng)警報警專用圖標(biāo)