Browse Source

Thanks files; More code comments

master
parent
commit
fe56be2a04
  1. 8
      Makefile
  2. 13
      README.md
  3. 34
      src/client/main.go
  4. 15
      src/server/main.go
  5. 57
      src/server/thanks/thanks.go
  6. 12
      src/server/thanksdir/thanks01.txt
  7. 16
      src/server/thanksdir/thanks02.txt
  8. 11
      src/server/thanksdir/thanks03.txt
  9. 11
      src/server/thanksdir/thanks04.txt
  10. 12
      src/server/thanksdir/thanks05.txt

8
Makefile

@ -2,9 +2,10 @@ all: server client
mkdir -p bin mkdir -p bin
mv spolitewareServer* bin mv spolitewareServer* bin
mv spolitewareClient* bin mv spolitewareClient* bin
mv thanksdir bin
server: server:
cd src/server && go build && mv spolitewareServer ../../ cd src/server && CGO_ENABLED=0 go build && mv spolitewareServer ../../ && cp -r thanksdir ../../
client: client:
cd src/client && CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build && mv spolitewareClient ../../spolitewareClient_linux_amd64 cd src/client && CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build && mv spolitewareClient ../../spolitewareClient_linux_amd64
@ -12,9 +13,10 @@ client:
cd src/client && CGO_ENABLED=0 GOOS=windows GOARCH=386 go build && mv spolitewareClient.exe ../../spolitewareClient_windows_x32.exe cd src/client && CGO_ENABLED=0 GOOS=windows GOARCH=386 go build && mv spolitewareClient.exe ../../spolitewareClient_windows_x32.exe
cd src/client && CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build && mv spolitewareClient.exe ../../spolitewareClient_windows_amd64.exe cd src/client && CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build && mv spolitewareClient.exe ../../spolitewareClient_windows_amd64.exe
release: client release: client server
mkdir -p release/spoliteware mkdir -p release/spoliteware
cp LICENSE release/spoliteware cp LICENSE release/spoliteware
cd src/server && CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build && mv spolitewareServer ../../release/spoliteware mv spolitewareServer release/spoliteware
mv thanksdir release/spoliteware
mv spolitewareClient* release/spoliteware mv spolitewareClient* release/spoliteware
cd release && zip -r spoliteware spoliteware cd release && zip -r spoliteware spoliteware

13
README.md

@ -1,9 +1,19 @@
# Spoliteware - a polite and considerate spyware # Spoliteware - a polite and considerate spyware
A spyware that asks permission to collect data beforehand. A polite spyware that asks permission to collect data beforehand.
## Features ## Features
### v0.1.1
### Client
- Display thanks message from the server
### Server
- Thanks system and thanksfiles
### v0.1.0
### Client ### Client
- System information - System information
@ -12,7 +22,6 @@ A spyware that asks permission to collect data beforehand.
- TLS support - TLS support
## TODO ## TODO
- Give some sort of "reward" for permitting to scan client's machine
- More green telemetry options - More green telemetry options
- Be more open on what the program does - Be more open on what the program does

34
src/client/main.go

@ -18,6 +18,7 @@ import (
"encoding/json" "encoding/json"
"flag" "flag"
"fmt" "fmt"
"io"
"net/http" "net/http"
"os" "os"
"path/filepath" "path/filepath"
@ -27,7 +28,7 @@ import (
) )
const ( const (
Version string = "client v0.1.0" Version string = "client v0.1.1"
) )
var ( var (
@ -35,21 +36,25 @@ var (
serverAddr *string = flag.String("server", "http://localhost:13370/", "Set scheme://addr:port for receiving server") serverAddr *string = flag.String("server", "http://localhost:13370/", "Set scheme://addr:port for receiving server")
) )
// The structure of the generalised per computer data that is identical to the server's
// representation
type Data struct { type Data struct {
Hostname string `json:"hostname"` Hostname string `json:"hostname"`
Username string `json:"username"` Username string `json:"username"`
System map[string]string `json:"system"` System map[string]string `json:"system"`
} }
// Prints notification on the state of things
func greeting() { func greeting() {
fmt.Printf( fmt.Printf(
`I'm sorry to inform you, but you've (intentionally or not) launched a spyware on your machine ! `I'm sorry to inform you, but you've (intentionally or not) launched a spyware on your machine!
But rest assured, I will do no harm to your computer and am to withdraw if you would wish so. But rest assured, I will do no harm to your computer and am to withdraw if you would wish so.
No data will be collected and sent without your permission. No data will be collected and sent without your permission.
`) `)
} }
// Asks for permission to collect all kinds of data on the machine
func askForAllPerms() bool { func askForAllPerms() bool {
fmt.Printf(`Would you grant me a permission to [system information; files lookup; ] fmt.Printf(`Would you grant me a permission to [system information; files lookup; ]
(If no -> (optional) specify separate permissions afterwards) y/N: `) (If no -> (optional) specify separate permissions afterwards) y/N: `)
@ -65,6 +70,7 @@ func askForAllPerms() bool {
} }
} }
// Asks for permission to collect system information
func askForSystemInfo() bool { func askForSystemInfo() bool {
fmt.Printf("\nWould you allow me to look around and collect some information about your computer ? [y/N]: ") fmt.Printf("\nWould you allow me to look around and collect some information about your computer ? [y/N]: ")
var input string = "n" var input string = "n"
@ -80,6 +86,7 @@ func askForSystemInfo() bool {
} }
} }
// Asks whether a local copy of the whole collected data is needed
func localCopyNeeded() bool { func localCopyNeeded() bool {
fmt.Printf("\nDo you want to save a local copy as well ? [y/N]: ") fmt.Printf("\nDo you want to save a local copy as well ? [y/N]: ")
var input string = "n" var input string = "n"
@ -113,6 +120,7 @@ func main() {
var data Data var data Data
data.System = nil data.System = nil
// Greet and ask for permissions
greeting() greeting()
if askForAllPerms() { if askForAllPerms() {
data.System = osutil.GetSystemInfo() data.System = osutil.GetSystemInfo()
@ -123,6 +131,7 @@ func main() {
} }
if data.System == nil { if data.System == nil {
// NOTICE! add new checks for new fields when they're added
fmt.Printf("\nNothing to send. Bailing out\n") fmt.Printf("\nNothing to send. Bailing out\n")
return return
} }
@ -135,24 +144,26 @@ func main() {
return return
} }
// Try to send collected information to the server
postBody := bytes.NewBuffer(dataJson) postBody := bytes.NewBuffer(dataJson)
var retries uint8 = 0 var retries uint8 = 0
var response *http.Response
for { for {
if retries == 5 { if retries == 5 {
fmt.Printf("\nFailed to send data\n") fmt.Printf("\nFailed to send data\n")
return return
} }
response, err := http.Post(*serverAddr, "application/json", postBody) response, err = http.Post(*serverAddr, "application/json", postBody)
if err != nil || response == nil { if err != nil || response == nil {
// try to resend // Try to resend
time.Sleep(time.Second * 5) time.Sleep(time.Second * 5)
retries++ retries++
continue continue
} }
if response.StatusCode != http.StatusOK { if response.StatusCode != http.StatusOK {
// try to resend // Try to resend
time.Sleep(time.Second * 5) time.Sleep(time.Second * 5)
retries++ retries++
continue continue
@ -160,8 +171,18 @@ func main() {
break break
} }
fmt.Printf("\nSuccesfully sent data. Thank you !\n") // Successfully sent
fmt.Printf("\nSuccesfully sent data\n")
// Print thanks from the server
defer response.Body.Close()
thanks, err := io.ReadAll(response.Body)
if err != nil {
fmt.Printf("\nFailed to read thanks message from the server. Better luck next time. Thank you !\n")
}
fmt.Printf("\n%s\n", thanks)
// Create local copy if needed
if localCopyNeeded() { if localCopyNeeded() {
wdir, err := os.Getwd() wdir, err := os.Getwd()
if err != nil { if err != nil {
@ -182,6 +203,7 @@ func main() {
fmt.Printf("Saved to %s\n", copyPath) fmt.Printf("Saved to %s\n", copyPath)
} }
// Don't close the console window for windows users
if runtime.GOOS == "windows" { if runtime.GOOS == "windows" {
fmt.Scanln() fmt.Scanln()
} }

15
src/server/main.go

@ -13,6 +13,7 @@ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR I
package main package main
import ( import (
"Unbewohnte/spolitewareServer/thanks"
"encoding/json" "encoding/json"
"flag" "flag"
"fmt" "fmt"
@ -31,7 +32,7 @@ type Data struct {
System map[string]string `json:"system"` System map[string]string `json:"system"`
} }
const Version string = "server v0.1.0" const Version string = "server v0.1.1"
var ( var (
version *bool = flag.Bool("version", false, "Print version information and exit") version *bool = flag.Bool("version", false, "Print version information and exit")
@ -39,6 +40,7 @@ var (
keyFile *string = flag.String("key", "", "SSL private key file path") keyFile *string = flag.String("key", "", "SSL private key file path")
certFile *string = flag.String("cert", "", "SSL certificate file path") certFile *string = flag.String("cert", "", "SSL certificate file path")
verbose *bool = flag.Bool("verbose", false, "Print user data-centric messages or not") verbose *bool = flag.Bool("verbose", false, "Print user data-centric messages or not")
thanksdirName *string = flag.String("thanksdirname", "thanksdir", "Select the NAME of the thanks directory with thanks files")
) )
func main() { func main() {
@ -72,6 +74,8 @@ func main() {
return return
} }
thanksdir := filepath.Join(filepath.Dir(executablePath), *thanksdirName)
mux := http.NewServeMux() mux := http.NewServeMux()
mux.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) { mux.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) {
if *keyFile != "" && *certFile != "" { if *keyFile != "" && *certFile != "" {
@ -147,7 +151,14 @@ func main() {
return return
} }
w.WriteHeader(http.StatusOK) // Send thanks
thanksStr, err := thanks.GetRandom(thanksdir)
if err != nil {
w.Write([]byte(thanks.Default()))
} else {
w.Write([]byte(thanksStr))
}
if *verbose { if *verbose {
fmt.Printf("[INFO] Received data from %s_%s_%s\n", clientData.Hostname, clientData.Username, ip) fmt.Printf("[INFO] Received data from %s_%s_%s\n", clientData.Hostname, clientData.Username, ip)
} }

57
src/server/thanks/thanks.go

@ -0,0 +1,57 @@
package thanks
import (
"io"
"math/rand"
"os"
"path/filepath"
)
// Default thanks
func Default() string {
return `
Thank you !
`
}
// Fetches random thanks file from thanksdir
func GetRandom(thanksdir string) (string, error) {
entries, err := os.ReadDir(thanksdir)
if err != nil {
return Default(), err
}
fileIndex := rand.Intn(len(entries))
entryInfo, err := entries[fileIndex].Info()
if err != nil {
return Default(), err
}
if entryInfo.IsDir() {
return Default(), nil
}
thanksfile, err := os.Open(filepath.Join(thanksdir, entryInfo.Name()))
if err != nil {
return Default(), err
}
defer thanksfile.Close()
thanks, err := io.ReadAll(thanksfile)
if err != nil {
return Default(), err
}
return string(thanks), nil
}

12
src/server/thanksdir/thanks01.txt

@ -0,0 +1,12 @@
Thank you! Have a nice day!
⠀⠀⠀⠀⠀⠀⠀⢰⠒⠒⠒⠒⠒⠒⢲⡖⣶⣶⡆⠀⠀⠀⠀⠀⠀⠀
⠀⠀⢀⡀⣯⠉⠉⠉⣖⣲⣶⡆⠀⠀⠈⠉⠉⠉⠉⠉⠉⢱⠀⠀⠀⠀
⢀⣀⣸⠀⠀⠀⠀⠀⠈⠉⠉⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣇⣀⡀
⢸⣿⣀⣀⡀⠀⠿⠿⠀⠀⠀⣸⣙⣿⣿⠀⢸⣿⠀⠀⠀⠀⠀⠀⢰⡇
⢸⡿⠾⠿⠟⠀⠀⠀⣤⡄⠀⠸⠿⠿⠟⠀⠸⠿⠀⠀⠀⣠⣤⠀⢸⡇
⢸⡃⠀⠀⠀⠀⠀⠀⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⠛⠀⢸⡇
⢸⣖⠀⠀⠀⠀⠀⠀⠙⠋⠀⢴⣶⣶⣶⠀⠀⠀⣶⣶⠀⠀⠀⠀⢸⡇
⢸⣿⣶⠀⠀⠀⣶⣶⠀⠀⠀⠈⠉⠉⠉⠀⠀⠀⠉⠉⠀⠀⠀⣷⣾⡇
⠈⠉⢹⣿⣿⣀⣀⣠⠀⠀⠀⠀⠀⠀⠸⣿⡇⠀⣀⣀⣀⣿⣿⡏⠉⠁
⠀⠀⠀⠀⢿⠿⠿⢿⣀⣀⣀⣀⣠⣤⣤⣤⣤⣤⣿⠿⠿⡿⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠸⠿⠿⠿⠿⠿⣿⣿⣿⣿⠿⠇⠀⠀⠀⠀⠀⠀⠀

16
src/server/thanksdir/thanks02.txt

@ -0,0 +1,16 @@
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⡴⠚⣉⡙⠲⠦⠤⠤⣤⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⢀⣴⠛⠉⠉⠀⣾⣷⣿⡆⠀⠀⠀⠐⠛⠿⢟⡲⢦⡀⠀⠀⠀⠀
⠀⠀⠀⠀⣠⢞⣭⠎⠀⠀⠀⠀⠘⠛⠛⠀⠀⢀⡀⠀⠀⠀⠀⠈⠓⠿⣄⠀⠀⠀
⠀⠀⠀⡜⣱⠋⠀⠀⣠⣤⢄⠀⠀⠀⠀⠀⠀⣿⡟⣆⠀⠀⠀⠀⠀⠀⠻⢷⡄⠀
⠀⢀⣜⠜⠁⠀⠀⠀⢿⣿⣷⣵⠀⠀⠀⠀⠀⠿⠿⠿⠀⠀⣴⣶⣦⡀⠀⠰⣹⡆
⢀⡞⠆⠀⣀⡀⠀⠀⠘⠛⠉⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢿⣿⣶⠇⠀⢠⢻⡇
⢸⠃⠘⣾⣏⡇⠀⠀⠀⠀⠀⠀⠀⡀⠀⠀⠀⠀⠀⠀⣠⣤⣤⡉⠁⠀⠀⠈⠫⣧
⡸⡄⠀⠘⠟⠀⠀⠀⠀⠀⠀⣰⣿⣟⢧⠀⠀⠀⠀⠰⡿⣿⣿⢿⠀⠀⣰⣷⢡⢸
⣿⡇⠀⠀⠀⣰⣿⡻⡆⠀⠀⠻⣿⣿⣟⠀⠀⠀⠀⠀⠉⠉⠉⠀⠀⠘⢿⡿⣸⡞
⠹⣽⣤⣤⣤⣹⣿⡿⠇⠀⠀⠀⠀⠉⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡔⣽⠀
⠀⠙⢻⡙⠟⣹⠟⢷⣶⣄⢀⣴⣶⣄⠀⠀⠀⠀⠀⢀⣤⡦⣄⠀⠀⢠⣾⢸⠏⠀
⠀⠀⠘⠀⠀⠀⠀⠀⠈⢷⢼⣿⡿⡽⠀⠀⠀⠀⠀⠸⣿⣿⣾⠀⣼⡿⣣⠟⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⢠⡾⣆⠑⠋⠀⢀⣀⠀⠀⠀⠀⠈⠈⢁⣴⢫⡿⠁⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠈⠙⣧⣄⡄⠴⣿⣶⣿⢀⣤⠶⣞⣋⣩⣵⠏⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⢺⣿⢯⣭⣭⣯⣯⣥⡵⠿⠟⠛⠉⠉⠀⠀⠀⠀⠀⠀⠀
Thank you! You are the tallest when you first wake up.

11
src/server/thanksdir/thanks03.txt

@ -0,0 +1,11 @@
⠀⠀⠀⣖⠲⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⠉⡇⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠸⡆⠹⡀⣠⢤⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡏⠀⡧⢤⡄⠀⠀⠀⠀⠀
⠀⠀⠀⠀⡧⢄⣹⣅⣜⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⠁⠀⢹⠚⠃⠀⠀⠀⠀⠀
⠀⣀⠴⢒⣉⡹⣶⣤⣀⡉⠉⠒⠒⠒⠤⠤⣀⣀⣀⠇⠀⠀⢸⠠⣄⠀⠀⠀⠀⠀
⠀⠈⠉⠁⠀⠀⠀⠉⠒⠯⣟⣲⠦⣤⣀⡀⠀⠀⠈⠉⠉⠉⠛⠒⠻⢥⣀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠙⣲⡬⠭⠿⢷⣦⣤⢄⣀⠀⠀⠚⠛⠛⠓⢦⡀
⠀⠀⠀⠀⠀⠀⠀⢀⣀⠤⠴⠚⠉⠁⠀⠀⠀⠀⣀⣉⡽⣕⣯⡉⠉⠉⠑⢒⣒⡾
⠀⠀⣀⡠⠴⠒⠉⠉⠀⢀⣀⣀⠤⡤⢶⣶⣋⠉⠉⠀⠀⠀⠈⠉⠉⠉⠉⠉⠁⠀
⣖⣉⣁⣠⠤⠶⡶⡶⢍⡉⠀⠀⠀⠙⠒⠯⠜⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠁⠀⠀⠀⠀⠑⢦⣯⠇
Thank you! 2 is the only even prime number.

11
src/server/thanksdir/thanks04.txt

@ -0,0 +1,11 @@
Thank you! Wikipedia is downloadable.
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⠄⠒⡢⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⡀⣠⡀⠀⠀⢰⡣⢀⠀⡃⢀⠀
⠀⠀⢀⡾⢇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⠔⡡⠒⣒⠫⣆⣈⣴⡡⠁⠹⠓⠐⠂
⠀⠀⢸⠀⡞⠀⠀⠀⡀⠀⠀⠀⠀⠀⣄⡈⢎⠀⠻⠃⠈⡇⠊⠉⠔⠁⠀⠀⠀⠀
⠀⠀⣠⡿⠇⠒⣒⣒⣏⡤⢤⣀⠀⠀⢁⡿⡌⠄⠀⠀⣴⠇⠈⠀⠁⠀⠀⠀⠀⠀
⠀⣾⠋⣡⣈⠄⠀⠚⠃⠩⢹⢛⠨⠟⠇⠠⡐⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠸⡇⣾⠙⡟⣿⠀⠀⠀⠘⠛⠨⠀⡃⠀⠘⡹⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠱⢌⣂⡧⠏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠟⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⣀⡀⢡⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠈⢻⠥⠌⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀

12
src/server/thanksdir/thanks05.txt

@ -0,0 +1,12 @@
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⠳⢶⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⣤⣤⣤⣤⡿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠸⣯⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠛⠂⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⢸⣛⣟⣻⣟⣻⣟⣻⣟⣻⣛⣿⣛⣿⣛⣿⣟⣛⣛⣻⣿⣿⣟⣛⣻⡇⠀⠀
⠀⠀⢸⣉⣹⣏⣹⣏⣹⣏⣻⣋⣿⣉⣿⣉⣿⣙⣟⣉⣹⣏⣹⣏⣹⣏⣻⡇⠀⠀
⠀⠀⢸⣹⣏⣹⣏⣹⣏⣹⣏⣿⣉⣿⣉⣿⣉⣿⠈⡿⢿⣏⣹⣏⣹⣏⣿⡇⠀⠀
⠀⠀⢸⣉⣹⣏⣹⣏⣹⣏⣽⣍⣿⣉⣿⣉⣿⣏⣠⣷⣾⣏⣹⣏⣹⣏⣽⡇⠀⠀
⠀⠀⢸⣭⣯⣽⣯⣭⣭⣭⣭⣭⣭⣭⣭⣿⣭⣿⣭⣯⣽⣯⣭⣭⣽⣯⣽⡇⠀⠀
Thank you! Crazy how people made sand to do math
Loading…
Cancel
Save