commit aa44e444097f6239b0cfe71f74e022ed3229e839
Author: Hadi <112569860+anotherhadi@users.noreply.github.com>
Date: Wed Sep 24 17:00:35 2025 +0200
Init
Signed-off-by: Hadi <112569860+anotherhadi@users.noreply.github.com>
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 0000000..2b6774f
--- /dev/null
+++ b/CONTRIBUTING.md
@@ -0,0 +1,14 @@
+# Contributing
+
+Everybody is invited and welcome to contribute to this repo. There is a lot to
+do... Check the issues!
+
+The process is straight-forward.
+
+- Read
+ [How to get faster PR reviews](https://github.com/kubernetes/community/blob/master/contributors/guide/pull-requests.md#best-practices-for-faster-reviews)
+ by Kubernetes. (but skip step 0 and 1)
+- [Fork](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/fork-a-repo)
+ this repo.
+- Write your changes (bug fixe, new feature, issues fix, ...).
+- Create a Pull Request against the main branch.
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..5615ec7
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2025 Hadi
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..ccde074
--- /dev/null
+++ b/README.md
@@ -0,0 +1,100 @@
+# Gravatar-Recon ๐ค
+
+
+
+
+
+
+
+- [๐งพ Project Overview](#-project-overview)
+- [๐ Features](#-features)
+- [โ ๏ธ Disclaimer](#%EF%B8%8F-disclaimer)
+- [๐ฆ Installation](#-installation)
+- [๐งช Usage](#-usage)
+- [๐ก Examples](#-examples)
+- [๐ค Contributing](#-contributing)
+
+## ๐งพ Project Overview
+
+Retrieve and aggregate public **OSINT data from Gravatar**. Given an **email
+address**, the tool queries the Gravatar API and extracts useful information
+such as profile metadata, avatar, social accounts, and contact info.
+
+## ๐ Features
+
+- Export results to JSON
+- Fetch avatar directly
+- Extract profile metadata:
+ - Display name, bio, location, job, company
+ - Public emails
+ - Phone numbers
+ - Contact forms, calendars
+- Enumerate linked accounts (Twitter, GitHub, Mastodon, etc.)
+- Parse profile background colors and styles
+
+## โ ๏ธ Disclaimer
+
+This tool is intended for **educational purposes only**. Use responsibly and
+ensure you have permission to access the data you are querying.
+
+## ๐ฆ Installation
+
+### With Go
+
+```bash
+go install github.com/anotherhadi/gravatar-recon@latest
+```
+
+### With Nix/NixOS
+
+
+Click to expand
+
+**From anywhere (using the repo URL):**
+
+```bash
+nix run github:anotherhadi/gravatar-recon -- [--flags value] target_email
+```
+
+**Permanent Installation:**
+
+```bash
+# add the flake to your flake.nix
+{
+ inputs = {
+ gravatar-recon.url = "github:anotherhadi/gravatar-recon";
+ };
+}
+
+# then add it to your packages
+environment.systemPackages = with pkgs; [ # or home.packages
+ inputs.gravatar-recon.defaultPackage.${pkgs.system}
+];
+```
+
+
+
+## ๐งช Usage
+
+```bash
+gravatar-recon [--flags value] target_email@example.com
+```
+
+### Flags
+
+```txt
+-j, --json string Write results to specified JSON file
+-s, --silent Suppress all non-essential output
+-a, --print-avatar Show the avatar in the output
+```
+
+## ๐ก Examples
+
+```bash
+gravatar-recon myemail@gmail.com
+gravatar-recon myemail@gmail.com --json output.json
+```
+
+## ๐ค Contributing
+
+Contributions are welcome! See [CONTRIBUTING.md](CONTRIBUTING.md) for details.
diff --git a/cmd/json.go b/cmd/json.go
new file mode 100644
index 0000000..1ab1948
--- /dev/null
+++ b/cmd/json.go
@@ -0,0 +1,31 @@
+package main
+
+import (
+ "encoding/json"
+ "os"
+
+ "github.com/charmbracelet/log"
+)
+
+func writeJson(outputPath string, data any) {
+ if outputPath == "" {
+ return
+ }
+ file, err := os.Create(outputPath)
+ if err != nil {
+ log.Error("Failed to create JSON file", "err", err)
+ return
+ }
+
+ defer func() {
+ _ = file.Close()
+ }()
+
+ as_json, _ := json.MarshalIndent(data, "", "\t")
+ _, err = file.Write(as_json)
+ if err != nil {
+ log.Error("Failed to write to JSON file", "err", err)
+ return
+ }
+ log.Info("JSON output written to file", "file", outputPath)
+}
diff --git a/cmd/main.go b/cmd/main.go
new file mode 100644
index 0000000..d46d3fa
--- /dev/null
+++ b/cmd/main.go
@@ -0,0 +1,85 @@
+package main
+
+import (
+ "fmt"
+ "os"
+ "regexp"
+ "strings"
+
+ gravatar_recon "github.com/anotherhadi/gravatar-recon"
+ "github.com/anotherhadi/gravatar-recon/utils"
+ "github.com/charmbracelet/log"
+
+ flag "github.com/spf13/pflag"
+)
+
+func isEmailValid(email string) bool {
+ var re = regexp.MustCompile(`^[a-zA-Z0-9._%+\-]+@[a-zA-Z0-9.\-]+\.[a-zA-Z]{2,}$`)
+ return re.MatchString(email)
+}
+
+func main() {
+
+ flag.Usage = func() {
+ fmt.Fprintf(os.Stderr, "Usage:\n")
+ fmt.Fprintf(os.Stderr, "gravatar-recon [flags] \n")
+ fmt.Fprintf(os.Stderr, "\n")
+ fmt.Fprintf(os.Stderr, "Flags:\n")
+ flag.PrintDefaults()
+ }
+
+ flag.CommandLine.SetNormalizeFunc(wordSepNormalizeFunc)
+ flag.CommandLine.SortFlags = false
+
+ silent := flag.BoolP("silent", "s", false, "Suppress all non-essential output")
+ printAvatar := flag.BoolP("print-avatar", "a", true, "Show the avatar in the output")
+ jsonOutput := flag.StringP("json", "j", "", "Write results to specified JSON file")
+
+ flag.Parse()
+
+ // TAIL
+
+ nonFlagArgs := flag.Args()
+ if len(nonFlagArgs) > 1 {
+ log.Error("Please provide only one target (email)")
+ flag.Usage()
+ os.Exit(1)
+ } else if len(nonFlagArgs) == 0 {
+ log.Error("Please provide a target (email)")
+ flag.Usage()
+ os.Exit(1)
+ }
+
+ email := strings.TrimSpace(flag.Arg(0))
+
+ if !isEmailValid(email) {
+ log.Fatal("Invalid email address", "email", email)
+ return
+ }
+
+ profiles, err := gravatar_recon.GetGravatarProfiles(email)
+ if err != nil {
+ log.Fatal("Failed to get Gravatar profile", "err", err)
+ }
+
+ if !*silent {
+ utils.Header()
+ for _, profile := range *profiles {
+ utils.PrintTitle(profile.PreferredUser + ":")
+ if *printAvatar {
+ utils.PrintAvatar(profile.ThumbnailURL)
+ }
+ utils.PrintStruct(profile, 0)
+ }
+ }
+ writeJson(*jsonOutput, profiles)
+}
+
+func wordSepNormalizeFunc(f *flag.FlagSet, name string) flag.NormalizedName {
+ from := []string{".", "_"}
+ to := "-"
+ for _, sep := range from {
+ name = strings.ReplaceAll(name, sep, to)
+ }
+ return flag.NormalizedName(name)
+}
diff --git a/flake.lock b/flake.lock
new file mode 100644
index 0000000..2155089
--- /dev/null
+++ b/flake.lock
@@ -0,0 +1,27 @@
+{
+ "nodes": {
+ "nixpkgs": {
+ "locked": {
+ "lastModified": 1758427187,
+ "narHash": "sha256-pHpxZ/IyCwoTQPtFIAG2QaxuSm8jWzrzBGjwQZIttJc=",
+ "owner": "NixOS",
+ "repo": "nixpkgs",
+ "rev": "554be6495561ff07b6c724047bdd7e0716aa7b46",
+ "type": "github"
+ },
+ "original": {
+ "owner": "NixOS",
+ "ref": "nixos-unstable",
+ "repo": "nixpkgs",
+ "type": "github"
+ }
+ },
+ "root": {
+ "inputs": {
+ "nixpkgs": "nixpkgs"
+ }
+ }
+ },
+ "root": "root",
+ "version": 7
+}
diff --git a/flake.nix b/flake.nix
new file mode 100644
index 0000000..7706d98
--- /dev/null
+++ b/flake.nix
@@ -0,0 +1,46 @@
+{
+ description = "Retrieve and aggregate public OSINT data from Gravatar. Given an email address, the tool queries the Gravatar API and extracts useful information such as profile metadata, avatar, social accounts, and contact info.";
+
+ inputs = {nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";};
+
+ outputs = {
+ self,
+ nixpkgs,
+ }: let
+ supportedSystems = ["x86_64-linux" "aarch64-linux"];
+
+ forAllSystems = f:
+ nixpkgs.lib.genAttrs supportedSystems
+ (system: f system (import nixpkgs {inherit system;}));
+
+ pname = "gravatar-recon";
+ version = "1.0.0";
+
+ ldflags = ["-s" "-w"];
+ in {
+ packages = forAllSystems (system: pkgs: {
+ "${pname}" = pkgs.buildGoModule {
+ inherit pname version ldflags;
+
+ src = ./.;
+ subPackages = ["cmd"];
+ outputs = ["out"];
+ installPhase = ''
+ mkdir -p $out/bin
+ cp $GOPATH/bin/cmd $out/bin/gravatar-recon
+ '';
+
+ vendorHash = "sha256-hjaIXZMK9+b+tlWD55OU3mS0CLUA/Oonn/RBHQdgs2g=";
+
+ meta = with pkgs.lib; {
+ description = "Retrieve and aggregate public OSINT data from Gravatar. Given an email address, the tool queries the Gravatar API and extracts useful information such as profile metadata, avatar, social accounts, and contact info.";
+ homepage = "https://github.com/anotherhadi/gravatar-recon";
+ platforms = platforms.unix;
+ };
+ };
+ });
+
+ defaultPackage =
+ forAllSystems (system: pkgs: self.packages.${system}.${pname});
+ };
+}
diff --git a/go.mod b/go.mod
new file mode 100644
index 0000000..4dbb766
--- /dev/null
+++ b/go.mod
@@ -0,0 +1,28 @@
+module github.com/anotherhadi/gravatar-recon
+
+go 1.25.0
+
+require (
+ github.com/charmbracelet/lipgloss v1.1.0
+ github.com/charmbracelet/log v0.4.2
+ github.com/saran13raj/go-pixels v0.0.0-20250629121333-58b240a3ae51
+ github.com/spf13/pflag v1.0.10
+)
+
+require (
+ github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
+ github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc // indirect
+ github.com/charmbracelet/x/ansi v0.8.0 // indirect
+ github.com/charmbracelet/x/cellbuf v0.0.13-0.20250311204145-2c3ea96c31dd // indirect
+ github.com/charmbracelet/x/term v0.2.1 // indirect
+ github.com/go-logfmt/logfmt v0.6.0 // indirect
+ github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
+ github.com/mattn/go-isatty v0.0.20 // indirect
+ github.com/mattn/go-runewidth v0.0.16 // indirect
+ github.com/muesli/termenv v0.16.0 // indirect
+ github.com/rivo/uniseg v0.4.7 // indirect
+ github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
+ golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect
+ golang.org/x/image v0.28.0 // indirect
+ golang.org/x/sys v0.30.0 // indirect
+)
diff --git a/go.sum b/go.sum
new file mode 100644
index 0000000..f10a729
--- /dev/null
+++ b/go.sum
@@ -0,0 +1,48 @@
+github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k=
+github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8=
+github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc h1:4pZI35227imm7yK2bGPcfpFEmuY1gc2YSTShr4iJBfs=
+github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc/go.mod h1:X4/0JoqgTIPSFcRA/P6INZzIuyqdFY5rm8tb41s9okk=
+github.com/charmbracelet/lipgloss v1.1.0 h1:vYXsiLHVkK7fp74RkV7b2kq9+zDLoEU4MZoFqR/noCY=
+github.com/charmbracelet/lipgloss v1.1.0/go.mod h1:/6Q8FR2o+kj8rz4Dq0zQc3vYf7X+B0binUUBwA0aL30=
+github.com/charmbracelet/log v0.4.2 h1:hYt8Qj6a8yLnvR+h7MwsJv/XvmBJXiueUcI3cIxsyig=
+github.com/charmbracelet/log v0.4.2/go.mod h1:qifHGX/tc7eluv2R6pWIpyHDDrrb/AG71Pf2ysQu5nw=
+github.com/charmbracelet/x/ansi v0.8.0 h1:9GTq3xq9caJW8ZrBTe0LIe2fvfLR/bYXKTx2llXn7xE=
+github.com/charmbracelet/x/ansi v0.8.0/go.mod h1:wdYl/ONOLHLIVmQaxbIYEC/cRKOQyjTkowiI4blgS9Q=
+github.com/charmbracelet/x/cellbuf v0.0.13-0.20250311204145-2c3ea96c31dd h1:vy0GVL4jeHEwG5YOXDmi86oYw2yuYUGqz6a8sLwg0X8=
+github.com/charmbracelet/x/cellbuf v0.0.13-0.20250311204145-2c3ea96c31dd/go.mod h1:xe0nKWGd3eJgtqZRaN9RjMtK7xUYchjzPr7q6kcvCCs=
+github.com/charmbracelet/x/term v0.2.1 h1:AQeHeLZ1OqSXhrAWpYUtZyX1T3zVxfpZuEQMIQaGIAQ=
+github.com/charmbracelet/x/term v0.2.1/go.mod h1:oQ4enTYFV7QN4m0i9mzHrViD7TQKvNEEkHUMCmsxdUg=
+github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
+github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/go-logfmt/logfmt v0.6.0 h1:wGYYu3uicYdqXVgoYbvnkrPVXkuLM1p1ifugDMEdRi4=
+github.com/go-logfmt/logfmt v0.6.0/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs=
+github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=
+github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
+github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
+github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
+github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc=
+github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
+github.com/muesli/termenv v0.16.0 h1:S5AlUN9dENB57rsbnkPyfdGuWIlkmzJjbFf0Tf5FWUc=
+github.com/muesli/termenv v0.16.0/go.mod h1:ZRfOIKPFDYQoDFF4Olj7/QJbW60Ol/kL1pU3VfY/Cnk=
+github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
+github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
+github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
+github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
+github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
+github.com/saran13raj/go-pixels v0.0.0-20250629121333-58b240a3ae51 h1:H/XUfYcLxI3CBmDlgBpnOeTntRgqWvIoUXnqhCF5a0s=
+github.com/saran13raj/go-pixels v0.0.0-20250629121333-58b240a3ae51/go.mod h1:sqhdZVLvqzTEBtmZBuTnFDUW0Lsryw2X2/wrLgqLEYg=
+github.com/spf13/pflag v1.0.10 h1:4EBh2KAYBwaONj6b2Ye1GiHfwjqyROoF4RwYO+vPwFk=
+github.com/spf13/pflag v1.0.10/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
+github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
+github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
+github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavMF/ppJZNG9ZpyihvCd0w101no=
+github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e/go.mod h1:RbqR21r5mrJuqunuUZ/Dhy/avygyECGrLceyNeo4LiM=
+golang.org/x/exp v0.0.0-20231006140011-7918f672742d h1:jtJma62tbqLibJ5sFQz8bKtEM8rJBtfilJ2qTU199MI=
+golang.org/x/exp v0.0.0-20231006140011-7918f672742d/go.mod h1:ldy0pHrwJyGW56pPQzzkH36rKxoZW1tw7ZJpeKx+hdo=
+golang.org/x/image v0.28.0 h1:gdem5JW1OLS4FbkWgLO+7ZeFzYtL3xClb97GaUzYMFE=
+golang.org/x/image v0.28.0/go.mod h1:GUJYXtnGKEUgggyzh+Vxt+AviiCcyiwpsl8iQ8MvwGY=
+golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc=
+golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
+gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
+gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
diff --git a/main.go b/main.go
new file mode 100644
index 0000000..645f21b
--- /dev/null
+++ b/main.go
@@ -0,0 +1,109 @@
+package gravatar_recon
+
+import (
+ "crypto/md5"
+ "encoding/hex"
+ "encoding/json"
+ "fmt"
+ "io"
+ "net/http"
+ "strings"
+)
+
+type GravatarProfile struct {
+ Hash string `json:"hash"`
+ ProfileURL string `json:"profileUrl"`
+ PreferredUser string `json:"preferredUsername"`
+ ThumbnailURL string `json:"thumbnailUrl"`
+
+ Photos []struct {
+ Value string `json:"value"`
+ Type string `json:"type"`
+ } `json:"photos"`
+
+ DisplayName string `json:"displayName"`
+ Pronunciation string `json:"pronunciation"`
+ Pronouns string `json:"pronouns"`
+ AboutMe string `json:"aboutMe"`
+ CurrentLocation string `json:"currentLocation"`
+ JobTitle string `json:"job_title"`
+ Company string `json:"company"`
+
+ PhoneNumbers []struct {
+ Type string `json:"type"`
+ Value string `json:"value"`
+ } `json:"phoneNumbers"`
+
+ ContactInfo []struct {
+ Type string `json:"type"`
+ Value string `json:"value"`
+ } `json:"contactInfo"`
+
+ Emails []struct {
+ Primary string `json:"primary"`
+ Value string `json:"value"`
+ } `json:"emails"`
+
+ Accounts []struct {
+ Domain string `json:"domain"`
+ Display string `json:"display"`
+ URL string `json:"url"`
+ IconURL string `json:"iconUrl"`
+ IsHidden bool `json:"is_hidden"`
+ Username string `json:"username"`
+ Verified bool `json:"verified"`
+ Name string `json:"name"`
+ Shortname string `json:"shortname"`
+ } `json:"accounts"`
+
+ ProfileBackground struct {
+ Color string `json:"color"`
+ Opacity float64 `json:"opacity"`
+ Size int `json:"size"`
+ PrimaryColor string `json:"primary_color"`
+ SurfaceColor string `json:"surface_color"`
+ } `json:"profileBackground"`
+}
+
+type gravatarResponse struct {
+ Entry []GravatarProfile `json:"entry"`
+}
+
+func md5Hash(email string) string {
+ email = strings.ToLower(strings.TrimSpace(email))
+ hash := md5.Sum([]byte(email))
+ return hex.EncodeToString(hash[:])
+}
+
+func GetGravatarProfiles(email string) (*[]GravatarProfile, error) {
+ hash := md5Hash(email)
+ url := fmt.Sprintf("https://www.gravatar.com/%s.json", hash)
+
+ req, err := http.NewRequest("GET", url, nil)
+ if err != nil {
+ return nil, err
+ }
+ req.Header.Set("User-Agent", "Go-OSINT-Client/1.0")
+
+ resp, err := http.DefaultClient.Do(req)
+ if err != nil {
+ return nil, err
+ }
+ defer resp.Body.Close()
+
+ if resp.StatusCode != 200 {
+ return nil, fmt.Errorf("no gravatar profile found (status %d)", resp.StatusCode)
+ }
+
+ body, err := io.ReadAll(resp.Body)
+ if err != nil {
+ return nil, err
+ }
+
+ var profiles gravatarResponse
+ if err := json.Unmarshal(body, &profiles); err != nil {
+ return nil, err
+ }
+
+ return &profiles.Entry, nil
+}
diff --git a/utils/print.go b/utils/print.go
new file mode 100644
index 0000000..a23454b
--- /dev/null
+++ b/utils/print.go
@@ -0,0 +1,164 @@
+package utils
+
+import (
+ "fmt"
+ "io"
+ "net/http"
+ "os"
+ "reflect"
+ "sort"
+ "strings"
+
+ "github.com/charmbracelet/lipgloss"
+ gopixels "github.com/saran13raj/go-pixels"
+)
+
+var (
+ grey = lipgloss.Color("#7d7d7d")
+ green = lipgloss.Color("#a6e3a1")
+ blue = lipgloss.Color("#7287fd")
+
+ greyStyle = lipgloss.NewStyle().Foreground(grey)
+ greenStyle = lipgloss.NewStyle().Foreground(green)
+ titleStyle = lipgloss.NewStyle().Bold(true).Foreground(blue)
+)
+
+func PrintStruct(s any, indent int) {
+ prefix := strings.Repeat(" ", indent)
+
+ v := reflect.ValueOf(s)
+ if !v.IsValid() {
+ return
+ }
+ t := reflect.TypeOf(s)
+
+ for v.Kind() == reflect.Ptr || v.Kind() == reflect.Interface {
+ if v.IsNil() {
+ return
+ }
+ v = v.Elem()
+ t = v.Type()
+ }
+
+ switch v.Kind() {
+ case reflect.Struct:
+ if v.NumField() == 0 {
+ fmt.Println(prefix + greyStyle.Render("No data found"))
+ fmt.Println("")
+ return
+ }
+
+ printed := 0
+ for i := 0; i < v.NumField(); i++ {
+ field := t.Field(i).Name
+ value := v.Field(i)
+ if !value.CanInterface() {
+ continue
+ }
+ if !value.IsValid() || (value.Kind() == reflect.String && value.String() == "") {
+ continue
+ }
+ if value.Kind() == reflect.String && value.String() == "0001-01-01 00:00:00 +0000 UTC" {
+ continue
+ }
+ printed++
+
+ switch value.Kind() {
+ case reflect.Struct, reflect.Slice, reflect.Array, reflect.Ptr, reflect.Map, reflect.Interface:
+ fmt.Println(prefix + greyStyle.Render(field+":"))
+ PrintStruct(value.Interface(), indent+1)
+
+ case reflect.String:
+ fmt.Printf("%s%s %s\n", prefix, greyStyle.Render(field+":"), greenStyle.Render(fmt.Sprintf("%q", value.Interface())))
+
+ default:
+ fmt.Printf("%s%s %s\n", prefix, greyStyle.Render(field+":"), greenStyle.Render(fmt.Sprintf("%v", value.Interface())))
+ }
+ }
+ if printed == 0 {
+ fmt.Println(prefix + greyStyle.Render("No data found"))
+ }
+ fmt.Println("")
+
+ case reflect.Slice, reflect.Array:
+ if v.Len() == 0 {
+ fmt.Println(prefix + greyStyle.Render("No data found"))
+ fmt.Println("")
+ return
+ }
+ for i := 0; i < v.Len(); i++ {
+ PrintStruct(v.Index(i).Interface(), indent)
+ }
+
+ case reflect.Map:
+ if v.Len() == 0 {
+ fmt.Println(prefix + greyStyle.Render("No data found"))
+ return
+ }
+
+ keys := v.MapKeys()
+ keyStrs := make([]string, len(keys))
+ for i, k := range keys {
+ keyStrs[i] = fmt.Sprintf("%v", k.Interface())
+ }
+ sort.Strings(keyStrs)
+
+ for _, keyStr := range keyStrs {
+ for _, k := range keys {
+ if fmt.Sprintf("%v", k.Interface()) == keyStr {
+ val := v.MapIndex(k)
+ fmt.Println(prefix + greyStyle.Render(fmt.Sprintf("%v:", k.Interface())))
+ PrintStruct(val.Interface(), indent+1)
+ }
+ }
+ }
+
+ default:
+ fmt.Println(prefix + greenStyle.Render(fmt.Sprintf("%v", v.Interface())))
+ }
+}
+
+func Header() {
+ asciiArt := " _____ _ \n| __|___ ___ _ _ ___| |_ ___ ___ ___ ___ ___ ___ ___ ___ \n| | | _| .'| | | .'| _| .'| _|___| _| -_| _| . | |\n|_____|_| |__,|\\_/|__,|_| |__,|_| |_| |___|___|___|_|_|"
+
+ grey := lipgloss.Color("#7d7d7d")
+
+ greyStyle := lipgloss.NewStyle().Foreground(grey)
+ fmt.Println(
+ greyStyle.Render(lipgloss.JoinVertical(lipgloss.Right, asciiArt, "@anotherhadi\n")),
+ )
+}
+
+func PrintTitle(title string) {
+ fmt.Println(titleStyle.Render(title) + "\n")
+}
+
+func PrintAvatar(url string) {
+ if url == "" {
+ return
+ }
+
+ resp, err := http.Get(url)
+ if err != nil {
+ return
+ }
+ defer resp.Body.Close()
+
+ tmpfile, err := os.CreateTemp("", "avatar-*.png")
+ if err != nil {
+ return
+ }
+ defer os.Remove(tmpfile.Name())
+
+ _, err = io.Copy(tmpfile, resp.Body)
+ if err != nil {
+ return
+ }
+
+ output, err := gopixels.FromImagePath(tmpfile.Name(), 30, 25, "halfcell", true)
+
+ if err != nil {
+ return
+ }
+ fmt.Println(output + "\n")
+}