JAVA代码审计2个小tips

1、lib文件过多时,快速定位lib代码文件

如已知java-callgraph找出的类名
但不知道在哪个lib文件时可利用该工具快速获取到相关lib,适用于大量不知道lib文件的情况。
SearchClassInJar.jar
image.png

2、快速定位api路由思路

静态:

springmvc框架

老生常谈的东西了
IDEA的RestfulTool插件,一键化提取spring mvc框架的api路由。
image.png
image.png
一键化提取相关API
然后crtl+all即可
image.png

struts2框架:

这个框架的静态路由提取外面就讲的比较少了,因为不同的struts2 路由写法可能大概都不相同。
但是经过如果有深入去实际研究的话会发现基本上都是
命名空间/类名,函数,特定构造方法进行构造的路由。
因此我们可以有限提取出相关的类名,方法名。而后按照固定格式去构造。

如这里以codeql构造以例
采用这个方法进行构造一个完整的路由。

import java

from RefType c, Callable cf
where 
c.getName().toLowerCase().regexpMatch(".*action") and
cf = c.getAMember() and
not c.getName().regexpMatch(".*<.*>.*")
select c+".do?method="+cf

如果不会用codeql也可采用,提取出相关的类名,方法
而后转个python脚本,进行特定构造即可。
image.png

非静态(代码可运行):

强烈推荐这个项目,如果代码可跑起来,可直接调用该router-router去获取路由。
https://github.com/kyo-w/router-router

原理:

https://xz.aliyun.com/t/12651
调试技术可以获取一个jvm

SocketAttachingConnector socketAttachingConnector = new SocketAttachingConnector();
Map<String, Connector.Argument> argumentHashMap = socketAttachingConnector.defaultArguments();
argumentHashMap.get("hostname").setValue("127.0.0.1");
argumentHashMap.get("port").setValue("5005");
argumentHashMap.get("timeout").setValue("3000");
VirtualMachine attach = socketAttachingConnector.attach(argumentHashMap);

然后基于jvm中去获取相关中间组件的路由即可

使用条件:
  • Java JDK11
  • 网络端口默认9090

image.png
启动端口后
image.png
连接然后启动路由即可
然后调试完成后即可自动化获取到路由了93f0106a1a76ed3630dbf114ba91efcc.png
d53c3fe6080d6f2aa986a4b7b0633da3.png

  • 4
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
Here are some tips that could help you in your journey to learn Java: 1. Get Familiar with the Basics: Start with the basics of Java syntax, data types, variables, operators, control structures, loops, and functions. 2. Practice, Practice, Practice: The more you practice, the better you get. Write code to solve simple problems, and gradually increase the complexity of the problems you tackle. 3. Use Online Resources: There are many online resources available for learning Java, including online tutorials, video courses, and forums. Take advantage of these resources to deepen your understanding of the language. 4. Join a Study Group: Joining a study group can be a great way to stay motivated and learn from others. You can also learn from others’ mistakes and share your own experiences. 5. Read Java Documentation: The official Java documentation is a wealth of information, and it’s a great resource for learning the ins and outs of the language. 6. Work on Projects: Choose a project that interests you, and work on it until it’s complete. This will help you put into practice everything you’ve learned and also give you a sense of accomplishment. 7. Debugging: Learn to debug your code effectively. This will help you find and fix bugs quickly and easily, and improve your overall programming skills. 8. Stay Up-to-Date: Java is constantly evolving, and new features and libraries are added regularly. Stay up-to-date with the latest developments in the Java world to improve your skills and keep your knowledge fresh. Remember, learning Java takes time and effort, but with persistence and determination, you can become a proficient Java programmer.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

goddemon

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值