4

I'd like help in setting password in a batch file but without exposing password.

If I SET password="abc123", I don't want abc123 to be visible in the batch file, as other people will be running the .bat file.

SachaDee
  • 9,245
  • 3
  • 23
  • 33
primosad
  • 53
  • 1
  • 4
  • Any help would be much appreciated, and thanks in advance – primosad Jun 22 '17 at 18:50
  • 1
    check [this](https://stackoverflow.com/questions/25582295/xor-a-string-in-a-bat-file) and [this](https://stackoverflow.com/questions/28174386/how-can-a-bat-file-be-converted-to-exe-without-third-party-tools) – npocmaka Jun 22 '17 at 19:01
  • 1
    Not an answer, but just FYI: `set password="string"` would set the password to `"string"`, not `string`. – Regejok Jun 22 '17 at 19:06
  • You can use this method [Password hidden using ADS](http://scripts.dragon-it.co.uk/scripts.nsf/docs/batch-password1!OpenDocument&ExpandSection=3&AutoFramed) – Hackoo Jun 22 '17 at 20:13

2 Answers2

3

There is unfortunately no good solution to hide a password in batch

Even if you crypt it, change it to HEX, hide it in an Alternative Data Stream (ADS) or whatever you want.

At a moment you have to test the value in your code with an IF test.

At this point the password, crypted or not, will be visible or settedin a variable that can be echoed.

You can also compress your BAT in a self-extracting .EXE, but this is very easy to crack, while the .BAT file have to be decompressed before you run it (in the %temp% folder).

So there is no way to really hide a password in a .BAT file

SachaDee
  • 9,245
  • 3
  • 23
  • 33
  • You are right and here is an example to catch files in the temporary folder ==> https://pastebin.com/raw/LGzywPCn – Hackoo Jun 22 '17 at 20:09
1

You can try this method : Password hidden using ADS

  1. create and save your batch file
  2. use the ECHO command to 'place' your password into an ADS attached to your batch file
  3. use redirection to read the password from the ADS (Alternative Data Stream) file
Hackoo
  • 18,337
  • 3
  • 40
  • 70