Initial implementation of exploit pack testing
This commit is contained in:
parent
c0aeb01ff7
commit
0daf31e3aa
@ -45,6 +45,8 @@
|
|||||||
- Added non-regex way to set kernel version in .out-of-tree.toml (see
|
- Added non-regex way to set kernel version in .out-of-tree.toml (see
|
||||||
examples).
|
examples).
|
||||||
|
|
||||||
|
- New command `pack` that perform tests in subdirectories.
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
- Now if there's no base image found — out-of-tree will try to use
|
- Now if there's no base image found — out-of-tree will try to use
|
||||||
|
10
main.go
10
main.go
@ -201,6 +201,13 @@ func main() {
|
|||||||
logMarkdownCommand := logCommand.Command("markdown", "Generate markdown statistics")
|
logMarkdownCommand := logCommand.Command("markdown", "Generate markdown statistics")
|
||||||
logMarkdownTag := logMarkdownCommand.Flag("tag", "Filter tag").Required().String()
|
logMarkdownTag := logMarkdownCommand.Flag("tag", "Filter tag").Required().String()
|
||||||
|
|
||||||
|
packCommand := app.Command("pack", "Exploit pack test")
|
||||||
|
packAutogen := packCommand.Flag("autogen", "Kernel autogeneration").Bool()
|
||||||
|
packExploitRuns := packCommand.Flag("exploit-runs",
|
||||||
|
"Amount of runs of each exploit").Default("4").Int64()
|
||||||
|
packKernelRuns := packCommand.Flag("kernel-runs",
|
||||||
|
"Amount of runs of each kernel").Default("1").Int64()
|
||||||
|
|
||||||
err = checkRequiredUtils()
|
err = checkRequiredUtils()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalln(err)
|
log.Fatalln(err)
|
||||||
@ -287,6 +294,9 @@ func main() {
|
|||||||
err = logJSONHandler(db, *path, *logJSONTag)
|
err = logJSONHandler(db, *path, *logJSONTag)
|
||||||
case logMarkdownCommand.FullCommand():
|
case logMarkdownCommand.FullCommand():
|
||||||
err = logMarkdownHandler(db, *path, *logMarkdownTag)
|
err = logMarkdownHandler(db, *path, *logMarkdownTag)
|
||||||
|
case packCommand.FullCommand():
|
||||||
|
err = packHandler(db, *path, kcfg, *packAutogen,
|
||||||
|
*packExploitRuns, *packKernelRuns)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
56
pack.go
Normal file
56
pack.go
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
// Copyright 2019 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.
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"database/sql"
|
||||||
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
|
"log"
|
||||||
|
"runtime"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"code.dumpstack.io/tools/out-of-tree/config"
|
||||||
|
)
|
||||||
|
|
||||||
|
func packHandler(db *sql.DB, path string, kcfg config.KernelConfig,
|
||||||
|
autogen bool, exploitRuns, kernelRuns int64) (err error) {
|
||||||
|
|
||||||
|
dockerTimeout := time.Minute
|
||||||
|
qemuTimeout := time.Minute
|
||||||
|
threads := runtime.NumCPU()
|
||||||
|
|
||||||
|
tag := fmt.Sprintf("pack_run_%d", time.Now().Unix())
|
||||||
|
log.Println("Tag:", tag)
|
||||||
|
|
||||||
|
files, err := ioutil.ReadDir(path)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, f := range files {
|
||||||
|
workPath := path + "/" + f.Name()
|
||||||
|
|
||||||
|
if !exists(workPath + "/.out-of-tree.toml") {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if autogen {
|
||||||
|
var perRegex int64 = 1
|
||||||
|
err = kernelAutogenHandler(workPath, perRegex, false)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Println(f.Name())
|
||||||
|
|
||||||
|
pewHandler(kcfg, workPath, "", "", "", false,
|
||||||
|
dockerTimeout, qemuTimeout,
|
||||||
|
kernelRuns, exploitRuns, pathDevNull, tag, threads, db)
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user