2014-10-12 44 views
-1

我正在嘗試使用批量打包基本反釣魚軟件。我正在使用它來刪除與gmail登錄頁面類似的html文件。這是我的代碼:批量反釣魚軟件

@echo off 
color fc 
title Anti-Phishing 
cls 
echo =============== 
echo [Anti-Phishing] 
echo =============== 
echo If There's no message ,You are protected. 
set /p a=Enter a HTML file to scan: 
for /f %%x in ('findstr /i /m "gmail google add account" %a%.html') do (
    if /i %%x equ %a%.html (
     for /f %%z in ('findstr /i /b /m "tskill del copy shutdown ipconfig ren reg" %a%.html') do (
      if /i %%z equ %a%.html (
       cls 
       echo Fake Page Detected!! 
       del %a%.html 
       echo %a%.html was deleted.... 
       pause >nul 
      ) 
     ) 
    ) 
) 
pause >nul 

它說它無法打開html文件。請幫我理解我的錯誤。我對批處理很新。

+0

什麼是您的html文件名?添加一行,如'echo「%a%」「%% x」&pause'並查看控制檯上的內容。 – foxidrive 2014-10-12 12:27:13

回答

0

這裏是你的代碼一點點改進:

@echo off 
color fc 
title Anti-Phishing 
cls 
echo =============== 
echo [Anti-Phishing] 
echo =============== 
echo If There's no message ,You are protected. 
set "HtmlFile="" 
set /p "HtmlFile=Enter a HTML file to scan: " 
set "HtmlFile=%HtmlFile:"=%" 
if "%HtmlFile%"=="" goto :EOF 
if "%HtmlFile:~-5%"==".html" set "HtmlFile=%HtmlFile:~0,-5%" 
if "%HtmlFile%"=="" goto :EOF 
if not exist "%HtmlFile%.html" (
    echo File "%HtmlFile%.html" not found. 
    echo. 
    echo Exit with any key ... 
    pause>nul 
    goto :EOF 
) 
for /f %%x in ('%SystemRoot%\System32\findstr.exe /i /m "gmail google add account" "%HtmlFile%.html"') do (
    if /i %%x equ "%HtmlFile%.html" (
     for /f %%z in ('%SystemRoot%\System32\findstr.exe /i /b /m "tskill del copy shutdown ipconfig ren reg" "%HtmlFile%.html"') do (
      if /i "%%z" equ "%HtmlFile%.html" (
       cls 
       echo Fake Page Detected!! 
       del "%HtmlFile%.html" 
       echo "%HtmlFile%.html" was deleted. 
       pause >nul 
      ) 
     ) 
    ) 
) 
pause >nul 

此批處理文件首先定義一個環境變量HtmlFile只是一個雙引號的字符串值。

用戶提示符後的下一行刪除所有用戶從字符串中輸入的雙引號。如果用戶在提示符下按下RETURN或ENTER鍵而沒有輸入任何文件名,這將導致一個空字符串。在這種情況下批處理文件退出。

接下來,批處理代碼檢查HTML文件的名稱是否以「.html」結尾輸入。由於文件擴展名是通過批處理代碼自動添加的(出於某種未知原因),字符串「.html」將從文件名中刪除。

它可能再次發生,剩下的字符串現在是一個空字符串。

最後批處理文件檢查是否可以在文件系統中找到具有絕對路徑或相對路徑的文件名。否則會輸出錯誤信息。

請注意,此批處理文件不能使用HTTP(超文本傳輸​​協議)或其他訪問WWW文件的協議評估網頁。它只能通過UNC路徑用於本地驅動器,網絡驅動器或公共共享上的文件。

所有對環境變量HtmlFile的引用都包含在雙引號中,以便在批處理文件用戶輸入的文件名(帶或不帶路徑)中存在空格或其他特殊字符的情況下。