1
0

Use different stages for kernel exploit and kernel module

This commit is contained in:
dump_stack() 2018-10-07 14:47:14 +00:00
parent 0f569c88cc
commit 59d86cef7b

84
main.go
View File

@ -9,6 +9,7 @@ import (
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"log" "log"
"math/rand"
"os" "os"
"os/exec" "os/exec"
"regexp" "regexp"
@ -174,21 +175,16 @@ func cleanDmesg(q *qemu.QemuSystem) (err error) {
return return
} }
func run(q *qemu.QemuSystem, ka artifact, ki kernelInfo, file string) (output string, err error) { func testKernelModule(q *qemu.QemuSystem, ka artifact) (output string, err error) {
switch ka.Type { // TODO
case KernelModule: err = errors.New("Not implemented")
output, err = q.CopyAndInsmod(file)
case KernelExploit:
output, err = q.CopyAndRun("user", file)
default:
err = errors.New("Unsupported artifact type")
}
return return
} }
func test(q *qemu.QemuSystem, ka artifact) (output string, err error) { func testKernelExploit(q *qemu.QemuSystem, ka artifact,
remoteExploitPath string) (output string, err error) {
// TODO // TODO
err = errors.New("Not implemented")
return return
} }
@ -203,26 +199,21 @@ func genOkFail(name string, ok bool) aurora.Value {
} }
func dumpResult(ka artifact, ki kernelInfo, build_ok, run_ok, test_ok *bool) { func dumpResult(ka artifact, ki kernelInfo, build_ok, run_ok, test_ok *bool) {
var stest aurora.Value distroInfo := fmt.Sprintf("%s-%s {%s}", ki.DistroType,
if ka.Type == KernelExploit { ki.DistroRelease, ki.KernelRelease)
stest = genOkFail("LPE", *test_ok)
} else {
stest = genOkFail("TEST", *test_ok)
}
var srun aurora.Value colored := ""
if ka.Type == KernelExploit { if ka.Type == KernelExploit {
srun = genOkFail("RUN", *run_ok) colored = aurora.Sprintf("[*] %40s: %s %s", distroInfo,
genOkFail("BUILD", *build_ok),
genOkFail("LPE", *test_ok))
} else { } else {
srun = genOkFail("INSMOD", *run_ok) colored = aurora.Sprintf("[*] %40s: %s %s %s", distroInfo,
genOkFail("BUILD", *build_ok),
genOkFail("INSMOD", *run_ok),
genOkFail("TEST", *test_ok))
} }
colored := aurora.Sprintf("[*] %40s: %s %s %s",
fmt.Sprintf("%s-%s {%s}", ki.DistroType, ki.DistroRelease,
ki.KernelRelease),
genOkFail("BUILD", *build_ok),
srun, stest)
fmt.Println(colored) fmt.Println(colored)
} }
@ -265,19 +256,38 @@ func whatever(swg *sizedwaitgroup.SizedWaitGroup, ka artifact, ki kernelInfo) {
return return
} }
// TODO Write run log to file or database if ka.Type == KernelModule {
_, err = run(q, ka, ki, outFile) // TODO Write insmod log to file or database
if err != nil { _, err = q.CopyAndInsmod(outFile)
return if err != nil {
} return
run_ok = true }
run_ok = true
// TODO Write test results to file or database // TODO Write test results to file or database
_, err = test(q, ka) _, err = testKernelModule(q, ka)
if err != nil { if err != nil {
return return
}
test_ok = true
} else if ka.Type == KernelExploit {
remoteExploitPath := fmt.Sprintf("/tmp/exploit_%d.ko", rand.Int())
err = q.CopyFile("root", outFile, remoteExploitPath)
if err != nil {
return
}
// TODO Write test results to file or database
_, err = testKernelExploit(q, ka, remoteExploitPath)
if err != nil {
return
}
run_ok = true // does not really used
test_ok = true
} else {
err = errors.New("Unsupported artifact type")
} }
test_ok = true return
} }
type kernelConfig struct { type kernelConfig struct {