Last active
June 3, 2025 11:45
-
-
Save curability4apish/96c2f1bb45426afac7cf2761ff73b9f7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
setlocal enabledelayedexpansion | |
rem Manually define the Downloads folder path here | |
set "downloadsFolder=D:\Downloads" | |
rem Check if the path is valid | |
if not exist "!downloadsFolder!" ( | |
echo Error: The specified folder does not exist. | |
goto :end | |
) | |
:main | |
cls | |
echo Listing all .exe and .zip files in the specified Downloads folder (newest to oldest): | |
set "count=0" | |
for /f "tokens=*" %%F in ('dir "!downloadsFolder!\*.exe" "!downloadsFolder!\*.zip" /b /a-d /o-d /t:c 2^>nul') do ( | |
set /a count+=1 | |
echo !count!. %%F | |
set "file[!count!]=%%F" | |
) | |
rem Check if any .exe or .zip files were found | |
if %count%==0 ( | |
echo No .exe or .zip files found in the Downloads folder. | |
goto :list_other_files | |
) | |
rem Prompt user to select a file | |
echo. | |
echo Press 0 to list other files (e.g., .docx, .mp4) in the Downloads folder. | |
set /p "choice=Enter the number of the file you want to select: " | |
if %choice%==0 ( | |
goto :list_other_files | |
) | |
set "selectedFile=!file[%choice%]!" | |
rem Validate the user's choice | |
if "!selectedFile!"=="" ( | |
echo Invalid selection. | |
goto :main | |
) | |
goto :process_file | |
:list_other_files | |
cls | |
echo Listing other files in the specified Downloads folder (newest to oldest): | |
set "count=0" | |
for /f "tokens=*" %%F in ('dir "!downloadsFolder!\*" /b /a-d /o-d /t:c 2^>nul ^| findstr /v /i /e ".exe .zip"') do ( | |
set /a count+=1 | |
echo !count!. %%F | |
set "file[!count!]=%%F" | |
) | |
rem Check if any other files were found | |
if %count%==0 ( | |
echo No other files found in the Downloads folder. | |
goto :main | |
) | |
rem Prompt user to select a file from the additional list | |
echo. | |
echo Press 0 to go back to the previous menu. | |
set /p "choice=Enter the number of the file you want to select: " | |
if %choice%==0 ( | |
goto :main | |
) | |
set "selectedFile=!file[%choice%]!" | |
rem Validate the user's choice | |
if "!selectedFile!"=="" ( | |
echo Invalid selection. | |
goto :list_other_files | |
) | |
goto :process_file | |
:process_file | |
set "filePath=!downloadsFolder!\!selectedFile!" | |
echo Selected File Path: !filePath! | |
rem Check if the file exists | |
if not exist "!filePath!" ( | |
echo Error: The selected file does not exist. | |
goto :main | |
) | |
rem Calculate the MD5 hash and output to temp.txt | |
certUtil -hashfile "!filePath!" MD5 > temp.txt | |
rem Read the output and find the line that contains the actual hash | |
set "hash=" | |
for /f "skip=1 tokens=*" %%A in (temp.txt) do ( | |
if not defined hash ( | |
set "hash=%%A" | |
) | |
) | |
rem Remove trailing spaces from the hash | |
for %%A in (!hash!) do set "hash=%%A" | |
rem Check if hash is set | |
if not defined hash ( | |
echo Error: Could not calculate the hash. | |
goto :main | |
) | |
echo Hash: !hash! | |
rem Open the URL in the default web browser | |
start https://www.virustotal.com/gui/file/!hash! | |
del temp.txt | |
goto :main | |
:end | |
pause |
A simplified version.
@echo off
setlocal enabledelayedexpansion
rem Check if any arguments are provided
if "%~1"=="" (
echo Please provide at least one file as an argument.
pause
goto :end
)
rem Loop through each file provided as an argument
for %%F in (%*) do (
echo File: %%F
rem Calculate the SHA256 hash and output to temp.txt
certUtil -hashfile "%%F" sha256 > temp.txt
rem Read the output and find the line that contains the actual hash
set hash=
for /f "skip=1" %%A in (temp.txt) do (
set hash=%%A
goto :break
)
:break
echo Hash: !hash!
rem Open the VirusTotal URL in the default web browser
start "" "https://www.virustotal.com/gui/file/!hash!"
del temp.txt
)
:end
endlocal
pause
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
VirusTotal Opener
Description
This batch script opens VirusTotal's webpage of the scan result of the file you want to scan. If it hasn't been uploaded, you may upload it manually through your browser.
How It Works
The script initially lists all
.exe
and.zip
files in the user's Downloads folder.The user is prompted to select a file from the list by entering the corresponding number.
If the user enters
0
, the script lists other types of files in the Downloads folder.The user can then select a file from the new list or go back to the previous menu by entering
0
.Once a file is selected, the script calculates its MD5 hash.
The script opens a VirusTotal URL with the calculated hash for scanning.
The script loops back to the main menu after processing the file.
Prerequisites
certUtil
utility (included with Windows) to calculate the MD5 hash.v2 Updates