Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Getting "!" and other difficult characters to encrypt.  (Read 9598 times)

0 Members and 1 Guest are viewing this topic.

zask

    Topic Starter


    Intermediate

    • Experience: Experienced
    • OS: Other
    Getting "!" and other difficult characters to encrypt.
    « on: October 14, 2017, 11:26:54 AM »
    I've managed to get most the special characters but
    Characters like "!" And "*" are giving me problems.
    Possible work arounds?

    I can elaborate if it's not clear to understand.

    Code: [Select]
    title Encrypt Batch File
    color 0a
    @echo off
    mode con:cols=50 lines=2
    echo Encrypt text files.
    pause
    cls
    mode con:cols=100 lines=2
     
    set CaseType=97
    > Randalphabet.vbs echo randomize timer
    >> Randalphabet.vbs echo RandAlphabet=""
    >> Randalphabet.vbs echo Do
    >> Randalphabet.vbs echo randchar = Chr(Int(26*Rnd+%CaseType%))
    >> Randalphabet.vbs echo If Instr(RandAlphabet, randchar) = 0 Then RandAlphabet = RandAlphabet ^& randchar
    >> Randalphabet.vbs echo if len(RandAlphabet) = 26 Then exit Do
    >> Randalphabet.vbs echo Loop
    >> Randalphabet.vbs echo wscript.echo RandAlphabet
    for /f "delims=" %%A in ('cscript //nologo Randalphabet.vbs') do set Randalphabet=%%A
    del Randalphabet.vbs
     
    set /a key1=%random% %% 3%random:~-1%%random:~-1% + 1
    set /a key2=%random% %% 3%random:~-1%%random:~-1% + 1
    set /a key3=%random% %% 3%random:~-1%%random:~-1% + 1
    set /a key4=%random% %% 3%random:~-1%%random:~-1% + 1
    set /a key5=%random% %% 3%random:~-1%%random:~-1% + 1
     
    set /a count1=%random% %% 2
    if "%count1%"=="0" set "math1=+" & set "math2=-"
    if "%count1%"=="1" set "math1=-" & set "math2=+"
    if "%math2%"=="+" set "math3=-" & set "math4=+"
    if "%math2%"=="-" set "math3=+" & set "math4=-"
     
    set /a count2=%random% %% 27
    if %count2%==1 set separator=È
    if %count2%==2 set separator=»
    if %count2%==3 set separator=¼
    if %count2%==4 set separator=º
    if %count2%==5 set separator=Í
    if %count2%==6 set separator=¿
    if %count2%==7 set separator=¹
    if %count2%==8 set separator=µ
    if %count2%==9 set separator=Ø
    if %count2%==10 set separator=¸
    if %count2%==11 set separator=Ð
    if %count2%==12 set separator=×
    if %count2%==13 set separator=Ù
    if %count2%==14 set separator=Ï
    if %count2%==15 set separator=Ô
    if %count2%==16 set separator=´
    if %count2%==17 set separator=Ñ
    if %count2%==18 set separator=½
    if %count2%==19 set separator=³
    if %count2%==20 set separator=Ò
    if %count2%==21 set separator=¾
    if %count2%==22 set separator=Å
    if %count2%==23 set separator=Ä
    if %count2%==24 set separator=¶
    if %count2%==25 set separator=Ç
    if %count2%==26 set separator=Ë
    if %count2%==27 set separator=·
     
    :options
    set /p "FILEA= Enter the name of the text file that you wish to encrypt (Example; "Somefiletxt") : "
    cls
    if not exist %FILEA% echo The file "%FILEA%" does not exist. & pause & cls & goto options
    set /p "FILEB= Enter the name of the decrypter that will be generated (Example; "Decrypter.bat") : "
    cls
    set /p "FILEC= Would you like to separate the encrypted text from the decrypter? (Y/N) : "
    cls
     
    Setlocal EnableDelayedExpansion
    echo > "%FILEB%" @echo off
    echo >> "%FILEB%" mode 200
    Setlocal EnableExtensions
    for /f "delims=" %%A in (%FILEA%) do (
    Set /a C+=1
    Set X[!C!]=%%A
    set code=%%A
    set chars=0123456789%Randalphabet%^|^^%%^&^<^>^{^}^[^]^(^)
    for /l %%C in (10 1 48) do (
    for /f %%D in ("!chars:~%%C,1!") do (
    set /a math=%%C*%key1%*%key1%-%key1%/%key1%%math1%%key2%*%key2%-%key2%/%key2%%math2%%key3%*%key3%-%key3%/%key3%%math1%%key4%*%key4%-%key4%/%key4%%math4%%key5%*%key5%-%key5%/%key5%+5
    for /f %%E in ("!math!") do (
    set "code=!code:%%D=%separator%%%E!"
    )
    )
    )
    if /i "%FILEC%"=="N" echo >> "%FILEB%" echo ^>^> lmotqocflhoi.txt !code!
    if /i "%FILEC%"=="Y" echo >> "lmotqocflhoi.txt" !code!
    )
     
    echo >> "%FILEB%" Setlocal EnableExtensions EnableDelayedExpansion
    echo >> "%FILEB%" for /f "delims=" %%%%A in (lmotqocflhoi.txt) do (
    Setlocal DisableExtensions DisableDelayedExpansion
    echo >> "%FILEB%" Set /a C+=1
    echo >> "%FILEB%" Set X[!C!]=%%%%A
    echo >> "%FILEB%" set gcfnipvbergt=%%%%A
    echo >> "%FILEB%" set pspfckinvcrn=0123456789%Randalphabet%^^^|^^^^%%%%^^^&^^^<^^^>^^^{^^^}^^^[^^^]^^^(^^^)
    echo >> "%FILEB%" for /l %%%%C in (10 1 48) do (
    echo >> "%FILEB%" for /f %%%%D in ("!pspfckinvcrn:~%%%%C,1!") do (
    echo >> "%FILEB%" set /a qmgsmphoomrhmu=%%%%C*%key1%*%key1%-%key1%/%key1%%math1%%key2%*%key2%-%key2%/%key2%%math2%%key3%*%key3%-%key3%/%key3%%math1%%key4%*%key4%-%key4%/%key4%%math4%%key5%*%key5%-%key5%/%key5%+5
    echo >> "%FILEB%" for /f %%%%E in ("!qmgsmphoomrhmu!") do (
    echo >> "%FILEB%" set "gcfnipvbergt=!gcfnipvbergt:%%%%E=%%%%D!"
    echo >> "%FILEB%" )
    echo >> "%FILEB%" )
    echo >> "%FILEB%" )
    echo >> "%FILEB%" for /f %%%%F in ("!gcfnipvbergt!") do (
    echo >> "%FILEB%" set "gcfnipvbergt=!gcfnipvbergt:%separator%=!"
    Setlocal EnableExtensions EnableDelayedExpansion
    echo >> "%FILEB%" echo ^^!gcfnipvbergt^^!
    echo >> "%FILEB%" )
    echo >> "%FILEB%" )
    if /i "%FILEC%"=="N" echo >> "%FILEB%" del lmotqocflhoi.txt
    echo >> "%FILEB%" echo.
    echo >> "%FILEB%" pause
     
    echo > "poly.vbs" randomize
    echo >> "poly.vbs" set daeh=createobject("scripting.filesystemobject")
    echo >> "poly.vbs" set iftkmc=daeh.opentextfile(%0,1)
    echo >> "poly.vbs" lrur=iftkmc.readall
    echo >> "poly.vbs" gsvlabhrht="gcfnipvbergt pspfckinvcrn qmgsmphoomrhmu lmotqocflhoi":hheaqqhtloeset=split(gsvlabhrht," ")
    echo >> "poly.vbs" for each kbjalobheu in hheaqqhtloeset
    echo >> "poly.vbs" for cunuvblq=1 to int(rnd*6)+2
    echo >> "poly.vbs" tjai=tjai+chr((int(rnd*22)+97))+chr(int(rnd*22)+97)
    echo >> "poly.vbs" next
    echo >> "poly.vbs" lrur=replace(lrur,kbjalobheu,tjai):tjai=""
    echo >> "poly.vbs" next
    echo >> "poly.vbs" set iftkmc=daeh.opentextfile(%0,2,1)
    echo >> "poly.vbs" iftkmc.writeline lrur
    echo >> "poly.vbs" Set fso = CreateObject("Scripting.FileSystemObject")
    echo >> "poly.vbs" fso.DeleteFile WScript.ScriptFullName
    echo >> "poly.vbs" iftkmc.close
    start "" "poly.vbs

    Geek-9pm


      Mastermind
    • Geek After Dark
    • Thanked: 1026
      • Gekk9pm bnlog
    • Certifications: List
    • Computer: Specs
    • Experience: Expert
    • OS: Windows 10
    Re: Getting "!" and other difficult characters to encrypt.
    « Reply #1 on: October 14, 2017, 02:07:38 PM »
    Is there some reference work that outlines the algorithm you use?

    Normally, when ASCII text is to be encrypted, all control chars must be escaped to something else. The should not be a need to makes exceptions for the other chars. Which means that using only DOS commands is not really good idea. Many chars have special meaning in DOS and it is hard to come up with an escape method for them.

    zask

      Topic Starter


      Intermediate

      • Experience: Experienced
      • OS: Other
      Re: Getting "!" and other difficult characters to encrypt.
      « Reply #2 on: October 14, 2017, 03:42:51 PM »
      I found something, Google this

      "viewtopic.php?t=1485 dos tips" without quotes
      Click the first link that appears.

      It's related to the situation but it's to difficult for me to understand how to implement.
      « Last Edit: October 14, 2017, 03:58:33 PM by zask »

      zask

        Topic Starter


        Intermediate

        • Experience: Experienced
        • OS: Other
        Re: Getting "!" and other difficult characters to encrypt.
        « Reply #3 on: October 14, 2017, 04:01:39 PM »
        The algorithm is borrowed from technology crazys YouTube channel's tutorial on batch encryption. I basically made his script more advanced but I'll add notes to my script too in due time. Will take a lot of explanation.

        BC_Programmer


          Mastermind
        • Typing is no substitute for thinking.
        • Thanked: 1140
          • Yes
          • Yes
          • BC-Programming.com
        • Certifications: List
        • Computer: Specs
        • Experience: Beginner
        • OS: Windows 11
        Re: Getting "!" and other difficult characters to encrypt.
        « Reply #4 on: October 14, 2017, 04:14:31 PM »
        Quote
        Possible work arounds?
        Actually learn what you are doing instead of copy-pasting from incompetent youtubers?
        I was trying to dereference Null Pointers before it was cool.

        zask

          Topic Starter


          Intermediate

          • Experience: Experienced
          • OS: Other
          Re: Getting "!" and other difficult characters to encrypt.
          « Reply #5 on: October 14, 2017, 08:28:06 PM »
          Code is very much changed from original source and this was for personal use, also I asked him if it was ok.  I know what everything in the source does line for line so what do you mean actually learn what your doing?
          « Last Edit: October 14, 2017, 08:56:38 PM by zask »

          zask

            Topic Starter


            Intermediate

            • Experience: Experienced
            • OS: Other
            Re: Getting "!" and other difficult characters to encrypt.
            « Reply #6 on: October 14, 2017, 08:32:19 PM »
            The source is clearly not just copied and paste, it clearly has been greatly modified for more useful purposes, the algorithm isn't even entirely the same

            zask

              Topic Starter


              Intermediate

              • Experience: Experienced
              • OS: Other
              Re: Getting "!" and other difficult characters to encrypt.
              « Reply #7 on: October 14, 2017, 08:38:04 PM »
              You don't have to criticize I have zero intention of stealing credit from other youtubers.
              « Last Edit: October 14, 2017, 09:04:45 PM by zask »

              zask

                Topic Starter


                Intermediate

                • Experience: Experienced
                • OS: Other
                Re: Getting "!" and other difficult characters to encrypt.
                « Reply #8 on: October 14, 2017, 08:42:53 PM »
                Like it seriously offends me how you make such a claim. I've been breaking this script down and modifying it and you just act like all I did is copy, paste, added some REM statements and happy faces and boom a brand new script. Like you could at least have looked at the differences in the scripts. I'll go somewhere else for help jesh.
                « Last Edit: October 14, 2017, 09:05:12 PM by zask »

                zask

                  Topic Starter


                  Intermediate

                  • Experience: Experienced
                  • OS: Other
                  Re: Getting "!" and other difficult characters to encrypt.
                  « Reply #9 on: October 14, 2017, 08:51:14 PM »
                  I get your like an expert and all but I have been trying to learn, and your completlying dising on me and I've done nothing wrong. There is a difference from borrowing a script, modifying it, etc, from just taking the script and copy and pasting, I even told you who the original algorithm came from so like Im not plagiarizing or anything. All I did is paraphrased his source and made it much more advanced than the original.
                  « Last Edit: October 14, 2017, 09:08:50 PM by zask »

                  zask

                    Topic Starter


                    Intermediate

                    • Experience: Experienced
                    • OS: Other
                    Re: Getting "!" and other difficult characters to encrypt.
                    « Reply #10 on: October 14, 2017, 09:00:21 PM »
                    If the source is nearly 70% changed then I have been learning from what i code.

                    BC_Programmer


                      Mastermind
                    • Typing is no substitute for thinking.
                    • Thanked: 1140
                      • Yes
                      • Yes
                      • BC-Programming.com
                    • Certifications: List
                    • Computer: Specs
                    • Experience: Beginner
                    • OS: Windows 11
                    Re: Getting "!" and other difficult characters to encrypt.
                    « Reply #11 on: October 14, 2017, 09:18:40 PM »
                    if you knew what you were doing you would not be having issues determining why certain characters were causing problems :P.

                    I wasn't even intending to accuse you of stealing. They provide it for free, after all. Regardless of how much it may have been altered though, it started with a rotten base- The 'incompetent youtuber" part is probably the major takeaway there. I doubt they even wrote the batch file to start with anyway. There are innumerable youtube channels started by upstart teenagers who's parents and family have told them all their life  they will be the next "Bill Gates" because they can log in to face book or use the Command Prompt. Some of them take it to heart and start pretty much writing their memoirs before they are out of high school, like that guy. I mean, at least I had the good sense to wait until I was 21 to be a smartass know-it-all.

                    In any case * and ! are not inherently different than any other character when it comes to these kind of transformation algorithms, so I'd guess that it is related to ! and * having special meaning within the Command Prompt itself, possibly caused entirely by the many layers of unnecessary indirection that are present here, where it constructs accessory batch files and scripts via echo commands. You might start by changing it to not delete these accessory files and examining the batch and VBScript files it creates as they may be where the issue lies, likely in the form of unescaped characters.

                    I was trying to dereference Null Pointers before it was cool.

                    zask

                      Topic Starter


                      Intermediate

                      • Experience: Experienced
                      • OS: Other
                      Re: Getting "!" and other difficult characters to encrypt.
                      « Reply #12 on: October 15, 2017, 07:17:02 AM »
                      I wasn't saying you was accusing me of stealing I was just pointing out that I wasn't.

                      I understand but what you mean, with the whole youtube and where it came from, I do agree, but i have no where to learn from. I do understand what this script does, i learned it line for line. what I don't understand is the whole trying to escape "!" I have tried adding "^^!", I know how to escape it, just not in this situation. I only have general knowledge of the language, And I know like a fair amount of cmd now, but don't understand everything in entirety, i can read some code and understand it well and other scripts I just can't figure out what I'm looking at. Like honestly I put a decient amount of work in the above script, almost more than the original script even had. But I don't know everything, I'm not a mastermind coder. I only applied what I knew I could do to the script, that's why I was asking questions here. Because  I'm trying to learn and it's difficult when there is so little information anywhere on the Internet about command line, YouTube is filled with horrible noob tutorials, every website that helps individuals require at least that person to create his source before they can actually help that person. It's not necessary a big issue, but when i first started out trying to learn, it made it almost impossible to learn anything because I wasnt allowed to learn from others code or have had the knowledge to create my own. Im a person who learns from books, and there is very few books on commamd line that I've found.

                      You say I should learn but I really have been teaching myself a lot more than my old lazy bad habit days, I've been on dos tips breaking down scripts trying to understand them and such. I just do this because I'm really interested in it, but even with all the tutorials, breaking down code, and etc, I'm still not learning how to stretch it into something that I can create by scratch.
                      « Last Edit: October 15, 2017, 07:50:32 AM by zask »

                      zask

                        Topic Starter


                        Intermediate

                        • Experience: Experienced
                        • OS: Other
                        Re: Getting "!" and other difficult characters to encrypt.
                        « Reply #13 on: October 15, 2017, 07:18:52 AM »
                        And I'm not even trying to be a smartass, I'm just trying to learn, honestly, and I was only going to use the script personally. I don't think for a split second that I'm possibly even as remotely close to being as good as you guys or even the guys at dos tips. But where do I go when there isn't anything good anywhere, all tutorials just show the basics and never get into deep details.
                        « Last Edit: October 15, 2017, 07:35:44 AM by zask »

                        BC_Programmer


                          Mastermind
                        • Typing is no substitute for thinking.
                        • Thanked: 1140
                          • Yes
                          • Yes
                          • BC-Programming.com
                        • Certifications: List
                        • Computer: Specs
                        • Experience: Beginner
                        • OS: Windows 11
                        Re: Getting "!" and other difficult characters to encrypt.
                        « Reply #14 on: October 15, 2017, 07:47:46 AM »
                        Again, you were not the smartass to which I referred, but rather the youtuber. They are unreliable as a resource, as they barely understand the material themselves. This tends to be the case for the majority of youtube channels who create tutorials like this, unfortunately.

                        As I mentioned, The script creates additional scripts as part of it's operation. I would suspect the issue lies there, If you remove the segments of code responsible for deleting those helper files, and then you can examine the contents of the files generated and make sure there are no characters that aren't escaped when they should be, or otherwise test/validate those segments of the entire operation.
                        I was trying to dereference Null Pointers before it was cool.