This guide provides instructions on how to run the Gopher tool, a utility designed to analyze Go projects. It also covers the necessary steps to clean up any previous scan results. In the basicRules, we provide the CryDict Rules for golang basic cryptography library. If you want to try writing your own CryDict documentation, you can refer to CryDict_tutorial/readme.md. In the compressed file(script), we provide specific code for comparing with cryptogo testing. In the test_code folder, we provide the projects for testing.
Before you begin, make sure that the Go language environment is installed on your computer. If not, please follow these steps to install it:
-
Visit the Go Official Download Page: Visit https://golang.org/dl/ and download the latest stable release for your operating system.
-
Install Go:
- For Linux users, extract the downloaded package and add the
godirectory to your system path (PATH) environment variable. - For Windows users, run the downloaded installer and make sure to check the option "Add Go to PATH" during installation.
- For Linux users, extract the downloaded package and add the
-
Verify Installation: Open a terminal or command prompt window and type
go versionto check if Go has been correctly installed.
Assuming you have installed Go and want to place the Gopher project within the standard Go workspace structure, usually located at $HOME/go/src (Linux) or %USERPROFILE%\go\src (Windows). Here are the setup steps:
-
Create Go Workspace: If you haven't created a Go workspace yet, manually create a directory named
goand within it create a subdirectory namedsrc. For example, on Linux you can use the following command:mkdir -p $HOME/go/srcFor Windows users, you can do this:
md %USERPROFILE%\go\src
-
Clone or Copy the Gopher Project: Place the Gopher project into the
srcdirectory so its path becomes$HOME/go/src/gopher(Linux) or%USERPROFILE%\go\src\gopher(Windows).
Before running Gopher, ensure that the system environment variable GO111MODULE is set to on.
Here’s how you can do it:
-
On Unix systems (Linux):
- Open your terminal.
- Run the following command:
export GO111MODULE=on
This will set the
GO111MODULEenvironment variable for the current shell session only.If you want to make this setting permanent, add the above line to your shell's startup file (like
.bashrc,.bash_profile, or.zshrcif you're using ZSH). -
On Windows:
- Open Command Prompt.
- Use the
setcommand:set GO111MODULE=on
This will be active only for the current Command Prompt window.
To set it permanently, you might need to modify the system's environment variables through the Control Panel or System Properties.
Setting GO111MODULE=on tells Go to use modules for source management by default, which is useful when working on projects that use Go modules for dependency management.
To execute the Gopher tool, follow these steps:
-
Navigate to the Gopher Directory:
cd $HOME/go/src/gopher
-
Execute the Gopher Tool: Run the Gopher executable with the target project directory as an argument. Please note that some code repositories require downloading code from the network, and poor network conditions may cause delays. Use the appropriate command based on your operating system:
# For Linux chmod 777 gopher ./gopher ./test_code/beego-2.2.0 # For Windows ./gopher.exe .\test_code\beego-2.2.0
Replace
./test_code/beego-2.2.0with the path to the project directory you wish to analyze. The provided test code originates from the Beego 2.2.0 repository. The detection process takes less than 1 minute. After running Gopher, you will receive an error alert about MD5 and an error alert indicating the skipping of TLS validation.
You can obtain the scan results from the command line window. In addition, the scan results of gopher will be saved in the corresponding project's scan_desults/results.txt.
Note: If there are too many files in $GOPATH/pkg, the scan speed will significantly decrease on computers with mechanical hard drives. The scan speed might also drop on computers with solid-state drives.