-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
105 changed files
with
2,697 additions
and
661 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package app | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"os/exec" | ||
"path/filepath" | ||
) | ||
|
||
func run(cmdName string, cmdArgs ...string) error { | ||
cmd := exec.Command(cmdName, cmdArgs...) | ||
cmd.Stdout = os.Stdout | ||
cmd.Stderr = os.Stderr | ||
return cmd.Run() | ||
} | ||
|
||
func asService(args []string) { | ||
serviceName := "yapscan" | ||
|
||
binpath, err := filepath.Abs(args[0]) | ||
if err != nil { | ||
fmt.Printf("ERROR: Could not determine absolute path of yapscan.exe, %v\n", err) | ||
os.Exit(1) | ||
} | ||
|
||
args = args[2:] | ||
scStartArguments := []string{"start", serviceName} | ||
scStartArguments = append(scStartArguments, args...) | ||
|
||
fmt.Println("WARNING: This feature is experimental!") | ||
fmt.Println("WARNING: You will not see any output of the executed service. Using --log-path is strongly advised.") | ||
|
||
fmt.Println("Removing service in case it exists already...") | ||
run("sc.exe", "delete", "yapscan") | ||
fmt.Println("Done removing.") | ||
|
||
fmt.Println("Installing service...") | ||
err = run("sc.exe", "create", serviceName, "type=", "own", "start=", "demand", "binpath=", binpath) | ||
if err != nil { | ||
fmt.Println("FAILURE") | ||
fmt.Print(err) | ||
os.Exit(10) | ||
} | ||
fmt.Println("Done installing service.") | ||
|
||
fmt.Println("Starting service with arguments...") | ||
err = run("sc.exe", scStartArguments...) | ||
if err != nil { | ||
fmt.Println("FAILURE") | ||
fmt.Print(err) | ||
os.Exit(11) | ||
} | ||
fmt.Println("Done starting service, yapscan should now be running as a service with the following arguments") | ||
fmt.Println(args) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package app | ||
|
||
import ( | ||
"fmt" | ||
"strconv" | ||
|
||
"github.com/fkie-cad/yapscan/procio" | ||
"github.com/targodan/go-errors" | ||
"github.com/urfave/cli/v2" | ||
) | ||
|
||
func crashProcess(c *cli.Context) error { | ||
err := initAppAction(c) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
if c.NArg() != 1 { | ||
return errors.Newf("expected exactly one arguments, got %d", c.NArg()) | ||
} | ||
pid_, err := strconv.ParseUint(c.Args().Get(0), 10, 64) | ||
if err != nil { | ||
return errors.Newf("\"%s\" is not a pid", c.Args().Get(0)) | ||
} | ||
pid := int(pid_) | ||
|
||
crashMethod, err := procio.ParseCrashMethod(c.String("method")) | ||
if err != nil { | ||
return fmt.Errorf("invalid parameter, %w", err) | ||
} | ||
|
||
proc, err := procio.OpenProcess(pid) | ||
if err != nil { | ||
return errors.Newf("could not open process %d, reason: %w", pid, err) | ||
} | ||
|
||
return proc.Crash(crashMethod) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.