-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added go binaries versions >= 1.11.9 (#9)
* Update Readme.md * Added go binaries generation script --------- Co-authored-by: Moritz <[email protected]>
- Loading branch information
Showing
6 changed files
with
156 additions
and
1 deletion.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,21 @@ | ||
# Test Files for Go Binary Versions | ||
|
||
This repository contains two ZIP archives, each containing compiled Go binaries for minor versions 1.11 to 1.20, specifically for the 386 and amd64 architectures, along with their corresponding source code. | ||
|
||
## Contents | ||
|
||
Each ZIP archive corresponds to a specific architecture and contains the following files: | ||
|
||
- `bin/versions_32.zip`: Zip file containing the compiled Go binaries for the 386 architecture. | ||
- `bin/versions_64.zip`: Zip file containing the compiled Go binaries for the amd64 architecture. | ||
- `main32.go`: Source code for the 386 architecture binaries. | ||
- `main64.go`: Source code for the amd64 architecture binaries. | ||
|
||
## Generating Go Binaries using Docker | ||
|
||
To automate the process of generating Go binaries for all versions from 1.11 to 1.20 using Docker, you can use the provided Python script. Follow the steps below: | ||
|
||
- Make sure Docker is installed and properly configured on your system. | ||
- Run the script using the following command: `python3 go_binary_generator.py`. | ||
|
||
The script will handle the setup, compilation, and generation of Go binaries for the specified minor versions. The resulting binaries will be saved in the `bin/` directory. |
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,4 @@ | ||
module go-test | ||
|
||
go 1.19 | ||
|
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,91 @@ | ||
# Copyright (C) 2023 Mandiant, Inc. All Rights Reserved. | ||
""" | ||
This Python script automates the process of generating Go binaries for versions 1.11 to 1.20 using Docker. By leveraging Docker containers, it ensures a consistent and reproducible environment for compiling the Go source code across different platforms. | ||
Please note that Docker must be installed and properly configured on your system for the script to execute successfully. | ||
Usage: | ||
python go_binary_generator.py | ||
The resulting binaries will be saved in the `bin/` directory. | ||
""" | ||
|
||
import subprocess | ||
|
||
go_versions = """ | ||
1.11 | ||
1.12 | ||
1.13 | ||
1.14 | ||
1.15 | ||
1.16 | ||
1.17 | ||
1.18 | ||
1.19 | ||
1.20 | ||
""" | ||
|
||
f = open("docker-compose.yml", "w") | ||
|
||
f.write( | ||
"""services: | ||
app: | ||
build: .""" | ||
) | ||
|
||
f.close() | ||
|
||
subprocess.call(["docker", "compose", "up"]) | ||
print("Compose is UP") | ||
|
||
architecture = {"386": 32, "amd64": 64} | ||
|
||
for arch in architecture.keys(): | ||
for version in go_versions.split(): | ||
print("version: ", version) | ||
|
||
f = open("Dockerfile", "w") | ||
|
||
f.write( | ||
"""# syntax=docker/dockerfile:1 | ||
FROM golang:{} | ||
WORKDIR /app | ||
COPY go.mod ./ | ||
RUN go mod download | ||
COPY *.go ./ | ||
RUN GOOS=windows GOARCH={} go install main{}.go""".format( | ||
version, arch, architecture[arch] | ||
) | ||
) | ||
f.close() | ||
|
||
f = open("go.mod", "w") | ||
|
||
f.write( | ||
"""module go-test | ||
go {} | ||
""".format( | ||
version | ||
) | ||
) | ||
|
||
f.close() | ||
|
||
subprocess.call(["docker", "build", "--tag", "go-test", "."]) | ||
subprocess.call( | ||
[ | ||
"docker", | ||
"run", | ||
"-v", | ||
".:/var/opt", | ||
"go-test", | ||
"mv", | ||
"/go/bin/main{}.exe".format(architecture[arch]), | ||
"/var/opt/bin/main_{}_{}.exe".format(architecture[arch], version), | ||
] | ||
) | ||
|
||
subprocess.call(["docker", "compose", "down"]) | ||
print("Compose is DOWN") |
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,20 @@ | ||
package main; | ||
|
||
import ( | ||
"fmt"; | ||
"os"; | ||
"bufio"; | ||
) | ||
|
||
func main() { | ||
fmt.Print("Enter Password: "); | ||
user_input,_,err := bufio.NewReader(os.Stdin).ReadLine(); | ||
if err != nil { | ||
fmt.Println("Something is wrong with your computer, ",err); | ||
} | ||
if string(user_input) == "Bugfest" { | ||
fmt.Println("You Cracked it, A Hero is born"); | ||
} else { | ||
fmt.Println("Don't Worry, Relax, Chill and Try harder"); | ||
} | ||
} |
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,20 @@ | ||
package main; | ||
|
||
import ( | ||
"fmt"; | ||
"os"; | ||
"bufio"; | ||
) | ||
|
||
func main() { | ||
fmt.Print("Enter Password: "); | ||
user_input,_,err := bufio.NewReader(os.Stdin).ReadLine(); | ||
if err != nil { | ||
fmt.Println("Something is wrong with your computer, ",err); | ||
} | ||
if string(user_input) == "PasswordisPrank" { | ||
fmt.Println("You Cracked it, A Hero is born"); | ||
} else { | ||
fmt.Println("Don't Worry, Relax, Chill and Try harder"); | ||
} | ||
} |