How do I modify some Strings in an executable?

-2

I made a small application, in batch language, which I then made into a .exe file.

The file asks for a password to be opened, opening a window where it should be inserted, but this password is fixed because it is written in the file .bat that gave the .exe . >

What I want is a system, which can be inserted into the source code, so that you have the possibility to change the password.

For example, if it is "Paul 123" when opening the window where the password is written, the letter "X" or the number "Y" is inserted which will make a goto to a different line where a echo will be prompted to enter the new password. Of course you would have to have, as a security measure, the need to enter the original password first.

The line of code that takes care of asking for the password in my application is

set /p "pass=>" 
if NOT %pass%== "Palavra-passe-sem-as-aspas" goto FAIL

If it is not possible to do this in batch language, it can be anywhere else where possible.

My difficulty is that my knowledge of the commands and their syntax is very limited and boils down to the basics of .bat files, so it would have to be done in a way that I could copy the lines of code , into the source code of my application, so that it could run.

In case it is not possible to mix the two languages into a single file, the code would have to be executed in a way that would be executed separately so that it could act on the application executable, so I would need to know how to make this code an independent executable.

In addition, in this application that I did, when you type the password in the insert window, it appears revealed and I wanted to know how to do it, so that it appeared as asterisks.

    
asked by anonymous 18.05.2016 / 13:38

1 answer

0

Paul, I do not have much time to give you a ready answer, but I can help you with some things that I believe will reach your goal.

Based on your limitation on only batch to make your commands, I have an idea.

  • Your password could be in a separate file, and using encryption, you could read the contents of the decrypt file and do what you want, changing password, etc. I do not see any other way to do this, because your batch file is already in .exe , I found an example you can use to do this

    how to encrypt a text file using batch?

  • To make the typed characters appear ******** , you can use the script below:

    @Echo Off
    SetLocal EnableExtensions EnableDelayedExpansion
    
    Set /P "=Enter a Password:" < Nul
    Call :PasswordInput
    Echo(Your password text:!pwd!
    Pause
    
    Goto :Eof
    
    :PasswordInput
    :: consolesoft.com/batch/?#password_input
    ::Author: Carlos Montiers Aguilera
    ::Last updated: 20150405. Created: 20150401.
    ::Set variable pwd with input password
    ::Needs delayed expansion enabled
    Set "pwd="
    Set "INTRO=" &For /F "skip=1" %%# in (
    '"Echo(|Replace.exe ? . /U /W"'
    ) Do If Not Defined INTRO Set "INTRO=%%#"
    For /F %%# In (
    '"Prompt $H &For %%_ In (_) Do Rem"') Do Set "BKSPACE=%%#"
    :_PasswordInput_Kbd
    Set "Excl="
    Set "CHR=" &For /F skip^=1^ delims^=^ eol^= %%# in (
    'Replace.exe ? . /U /W') Do If Not Defined CHR (
    Set "CHR=%%#" &If "%%#"=="!" Set "Excl=yes")
    If "!INTRO!"=="!CHR!" Echo(&Goto :Eof
    If "!BKSPACE!"=="!CHR!" (If Defined pwd (
    Set "pwd=!pwd:~0,-1!"
    Set /P "=!BKSPACE! !BKSPACE!" <Nul)
    Goto :_PasswordInput_Kbd
    ) Else If Not Defined Excl (
    Set "pwd=!pwd!!CHR:~0,1!"
    ) Else Set "pwd=!pwd!^!"
    Set /P "=*" <Nul
    Goto :_PasswordInput_Kbd
    

    Source: link
     Author: Carlos  Origin: Chile

19.05.2016 / 21:26