2

I have a batch file which is used to connect to a remote server.

Tha batch file contains:

WMIC /NODE:"ip_address" /user: user_name /password: pass_word process call create "path\abc.bat"

I want to encrypt pass_word.

biswajit
  • 2,707
  • 4
  • 17
  • 16
  • What kind of encryption? What is the decryption support provided by the WMIC command? You wish to encrypt or just encode? Please provide more details. – vijayinani Jun 16 '17 at 06:49
  • I don't know whether WMIC provides any encryption/decryption support. So just Encoding (In stead of Encryption) would do the job. – biswajit Jun 16 '17 at 06:56
  • First, you need to check if WMIC even supports decoding. If yes, what kind of encoding/decoding? Is it Base 64? – vijayinani Jun 16 '17 at 07:00
  • check this: https://stackoverflow.com/questions/25582295/xor-a-string-in-a-bat-file/25583032 – npocmaka Jun 16 '17 at 07:01
  • you can also "convert" your batch into exe - https://stackoverflow.com/questions/28174386/how-can-a-bat-file-be-converted-to-exe-without-third-party-tools – npocmaka Jun 16 '17 at 07:02
  • This might help you to inline encode the password and pass as a parameter to WMIC : https://stackoverflow.com/questions/37046771/base64-encode-string-command-line-windows – vijayinani Jun 16 '17 at 07:03
  • @vijayinani - I was thinking of something like that. I will implement this and see how it goes. Thanks! – biswajit Jun 16 '17 at 07:15
  • You can also take a look at this method using ADS [Prompt for password then save it](http://scripts.dragon-it.co.uk/scripts.nsf/MainFrame?OpenFrameSet&Frame=East&Src=%2Fscripts.nsf%2Fdocs%2Fbatch-prompt-password-save-it!OpenDocument%26AutoFramed) – Hackoo Jun 17 '17 at 12:47

1 Answers1

3

Not exact answer to the question, but, as per the comments discussion and your acceptance to the alternate approach, the below might help you to inline encode the password and pass as a parameter to WMIC:

Base64 Encode "string" - command-line Windows?

vijayinani
  • 2,548
  • 2
  • 26
  • 48
  • Base64 just encode the password to base64 literals. It is not an encryption scheme as asked by @Biswajit Paul above – Awan Biru Jul 07 '20 at 16:29
  • 1
    @Awan Biru ... Did you go thru the comments in the question? He is fine with simple encoding decoding too. So this answer. Have some time to go thru comments before deciding. – vijayinani Jul 07 '20 at 16:50
  • Since, original question did not changed, aren't your answer more suitable as comment instead? Your answer could misleads other readers, since encoding is not encrypting. – Awan Biru Jul 07 '20 at 16:54
  • Have altered my answer. And moreover this is not heavily voted question to rely upon. The question is very raw to refer. You will find many such threads on sof. – vijayinani Jul 07 '20 at 17:02