-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
200 lines (167 loc) · 4.48 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
package main
import (
"Totem/vscoservice"
"errors"
"fmt"
"net/http"
"os"
"strconv"
"github.com/spf13/cobra"
"gopkg.in/yaml.v3"
)
var (
httpClient = http.DefaultClient
home, _ = os.UserHomeDir()
desktop = home + "/Desktop"
totemPath = desktop + "/Totem"
trackingFile = totemPath + "/Tracking.yaml"
)
var (
rootCMD = &cobra.Command{
Use: "totem",
Short: "Multi-user OSINT Tool",
Run: func(cmd *cobra.Command, args []string) {},
}
)
func main() {
// Create /Totem if it does not exist
if _, err := os.Stat(totemPath); errors.Is(err, os.ErrNotExist) {
err := os.Mkdir(totemPath, os.ModePerm)
if err != nil {
panic(err)
}
}
os.Chdir(totemPath)
trackingProfiles := deserializeTrackingProfiles()
runCMD := &cobra.Command{
Use: "run",
Short: "Runs all active profiles, or runs profiles selected.",
Args: cobra.ArbitraryArgs,
Run: func(cmd *cobra.Command, args []string) {
if len(args) == 0 {
runAllActiveTrackingProfiles(trackingProfiles)
} else {
for _, a := range args {
runTrackingProfile(a, trackingProfiles)
}
}
},
}
printCMD := &cobra.Command{
Use: "print",
Short: "Prints out all profiles",
Run: func(cmd *cobra.Command, args []string) {
printTrackingProfiles(trackingProfiles)
},
}
bioCMD := &cobra.Command{
Use: "bio",
Short: "Prints out a profile's bios",
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
getBioInfoForTrackingProfile(args[0], trackingProfiles)
},
}
rootCMD.AddCommand(runCMD)
rootCMD.AddCommand(printCMD)
rootCMD.AddCommand(bioCMD)
Execute()
serializeTrackingProfiles(&trackingProfiles)
}
func Execute() {
if err := rootCMD.Execute(); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
}
func runAllActiveTrackingProfiles(trackingProfiles []vscoservice.VSCOTrackingProfile) {
for i := range trackingProfiles {
if trackingProfiles[i].Active {
getUser(&trackingProfiles[i])
}
}
}
func runTrackingProfile(targetName string, trackingProfiles []vscoservice.VSCOTrackingProfile) {
for i := range trackingProfiles {
if trackingProfiles[i].TargetName == targetName {
getUser(&trackingProfiles[i])
}
}
}
func getBioInfoForTrackingProfile(targetName string, trackingProfiles []vscoservice.VSCOTrackingProfile) {
// For each account, print out the bio history
for i := range trackingProfiles {
if trackingProfiles[i].TargetName == targetName {
userpath := totemPath + "/" + trackingProfiles[i].TargetName
for k := range trackingProfiles[i].Accounts {
accountPath := userpath + "/" + trackingProfiles[i].Accounts[k].Username
os.Chdir(accountPath)
service := vscoservice.New(&trackingProfiles[i].Accounts[k], userpath)
service.PrintBio(false)
os.Chdir("..")
}
}
}
}
func printTrackingProfiles(trackingProfiles []vscoservice.VSCOTrackingProfile) {
for _, tp := range trackingProfiles {
fmt.Println("--------" + tp.TargetName + "--------")
fmt.Println("Active:", tp.Active)
fmt.Println("Accounts:")
for _, a := range tp.Accounts {
fmt.Println(" +", a.Username, "("+strconv.Itoa(a.UserID)+")")
}
}
}
func deserializeTrackingProfiles() []vscoservice.VSCOTrackingProfile {
var trackingProfiles []vscoservice.VSCOTrackingProfile
if _, err := os.Stat(trackingFile); errors.Is(err, os.ErrNotExist) {
return nil
}
bytes, err := os.ReadFile(trackingFile)
if err != nil {
panic(err)
}
err = yaml.Unmarshal(bytes, &trackingProfiles)
if err != nil {
panic(err)
}
return trackingProfiles
}
func serializeTrackingProfiles(profiles *[]vscoservice.VSCOTrackingProfile) {
bytes, err := yaml.Marshal(profiles)
if err != nil {
panic(err)
}
err = os.WriteFile(trackingFile, bytes, os.ModePerm)
if err != nil {
panic(err)
}
}
// Runs vscoservice on a TrackingProfile & all of it's accounts
func getUser(tp *vscoservice.VSCOTrackingProfile) {
userpath := totemPath + "/" + tp.TargetName
if _, err := os.Stat(userpath); errors.Is(err, os.ErrNotExist) {
err := os.Mkdir(userpath, os.ModePerm)
if err != nil {
panic(err)
}
}
os.Chdir(userpath)
for i, a := range tp.Accounts {
accountPath := userpath + "/" + a.Username
if _, err := os.Stat(accountPath); errors.Is(err, os.ErrNotExist) {
err := os.Mkdir(accountPath, os.ModePerm)
if err != nil {
panic(err)
}
}
os.Chdir(accountPath)
service := vscoservice.New(&tp.Accounts[i], userpath)
service.CheckBio()
service.CheckProfileImage()
service.CheckGalleryMedia()
service.CheckCollectionMedia()
os.Chdir("..")
}
}