p-mailsend_v4.0 code
Correction:
Removed iget.vbs, so there will be no virus prompt now
Enhanced parameter verification, so when parameters are incorrect, there will be no unresponsive phenomenon
When a password needs to be entered, it is not displayed in plain text
::p-mailsend.cmd
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: p-mailsend_v4.0 ::
:: ::
:: Code by : vkill ::
:: Thanks : bjsh,est,lxmxm... ::
:: Source : http://www.vkill.net http://bbs.cn-dos.net ::
:: Function : Command-line email sending program (mass sending/multiple attachments/anonymous) ::
:: Principle: Principle of sending and receiving emails via telnet ::
:: Last Update: 2007-11-12 ::
:: Program Dependent Files: nc.exe;rar.exe;base64.exe ::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
@echo off&endlocal&setlocal ENABLEDELAYEDEXPANSION
set "t_=test.conf"
::Here is the detailed setting for anonymous sending
set "anonymous="QQ mailbox administrator anonymous test" <10000@qq.com>"
call :del_
set "oneself=%~f0"
if "%1"=="" (
echo Please execute %oneself% /? at the command line to view detailed command line help
ping -n 5 127.1 >nul 2>nul
goto :eof
)
if "%1"=="/?" goto help
if "%1"=="-?" goto help
for %%? in (/h,-h,--h) do (if "%~1"=="%%?" goto help)
echo.
echo p-mailsend_v4.0 by:vkill
echo _________________________________________________
set/p=Dependency file integrity check...<nul
set "tools_name=nc.exe;rar.exe;base64.exe"
for %%? in (%tools_name%) do (
if *%%~$PATH:?==* if not exist %%? (
echo no, Missing file %%? &goto :sleep_
)
)
set/p=ok<nul&echo.
set/p=Analyze whether parameters are correct...<nul
set n=0
if not "%1"=="" (
:loop_ap
set/a n+=1
if "%1"=="/hu" (set "hu=on" &shift)
if "%1"=="/ht" (set "ht=on" &shift)
if "%1"=="/ch" (set "ch=on" &shift)
if "%1"=="/u" ((for /f "tokens=1-2 delims=@" %%a in ('echo %~2') do (set "user=%%a"& set "server=%%b")) &shift&shift)
if "%1"=="/p" (set "pass=%~2" &shift&shift)
if "%1"=="/t" (set "to=%~2" &shift&shift)
if "%1"=="/s" (set "subject=%~2" &shift&shift)
if "%1"=="/c" (set "content=%~2" &shift&shift)
if "%1"=="/a" (set "accessories=%~2" &shift&shift)
if not "%1"=="" (echo %~1|findstr "^/" >nul 2>nul ||(echo no, Parameter "%~1" is incorrect&goto :sleep_))
if !n!==10 (echo no, Parameter "%~1" is incorrect&goto :sleep_)
if not "%1"=="" (goto loop_ap)
)
set/p=ok<nul&echo.
set/p=Analyze whether necessary parameters are missing...<nul
for %%? in (user server to subject) do (if not defined %%? (echo no&goto :sleep_))
set/p=ok<nul&echo.
if not defined pass (
:inputpass
for /f "tokens=1 delims=:" %%? in ('findstr /N "=Hiddenpass.cmd_s=" "%oneself%"') do (more +%%? %oneself%>"%temp%\a")
for /f "tokens=1 delims=:" %%? in ('findstr /N "=Hiddenpass.cmd_e=" "%oneself%"') do (set/a "a=%%?-1" & more +!a! %oneself%>"%temp%\b")
findstr /V /B /E /G:"%temp%\b" "%temp%\a">"%temp%\pass.cmd"
start /wait cmd /k ""%temp%\pass.cmd" "!user!@!server!""
set/p password=<%temp%\pass
set "pass=!password:~9!"
if not defined pass goto inputpass
del /f/q "%temp%\pass" >nul 2>nul
del /f/q "%temp%\pass.cmd" >nul 2>nul
del /f/q "%temp%\a" >nul 2>nul
del /f/q "%temp%\b" >nul 2>nul
)
set/p=Verify whether this address supports sending emails...<nul
for /f "tokens=3-6 delims=," %%a in ('findstr "^::,%server%," "%oneself%"') do (
set "smtp=%%a"&set "port=%%b"&set "authentication_method=%%c"&set "max_z=%%d"
)
if not defined smtp (echo no&goto :sleep_)
set/p=ok<nul&echo.
set/p=Verify network connectivity...<nul
for /f "tokens=2 delims=" %%? in ('ping -n 1 %smtp% ^|findstr /i "^ping.*"') do (set "ip=%%?")
if not defined ip (echo no&goto :sleep_)
set/p=ok<nul&echo.
set/p=Verify telnet %smtp% %port% connectivity...<nul
>"%temp%\l%t_%" echo quit
nc -d -nvv %ip% %port% < "%temp%\l%t_%" >"%temp%\p-mailsend.log"
findstr . "%temp%\p-mailsend.log">nul 2>nul||(echo no&goto :sleep_)
set/p=ok<nul&echo.
set/p=Verify successful login...<nul
if "%authentication_method%"=="1" call :authentication_method1
copy "%temp%\%t_%" "%temp%\l%t_%">nul 2>nul
>>"%temp%\l%t_%" echo quit
nc -d -nvv %ip% %port% < "%temp%\l%t_%" >"%temp%\p-mailsend.log"
set n=0
for /f "tokens=1,2* delims=:" %%a in ('findstr /N . "%temp%\p-mailsend.log"') do (set "n=%%a"&set "x%%a=%%b")
set/a n-=1
echo "!x%n%!"|findstr "235 " >nul 2>nul ||(echo no, Error "!x%n%!"&goto :sleep_)
set/p=ok<nul&echo.
::Continue to write nc configuration file
>>"%temp%\%t_%" echo mail from: ^<%user%@%server%^>
if exist "%to%" (
for /f "tokens=*" %%? in ('findstr "^@" "!to!"') do (set "lto=%%?,!lto!")
)
if defined lto (set "to=!lto!")
for %%? in (!to!) do (>>"%temp%\%t_%" echo rcpt to: ^<%%?^>)
>>"%temp%\%t_%" echo data
if not defined hu (>>"%temp%\%t_%" echo From: %user%@%server%) else (>>"%temp%\%t_%" echo From: %anonymous%)
if not defined ht (>>"%temp%\%t_%" echo To: %to%)
>>"%temp%\%t_%" echo Subject: %subject%
>>"%temp%\%t_%" echo X-mailer: p-mailsend_v4.0
>>"%temp%\%t_%" echo Mime-Version: 1.0
>>"%temp%\%t_%" echo Content-Type: multipart/mixed;
>>"%temp%\%t_%" echo boundary="=====vkill====="
>>"%temp%\%t_%" echo.
>>"%temp%\%t_%" echo --=====vkill=====
if defined content call :htmlortxt !content!
>>"%temp%\%t_%" echo charset="gb2312"
>>"%temp%\%t_%" echo Content-Transfer-Encoding: 7bit
>>"%temp%\%t_%" echo.
if defined content (dir !content! >nul 2>nul &&(type "!content!">>"%temp%\%t_%" &>>"%temp%\%t_%" echo.) ||(>>"%temp%\%t_%" echo !content!)) else (>>"%temp%\%t_%" echo :^))
set z=0
if defined accessories set/p=Compressing and encoding attachments...<nul
echo "%accessories%" |findstr ")" >nul 2>nul && (echo no, Attachment path or file name cannot contain ^)&goto :sleep_)
if defined accessories (
for /f "tokens=1,2,3,4,5,6 delims=→" %%a in ('echo %accessories%') do (
call :compress_and_encode_attachment "%%~a"
call :compress_and_encode_attachment "%%~b"
call :compress_and_encode_attachment "%%~c"
call :compress_and_encode_attachment "%%~d"
call :compress_and_encode_attachment "%%~e"
call :compress_and_encode_attachment "%%~f" )
)
if defined xx (echo no, Compression or encoding of attachment error&goto :sleep_)
if not !z! lss %max_z% (echo Attachment is too large, %server% mailbox supports maximum attachment size of %max_z%K&goto :sleep_)
if defined accessories (set/p=ok<nul&echo.)
>>"%temp%\%t_%" echo --=====vkill=====--
>>"%temp%\%t_%" echo .
>>"%temp%\%t_%" echo quit
::Send email
set/p=Sending email...<nul
nc -d -nvv %ip% %port% < ""%temp%\%t_%"" >"%temp%\p-mailsend.log"
for /f "tokens=*" %%? in ("%temp%\p-mailsend.log") do (
if defined vk1 if not defined vk2 (set vk2=0&set "email_sending_error=%%?"&echo "%%?"|findstr "250 " >nul 2>nul ||(set vk3=0))
echo "%%?"|findstr "354 " >nul 2>nul &&(set vk1=0)
)
if defined vk3 (echo no, Error "!email_sending_error!"&goto :sleep_)
set/p=ok<nul&echo.
call :del_
echo _________________________________________________
echo Email sending completed, exiting in 2 seconds
ping -n 2 127.1 >nul 2>nul
goto :eof
::all call::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:help
echo.
echo p-mailsend_v4.0 2007.11 by:vkill Thanks to bjsh,est,lxmxm...
echo Copyright (C) 2006-2008 http://www.vkill.net http://bbs.cn-dos.net
echo Currently supported mailboxes: 21cn.com,sina.com,163.com,126.com,sohu.com,yahoo.com.cn,qq.com
echo Program dependent files: nc.exe;rar.exe;base64.exe
echo If dependent files are incomplete, please manually download to the windows directory from http://www.vkill.net/tools.html
echo.
echo Usage:
echo p-mailsend /u user@address /t recipient /s subject
echo.
echo /hu Anonymous sending
echo /ht Hide other recipients when sending to multiple parties
echo /u * Username@address Example:/u 122755990@qq.com
echo /p Password
echo /t * Recipient:(Recipient/text file path with written recipients)
echo (Multiple recipients separated by ,; enclosed in "") Example:/t "abc@163.com,123@56.com"
echo (Text file format for recipients is as follows:)
echo a@163.com
echo b@163.com
echo c@163.com
echo /s * Subject
echo /c Content:(Text/text file path with written content)
echo /ch HTML format switch for email content, indicating that the sent content is in HTML format
echo /a Attachment:(Absolute/relative path, multiple attachments separated by → enclosed in "") Example:/a "c:\a b.cmd→1234.txt"
goto :eof
:authentication_method1
>>"%temp%\%t_%" echo helo vkill
>>"%temp%\%t_%" echo auth login
for %%? in (%user%;%pass%) do (
set/p=%%?^<nul|base64>"l!t_!"
set/p v=<"l!t_!"
>>"%temp%\%t_%" echo !v!
del /f/q "l!t_!"
)
goto :eof
:del_
del /f/q "%temp%\%t_%">nul 2>nul
del /f/q "%temp%\l%t_%">nul 2>nul
del /f/q "%temp%\p-mailsend.log">nul 2>nul
goto :eof
:htmlortxt
if "%ch%"=="on" (>>"%temp%\%t_%" echo Content-Type: text/html;) else (>>"%temp%\%t_%" echo Content-Type: text/plain;)
goto :eof
:compress_and_encode_attachment
if "%~1"=="" exit/b
if "%~x1"==".rar" (copy "%~1" "%temp%\%~n1_.rar" >nul 2>nul) else (
dir %~1 >nul 2>nul &&(rar.exe -r a "%temp%\%~n1_.rar" "%~1" >nul 2>nul)||(rar.exe a "%temp%\%~n1_.rar" "%~1" >nul 2>nul)
)
if not exist "%temp%\%~n1_.rar" (set xx=vkill&exit/b)
for %%? in ("%temp%\%~n1_.rar") do (set/a z=z+%%~z?)
>>"%temp%\%t_%" echo --=====vkill=====
>>"%temp%\%t_%" echo Content-Type: application/octet-stream;
>>"%temp%\%t_%" echo name="%~n1_.rar"
>>"%temp%\%t_%" echo Content-Transfer-Encoding: base64
>>"%temp%\%t_%" echo Content-Disposition: attachment;
>>"%temp%\%t_%" echo filename="%~n1_.rar"
>>"%temp%\%t_%" echo.
base64.exe -i "%temp%\%~n1_.rar">>"%temp%\%t_%"
>>"%temp%\%t_%" echo.
del /f/q "%temp%\%~n1_.rar" >nul 2>nul
goto :eof
:sleep_
call :del_
ping -n 2 127.1 >nul 2>nul
goto :eof
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
=Hiddenpass.cmd_s=
@echo off
chcp 437>nul&graftabl 936>nul
echo hP1X500Pf3/f1/5++u5x>in.com
echo (Note: Password is not displayed in plain text when entered)
set /p password=Please enter the password for mail:%~1:<nul
for /f "tokens=*" %%i in ('in.com') do set password=%%i
del in.com
echo.
>%temp%\pass set password
exit
=Hiddenpass.cmd_e=
:::::::::::::::::::::Currently supported addresses::::::::::::::::::::::
::,Mailbox address,smtp address,telnet smtp port,authentication method,maximum attachment size (k)
::,21cn.com,smtp.21cn.com,25,1,15000000
::,sina.com,smtp.sina.com.cn,25,1,15000000
::,163.com,smtp.163.com,25,1,20000000
::,126.com,smtp.126.com,25,1,20000000
::,sohu.com,smtp.sohu.com,25,1,10000000
::,yahoo.com.cn,smtp.mail.yahoo.com,25,1,15000000
::,yahoo.com,smtp.mail.yahoo.com,25,1,15000000
::,qq.com,smtp.qq.com,25,1,5000000
::
[
Last edited by vkill on 2007-11-18 at 05:46 PM ]