2018-11-23 09:11:18 +00:00
|
|
|
// Copyright 2018 Mikhail Klementev. All rights reserved.
|
|
|
|
// Use of this source code is governed by a AGPLv3 license
|
|
|
|
// (or later) that can be found in the LICENSE file.
|
|
|
|
|
2024-02-17 22:38:43 +00:00
|
|
|
package cmd
|
2018-11-23 09:11:18 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/naoina/toml"
|
2019-02-02 21:24:29 +00:00
|
|
|
|
2024-02-20 13:25:31 +00:00
|
|
|
"code.dumpstack.io/tools/out-of-tree/artifact"
|
2023-05-18 16:07:24 +00:00
|
|
|
"code.dumpstack.io/tools/out-of-tree/distro"
|
2018-11-23 09:11:18 +00:00
|
|
|
)
|
|
|
|
|
2023-01-31 07:13:33 +00:00
|
|
|
type GenCmd struct {
|
|
|
|
Type string `enum:"module,exploit" required:"" help:"module/exploit"`
|
|
|
|
}
|
|
|
|
|
|
|
|
func (cmd *GenCmd) Run(g *Globals) (err error) {
|
|
|
|
switch cmd.Type {
|
|
|
|
case "module":
|
2024-02-20 13:25:31 +00:00
|
|
|
err = genConfig(artifact.KernelModule)
|
2023-01-31 07:13:33 +00:00
|
|
|
case "exploit":
|
2024-02-20 13:25:31 +00:00
|
|
|
err = genConfig(artifact.KernelExploit)
|
2023-01-31 07:13:33 +00:00
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2024-02-20 13:25:31 +00:00
|
|
|
func genConfig(at artifact.ArtifactType) (err error) {
|
|
|
|
a := artifact.Artifact{
|
2018-11-23 09:11:18 +00:00
|
|
|
Name: "Put name here",
|
|
|
|
Type: at,
|
|
|
|
}
|
2024-02-20 13:25:31 +00:00
|
|
|
a.Targets = append(a.Targets, artifact.Target{
|
2023-05-18 18:48:09 +00:00
|
|
|
Distro: distro.Distro{ID: distro.Ubuntu, Release: "18.04"},
|
2024-02-20 13:25:31 +00:00
|
|
|
Kernel: artifact.Kernel{Regex: ".*"},
|
2023-05-18 16:07:24 +00:00
|
|
|
})
|
2024-02-20 13:25:31 +00:00
|
|
|
a.Targets = append(a.Targets, artifact.Target{
|
2023-05-18 18:48:09 +00:00
|
|
|
Distro: distro.Distro{ID: distro.Debian, Release: "8"},
|
2024-02-20 13:25:31 +00:00
|
|
|
Kernel: artifact.Kernel{Regex: ".*"},
|
2018-11-23 09:11:18 +00:00
|
|
|
})
|
2024-02-20 13:25:31 +00:00
|
|
|
a.Preload = append(a.Preload, artifact.PreloadModule{
|
2022-02-16 20:35:06 +00:00
|
|
|
Repo: "Repo name (e.g. https://github.com/openwall/lkrg)",
|
2020-06-14 20:14:59 +00:00
|
|
|
})
|
2024-02-20 13:25:31 +00:00
|
|
|
a.Patches = append(a.Patches, artifact.Patch{
|
2023-02-16 10:21:44 +00:00
|
|
|
Path: "/path/to/profiling.patch",
|
|
|
|
})
|
2018-11-23 09:11:18 +00:00
|
|
|
|
|
|
|
buf, err := toml.Marshal(&a)
|
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
fmt.Print(string(buf))
|
|
|
|
return
|
|
|
|
}
|