Advertisement
FailSecurityBR

SMTP.class | #FailSecBR

Sep 16th, 2012
492
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.12 KB | None | 0 0
  1. Aviso ! Isto não foi uma invasão, apenas peguei um arquivo já disponível dentro do sistema !
  2. SMTP Connection found on abem-educmed
  3.  
  4. Site: http://www.abem-educmed.org.br/
  5.  
  6.  
  7. Using FTP connection [FTPUSE] where ftpuse X: ftp.abem-educmed.org.br uses : netrix.abem-educmed.org.br for server FTP
  8.  
  9.  
  10. Arquivo: smtp.class {Tem o arquivo disponibilizado no site em /pcchair/smtp.class }
  11.  
  12.  
  13. class SMTP {
  14. var $smtp_sock = "";
  15. var $theServer = "";
  16. var $thePort = 25;
  17. var $theError = "";
  18. var $theFrom = "";
  19. var $theTo = "";
  20. var $theSubject = "";
  21. var $theBody = "";
  22. var $theAttachment = Array();
  23. var $nbAttachments = 0;
  24.  
  25. function SMTP($server) {
  26. $this->theServer = $server;
  27. }
  28.  
  29. function connect() { // Used internally
  30. if ($this->theServer != "") {
  31. while ((!$this->smtp_sock = fsockopen($this->theServer, $this->thePort, &$errno, &$errstr, 30)) && ($tries<50)) {
  32. debug ("Couldn't open mail connection to ".$this->theServer."! ($errno, $errstr, try $tries)");
  33. $tries++;
  34. $this->wait(5);
  35. }
  36. $reply=$this->get_lines();
  37. return TRUE;
  38. } else {
  39. debug ("No server defined!");
  40. $this->theError = "No server defined!";
  41. return FALSE;
  42. }
  43. }
  44.  
  45. function hello() { // Used internally
  46. if ($this->smtp_sock != "") {
  47. fputs($this->smtp_sock, "HELO ".$this->theServer."\n");
  48. $reply=$this->get_lines();
  49. } else {
  50. debug ("Not connected!");
  51. $this->theError = "Not connected!";
  52. return FALSE;
  53. }
  54. }
  55.  
  56. function from($from) {
  57. $this->theFrom = $from;
  58. }
  59.  
  60. function to($to) {
  61. $this->theTo = $to;
  62. }
  63.  
  64. function subject($subject) {
  65. $this->theSubject = $subject;
  66. }
  67.  
  68. function body($body) {
  69. $this->theBody = $body;
  70. }
  71.  
  72. function attachment($attachment, $attachment_name) {
  73. if (($attachment != "") && ($attachment_name != "")) {
  74. $this->theAttachment[$this->nbAttachments]["file"] = $attachment;
  75. $this->theAttachment[$this->nbAttachments]["file_name"] = $attachment_name;
  76. $this->nbAttachments++;
  77. }
  78. }
  79.  
  80. function send() {
  81. if ($this->connect()) {
  82. $this->hello();
  83. fputs($this->smtp_sock, "MAIL FROM: ".$this->theFrom."\n");
  84. $reply=$this->get_lines();
  85. fputs($this->smtp_sock, "RCPT TO: ".$this->theTo."\n");
  86. $reply=$this->get_lines();
  87. fputs($this->smtp_sock, "DATA\n");
  88. $reply=$this->get_lines();
  89. fputs($this->smtp_sock, "From: ".$this->theFrom."\n");
  90. fputs($this->smtp_sock, "To: ".$this->theTo."\n");
  91. fputs($this->smtp_sock, "Subject: ".$this->theSubject."\n");
  92.  
  93. if ($this->nbAttachments >0) {
  94. $boundary = "--------" . uniqid( "part" );
  95.  
  96. $headers .= "MIME-Version: 1.0";
  97. $headers .= "\nContent-Type: multipart/mixed; boundary=\"$boundary\"";
  98.  
  99. $messagetmp = "This is a multi-part message in MIME format.\n\n";
  100. $messagetmp .= "--$boundary\n";
  101. $messagetmp .= "Content-Type: text/plain; charset=us-ascii\n";
  102. $messagetmp .= "Content-Transfer-Encoding: 7bit\n\n";
  103. $messagetmp .= $this->theBody . "\n\n";
  104.  
  105. for($i=0; $i<$this->nbAttachments; $i++) {
  106. $file = $this->theAttachment[$i]["file"];
  107. $file_name = $this->theAttachment[$i]["file_name"];
  108.  
  109. $file_type = "application/octet-stream";
  110.  
  111. $messagetmp .= "--$boundary\n";
  112. $messagetmp .= "Content-Type: " . $file_type . "; name=\"$file_name\"\n";
  113. $messagetmp .= "Content-Transfer-Encoding: base64\n\n";
  114. $messagetmp .= chunk_split( base64_encode($file) );
  115. $messagetmp .= "\n";
  116.  
  117. $messagetmp .= "\n\n";
  118. }
  119. $this->theBody = $headers."\n".$messagetmp;
  120. }
  121.  
  122.  
  123. fputs($this->smtp_sock, $this->theBody."\n");
  124. fputs($this->smtp_sock, "\n.\nQUIT\n");
  125. $reply=$this->get_lines();
  126. return TRUE;
  127. }
  128. }
  129.  
  130. function wait($t) {
  131. $start = time();
  132. $end = $start;
  133. while ($end < ($start+$t)) {
  134. $end = time();
  135. }
  136. }
  137.  
  138. function get_lines() {
  139. $data = "";
  140.  
  141. while($str = fgets($this->smtp_sock,515)) {
  142. $data .= $str;
  143. if(substr($str,3,1) == " ") { break; }
  144. }
  145. return $data;
  146. }
  147. }
  148.  
  149. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement