MSFN Forum: CMD: OPTION to jump - MSFN Forum

Jump to content


  • 2 Pages +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

CMD: OPTION to jump Rate Topic: -----

#1 User is offline   Caml Light 

  • Junior
  • Pip
  • Group: Members
  • Posts: 85
  • Joined: 03-October 03

Posted 30 August 2011 - 07:44 PM

Hi guys! If my batch file contains this:

:Sorry
ECHO Sorry!

:Welcome
ECHO Welcome!

Is it possible to jump to the ":Sorry" label if i open the cmd file and to jump to the ":Welcome" label if i open the same cmd file followed by an option (for example: batch.cmd /jump)?

Thank you!!


#2 User is offline   IcemanND 

  • MSFN Junkie
  • Group: Super Moderator
  • Posts: 3,266
  • Joined: 24-September 03
  • OS:Windows 7 x64
  • Country: Country Flag

Posted 30 August 2011 - 09:08 PM

goto %1

:sorry
Echo Sorry!
Goto :end

:welcome
echo welcome
Goto :end

:end


just use the label name for the switch

#3 User is offline   Caml Light 

  • Junior
  • Pip
  • Group: Members
  • Posts: 85
  • Joined: 03-October 03

Posted 30 August 2011 - 10:28 PM

GREAT! Thank you very much! :thumbup

#4 User is offline   Caml Light 

  • Junior
  • Pip
  • Group: Members
  • Posts: 85
  • Joined: 03-October 03

Posted 30 August 2011 - 11:18 PM

a last question... if i convert my CMD batch to EXE, for a person that doesn't know the label i've given, is it possible to jump directly to the "Welcome" label, or anyway to find it's name? I'd to protect my batch file.. so do you think it's a secure solution? Thanks! :hello:

This post has been edited by Caml Light: 30 August 2011 - 11:20 PM


#5 User is offline   allen2 

  • Not really Newbie
  • PipPipPipPipPipPipPip
  • Group: Members
  • Posts: 1,737
  • Joined: 13-January 06

Posted 31 August 2011 - 12:19 AM

It just depends on how secure you want it to be: if you use a batch to exe converter, most of them will only unpack the batch in a temporary folder and run it from there and then the protection will be very light.

#6 User is offline   Caml Light 

  • Junior
  • Pip
  • Group: Members
  • Posts: 85
  • Joined: 03-October 03

Posted 31 August 2011 - 03:44 AM

..and what do you suggest me to protect better my cmd script? Thanks in advance!

#7 User is online   Kelsenellenelvian 

  • WPI Guru
  • Group: Developers
  • Posts: 8,326
  • Joined: 18-September 03
  • OS:Windows 7 x64
  • Country: Country Flag

Posted 31 August 2011 - 03:53 AM

Make it into a autoit file and compile it with password...

#8 User is online   jaclaz 

  • The Finder
  • Group: Developers
  • Posts: 11,458
  • Joined: 23-July 04
  • OS:none specified
  • Country: Country Flag

Posted 31 August 2011 - 04:17 AM

View PostKelsenellenelvian, on 31 August 2011 - 03:53 AM, said:

Make it into a autoit file and compile it with password...

....and make it longer than 12 characters and make sure you insert "strange" non alpha-numeric characters and not a-z/A-Z ones.
Examples:
  • h1_1_@m_@_|33t_p@§§vv0rd
  • ÿ00_vv0n*t_cr@ç#-m3


:angel

BTW, IcemanND's nice batch may be "bettered" (assuming you are on a 2K/XP or later NT based system):
@ECHO OFF
SETLOCAL ENABLEEXTENSIONS
IF NOT "%1"=="" FOR /F %%A in ('type %~nx0 ^|FIND ":%1" ^| FIND /V "FIND"') DO GOTO :%1
Echo A suffusion of yellow ...
GOTO :EOF

:sorry
Echo Sorry!
GOTO :EOF

:welcome
echo welcome


OR (to follow your original post):
@ECHO OFF
SETLOCAL ENABLEEXTENSIONS
IF NOT "%1"=="" FOR /F %%A in ('type %~nx0 ^|FIND ":%1" ^| FIND /V "FIND"') DO GOTO :%1
Echo Sorry!
GOTO :EOF
:welcome
echo welcome


OR:
@ECHO OFF
SETLOCAL
IF /I "%1"=="welcome" GOTO :%1
Echo Sorry!
GOTO :EOF
:welcome
echo welcome



jaclaz

This post has been edited by jaclaz: 31 August 2011 - 04:21 AM


#9 User is online   Kelsenellenelvian 

  • WPI Guru
  • Group: Developers
  • Posts: 8,326
  • Joined: 18-September 03
  • OS:Windows 7 x64
  • Country: Country Flag

Posted 31 August 2011 - 04:29 AM

•h1_1_@m_@_|33t_p@§§vv0rd

•ÿ00_vv0n*t_cr@ç#-m3


OMG LOLZ

#10 User is offline   allen2 

  • Not really Newbie
  • PipPipPipPipPipPipPip
  • Group: Members
  • Posts: 1,737
  • Joined: 13-January 06

Posted 31 August 2011 - 06:44 AM

You can use an obfuscator (some batch to exe do this but most of them aren't free) or use another language like autoit (which is a little more secure when using a password ).
You could also change the code to make it so complex that just reading it would not help "the man in the middle" to understand it.

This post has been edited by allen2: 31 August 2011 - 06:44 AM


#11 User is offline   Tripredacus 

  • K-Mart-ian Legend
  • Group: Super Moderator
  • Posts: 8,690
  • Joined: 28-April 06
  • OS:Server 2012
  • Country: Country Flag

Posted 31 August 2011 - 08:44 AM

IIRC, the password in AutoIT is only for their decompiler that is meant for AutoIT v2 executables. It was this entire purpose (they lock topics over there if you ask about it) that this function was removed in v3, although you can still put a password in it. But this password does nothing for other decompilers.

#12 User is offline   Caml Light 

  • Junior
  • Pip
  • Group: Members
  • Posts: 85
  • Joined: 03-October 03

Posted 31 August 2011 - 09:31 AM

thank you for your reply guys! I want to specify that to protect my batch i can't use any password to type in.
To convert to EXE my batch i've used "Bat To Exe Converter 1.5.1.0". Do you think it's enough secure? Better Offuscator?

Now i've added the code by jaclaz:

@ECHO OFF
SETLOCAL
IF /I "%1"=="welcome" GOTO :%1
Echo Sorry!
GOTO :EOF
:welcome
echo welcome

But if an expert user will decrypt my batch, this method will be vain.

#13 User is offline   Caml Light 

  • Junior
  • Pip
  • Group: Members
  • Posts: 85
  • Joined: 03-October 03

Posted 31 August 2011 - 09:36 AM

I've find Crypto Obfuscator, but is it only for .NET??

#14 User is online   Kelsenellenelvian 

  • WPI Guru
  • Group: Developers
  • Posts: 8,326
  • Joined: 18-September 03
  • OS:Windows 7 x64
  • Country: Country Flag

Posted 31 August 2011 - 09:52 AM

yes it looks like it

I like the looks of this:

http://www.bdargo.com/

This post has been edited by Kelsenellenelvian: 31 August 2011 - 09:53 AM


#15 User is online   jaclaz 

  • The Finder
  • Group: Developers
  • Posts: 11,458
  • Joined: 23-July 04
  • OS:none specified
  • Country: Country Flag

Posted 31 August 2011 - 10:20 AM

This seem to me "good enough":
http://www.f2ko.de/p...lang=en&pid=b2e

But we also have an IDE for batch files :w00t::
http://sourceforge.n.../batchcompiler/

And also a new thingy , Visualbatch :ph34r: :
http://visualbatch.sourceforge.net/

The good ol' way:
http://www.ericphelp...obfuscating.txt

jaclaz

This post has been edited by jaclaz: 31 August 2011 - 10:22 AM


#16 User is offline   Caml Light 

  • Junior
  • Pip
  • Group: Members
  • Posts: 85
  • Joined: 03-October 03

Posted 31 August 2011 - 11:18 AM

Guys, i've decided to use for now this converter: http://www.f2ko.de/p...lang=en&pid=b2e

It's free. Now i've an issue. Compiling my batch with this code:

@ECHO OFF
SETLOCAL
IF /I "%1"=="welcome" GOTO :%1
Echo Sorry!
GOTO :EOF
:welcome
echo welcome

the exe launched with welcome option goes directly to the end of the script. With the original batch instead it's all fine.

#17 User is offline   Yzöwl 

  • Wise Owl
  • Group: Super Moderator
  • Posts: 4,364
  • Joined: 13-October 04
  • OS:Windows 7 x64

Posted 31 August 2011 - 12:24 PM

Not an answer to your last question but, if you use a batch file like this:
@ECHO OFF
ECHO=_%~1|FINDSTR/X "_-? _/?">NUL 2>&1||GOTO Sorry
REM Your scripting starts below here
ECHO=Welcome!
PAUSE
REM Your scripting ends above here
GOTO :EOF
:Sorry
ECHO=	Sorry!
ECHO=
ECHO=Press any key to Exit.
PAUSE>NUL
Only users entering a parameter of /? or -? will run the script. The idea behind this is that they should be the most obvious switches to run by someone 'switched on' an unknowing user will always get the Sorry message.

#18 User is offline   Caml Light 

  • Junior
  • Pip
  • Group: Members
  • Posts: 85
  • Joined: 03-October 03

Posted 31 August 2011 - 02:09 PM

Hi Yzöwl, i've mixed it with one of your batch.... so this is the final result:

@ECHO OFF
SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION
COLOR F0

ECHO=_%~1|FINDSTR/X "_-123456 _/123456">NUL 2>&1||GOTO Error

FOR /R %%A IN (Windows*-KB*.EXE) DO (
ECHO= Installation of %%~nA...
>NUL PING -n 4 127.0.0.1
"%%A" /quiet /norestart)
ECHO=
ECHO= == Press any key to restart. ==
>NUL PAUSE
SHUTDOWN.EXE /r /t 0
GOTO :EOF

:Error
ECHO= Error.
ECHO=
ECHO= Press any key to exit...
PAUSE>NUL
EXIT

I've for you two questions:

1) Is this batch correct for you??
2) I compile it with this utility: http://www.f2ko.de/p...lang=en&pid=b2e
Once that i launch the obtained EXE with the correct option: "file.exe /?" the batch goes directly to this string: "ECHO= == Press any key to restart. ==", jumping the FOR /R loop command.

Any idea? :yes:

This post has been edited by Caml Light: 31 August 2011 - 04:26 PM


#19 User is offline   Yzöwl 

  • Wise Owl
  • Group: Super Moderator
  • Posts: 4,364
  • Joined: 13-October 04
  • OS:Windows 7 x64

Posted 31 August 2011 - 03:39 PM

A couple of things to mention:
  • You don't need to enable delayed expansion.
  • If for some reason the file is run in the wrong location and there are no hotfixes found, your script would still restart the system


As far as your problem goes, I'd suggest that your 'compiler' may not be designed to pass parameters provided to it through to the script.

#20 User is offline   Caml Light 

  • Junior
  • Pip
  • Group: Members
  • Posts: 85
  • Joined: 03-October 03

Posted 31 August 2011 - 04:17 PM

ok, i've solved the problem cutting down from the posted code every "%~dp0" string. Now with "FOR /R %%A" it seems to work. Please Yzöwl, i've copied your batch from an another topic, and you had enabled delayed expansion there. So, cleaning all the code as you know to do... how do you could to rewrite the code i've posted?

Thanks for your patience.

This post has been edited by Caml Light: 31 August 2011 - 04:23 PM


Share this topic:


  • 2 Pages +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users



All trademarks mentioned on this page are the property of their respective owners
Copyright © 2001 - 2013 msfn.org
Privacy Policy