开发者

i have a prob with string replacing in batch

开发者 https://www.devze.com 2023-04-11 06:00 出处:网络
i am trying to make my own encryption for .dll files. but it wont work like i want it too can annyone help.

i am trying to make my own encryption for .dll files. but it wont work like i want it too can annyone help.


@echo off
set /p lol=(
echo %lol%>test.dll
for /f "tokens=*" %%j in (test.dll) do set f1=%%j
set f1=%f1:a=QUE%
set f1=%f1:b=GUI%
set f1=%f1:c=DOP%
set f1=%f1:d=EXO%
set f1=%f1:e=CUI%
set f1=%f1:f=RAY%
set f1=%f1:g=TAI%
set f1=%f1:h=YAM%
set f1=%f1:i=*+=%
set f1=%f1:j=UIT%
set f1=%f1:k=ITO%
set f1=%f1:l=ORC%
set f1=%f1:m=KIP%
set f1=%f1:n=JAA%
set f1=%f1:o=(.)%
set f1=%f1:p=)Y(%
set f1=%f1:q=!i!%
set f1=%f1:r=$S$%
set f1=%f1:s=WPL%
set f1=%f1:t=%*/%
set f1=%f1:u=FOL%
set f1=%f1:v=FUK%
set f1=%f1:w=@.@%
set f1=%f1:x=S$$%
set f1=%f1:y=^.^%
set f1=%f1:z=AAP%
set f1=%f1:A=qal%
set f1=%f1:B=gal%
set f1=%f1:C=dor%
set f1=%f1:D=ert%
set f1=%f1:E=332%
set f1=%f1:F=rat%
set f1=%f1:G=pok%
set f1=%f1:H=yap%
set f1=%f1:I=8-)%
set f1=%f1:J=uki%
set f1=%f1:K=ipa%
set f1=%f1:L=o:)%
set f1=%f1:M=kop%
set f1=%f1:N=jas%
set f1=%f1:O=911%
set f1=%f1:P=007%
set f1=%f1:Q=112%
set f1=%f1:R=4gh%
set f1=%f1:S=wrq%
set f1=%f1:T=5hi%
set f1=%f1:U=777%
set f1=%f1:V=gak%
set f1=%f1:W=2g2%
set f1=%f1:X=dom%
set f1=%f1:Y=666%
set f1=%f1:Z=aal%
set f1=%f1:0=ugb%
set f1=%f1:1=zup%
set f1=%f1:2=xfi%
set f1=%f1:3=cmv%
set f1=%f1:4=vui%
set f1=%f1:5=but%
set f1=%f1:6=nom%
set f1=%f1:7=mon%
set f1=%f1:8=hub%
set f1=%f1:9=whn%
set f1=%f1:!=ZIP%
set f1=%f1:@=XLO%
set f1=%f1:$=CVB%
set f1=%f1:%=VQE%
set f1=%f1:^=BUY%
set f1=%f1:&=NAM%
set f1=%f1:*=MAL%
set f1=%f1:(=LAL%
set f1=%f1:)=JN9%
set f1=%f1:#=255%
set f1=%f1:_=?19%
set f1=%f1:-={GT%
set f1=%f1:==SC}%
set f1=%f1:+=J~L%
set f1=%f1:\=;RT%
set f1开发者_开发百科=%f1:|=:OP%
set f1=%f1:{=KAA%
set f1=%f1:}=KAL%
set f1=%f1:[=PLO%
set f1=%f1:]=DQW%
set f1=%f1::=PIP%
set f1=%f1:;=AR9%
set f1=%f1:"=UNF%
set f1=%f1:'=CNP%
set f1=%f1:<=JMN%
set f1=%f1:>=HBH%
set f1=%f1:,=25J%
set f1=%f1:.=YF7%
set f1=%f1:/=UYG%
set f1=%f1:?=DFG%
set f1=%f1:`=PUY%
set f1=%f1:~=CV7%
echo %f1%>test.dll
pause
exit


Honestly, I am not sure what is intended with the code snippet. First, a redirection of > will clear off all contents of the dll file. Next, I suspect any of your commands in the set block after the first echo would get a chance to execute. Certainly, the %lol% variable will never get a value within the block, it will be evaluated before executing anything within the set block unless delayedexpansion is enabled. Try enabling delayedexpansion.

Put this on top:

setlocal enabledelayedexpansion

and qualify all %var%'s to !var!

Hope this post could give you some sort of start for you to achieve what you are upto.


First the complete idea is nice but worthless, as it can't be done with batch alone.
At least you can't read a NUL (0x00) character with batch.

Why your code can't works has many reasons, you read from test.dll while trying to write it simultaneously, how do you expect that it could work?

Your code doesn't handle any special characters, it's possible with batch but it's tricky.

The line set f1=%f1:*=MAL% can't work, as you can't replace a single star this way.
Also set f1=%f1:==SC}% and set f1=%f1:~=CV7% will fail by the same reason.

set f1=%f1:%=VQE% changes f1 always to =VQE independent of the content of f1.

Even if you remove these lines, your translation translates each character multiple times, the input a results to the output of

ZIPhubKAAGTJN9ZIPvuighabuthiwhnzupzupwhnzupzupPIPJN9cmvcmvxfivuighbuthiwhnzupzupvuighvuighabuthiwhnzupzupwhnzupzupPIPJN9*J~L=*UYG

To find such problems it's always a good idea to remove the exit and to enable echo on.


I'm not sure if it's fixed or more broken, but I got it to output this:

CVBXLOYF7XLOugbugbmonwhnzupzupPIPJN9CVBvuighabuthiwhnzupzupwhnzupzupPIPJN9cmvcmvxfivuighbuthiwhnzupzupvuighvuighabuthiwhnzupzupwhnzupzupPIPJN9*J~L=cmvcmvxfivuighbuthiwhnzupzupvuighvuighabuthiwhnzupzupwhnzupzupPIPJN9*J~L=xfigxfirqCVBCVBLALYF7JN9vuighabuthiwhnzupzupwhnzupzupPIPJN9cmvcmvxfivuighbuthiwhnzupzupvuighvuighabuthiwhnzupzupwhnzupzupPIPJN9*J~L=*/

Again, not sure if it worked or not, but I did use :

setlocal enabledelayedexpansion

Is there a way you have established for reversing this?

REM @echo off
setlocal enabledelayedexpansion
set /p lol=(
echo %lol%>test.txt
for /f "tokens=*" %%j in (test.txt) do set f1=%%j
set f1=%f1:a=QUE%
set f1=%f1:b=GUI%
set f1=%f1:c=DOP%
set f1=%f1:d=EXO%
set f1=%f1:e=CUI%
set f1=%f1:f=RAY%
set f1=%f1:g=TAI%
set f1=%f1:h=YAM%
set f1=%f1:i=*+=%
set f1=%f1:j=UIT%
set f1=%f1:k=ITO%
set f1=%f1:l=ORC%
set f1=%f1:m=KIP%
set f1=%f1:n=JAA%
set f1=%f1:o=(.)%
set f1=%f1:p=)Y(%
set f1=%f1:q=!i!%
set f1=%f1:r=$S$%
set f1=%f1:s=WPL%
set f1=%f1:t=%*/%
set f1=%f1:u=FOL%
set f1=%f1:v=FUK%
set f1=%f1:w=@.@%
set f1=%f1:x=S$$%
set f1=%f1:y=^.^%
set f1=%f1:z=AAP%
set f1=%f1:A=qal%
set f1=%f1:B=gal%
set f1=%f1:C=dor%
set f1=%f1:D=ert%
set f1=%f1:E=332%
set f1=%f1:F=rat%
set f1=%f1:G=pok%
set f1=%f1:H=yap%
set f1=%f1:I=8-)%
set f1=%f1:J=uki%
set f1=%f1:K=ipa%
set f1=%f1:L=o:)%
set f1=%f1:M=kop%
set f1=%f1:N=jas%
set f1=%f1:O=911%
set f1=%f1:P=007%
set f1=%f1:Q=112%
set f1=%f1:R=4gh%
set f1=%f1:S=wrq%
set f1=%f1:T=5hi%
set f1=%f1:U=777%
set f1=%f1:V=gak%
set f1=%f1:W=2g2%
set f1=%f1:X=dom%
set f1=%f1:Y=666%
set f1=%f1:Z=aal%
set f1=%f1:0=ugb%
set f1=%f1:1=zup%
set f1=%f1:2=xfi%
set f1=%f1:3=cmv%
set f1=%f1:4=vui%
set f1=%f1:5=but%
set f1=%f1:6=nom%
set f1=%f1:7=mon%
set f1=%f1:8=hub%
set f1=%f1:9=whn%
set f1=%f1:!=ZIP%
set f1=%f1:@=XLO%
set f1=%f1:$=CVB%
set f1=%f1:^%=VQE%
set f1=%f1:^=BUY%
set f1=%f1:&=NAM%
set f1=%f1:^*=MAL%
set f1=%f1:(=LAL%
set f1=%f1:)=JN9%
set f1=%f1:#=255%
set f1=%f1:_=?19%
set f1=%f1:-={GT%
set f1=%f1:^==SC}%
set f1=%f1:+=J~L%
set f1=%f1:\=;RT%
set f1=%f1:|=:OP%
set f1=%f1:{=KAA%
set f1=%f1:}=KAL%
set f1=%f1:[=PLO%
set f1=%f1:]=DQW%
set f1=%f1::=PIP%
set f1=%f1:;=AR9%
set f1=%f1:"=UNF%
set f1=%f1:'=CNP%
set f1=%f1:<=JMN%
set f1=%f1:>=HBH%
set f1=%f1:,=25J%
set f1=%f1:.=YF7%
set f1=%f1:^/=UYG%
set f1=%f1:?=DFG%
set f1=%f1:`=PUY%
set f1=%f1:^~=CV7%
echo %f1%>test.txt
pause

I had to use (^) to escape some characters you had that were messing up the output.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号