Advertisement
Wail3Y

sendmail

Sep 9th, 2018
1,750
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 4.19 KB | None | 0 0
  1. @echo off
  2. setLocal EnableDelayedExpansion
  3. :start
  4.  
  5. set /p sign1=<username.txt
  6. if not "%sign1%" =="" (goto signedin)
  7. :start2
  8. echo.>error.txt
  9. echo.>username.txt
  10. echo.>pass.txt
  11. echo.>body.txt
  12. set var1="@gmail.com"
  13. set username=
  14. set /P username=Enter your Gmail account username : %=%
  15. If NOT "%username%"=="%username:@gmail.com=%" (
  16.     goto next
  17. ) else (
  18.     goto wrong
  19. )
  20. pause
  21. :next
  22. cls
  23. echo %username%>username.txt
  24. Call :PasswordInput "Enter your Gmail account password"
  25. :maskdone
  26. echo %password%>pass.txt
  27. Powershell.exe -executionpolicy remotesigned -File  "%CD%\check.ps1"
  28. set /p error=<error.txt
  29. if "%error%" == "1" (goto wrong)
  30. cls
  31. :fromsignedin
  32. set recp=
  33. set /P recp=Enter the e-mail address of the recipient : %=%
  34. cls
  35. set subject=
  36. set /P subject=Enter the subject of your e-mail : %=%
  37. cls
  38. :attach
  39. echo Do you wish to add an attachment?
  40. echo.
  41. echo File extensions such as .exe, .zip, .7z, .rar... are unavailable.
  42. echo Consult "https://support.google.com/mail/answer/6590?hl=en" for more info.
  43. set attach=
  44. set /P attach=Input "1" for YES, "2" for NO : %=%
  45. if "%attach%" == "1" (goto loop)
  46. if "%attach%" == "2" (goto bodycontents)
  47. cls
  48. echo Invalid input.
  49. goto attach
  50. :loop
  51. set "tempfile=%temp%\file-%random%"
  52. if exist "%tempfile%" goto :loop
  53.  
  54. call :getfile "c:\"
  55.  
  56. for /f "delims=" %%a in ('powershell "%tempfile%.ps1" ') do (
  57.    set "filepath=%%~dpa"
  58.    set "filename=%%~nxa"
  59.    set chosenattach=%filepath%%filename%
  60.    :repeatlots
  61.    if not "%chosenattach%" =="" (goto attachnotempty)
  62.    goto attachnotempty
  63.    :attachnotempty
  64. pause
  65. del "%tempfile%.ps1"
  66. :attachrepeat
  67. cls
  68. echo You have chosen "%chosenattach%" as your attachment.
  69. echo Do you wish to continue with this attachment?
  70. set attachsure=
  71. set /p attachsure=Input "1" for YES, "2" for NO : %=%
  72. if "%attachsure%" == "1" (goto bodycontents)
  73. if "%attachsure%" == "2" (goto attach)
  74. cls
  75. echo Invalid input.
  76. goto attachrepeat
  77. :getfile
  78. (
  79. echo $ErrorActionPreference= 'silentlycontinue'
  80. echo $initialDirectory = "%~1"
  81. echo [System.Reflection.Assembly]::LoadWithPartialName^("System.windows.forms"^) ^| Out-Null
  82. echo $OpenFileDialog = New-Object System.Windows.Forms.OpenFileDialog
  83. echo $OpenFileDialog.initialDirectory = $initialDirectory
  84. echo $OpenFileDialog.filter = "All files (*.*)| *.*"
  85. echo $OpenFileDialog.ShowDialog^(^) ^| Out-Null
  86. echo $OpenFileDialog.filename
  87. ) > "%tempfile%.ps1"
  88. goto :EOF
  89. :bodycontents
  90. cls
  91. echo Enter the contents of your e-mail in the text file.
  92. echo.>body.txt
  93. :notdone
  94. start "" "%cd%\body.txt"
  95. :notdone2
  96. cls
  97. echo.
  98. echo Please remember to save the file. ("Ctrl" + "S")
  99. echo Press any key to submit the contents of the email.
  100. pause>nul
  101. :repeatconfirm
  102. set confirm=
  103. set /P confirm=Are you sure you want to continue? (Input "1" for YES, "2" for NO) : %=%
  104. if "%confirm%" == "1" (goto continue)
  105. if "%confirm%" == "2" (goto notdone2)
  106. cls
  107. echo Invalid input.
  108. goto repeatconfirm
  109. :continue
  110. taskkill /IM notepad.exe>nul
  111. :again
  112. tasklist /FI "IMAGENAME eq notepad.exe" 2>NUL | find /I /N "notepad.exe">NUL
  113. cls
  114. echo Waiting for Notepad to close...
  115. if "%ERRORLEVEL%"=="0" goto again
  116. cls
  117. for /f "delims=" %%i in (body.txt) do set "body=!body! %%i"
  118. echo %recp%>recp.txt
  119. echo %subject%>subject.txt
  120. echo %chosenattach%>path.txt
  121. Powershell.exe -executionpolicy remotesigned -File  "%CD%\exp.ps1"
  122. echo E-Mail Sent.
  123. ping 1.1.1.1 -n 1 -w 200>nul
  124. cls
  125. echo E-Mail Sent.
  126. goto start
  127. :wrong
  128. cls
  129. echo Invalid username or password.
  130. goto start
  131. :PasswordInput
  132. set "psCommand=powershell -Command "$pword = read-host 'Enter Password' -AsSecureString ; ^
  133.     $BSTR=[System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($pword); ^
  134.         [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($BSTR)""
  135. for /f "usebackq delims=" %%p in (`%psCommand%`) do set password=%%p
  136. goto maskdone
  137. :signedin
  138. echo The account "%sign1%" is logged in.
  139. echo Would you like to continue with that account?
  140. set sure=
  141. set /P sure=Press "1" to continue, "2" to sign out : %=%
  142. if "%sure%" == "1" (goto ffromsignedin)
  143. if "%sure%" == "2" (goto sstart2)
  144. cls
  145. echo Invalid input.
  146. goto signedin
  147. :ffromsignedin
  148. cls
  149. goto fromsignedin
  150. :sstart2
  151. goto start2
  152. :attachempty
  153. cls
  154. echo Invalid attachment.
  155. goto loop
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement