如何自动执行telnet端口25测试?

时间:2022-03-08 14:27:31

I need to make a large set of tests in telnet. I am working on some ways to auto detect dictionary attacks on our email server, and then throttle them back, or blacklist them etc.

我需要在telnet中进行大量测试。我正在研究一些方法来自动检测我们的电子邮件服务器上的字典攻击,然后限制它们,或将它们列入黑名单等。

I am now ready to run some tests and see if my work pays off. I figured I would just download some script kiddy app to run the tests. I can not find any and those I can are bad or binary and non configurable.

我现在准备进行一些测试,看看我的工作是否有成效。我想我会下载一些脚本kiddy app来运行测试。我找不到任何我可以找不到的或二进制和不可配置的。

I will have a list of addresses I generate in a loop.

我将在循环中生成一个地址列表。

I want to take $address as an argument and do this:

我想把$ address作为参数并执行此操作:

telnet myserver.com 25 helo some-string.com mail from: me@me.com rcpt to: $address quit

telnet myserver.com 25 helo some-string.com邮箱:me@me.com rcpt:$ address quit

Within that, I need to test a few things, such as, if I enable greylisting, I want to fail the script, as that is my first countermeasure. I suppose in that case, I would just have telnet timeout?

在其中,我需要测试一些东西,例如,如果我启用了灰名单,我想让脚本失败,因为这是我的第一个对策。我想在那种情况下,我只会有telnet超时?

  • helo should return a code string starting with 220, that is about as accurate as I need to make this test.

    helo应该返回一个以220开头的代码字符串,这与我进行此测试所需的一样准确。

  • mail from should return 250, or looking for OK would suffice

    邮件应该返回250,或者寻找OK就足够了

  • rctp to should return 250 or Ok sometimes, when I send in a valid user, but most of the time I will send in a bad address, so I look for the absence of 250 or OK.

    rctp to应该返回250或Ok有时,当我发送一个有效的用户,但大多数时候我会发送一个错误的地址,所以我寻找没有250或OK。

  • Finally, I will send in a quit.

    最后,我将发送退出。

I am not able to get conditions and logging to happen within an interactive situation. I looked at expect but could not get it to work.

我无法在交互情况下获得条件和日志记录。我看着期待,却无法让它发挥作用。

My code so far:

echo -e "helo foo\nmail from: foo.... | telnet example.com 25 | grep -i blah 

This did not perform as expected.

这没有达到预期的效果。

What can I do to accomplish my goal?

我能做些什么来实现我的目标?

4 个解决方案

#1


I'm surprised that Expect didn't do it for you since it's written for just these kinds of things.

我很惊讶,Expect并没有为你做这件事,因为它是为这些事情写的。

Perl is simpler in some ways and can get a job like this done. But with Perl, you won't bother with Telnet, you can instead open port 25 directly.

Perl在某些方面更简单,可以完成这样的工作。但是使用Perl,你不会打扰Telnet,你可以直接打开端口25。

If you really want to exercise your server get the source for Siege and modify it to talk SMTP instead of HTTP. That was my favorite tool for testing Apache performance and I'm sure it wouldn't be too hard to make it test Sendmail.

如果你真的想锻炼你的服务器获取Siege的来源并修改它来谈论SMTP而不是HTTP。这是我最喜欢的测试Apache性能的工具,我确信它不会太难以让它测试Sendmail。

#2


Try netcat: http://netcat.sourceforge.net/

试试netcat:http://netcat.sourceforge.net/

It'll let you send and receive data on a socket. telnet isn't what you want - it's for interactive use.

它可以让你在套接字上发送和接收数据。 telnet不是你想要的 - 它是用于交互式的。

#3


expect wrapped around netcat (instead of telnet) is probably the best initial bet. But, if you really need to this, I would use perl. There are SMTP client libraries for it.

期望缠绕netcat(而不是telnet)可能是最好的初始赌注。但是,如果你真的需要这个,我会使用perl。它有SMTP客户端库。

#4


You can use Bash syntax for that, e.g.

您可以使用Bash语法,例如

exec {stream}<>/dev/tcp/example.com/80
printf "GET / HTTP/1.1\nHost: example.com\nConnection: close\n\n" >&${stream}
grep Example <&${stream}

Here is another syntax example which dumps list of keys from memcached:

这是从memcached转储键列表的另一个语法示例:

exec {memcache}<>/dev/tcp/localhost/11211; printf "stats items\nquit\n" >&${memcache}; cat <&${memcache}

#1


I'm surprised that Expect didn't do it for you since it's written for just these kinds of things.

我很惊讶,Expect并没有为你做这件事,因为它是为这些事情写的。

Perl is simpler in some ways and can get a job like this done. But with Perl, you won't bother with Telnet, you can instead open port 25 directly.

Perl在某些方面更简单,可以完成这样的工作。但是使用Perl,你不会打扰Telnet,你可以直接打开端口25。

If you really want to exercise your server get the source for Siege and modify it to talk SMTP instead of HTTP. That was my favorite tool for testing Apache performance and I'm sure it wouldn't be too hard to make it test Sendmail.

如果你真的想锻炼你的服务器获取Siege的来源并修改它来谈论SMTP而不是HTTP。这是我最喜欢的测试Apache性能的工具,我确信它不会太难以让它测试Sendmail。

#2


Try netcat: http://netcat.sourceforge.net/

试试netcat:http://netcat.sourceforge.net/

It'll let you send and receive data on a socket. telnet isn't what you want - it's for interactive use.

它可以让你在套接字上发送和接收数据。 telnet不是你想要的 - 它是用于交互式的。

#3


expect wrapped around netcat (instead of telnet) is probably the best initial bet. But, if you really need to this, I would use perl. There are SMTP client libraries for it.

期望缠绕netcat(而不是telnet)可能是最好的初始赌注。但是,如果你真的需要这个,我会使用perl。它有SMTP客户端库。

#4


You can use Bash syntax for that, e.g.

您可以使用Bash语法,例如

exec {stream}<>/dev/tcp/example.com/80
printf "GET / HTTP/1.1\nHost: example.com\nConnection: close\n\n" >&${stream}
grep Example <&${stream}

Here is another syntax example which dumps list of keys from memcached:

这是从memcached转储键列表的另一个语法示例:

exec {memcache}<>/dev/tcp/localhost/11211; printf "stats items\nquit\n" >&${memcache}; cat <&${memcache}