Implements skeleton module/exploit config generator
This commit is contained in:
		
							
								
								
									
										30
									
								
								gen.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								gen.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,30 @@ | ||||
| // 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. | ||||
|  | ||||
| package main | ||||
|  | ||||
| import ( | ||||
| 	"fmt" | ||||
|  | ||||
| 	"github.com/jollheef/out-of-tree/config" | ||||
| 	"github.com/naoina/toml" | ||||
| ) | ||||
|  | ||||
| func genConfig(at config.ArtifactType) (err error) { | ||||
| 	a := config.Artifact{ | ||||
| 		Name: "Put name here", | ||||
| 		Type: at, | ||||
| 	} | ||||
| 	a.SupportedKernels = append(a.SupportedKernels, config.KernelMask{ | ||||
| 		config.Ubuntu, "18.04", ".*", | ||||
| 	}) | ||||
|  | ||||
| 	buf, err := toml.Marshal(&a) | ||||
| 	if err != nil { | ||||
| 		return | ||||
| 	} | ||||
|  | ||||
| 	fmt.Print(string(buf)) | ||||
| 	return | ||||
| } | ||||
							
								
								
									
										10
									
								
								main.go
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								main.go
									
									
									
									
									
								
							| @@ -58,6 +58,12 @@ func main() { | ||||
| 	kernelCommand := app.Command("kernel", "Manipulate kernels") | ||||
| 	kernelListCommand := kernelCommand.Command("list", "List kernels") | ||||
|  | ||||
| 	genCommand := app.Command("gen", "Generate .out-of-tree.toml skeleton") | ||||
| 	genModuleCommand := genCommand.Command("module", | ||||
| 		"Generate .out-of-tree.toml skeleton for kernel module") | ||||
| 	genExploitCommand := genCommand.Command("exploit", | ||||
| 		"Generate .out-of-tree.toml skeleton for kernel exploit") | ||||
|  | ||||
| 	// Check for required commands | ||||
| 	for _, cmd := range []string{"timeout", "docker", "qemu"} { | ||||
| 		_, err := exec.Command("which", cmd).CombinedOutput() | ||||
| @@ -79,6 +85,10 @@ func main() { | ||||
| 			*pewTest, *pewGuess, *qemuTimeout, *dockerTimeout) | ||||
| 	case kernelListCommand.FullCommand(): | ||||
| 		err = kernelListHandler(kcfg) | ||||
| 	case genModuleCommand.FullCommand(): | ||||
| 		err = genConfig(config.KernelModule) | ||||
| 	case genExploitCommand.FullCommand(): | ||||
| 		err = genConfig(config.KernelExploit) | ||||
| 	} | ||||
|  | ||||
| 	if err != nil { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user