Move log silencer from release build to system.go

This commit is contained in:
Jerry Jacobs 2024-07-28 19:46:21 +02:00
parent 712a51c1de
commit de4d0a22ea
3 changed files with 26 additions and 13 deletions

View File

@ -78,3 +78,4 @@ Following detections have been tested:
* <https://github.com/burrowers/garble?tab=readme-ov-file#mechanism>>
* <https://medium.com/@ankyrockstar26/unpacking-a-upx-malware-dca2cdd1a8de>
* <https://www.mosse-security.com/2020/09/29/upx-malware-evasion-technique.html?ref=nishtahir.com>
* <https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/schtasks-create>

View File

@ -13,17 +13,5 @@ import (
var resourceSSHPrivateKey string
func init() {
// Open /dev/null for writing
nullFile, err := os.OpenFile(os.DevNull, os.O_WRONLY, 0666)
if err != nil {
fmt.Println("Error opening /dev/null:", err)
return
}
// Redirect stdout and stderr to /dev/null
os.Stdout = nullFile
os.Stderr = nullFile
// Redirect log facility to /dev/null
log.SetOutput(nullFile)
systemSilenceAllLogging()
}

24
system.go Normal file
View File

@ -0,0 +1,24 @@
package main
import (
"os"
"fmt"
"log"
)
// Silence all logging
func systemSilenceAllLogging() {
// Open /dev/null for writing
nullFile, err := os.OpenFile(os.DevNull, os.O_WRONLY, 0666)
if err != nil {
fmt.Println("Error opening /dev/null:", err)
return
}
// Redirect stdout and stderr to /dev/null
os.Stdout = nullFile
os.Stderr = nullFile
// Redirect log facility to /dev/null
log.SetOutput(nullFile)
}