473,781 Members | 2,335 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

SMTP honeypot

12 New Member
Ok, I wrote a Honeypot in perl. It listens on port 25 and acts as a crude SMTP server.
It responds to the most basic commands(helo, mail from, rcpt to, data) needed for sending mail.
It has no way of closing the socket from the client side, so it acts also as a tarpit by not allowing automatic spam mailers to disconnect from it.
It does not actually send any mail, but simulates the situation.

Problems I'm having:

1.
Expand|Select|Wrap|Line Numbers
  1. #elsif ($message =~ '.') {print $client "250 Ok: queued as 6AB5150038\n";}
The last step in sending mail, is to put a "." on an empty line and press enter. But I cannot match ($message =~ '.'). What are the alternatives?
2. When I run the script and I connect to the port, it displays
Expand|Select|Wrap|Line Numbers
  1. print "Connection received\n";
for me and
Expand|Select|Wrap|Line Numbers
  1. print $client "220 mail.kuratkull.pri.ee ESMTP\n";
for the client. After i disconnect the client and reconnect, it doesn't display neither of them.
How can I fix this?
3. How could I log the IP of the client?

Thank you for your replies :)


Expand|Select|Wrap|Line Numbers
  1. #!/usr/local/bin/perl
  2.  
  3. use IO::Socket;
  4.  
  5. my $client;
  6. my $socket;
  7. my $message;
  8.  
  9. $socket = IO::Socket::INET->new(
  10.         "Proto" => "tcp",
  11.     "Reuse" => "1",        
  12.     "LocalPort" => "25",
  13.         "Listen" => 1) or die "ERROR: $!\n";
  14.  
  15. $client = $socket->accept();
  16.  
  17. print "Connection received\n";
  18.  
  19. print $client "220 mail.kuratkull.pri.ee ESMTP\n";
  20.  
  21. while ($message = <$client>) {
  22.  
  23. # the commands and the simulated anwsers to them. This is all static data.
  24. if ($message =~ "helo") {print $client "250 mail.kuratkull.pri.ee, How can I help you?\n";} 
  25. elsif ($message =~ "mail from:") {print $client "250 ok\n";}
  26. elsif ($message =~ "rcpt to:") {print $client "250 ok\n";}
  27. elsif ($message =~ "data") {print $client "354 go ahead and end data with .\n";}
  28. elsif ($message =~ "HELO") {print $client "250 mail.kuratkull.pri.ee, How can I help you?\n";} 
  29. elsif ($message =~ "MAIL FROM:") {print $client "250 ok\n";}
  30. elsif ($message =~ "RCPT TO:") {print $client "250 ok\n";}
  31. elsif ($message =~ "DATA") {print $client "354 go ahead and end data with .\n";}
  32. #elsif ($message =~ '.') {print $client "250 Ok: queued as 6AB5150038\n";}
  33. #else {print $client "500 Command not recognized: $message.";}
  34.  
  35. print "$message";
  36.  
  37. $out = "/home/httpd/html/smtpserv.txt";
  38.  
  39. open OUT, ">>$out" or die "Cannot open $out for append :$!";
  40. print OUT "\n", $message, scalar(localtime);
  41. close OUT;
  42.  
  43. print "Disconnected...\n";
  44. }
  45.  
  46. #this keeps the script running after the client disconnects
  47. my $new_sock = $socket->accept();
  48. while(<$new_sock>) {
  49.    print $_;
  50. }
  51. close($sock);
Feb 22 '07 #1
1 2231
kuratkull
12 New Member
It is also unreachable from outside my local network. Maybe this has to do something with "bind". I am looking for information, but there isn't very much of it.
If you could give me any help on this, it would be very appreciated too :)
Feb 22 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
2812
by: Dan Boyle | last post by:
Hi, I am having difficulty connection to an smtp host. I am using the following code but I don't think I fully understand what smtp host can be used. function setSMTPParams($host = null, $port = null, $helo = null, $auth = null, $user = null, $pass = null) { if (!is_null($host)) $this->smtp_params = $host;
21
3384
by: Nancy | last post by:
Hi, Guys, Is there any other way to use python or mod_python writing a web page? I mean, not use "form.py/email", no SMTP server. <form action="form.py/email" method="POST"> ... Thanks a lot. Nancy W
2
13704
by: RandRace | last post by:
I'm having some problems with a little script i wrote using net::smtp. I originally wrote it in linux where it works perfectly. I tried to use it from windows the other day and it doesn't work. It connects to the server and prints the banner but will not send mail. Here is my script: use Net::SMTP; my $smtp = Net::SMTP->new('smtp.comcast.net') or die "Can't Open server"!";
3
5588
by: dale zhang | last post by:
Hi, I write an asp.net web application. It has a “Contact Us” page, where users fill in their email, subject and text and hit send. Then the email will go to my hard coded yahoo email account. I was using optimum online service with smtp server as “mail.optonline.net”. I can receive email correctly. Now I switch to verizon DSL. I change my smtp server accordingly as
1
8042
by: bivin | last post by:
hai i am requesting your technical support. please help me. i have been working with this for five days. the problem is relating with the smtp. i am trying to send an email from the asp.net page. earlier it was showing send using not find error.
34
18271
by: antonyliu2002 | last post by:
I've set up the virtual smtp server on my IIS 5.1 like so: 1. Assign IP address to "All Unassigned", and listen to port 25. 2. Access Connection granted to "127.0.0.1". 3. Relay only allow "127.0.0.1". 4. Authentication: "Anonymous access" only. 5. Outbound connection listen to TCP 25. Besides,
6
3934
by: Alex Reinhart | last post by:
Being deluged by spam like nearly all of us (though fortunately I have a very good spam filter), I also hate spam as much as almost everybody. I know basic Python (enough to make a simple IRC bot) and I figured a good project to help learn Python would be to make a simple "proxypot." I've done some research and found one already existing, written in Perl (http://www.proxypot.org/). However, I prefer the syntax and ease of Python (and...
13
6814
by: jcor | last post by:
Hi, I'm trying some code to send a mail with my script. This is it: #!/usr/bin/perl use Net::SMTP; my $smtp_server='62.193.245.15'; my $smtp = Net::SMTP->new($smtp_server) or die "Can't Open server\n"; $smtp->mail('joao.correia@tvn.pt'); $smtp->to('jcor@sapo.pt'); $smtp->auth("joao.correia@tvn.pt","*password*");
5
5303
by: jimhill10 | last post by:
I have a perl script that creates an email attachment file from POST data on a web page. This works just fine. I want to customize the email body to contain all of the text data from the file itself. I thought this would be just a matter of using the $smtp->datasend($POSTvalues) with the $values coming from the names on the web page posting the data. Can someone show me what the correct code snippet would be? Here is my code: ...
0
9636
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
9474
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10306
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10139
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7485
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6727
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5504
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4037
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3632
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.