├── LICENSE ├── README.md ├── emailleaktest.bat └── emailleaktest.sh /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 macvk 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Email IP Leak Test 2 | Your IP can be exposed during email sending. The test analyzes mail headers and shows IP leaks. 3 | 4 | ## How to install & use 5 | Please choose the operating system you use, see below. [Windows](#windows) or [Linux](#linux) 6 | 7 | ### Windows 8 | If your operating system is Windows, then you can use [batch file](#windows---batch-file) to run the test. 9 | 10 | #### Windows - Batch file 11 | 12 | 1. Download emailleaktest.bat 13 | 14 | ``` 15 | powershell -command "& { (New-Object Net.WebClient).DownloadFile('https://raw.githubusercontent.com/macvk/emailleaktest/master/emailleaktest.bat', 'emailleaktest.bat') }" 16 | ``` 17 | 18 | 2. Run emailleaktest.bat 19 | ``` 20 | emailleaktest.bat 21 | ``` 22 | 23 | ### Linux 24 | If your operating system is Linux, then you can use [bash shell script](#linux---bash-shell-script) to run the test. 25 | 26 | #### Linux - Bash shell script 27 | 28 | 1. Download emailleaktest.sh 29 | ``` 30 | wget https://raw.githubusercontent.com/macvk/emailleaktest/master/emailleaktest.sh 31 | ``` 32 | 33 | ``` 34 | chmod +x emailleaktest.sh 35 | ``` 36 | 37 | 2. Run emailleaktest.sh 38 | ``` 39 | ./emailleaktest.sh 40 | ``` 41 | -------------------------------------------------------------------------------- /emailleaktest.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | rem Any questions: tutumbul@gmail.com 4 | rem https://bash.ws/emailleak 5 | 6 | for /F "tokens=*" %%g IN ('powershell -command "& { Get-Random -Minimum 1000000 -Maximum 9999999 }"') do (set /a leak_id=%%g) 7 | 8 | rem echo %leak_id% 9 | 10 | powershell -command "& { (New-Object Net.WebClient).DownloadFile('https://bash.ws/email-leak-test/test/%leak_id%?txt', '%leak_id%.txt') }" 11 | 12 | echo $to = "%leak_id%@bash.ws" > r.ps1 13 | echo while ($true) >> r.ps1 14 | echo ^{ >> r.ps1 15 | echo $username = Read-Host 'What is your email?' >> r.ps1 16 | echo if ($username.indexOf("@") -ne -1) >> r.ps1 17 | echo ^{ >> r.ps1 18 | echo break; >> r.ps1 19 | echo ^} >> r.ps1 20 | echo ^echo "Warning. Wrong email address"; >> r.ps1 21 | echo ^} >> r.ps1 22 | echo if ($username.indexOf("@gmail.com")) >> r.ps1 23 | echo ^{ >> r.ps1 24 | echo ^echo "Warning. Please enable less secure apps to get the script working, https://myaccount.google.com/lesssecureapps"; >> r.ps1 25 | echo ^} >> r.ps1 26 | echo $smtpdomain = $username.Substring($username.indexOf("@")+1); >> r.ps1 27 | echo $smtpdomain = "smtp.$smtpdomain"; >> r.ps1 28 | echo $inputsmtp = Read-Host "What is your outgoing smtp server [leave empty to use $smtpdomain]?" >> r.ps1 29 | echo if ($inputsmtp -ne "") >> r.ps1 30 | echo ^{ >> r.ps1 31 | echo $smtp = $inputsmtp; >> r.ps1 32 | echo ^} >> r.ps1 33 | echo $password = Read-Host 'What is your password?' -AsSecureString >> r.ps1 34 | echo $pw = [Runtime.InteropServices.Marshal]::PtrToStringAuto([Runtime.InteropServices.Marshal]::SecureStringToBSTR($password)) >> r.ps1 35 | echo $message = new-object Net.Mail.MailMessage; >> r.ps1 36 | echo $message.From = $username; >> r.ps1 37 | echo $message.To.Add($to);; >> r.ps1 38 | echo $message.Subject = ""; >> r.ps1 39 | echo $message.Body = ""; >> r.ps1 40 | echo ^echo "$smtp"; >> r.ps1 41 | echo $smtp = new-object Net.Mail.SmtpClient($smtpdomain, "587"); >> r.ps1 42 | echo $smtp.EnableSSL = $true; >> r.ps1 43 | echo $smtp.Credentials = New-Object System.Net.NetworkCredential($username, $pw); >> r.ps1 44 | echo $result = 1; >> r.ps1 45 | echo try >> r.ps1 46 | echo ^{ >> r.ps1 47 | echo $smtp.send($message); >> r.ps1 48 | echo ^} >> r.ps1 49 | echo catch >> r.ps1 50 | echo ^{ >> r.ps1 51 | echo ^echo "Error. Email was not sent, please check username and password. Try again..." >> r.ps1 52 | echo $result = 0; >> r.ps1 53 | echo ^} >> r.ps1 54 | echo exit $result; >> r.ps1 55 | 56 | PowerShell -NoProfile -ExecutionPolicy Bypass -Command "& './r.ps1'" 57 | 58 | 59 | if "%errorlevel%" == "0" ( 60 | del /q %leak_id%.txt 61 | del /q r.ps1 62 | exit 63 | ) 64 | 65 | 66 | echo|set /p="Checking." 67 | 68 | :loop 69 | 70 | powershell -command "& { (New-Object Net.WebClient).DownloadFile('https://bash.ws/email-leak-test/test/%leak_id%?txt', '%leak_id%.txt') }" 71 | 72 | echo|set /p="." 73 | 74 | for /f "tokens=1,2,3,4,5 delims=|" %%1 in (%leak_id%.txt) do ( 75 | if "%%5" == "done" ( 76 | if "%%1" == "1" ( 77 | goto :stop 78 | ) 79 | ) 80 | ) 81 | 82 | goto loop 83 | 84 | :stop 85 | 86 | echo done. 87 | 88 | echo Your IP: 89 | for /f "tokens=1,2,3,4,5 delims=|" %%1 in (%leak_id%.txt) do ( 90 | if "%%5" == "ip" ( 91 | if [%%1] neq [] ( 92 | if [%%3] neq [] ( 93 | if [%%4] neq [] ( 94 | echo %%1 [%%3, %%4] 95 | ) else ( 96 | echo %%1 [%%3] 97 | ) 98 | ) else ( 99 | echo %%1 100 | ) 101 | ) 102 | ) 103 | ) 104 | 105 | set /a ips=0 106 | 107 | for /f "tokens=1,2,3,4,5 delims=|" %%1 in (%leak_id%.txt) do ( 108 | if "%%5" == "mail" ( 109 | set /a ips=ips+1 110 | ) 111 | ) 112 | 113 | if "%ips%" == "0" ( 114 | echo No IPs found in mail header 115 | ) else ( 116 | echo Your email header has %ips% IPs: 117 | for /f "tokens=1,2,3,4,5 delims=|" %%1 in (%leak_id%.txt) do ( 118 | if "%%5" == "mail" ( 119 | if [%%1] neq [] ( 120 | if [%%3] neq [] ( 121 | if [%%4] neq [] ( 122 | echo %%1 [%%3, %%4] 123 | ) else ( 124 | echo %%1 [%%3] 125 | ) 126 | ) else ( 127 | echo %%1 128 | ) 129 | ) 130 | ) 131 | ) 132 | ) 133 | 134 | echo Conclusion: 135 | for /f "tokens=1,2,3,4,5 delims=|" %%1 in (%leak_id%.txt) do ( 136 | if "%%5" == "conclusion" ( 137 | if [%%1] neq [] ( 138 | echo %%1 139 | ) 140 | ) 141 | ) 142 | 143 | 144 | del /q %leak_id%.txt 145 | del /q r.ps1 146 | -------------------------------------------------------------------------------- /emailleaktest.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | RED='\033[0;31m' 4 | BOLD='\033[1m' 5 | NC='\033[0m' 6 | api_domain='bash.ws' 7 | error_code=1 8 | 9 | function increment_error_code { 10 | error_code=$((error_code + 1)) 11 | } 12 | 13 | function echo_bold { 14 | echo -e "${BOLD}${1}${NC}" 15 | } 16 | 17 | function echo_error { 18 | (>&2 echo -e "${RED}${1}${NC}") 19 | } 20 | 21 | function program_exit { 22 | command -v $1 > /dev/null 23 | if [ $? -ne 0 ]; then 24 | echo_error "Please, install \"$1\"" 25 | exit $error_code 26 | fi 27 | increment_error_code 28 | } 29 | 30 | 31 | function check_internet_connection { 32 | curl --silent --head --request GET "https://${api_domain}" | grep "200 OK" > /dev/null 33 | if [ $? -ne 0 ]; then 34 | echo_error "No internet connection." 35 | exit $error_code 36 | fi 37 | increment_error_code 38 | } 39 | 40 | function print_servers { 41 | 42 | if (( $jq_exists )); then 43 | 44 | echo ${result} | \ 45 | jq --monochrome-output \ 46 | --raw-output \ 47 | ".[] | select(.type == \"${1}\") | \"\(.ip)\(if .country_name != \"\" and .country_name != false then \" [\(.country_name)\(if .asn != \"\" and .asn != false then \" \(.asn)\" else \"\" end)]\" else \"\" end)\"" 48 | 49 | else 50 | 51 | while IFS= read -r line; do 52 | if [[ "$line" != *${1} ]]; then 53 | continue 54 | fi 55 | 56 | ip=$(echo $line | cut -d'|' -f 1) 57 | code=$(echo $line | cut -d'|' -f 2) 58 | country=$(echo $line | cut -d'|' -f 3) 59 | asn=$(echo $line | cut -d'|' -f 4) 60 | 61 | if [ -z "${ip// }" ]; then 62 | continue 63 | fi 64 | 65 | if [ -z "${country// }" ]; then 66 | echo "$ip" 67 | else 68 | if [ -z "${asn// }" ]; then 69 | echo "$ip [$country]" 70 | else 71 | echo "$ip [$country, $asn]" 72 | fi 73 | fi 74 | done <<< "$result" 75 | 76 | fi 77 | } 78 | 79 | program_exit curl 80 | program_exit ping 81 | program_exit mail 82 | check_internet_connection 83 | 84 | if command -v jq &> /dev/null; then 85 | jq_exists=1 86 | else 87 | jq_exists=0 88 | fi 89 | 90 | if hash shuf 2>/dev/null; then 91 | id=$(shuf -i 1000000-9999999 -n 1) 92 | else 93 | id=$(jot -w %i -r 1 1000000 9999999) 94 | fi 95 | 96 | if (( $jq_exists )); then 97 | format="json" 98 | else 99 | format="txt" 100 | fi 101 | 102 | result=$(curl --silent "https://${api_domain}/email-leak-test/test/${id}?${format}") 103 | 104 | mail -s "Test" ${id}@bash.ws < /dev/null > /dev/null 105 | 106 | for (( ; ; )) 107 | do 108 | result=$(curl --silent "https://${api_domain}/email-leak-test/test/${id}?${format}") 109 | 110 | is_done=$(print_servers "done") 111 | 112 | if [[ $is_done == *"1"* ]]; then 113 | 114 | break 115 | fi 116 | 117 | done 118 | 119 | echo_bold "Your IP:" 120 | print_servers "ip" 121 | 122 | echo "" 123 | ips_count=$(print_servers "mail" | wc -l) 124 | if [ ${ips_count} -eq "0" ];then 125 | echo_bold "No IPs found in mail header" 126 | else 127 | if [ ${ips_count} -eq "1" ];then 128 | echo_bold "Mail header has got ${ips_count} IP:" 129 | else 130 | echo_bold "Mail header has got ${ips_count} IPs:" 131 | fi 132 | print_servers "mail" 133 | fi 134 | 135 | echo "" 136 | echo_bold "Conclusion:" 137 | print_servers "conclusion" 138 | 139 | exit 0 140 | --------------------------------------------------------------------------------