Book Image

Security with Go

By : John Daniel Leon, Karthik Gaekwad
Book Image

Security with Go

By: John Daniel Leon, Karthik Gaekwad

Overview of this book

Go is becoming more and more popular as a language for security experts. Its wide use in server and cloud environments, its speed and ease of use, and its evident capabilities for data analysis, have made it a prime choice for developers who need to think about security. Security with Go is the first Golang security book, and it is useful for both blue team and red team applications. With this book, you will learn how to write secure software, monitor your systems, secure your data, attack systems, and extract information. Defensive topics include cryptography, forensics, packet capturing, and building secure web applications. Offensive topics include brute force, port scanning, packet injection, web scraping, social engineering, and post exploitation techniques.
Table of Contents (15 chapters)

Changing file permissions

Changing the permission of a file so that you can access it later from a lower-privileged user may also be useful. This example demonstrates how to change file permissions using the os package. You can change file permissions easily using the os.Chmod() function.

This program is named chmode.go so that it does not conflict with the default chmod program provided on most systems. It has the same basic functionality as chmod, but without any extra features.

The os.Chmod() function is straightforward, but it must be provided an os.FileMode type. The os.FileMode type is simply a uint32 type so that you can provide it a uint32 literal (a hardcoded number) or you will have to ensure that the file mode value you provide is casted to an os.FileMode type. In this example, we will take the string value provided from the command line (for example, "777&quot...