Created
December 27, 2024 16:33
-
-
Save Joseph413168/e147dcedf9d1bedcc27daea94bdcc22f 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 | |
| cls | |
| color a | |
| SETLOCAL EnableDelayedExpansion | |
| :GeolocatorSubmenu | |
| cls | |
| echo Welcome to the geolocator Submenu what would you like to do today? | |
| echo [1] Geolocate IPs In A file | |
| echo [2] Geolocate Other IPs | |
| echo [3] Geolocate My Public IP | |
| echo [4] Help | |
| set /p choice=Enter your choice : | |
| if "%choice%"=="1" ( | |
| goto :geolocateipsfromfilemenu | |
| ) | |
| if "%choice%"=="2" ( | |
| goto :geolocateotheripsstart | |
| ) | |
| if "%choice%"=="3" ( | |
| goto :GeolocateMyPublicIP | |
| ) | |
| if "%choice%"=="4" ( | |
| goto :GeolocatorSubmenuHelp | |
| ) | |
| cls | |
| echo Current directory: %cd% | |
| echo. | |
| :geolocateipsfromfilemenu | |
| cls | |
| echo Please enter the name of the file containing the IP addresses with its extension if it is in the current directory. | |
| echo If the file is not in the current directory, please specify its full path (e.g., "C:\path\to\file\ips.txt"). | |
| echo You may use the Help/Log/NewLog/back Commands | |
| echo Leave this field empty to reuse the previous (command/IP file) from the current session | |
| echo (a sample IP list is provided in the current directory you may refer to it by typing "IP.txt") | |
| set /p ipFile= | |
| if /i "%ipFile%"=="HELP" ( | |
| cls | |
| echo HELP - How to use the script: | |
| echo ------------------------------------------------------ | |
| echo 1. Enter the name of the file containing IP addresses to process. | |
| echo The file should contain one IP address per line. | |
| echo 2. Type "log" to view previously scanned IP logs. | |
| echo 3. Type "newlog" to reset the log and start fresh. | |
| echo 4. Type "back" to go back to the geolocator submenu. | |
| echo 5. The script will fetch geolocation information for each IP. | |
| echo 6. Leave the field empty to reuse the previous Command/IP File. | |
| echo 7. Results are saved in the following folders: | |
| echo - Raw JSON responses: ReconV3_Logs\File_IP_Geolocator_log\json_results | |
| echo - Extracted geolocation information: ReconV3_Logs\File_IP_Geolocator_log\geolocated_ips_from_file | |
| echo ------------------------------------------------------ | |
| pause | |
| goto :geolocateipsfromfilemenu | |
| ) | |
| if /i "%ipFile%"=="LOG" ( | |
| cls | |
| echo Scanned IP Logs: | |
| echo -------------------------- | |
| if not exist "ReconV3_Logs\File_IP_Geolocator_log\geolocated_ips_from_file" ( | |
| echo No logs found. Please scan some IPs first. | |
| ) else ( | |
| for /r "ReconV3_Logs\File_IP_Geolocator_log\geolocated_ips_from_file" %%f in (*_geo.txt) do ( | |
| echo Contents of %%~nxf: | |
| type "%%f" | |
| echo -------------------------- | |
| ) | |
| ) | |
| pause | |
| goto geolocateipsfromfilemenu | |
| ) | |
| if /i "%ipFile%"=="NEWLOG" ( | |
| cls | |
| echo Resetting the log... | |
| if exist "ReconV3_Logs\File_IP_Geolocator_log" ( | |
| rd /s /q "ReconV3_Logs\File_IP_Geolocator_log" | |
| echo Deleted: ReconV3_Logs\File_IP_Geolocator_log | |
| ) else ( | |
| echo Directory ReconV3_Logs\File_IP_Geolocator_log does not exist. | |
| ) | |
| echo Log has been reset. | |
| pause | |
| goto geolocateipsfromfilemenu | |
| ) | |
| if /i "%ipFile%"=="BACK" ( | |
| pause | |
| goto GeolocatorSubmenu | |
| ) | |
| if "%ipFile%"=="" ( | |
| echo You did not enter a file name. Please provide a valid file. | |
| pause | |
| goto geolocateipsfromfilemenu | |
| ) | |
| if not exist "%ipFile%" ( | |
| echo The file "%ipFile%" does not exist. Please provide a valid file with its extension or specify its full path. | |
| echo. | |
| pause | |
| goto geolocateipsfromfilemenu | |
| ) | |
| if not exist "ReconV3_Logs" mkdir "ReconV3_Logs" | |
| if not exist "ReconV3_Logs\File_IP_Geolocator_log" mkdir "ReconV3_Logs\File_IP_Geolocator_log" | |
| if not exist "ReconV3_Logs\File_IP_Geolocator_log\json_results" mkdir "ReconV3_Logs\File_IP_Geolocator_log\json_results" | |
| if not exist "ReconV3_Logs\File_IP_Geolocator_log\geolocated_ips_from_file" mkdir "ReconV3_Logs\File_IP_Geolocator_log\geolocated_ips_from_file" | |
| for /f "tokens=*" %%i in (%ipFile%) do ( | |
| set ip=%%i | |
| echo Processing IP: !ip! | |
| curl -s "https://ipinfo.io/!ip!/json" -o "ReconV3_Logs\File_IP_Geolocator_log\json_results\!ip!.json" | |
| if not exist "ReconV3_Logs\File_IP_Geolocator_log\json_results\!ip!.json" ( | |
| echo Failed to fetch data for IP: !ip! | |
| echo -------------------------- | |
| continue | |
| ) | |
| echo Geolocation Information for IP !ip! > "ReconV3_Logs\File_IP_Geolocator_log\geolocated_ips_from_file\!ip!_geo.txt" | |
| echo -------------------------- >> "ReconV3_Logs\File_IP_Geolocator_log\geolocated_ips_from_file\!ip!_geo.txt" | |
| for /f "tokens=1,* delims=:" %%a in ('findstr /i "city" "ReconV3_Logs\File_IP_Geolocator_log\json_results\!ip!.json"') do ( | |
| set city=%%b | |
| echo City: !city! >> "ReconV3_Logs\File_IP_Geolocator_log\geolocated_ips_from_file\!ip!_geo.txt" | |
| ) | |
| for %%f in (region country loc org postal timezone) do ( | |
| for /f "tokens=1,* delims=:" %%a in ('findstr /i "%%f" "ReconV3_Logs\File_IP_Geolocator_log\json_results\!ip!.json"') do ( | |
| set fieldValue=%%b | |
| if "!fieldValue!"=="" ( | |
| echo %%f: Field not found >> "ReconV3_Logs\File_IP_Geolocator_log\geolocated_ips_from_file\!ip!_geo.txt" | |
| ) else ( | |
| echo %%f: !fieldValue! >> "ReconV3_Logs\File_IP_Geolocator_log\geolocated_ips_from_file\!ip!_geo.txt" | |
| ) | |
| ) | |
| ) | |
| echo -------------------------- >> "ReconV3_Logs\File_IP_Geolocator_log\geolocated_ips_from_file\!ip!_geo.txt" | |
| ) | |
| echo Processing complete. Results saved in the following folders: | |
| echo - Raw JSON responses: ReconV3_Logs\File_IP_Geolocator_log\json_results | |
| echo - Extracted geolocation information: ReconV3_Logs\File_IP_Geolocator_log\geolocated_ips_from_file | |
| pause | |
| goto :geolocateipsfromfilemenu | |
| cls | |
| setlocal EnableDelayedExpansion | |
| :geolocateotheripsstart | |
| cls | |
| echo Please enter the IP address to geolocate, or type "HELP" for instructions, | |
| echo "LOG" to view the log, "NEWLOG" to reset the log, or "BACK" to go back: | |
| set /p "IP=Enter IP: " | |
| echo. | |
| if "%IP%"=="" set IP= | |
| if /i "%IP%"=="HELP" goto geolocateotheripshelp | |
| if /i "%IP%"=="LOG" goto geolocateotheripslog | |
| if /i "%IP%"=="NEWLOG" goto geolocateotheripsnewlog | |
| if /i "%IP%"=="BACK" goto GeolocatorSubmenu | |
| set city= | |
| set region= | |
| set country= | |
| set loc= | |
| set org= | |
| set postal= | |
| set timezone= | |
| if not exist "ReconV3_Logs" mkdir "ReconV3_Logs" | |
| if not exist "ReconV3_Logs\Geolocation_Results" mkdir "ReconV3_Logs\Geolocation_Results" | |
| if not exist "ReconV3_Logs\Geolocation_Results\plaintext_results" mkdir "ReconV3_Logs\Geolocation_Results\plaintext_results" | |
| if not exist "ReconV3_Logs\Geolocation_Results\json_results" mkdir "ReconV3_Logs\Geolocation_Results\json_results" | |
| curl -s https://ipinfo.io/%IP%/json > "ReconV3_Logs\Geolocation_Results\json_results\%IP%.json" | |
| findstr /i "city" "ReconV3_Logs\Geolocation_Results\json_results\%IP%.json" >nul | |
| if errorlevel 1 ( | |
| echo Invalid IP address. Please try again. | |
| del "ReconV3_Logs\Geolocation_Results\json_results\%IP%.json" | |
| pause | |
| goto geolocateotheripsstart | |
| ) | |
| for /f "tokens=1,* delims=:" %%a in ('findstr /i "city" "ReconV3_Logs\Geolocation_Results\json_results\%IP%.json"') do set city=%%b | |
| for /f "tokens=1,* delims=:" %%a in ('findstr /i "region" "ReconV3_Logs\Geolocation_Results\json_results\%IP%.json"') do set region=%%b | |
| for /f "tokens=1,* delims=:" %%a in ('findstr /i "country" "ReconV3_Logs\Geolocation_Results\json_results\%IP%.json"') do set country=%%b | |
| for /f "tokens=1,* delims=:" %%a in ('findstr /i "loc" "ReconV3_Logs\Geolocation_Results\json_results\%IP%.json"') do set loc=%%b | |
| for /f "tokens=1,* delims=:" %%a in ('findstr /i "org" "ReconV3_Logs\Geolocation_Results\json_results\%IP%.json"') do set org=%%b | |
| for /f "tokens=1,* delims=:" %%a in ('findstr /i "postal" "ReconV3_Logs\Geolocation_Results\json_results\%IP%.json"') do set postal=%%b | |
| for /f "tokens=1,* delims=:" %%a in ('findstr /i "timezone" "ReconV3_Logs\Geolocation_Results\json_results\%IP%.json"') do set timezone=%%b | |
| set city=%city:"=% | |
| set region=%region:"=% | |
| set country=%country:"=% | |
| set loc=%loc:"=% | |
| set org=%org:"=% | |
| set postal=%postal:"=% | |
| set timezone=%timezone:"=% | |
| echo Geolocation Information for %IP% > "ReconV3_Logs\Geolocation_Results\plaintext_results\%IP%.txt" | |
| echo -------------------------- >> "ReconV3_Logs\Geolocation_Results\plaintext_results\%IP%.txt" | |
| echo City: %city% >> "ReconV3_Logs\Geolocation_Results\plaintext_results\%IP%.txt" | |
| echo Region: %region% >> "ReconV3_Logs\Geolocation_Results\plaintext_results\%IP%.txt" | |
| echo Country: %country% >> "ReconV3_Logs\Geolocation_Results\plaintext_results\%IP%.txt" | |
| echo Location: %loc% >> "ReconV3_Logs\Geolocation_Results\plaintext_results\%IP%.txt" | |
| echo Organization: %org% >> "ReconV3_Logs\Geolocation_Results\plaintext_results\%IP%.txt" | |
| echo Postal Code: %postal% >> "ReconV3_Logs\Geolocation_Results\plaintext_results\%IP%.txt" | |
| echo Timezone: %timezone% >> "ReconV3_Logs\Geolocation_Results\plaintext_results\%IP%.txt" | |
| echo -------------------------- >> "ReconV3_Logs\Geolocation_Results\plaintext_results\%IP%.txt" | |
| echo Geolocation Information: | |
| echo -------------------------- | |
| echo City: %city% | |
| echo Region: %region% | |
| echo Country: %country% | |
| echo Location: %loc% | |
| echo Organization: %org% | |
| echo Postal Code: %postal% | |
| echo Timezone: %timezone% | |
| echo -------------------------- | |
| pause | |
| goto geolocateotheripsstart | |
| :geolocateotheripshelp | |
| cls | |
| echo HELP - How to Use the Script: | |
| echo ------------------------------------------------------ | |
| echo 1. Enter the IP address you want to geolocate. | |
| echo 2. Type "LOG" to view all saved logs. | |
| echo 3. Type "NEWLOG" to delete all logs and start fresh. | |
| echo 4. Geolocation details for each IP address will be saved as plaintext in: | |
| echo "ReconV3_Logs\Geolocation_Results\plaintext_results" | |
| echo 5. Raw JSON responses will be saved in: | |
| echo "ReconV3_Logs\Geolocation_Results\json_results" | |
| echo 6. To exit, close the window or type "BACK" to return to the previous menu. | |
| echo ------------------------------------------------------ | |
| pause | |
| goto geolocateotheripsstart | |
| :geolocateotheripslog | |
| cls | |
| echo Viewing geolocation logs: | |
| echo ------------------------------ | |
| if not exist "ReconV3_Logs\Geolocation_Results" ( | |
| echo No geolocation logs found. Please geolocate some IP addresses first. | |
| ) else ( | |
| echo Text-based Logs: | |
| for %%f in (ReconV3_Logs\Geolocation_Results\plaintext_results\*.txt) do ( | |
| echo Contents of %%f: | |
| type "%%f" | |
| echo ------------------------------ | |
| ) | |
| echo JSON Results: | |
| dir /b "ReconV3_Logs\Geolocation_Results\json_results" | |
| ) | |
| pause | |
| goto geolocateotheripsstart | |
| :geolocateotheripsnewlog | |
| cls | |
| echo Resetting logs... | |
| if exist "ReconV3_Logs\Geolocation_Results" ( | |
| rd /s /q "ReconV3_Logs\Geolocation_Results" | |
| echo Logs cleared. | |
| ) else ( | |
| echo No logs found to delete. | |
| ) | |
| pause | |
| goto geolocateotheripsstart | |
| :GeolocateMyPublicIP | |
| cls | |
| set logDir=ReconV3_Logs\Geolocate_My_Public_IP_Log | |
| set sessionLogFiles=0 | |
| :geolocatemypublicipmenu | |
| cls | |
| echo Current directory: %cd% | |
| echo. | |
| echo Please choose a command: | |
| echo 1 - Begin command to geolocate my public IP address | |
| echo 2 - Help command | |
| echo 3 - Log command to view the logs | |
| echo 4 - Newlog command to remove the log folder | |
| echo 5 - Back to go back to the geolocator Submenu | |
| echo. | |
| set /p command=Enter command: | |
| if /i "%command%"=="begin" goto :geolocatemypublicipstart | |
| if /i "%command%"=="help" goto :geolocatemypublicipadresshelp | |
| if /i "%command%"=="log" goto :geolocatemypubliciplog | |
| if /i "%command%"=="newlog" goto :geolocatemypiblicipadressnewlog | |
| if /i "%command%"=="Back" goto :GeolocatorSubmenu | |
| echo Invalid command | |
| pause | |
| goto geolocatemypublicipmenu | |
| :geolocatemypublicipstart | |
| for /f "delims=" %%i in ('curl -s https://ipinfo.io/ip') do set IP=%%i | |
| echo Your public IP address is: %IP% | |
| echo. | |
| curl -s https://ipinfo.io/%IP%/json > ipinfo.json | |
| for /f "tokens=1,* delims=:" %%a in ('findstr /i "city" ipinfo.json') do set city=%%b | |
| for /f "tokens=1,* delims=:" %%a in ('findstr /i "region" ipinfo.json') do set region=%%b | |
| for /f "tokens=1,* delims=:" %%a in ('findstr /i "country" ipinfo.json') do set country=%%b | |
| for /f "tokens=1,* delims=:" %%a in ('findstr /i "loc" ipinfo.json') do set loc=%%b | |
| for /f "tokens=1,* delims=:" %%a in ('findstr /i "org" ipinfo.json') do set org=%%b | |
| for /f "tokens=1,* delims=:" %%a in ('findstr /i "postal" ipinfo.json') do set postal=%%b | |
| for /f "tokens=1,* delims=:" %%a in ('findstr /i "timezone" ipinfo.json') do set timezone=%%b | |
| set city=%city:"=% | |
| set region=%region:"=% | |
| set country=%country:"=% | |
| set loc=%loc:"=% | |
| set org=%org:"=% | |
| set postal=%postal:"=% | |
| set timezone=%timezone:"=% | |
| echo Geolocation Information for Public IP: | |
| echo --------------------------------------- | |
| echo City: %city% | |
| echo Region: %region% | |
| echo Country: %country% | |
| echo Location: %loc% | |
| echo Organization: %org% | |
| echo Postal Code: %postal% | |
| echo Timezone: %timezone% | |
| if not exist "%logDir%" mkdir "%logDir%" | |
| if not exist "%logDir%\json_results" mkdir "%logDir%\json_results" | |
| if not exist "%logDir%\plaintext" mkdir "%logDir%\plaintext" | |
| echo Saving JSON to %logDir%\json_results\%IP%.json | |
| echo Saving Plaintext to %logDir%\plaintext\%IP%_geo.txt | |
| echo %IP% > "%logDir%\json_results\%IP%.json" | |
| echo City: %city% > "%logDir%\plaintext\%IP%_geo.txt" | |
| echo Region: %region% >> "%logDir%\plaintext\%IP%_geo.txt" | |
| echo Country: %country% >> "%logDir%\plaintext\%IP%_geo.txt" | |
| echo Location: %loc% >> "%logDir%\plaintext\%IP%_geo.txt" | |
| echo Organization: %org% >> "%logDir%\plaintext\%IP%_geo.txt" | |
| echo Postal Code: %postal% >> "%logDir%\plaintext\%IP%_geo.txt" | |
| echo Timezone: %timezone% >> "%logDir%\plaintext\%IP%_geo.txt" | |
| echo -------------------------- | |
| goto geolocatemypublicipmenu | |
| :geolocatemypublicipadresshelp | |
| cls | |
| echo ---------------------Help-------------------- | |
| echo 1 - begin - Starts the geolocation of your public IP and saves the data in JSON and plaintext files. | |
| echo 2 - log - Displays all logs from the current and previous sessions. | |
| echo 3 - newlog - Deletes all logs stored in the ReconV3_Logs folder. | |
| echo 4 - help - Displays this help page with a description of all available commands. | |
| echo 5 - back - Goes back to the geolocator submenu. | |
| echo --------------------------------------------- | |
| pause | |
| goto geolocatemypublicipmenu | |
| :geolocatemypubliciplog | |
| cls | |
| echo Scanned IP Logs: | |
| echo -------------------------- | |
| set logFilesExist=false | |
| for /f %%f in ('dir /b "%logDir%\plaintext\*.txt"') do ( | |
| if %%f NEQ "" ( | |
| set logFilesExist=true | |
| echo ------------------------------------------------------- | |
| type "%logDir%\plaintext\%%f" | |
| echo ------------------------------------------------------- | |
| ) | |
| ) | |
| if not "%logFilesExist%"=="true" ( | |
| echo No logs found. Please scan some IPs first. | |
| ) | |
| pause | |
| goto geolocatemypublicipmenu | |
| :geolocatemypiblicipadressnewlog | |
| cls | |
| rd /s /q "%logDir%" | |
| echo Log folder removed. | |
| pause | |
| goto geolocatemypublicipmenu | |
| :GeolocatorSubmenuHelp | |
| echo -------------------------- Help -------------------------- | |
| echo 1 - Geolocate IPs in a file: Reads a file containing a list of IP addresses and provides their geographical locations. | |
| echo 2 - Geolocate other IPs: Allows you to manually input one or more IP addresses to retrieve their geographical locations. | |
| echo 3 - Geolocate my public IP: Automatically detects your public IP address and provides its geographical location. | |
| echo 4 - Return to main menu: Navigates back to the main menu of the program. | |
| echo 5 - All results are saved in the "ReconV3_Logs folder. | |
| echo ---------------------------------------------------------- | |
| pause | |
| goto GeolocatorSubmenu |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment