Skip to content

Instantly share code, notes, and snippets.

@pog5
Created September 29, 2023 18:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pog5/4796774f0f3c24511ceb1facb79ea2e7 to your computer and use it in GitHub Desktop.
Save pog5/4796774f0f3c24511ceb1facb79ea2e7 to your computer and use it in GitHub Desktop.
Basic unfinished TrustedUninstaller (AME Wizard) implementation in Go
// FLOW FILE FORMAT (file.toml)
// version = "24.09"
//name = "Example Flow"
//info = "An example description that will appear!"
//author = "Pixel"
//steps = ["1", "2"]
//
//[1]
//status = "Messaging hi"
//type = "command"
//runas = "admin"
//command = "msg"
//args = [ "*", "hi" ]
//
//[2]
//status = "Messaging hi again"
//type = "command"
//runas = "admin"
//command = "msg"
//args = [ "*", "hi again" ]
package main
import (
"fmt"
"os"
"runtime"
"strings"
"github.com/pelletier/go-toml/v2"
)
type Flow struct {
Version string `toml:"version"`
Name string `toml:"name"`
Info string `toml:"info"`
Author string `toml:"author"`
}
type Step struct {
Status string `toml:"status"`
Type string `toml:"type"`
RunAs string `toml:"runas"`
Path string `toml:"path"`
Command string `toml:"command"`
Args []string `toml:"args"`
}
//type RegStep struct {
// Location string `toml:"location"`
// Type string `toml:"type"`
// Value string `toml:"value"`
// Action string `toml:"action"`
//}
func main() {
fmt.Println("Uranium 0.0: Debugging Ducky")
arguments := os.Args[1:]
// TODO
//var dryRun bool = false
//var verbose bool = false
//var unattend bool = false
var disclaimer bool = false
fmt.Println(fmt.Sprintf("Arguments: %s", strings.Join(arguments, " ")))
if len(arguments) < 1 || len(arguments) > 2 {
fmt.Println(" uranium <file> [arguments (-dv)]")
fmt.Println(" -a: Automatically agree to disclaimer")
fmt.Println(" -u: Unattend (Use defaults or skip if optional)")
fmt.Println(" -d: Dry run (Simulate actions)")
fmt.Println(" -v: Verbose (show commands being ran)")
return
}
if runtime.GOOS != "windows" {
fmt.Println("This tool only works on Windows [ for now ;) ]")
return
}
fileContents, err := os.ReadFile(arguments[0])
if err != nil {
fmt.Println(err)
fmt.Println(" uranium.exe <file> [arguments (-dv)]")
return
}
if len(arguments) == 2 {
for _, arg := range arguments[1] {
switch arg {
case 'a':
disclaimer = true
// TODO
//case 'd':
// dryRun = true
//case 'v':
// verbose = true
//case 'u':
// unattend = true
}
}
}
var flow Flow = Flow{}
err = toml.Unmarshal(fileContents, &flow)
if err != nil {
fmt.Println(err)
fmt.Println(" uranium.exe <file> [arguments (-dv)]")
return
}
fmt.Println("Loaded flow: " + flow.Name + " " + flow.Version + " by " + flow.Author)
fmt.Println(" " + flow.Info)
fmt.Println()
if !disclaimer {
fmt.Println("The author of this tool is not responsible for any damage caused by this tool.")
fmt.Println("Refer to the creator of the flow for more information and help/support.")
fmt.Print("Do you agree to the above? [Y/(N)]: ")
var response string
fmt.Scan(&response)
if response != "y" && response != "Y" {
fmt.Println("Exiting...")
return
}
fmt.Println()
}
// WIP
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment