Skip to content

Commit

Permalink
use string injection using ldflags for launcher's variables
Browse files Browse the repository at this point in the history
  • Loading branch information
89luca89 committed Jun 26, 2020
1 parent 26f20e9 commit 7d2f7af
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 3 additions & 1 deletion data/launcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ type obDependency struct {
obDepBFD []float64
}


var Stdout string = "ENABLESTDOUT"
const obErr = 1
const obCorrelationLevel = 0.4
const obStdLevel = 1
Expand Down Expand Up @@ -547,7 +549,7 @@ func obLauncher() {
obStderrIn, _ := obCommand.StderrPipe()
defer obStderrIn.Close()

obStdout, obErr := obStrconv.ParseBool("ENABLESTDOUT")
obStdout, obErr := obStrconv.ParseBool(Stdout)
if obErr != nil {
obExit()
}
Expand Down
8 changes: 4 additions & 4 deletions internal/pakkero/pakkero.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ func Pakkero(infile string, offset int64, outfile string, dependency string, com
// packages
fmt.Print(" → Registering Dependencies...")

Secrets[stdoutEnabledPlaceholder] = []string{"\"unset\"", "leaveunset"}
// ------------------------------------------------------------------------
// Register eventual dependency passed by cli
// If a dependency check is present, register it.
Expand All @@ -91,8 +92,6 @@ func Pakkero(infile string, offset int64, outfile string, dependency string, com
Secrets[offsetPlaceholder] = []string{fmt.Sprintf("%d", offset),
GenerateTyposquatName(128)}

Secrets[stdoutEnabledPlaceholder] = []string{strconv.FormatBool(stdout),
GenerateTyposquatName(128)}
// copy the stub from where to start.
launcherStub, _ := base64.StdEncoding.DecodeString(LauncherStub)
err := ioutil.WriteFile(launcherFile, launcherStub, 0644)
Expand Down Expand Up @@ -134,8 +133,9 @@ func Pakkero(infile string, offset int64, outfile string, dependency string, com
"-trimpath",
"-gcflags",
"-N -l -nolocalimports",
"-ldflags",
"-s -w -extldflags -static",
"-ldflags=" +
"-X main.Stdout=" + strconv.FormatBool(stdout) +
" -s -w -extldflags -static\"",
}
flags = append(flags, "-o")
flags = append(flags, outfile)
Expand Down

0 comments on commit 7d2f7af

Please sign in to comment.