Skip to content
KitploitKITPLOIT
工具博客
提交
工具博客
提交

黑客、渗透测试和网络安全工具,武装您的安全武器库!

Kitploit 是一个黑客、网络安全和渗透测试工具的目录。发现最新的项目更新,查找漏洞、分析系统、自动化测试并加强你的安全。

··订阅源·联系·隐私·© 2026 Kitploit

工具目录

分类

查看所有分类
Loading categories
joern — 基于代码属性图的 C/C++/Java/二进制/JavaScript/Python/Kotlin 开源代码分析平台。Discord https://discord.gg/vv4MH284Hc | Kitploit
工具/GitHubGitHub/joernio/joern
静态分析漏洞分析代码分析逆向工程二进制分析
GitHubjoernio/joern

joern

基于代码属性图的 C/C++/Java/二进制/JavaScript/Python/Kotlin 开源代码分析平台。Discord https://discord.gg/vv4MH284Hc

查看仓库
3.3k4302天前Kitploit 审核通过

最受欢迎

查看全部 →

发现我们社区最常用的工具。

探索所有工具

浏览我们的工具集合

查看所有工具 →
分享
网站

Joern 查询数据库("Joern-Scan")

这是开源代码分析平台 Joern 的核心查询数据库。它有两个用途:

  • 它提供了将 Joern 转变为即用型代码扫描工具所需的“电池”。
  • 它的查询可作为那些希望编写自己查询的人的示例。
  • 基于 JDK11 构建,但运行在 JRE >= 1.8 上

查询数据库作为一个独立的库分发,其中包括 Joern 作为依赖项。这意味着无需安装 Joern 即可使用数据库中的查询。

同时,数据库是一个 Joern 扩展,即在启动时动态加载后,其功能可在交互式 Joern shell 和 Joern 脚本中使用。

你可以 fork 这个项目来构建自己的自定义查询和扫描器,或者发送 PR 到本仓库,以便它们被考虑纳入默认发行版。

安装与运行

安装脚本会下载 joern 并将其安装到一个子目录中。查询数据库会作为扩展安装。

root@kitploit:~
./install.sh

你可以按如下方式运行所有查询:

root@kitploit:~
./joern-scan path/to/code

例如:

root@kitploit:~
mkdir foo
echo "int foo(int a, int b, int c, int d, int e, int f) {}" > foo/foo.c
./joern-scan foo

对目录 foo 中的示例代码运行所有查询,确定函数 foo 参数过多。

添加你自己的查询

请遵循以下规则,以获得无痛查询编写体验:

  • 包 io.joern.scanners 中的查询会在运行时自动被识别,因此请将你的查询放在那里。
  • 每个查询必须以注解 @q 开头,并且必须放在一个查询包中。一个查询包只是一个派生自 QueryBundle 的 object。
  • 查询可以有参数,但你必须为每个参数提供默认值。
  • 请为查询添加单元测试。这些测试也作为查询所做工作的规范。
  • 在发送 PR 之前,请使用 sbt scalafmt Test/scalafmt 格式化代码。

以 src/main/scala/io/joern/scanners/c/Metrics.scala 中的查询包 Metrics 为例:

root@kitploit:~
object Metrics extends QueryBundle {

  @q
  def tooManyParameters(n: Int = 4): Query =
    Query.make(
      name = "too-many-params",
      author = Crew.fabs,
      title = s"Number of parameters larger than $n",
      description = s"This query identifies functions with more than $n formal parameters",
      score = 1.0,
      withStrRep({ cpg =>
        cpg.method.internal.filter(_.parameter.size > n)
      }),
      tags = List(QueryTags.metrics)
    )

  @q
  def tooHighComplexity(n: Int = 4): Query =
    Query.make(
      name = "too-high-complexity",
      author = Crew.fabs,
      title = s"Cyclomatic complexity higher than $n",
      description = s"This query identifies functions with a cyclomatic complexity higher than $n",
      score = 1.0,
      withStrRep({ cpg =>
        cpg.method.internal.filter(_.controlStructure.size > n)
      }),
      tags = List(QueryTags.metrics)
    )
  ...
}

相应的查询测试位于 src/test/scala/io/joern/scanners。例如,度量查询的测试位于 src/test/scala/io/joern/scanners/c/MetricsTests.scala:

root@kitploit:~
class MetricsTests extends Suite {

  override val code = """
    int too_many_params(int a, int b, int c, int d, int e) {
    }
	...
	"""

  "find functions with too many parameters" in {
    Metrics.tooManyParameters(4)(cpg).map(_.evidence) match {
      case List(List(method: nodes.Method)) =>
        method.name shouldBe "too_many_params"
      case _ => fail
    }
  }
  ...
}

这些测试可以在查询开发过程中从 IntelliJ IDE 单独运行。

构建/测试数据库

我们使用 Scala 构建工具(sbt)。请确保已安装 sbt。版本无关紧要,因为 sbt 会根据构建文件(build.sbt)获取所需版本。

一旦安装了 sbt,你可以按如下方式构建和测试数据库:

root@kitploit:~
sbt test

你可以测试新开发的查询

如果你想用 joern-scan 测试新创建的查询,请按如下方式操作:

root@kitploit:~
sbt joerncli/stage
./querydb-install.sh && ./joern-scan <src>

将数据库导出为 JSON

在运行 install.sh 后,你可以启动

root@kitploit:~
./joern-scan --dump

创建一个名为 querydb.json 的文件,其中包含所有可用查询的列表及其元信息。

下载工具