Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var CommandName string = "OpenRansim"
View Source
var CryptCmd = &cobra.Command{ Use: "crypt", Short: "Realize cryptological operations", Long: `Realize cryptological operations`, RunE: func(cmd *cobra.Command, args []string) error { key := "openransim000000" if len(args) == 2 { text, err := read_from_file(args[1]) check(err) switch args[0] { case "encrypt_aes": ciphertext := encrypt_aes(string(text), key) write_to_file(ciphertext, args[1]) case "decrypt": plaintext := decrypt(string(text), key) write_to_file(plaintext, args[1]) default: fmt.Println("You can:\nencrypt_aes\ndecrypt\nexit") } } else { fmt.Println("Two args is required.\n\tFirst: (encrypt_aes|decrypt)\n\tSecond: File path") } return nil }, }
View Source
var FilesCmd = &cobra.Command{ Use: "files", Short: "List files, write over their, update, remove...", Long: `List files, write over their, update, remove...`, RunE: func(cmd *cobra.Command, args []string) error { go create_folder("TestDirectory") go create_files("TestDirectory", 50) return nil }, }
View Source
var InsideCryptoCmd = &cobra.Command{ Use: "inside-crypto", Short: "Encrypt the data and overwrite the original files", Long: `Encrypt the data and overwrite the original files`, PreRun: func(cmd *cobra.Command, args []string) { create_folder(inside_folder) create_files(inside_folder, num_files) inside_key = generate_rsa_key() }, RunE: func(cmd *cobra.Command, args []string) error { files := get_files(inside_folder) for _, file := range files { file_name := fmt.Sprintf(pwd+"/%s/%s", inside_folder, file.Name()) text, err := read_from_file(file_name) check(err) ciphertext := encrypt_aes(string(text), inside_key) write_to_file(ciphertext, file_name) } return nil }, PostRun: func(cmd *cobra.Command, args []string) { files := get_files(inside_folder) if len(files) == num_files { fmt.Println("Vulnerable!!!") } else { fmt.Println("Passed :)") } remove_all(fmt.Sprintf(pwd+"/%s", inside_folder)) }, }
View Source
var LockyCmd = &cobra.Command{ Use: "locky", Short: "It simulates one of the countless variables of ransomware Locky", Long: `It simulates one of the countless variables of ransomware Thor`, PreRun: func(cmd *cobra.Command, args []string) { create_folder(locky_folder) create_files(locky_folder, num_files) locky_key = generate_rsa_key() }, RunE: func(cmd *cobra.Command, args []string) error { files := get_files(locky_folder) for _, file := range files { file_path := fmt.Sprintf(pwd+"/%s/%s", locky_folder, file.Name()) text, err := read_from_file(file_path) check(err) ciphertext := encrypt_aes(string(text), locky_key) write_to_file(ciphertext, fmt.Sprintf(pwd+"/%s/%s.locky", locky_folder, generate_key())) remove(file_path) } return nil }, PostRun: func(cmd *cobra.Command, args []string) { files := get_files(locky_folder) if len(files) == num_files*2 { fmt.Println("Vulnerable!!!") } else { fmt.Println("Passed :)") } for _, file := range files { file_path := fmt.Sprintf(pwd+"/%s/%s", locky_folder, file.Name()) remove(file_path) } remove_all(fmt.Sprintf(pwd+"/%s", locky_folder)) }, }
View Source
var MoverCmd = &cobra.Command{ Use: "mover", Short: "Encrypts the data in a different folder than the original one and deletes the original", Long: `Encrypts the data in a different folder than the original one and deletes the original`, PreRun: func(cmd *cobra.Command, args []string) { create_folder(mover_folder) create_folder(new_mover_folder) create_files(mover_folder, num_files) mover_key = generate_rsa_key() }, RunE: func(cmd *cobra.Command, args []string) error { files := get_files(mover_folder) for _, file := range files { file_name := fmt.Sprintf(pwd+"/%s/%s", mover_folder, file.Name()) text, err := read_from_file(file_name) check(err) ciphertext := encrypt_aes(string(text), mover_key) new_file_name := fmt.Sprintf(pwd+"/%s/%s", new_mover_folder, file.Name()) write_to_file(ciphertext, new_file_name) remove(file_name) } remove(fmt.Sprintf(pwd+"/%s", mover_folder)) return nil }, PostRun: func(cmd *cobra.Command, args []string) { files := get_files(new_mover_folder) if len(files) == num_files { fmt.Println("Vulnerable!!!") } else { fmt.Println("Passed :)") } remove_all(fmt.Sprintf(pwd+"/%s", new_mover_folder)) remove_all(fmt.Sprintf(pwd+"/%s", mover_folder)) }, }
View Source
var NetworkCmd = &cobra.Command{ Use: "crypt", Short: "Realize networking operations", Long: `Realize networking operations`, RunE: func(cmd *cobra.Command, args []string) error { return nil }, }
View Source
var ReplacerCmd = &cobra.Command{ Use: "replacer", Short: "Replace the contents of the original files", Long: `Replace the contents of the original files`, PreRun: func(cmd *cobra.Command, args []string) { create_folder(replacer_folder) create_files(replacer_folder, num_files) }, RunE: func(cmd *cobra.Command, args []string) error { files := get_files(replacer_folder) for _, file := range files { file_name := fmt.Sprintf(pwd+"/%s/%s", replacer_folder, file.Name()) i, err := strconv.Atoi(file.Name()) check(err) write_to_file(rand_string(i*42), file_name) } return nil }, PostRun: func(cmd *cobra.Command, args []string) { files := get_files(replacer_folder) if len(files) == num_files { fmt.Println("Vulnerable!!!") } else { fmt.Println("Passed :)") } remove_all(fmt.Sprintf(pwd+"/%s", replacer_folder)) }, }
View Source
var RootCmd = &cobra.Command{
Short: "CLI for testing your Ransomware protection",
Long: `CLI for testing your Ransomware protection`,
}
RootCmd represents the base command when called without any subcommands
View Source
var StartCmd = &cobra.Command{ Use: "start", Short: "Prepare workspace", Long: `Prepare workspace`, RunE: func(cmd *cobra.Command, args []string) error { pwd, _ := os.Getwd() os.MkdirAll(pwd+"/TestDirectory", os.ModePerm) fmt.Println("Folder created: TestDirectory") time.Sleep(1000) fmt.Print("Creating random files ") num := 1 for ; num < 500; num++ { f, err := os.Create(fmt.Sprintf(pwd+"/TestDirectory/%d", num)) check(err) defer f.Close() _, err = f.WriteString(rand_string(num * 42)) check(err) f.Sync() fmt.Print(".") } fmt.Println("") return nil }, }
View Source
var StopCmd = &cobra.Command{ Use: "stop", Short: "Clean workspace", Long: `Clean workspace`, RunE: func(cmd *cobra.Command, args []string) error { pwd, _ := os.Getwd() d, err := os.Open(pwd + "/TestDirectory") check(err) defer d.Close() names, err := d.Readdirnames(-1) check(err) fmt.Println("Removing all files from 'TestDirectory' folder") for _, name := range names { err = os.RemoveAll(filepath.Join(pwd+"/TestDirectory", name)) if err != nil { return err } fmt.Print(".") } fmt.Println("") return nil }, }
View Source
var StreamerCmd = &cobra.Command{ Use: "streamer", Short: "Encrypts all data and groups it into a single file", Long: `Encrypts all data and groups it into a single file`, PreRun: func(cmd *cobra.Command, args []string) { create_folder(streamer_folder) create_files(streamer_folder, num_files) streamer_key = generate_rsa_key() }, RunE: func(cmd *cobra.Command, args []string) error { files := get_files(streamer_folder) var all_text string for _, file := range files { file_name := fmt.Sprintf(pwd+"/%s/%s", streamer_folder, file.Name()) text, err := read_from_file(file_name) check(err) ciphertext := encrypt_aes(string(text), streamer_key) all_text += ciphertext remove(file_name) } write_to_file(all_text, fmt.Sprintf(pwd+"/%s/streamer", streamer_folder)) return nil }, PostRun: func(cmd *cobra.Command, args []string) { files := get_files(streamer_folder) if len(files) == num_files+1 { fmt.Println("Vulnerable!!!") } else { fmt.Println("Passed :)") } remove_all(fmt.Sprintf(pwd+"/%s", streamer_folder)) }, }
View Source
var StrongCryptorCmd = &cobra.Command{ Use: "strong-cryptor", Short: "Encrypt the data and delete the originals safely", Long: `Encrypt the data and delete the originals safely`, PreRun: func(cmd *cobra.Command, args []string) { create_folder(strong_cryptor_folder) create_files(strong_cryptor_folder, num_files) strong_cryptor_key = generate_rsa_key() }, RunE: func(cmd *cobra.Command, args []string) error { files := get_files(strong_cryptor_folder) for _, file := range files { file_name := fmt.Sprintf(pwd+"/%s/%s", strong_cryptor_folder, file.Name()) text, err := read_from_file(file_name) check(err) ciphertext := encrypt_aes(string(text), strong_cryptor_key) write_to_file(ciphertext, file_name+".copy") for i := 0; i < 30; i++ { text, err := read_from_file(file_name) check(err) ciphertext := encrypt_aes(string(text), strong_cryptor_key) write_to_file(ciphertext, fmt.Sprintf("%s.%d", file_name, i)) } remove(file_name) } return nil }, PostRun: func(cmd *cobra.Command, args []string) { files := get_files(strong_cryptor_folder) if len(files) == num_files { fmt.Println("Vulnerable!!!") } else { fmt.Println("Passed :)") } remove_all(fmt.Sprintf(pwd+"/%s", strong_cryptor_folder)) }, }
View Source
var StrongCryptorFastCmd = &cobra.Command{ Use: "strong-cryptor-fast", Short: "Encrypt the data and delete the original files", Long: `Encrypt the data and delete the original files`, PreRun: func(cmd *cobra.Command, args []string) { create_folder(strong_cryptor_fast_folder) create_files(strong_cryptor_fast_folder, num_files) strong_cryptor_fast_key = generate_rsa_key() }, RunE: func(cmd *cobra.Command, args []string) error { files := get_files(strong_cryptor_fast_folder) for _, file := range files { file_name := fmt.Sprintf(pwd+"/%s/%s", strong_cryptor_fast_folder, file.Name()) text, err := read_from_file(file_name) check(err) ciphertext := encrypt_aes(string(text), strong_cryptor_fast_key) write_to_file(ciphertext, file_name+".copy") remove(file_name) } return nil }, PostRun: func(cmd *cobra.Command, args []string) { files := get_files(strong_cryptor_fast_folder) if len(files) == num_files { fmt.Println("Vulnerable!!!") } else { fmt.Println("Passed :)") } remove_all(fmt.Sprintf(pwd+"/%s", strong_cryptor_fast_folder)) }, }
View Source
var StrongCryptorNetCmd = &cobra.Command{ Use: "strong-cryptor-net", Short: "Encrypts data, clears original files and simulates an HTTP connection", Long: `Encrypts data, clears original files and simulates an HTTP connection`, PreRun: func(cmd *cobra.Command, args []string) { create_folder(strong_cryptor_net_folder) create_files(strong_cryptor_net_folder, num_files) strong_cryptor_net_key = generate_rsa_key() }, RunE: func(cmd *cobra.Command, args []string) error { files := get_files(strong_cryptor_net_folder) for _, file := range files { file_name := fmt.Sprintf(pwd+"/%s/%s", strong_cryptor_net_folder, file.Name()) text, err := read_from_file(file_name) check(err) ciphertext := encrypt_aes(string(text), strong_cryptor_net_key) write_to_file(ciphertext, file_name+".copy") remove(file_name) post(url, string(text)) } return nil }, PostRun: func(cmd *cobra.Command, args []string) { files := get_files(strong_cryptor_net_folder) if len(files) == num_files { fmt.Println("Vulnerable!!!") } else { fmt.Println("Passed :)") } remove_all(fmt.Sprintf(pwd+"/%s", strong_cryptor_net_folder)) }, }
View Source
var ThorCmd = &cobra.Command{ Use: "thor", Short: "It simulates one of the countless variables of ransomware Thor", Long: `It simulates one of the countless variables of ransomware Thor`, PreRun: func(cmd *cobra.Command, args []string) { create_folder(thor_folder) create_files(thor_folder, num_files) thor_key = generate_rsa_key() }, RunE: func(cmd *cobra.Command, args []string) error { files := get_files(thor_folder) for _, file := range files { file_path := fmt.Sprintf(pwd+"/%s/%s", thor_folder, file.Name()) text, err := read_from_file(file_path) check(err) ciphertext := encrypt_aes(string(text), thor_key) write_to_file(ciphertext, fmt.Sprintf(pwd+"/%s/%s.thor", thor_folder, file.Name())) remove(file_path) } change_wallpaper(url_wallpaper) return nil }, PostRun: func(cmd *cobra.Command, args []string) { files := get_files(thor_folder) if len(files) == num_files { fmt.Println("Vulnerable!!!") } else { fmt.Println("Passed :)") } remove_all(fmt.Sprintf(pwd+"/%s", thor_folder)) }, }
View Source
var WallpaperCmd = &cobra.Command{ Use: "wallpaper", Short: "Change the wallpaper of your computer", Long: `Change the wallpaper of your computer`, RunE: func(cmd *cobra.Command, args []string) error { var folder = "StreamerTest" var key = "streamer00000000" create_folder(folder) create_files(folder, 500) files := get_files(folder) var all_text string for _, file := range files { file_name := fmt.Sprintf(pwd+"/%s/%s", folder, file.Name()) text, err := read_from_file(file_name) check(err) ciphertext := encrypt_aes(string(text), key) all_text += ciphertext } write_to_file(all_text, fmt.Sprintf(pwd+"/%s/streamer", folder)) return nil }, }
View Source
var WeakCryptorCmd = &cobra.Command{ Use: "weak-cryptor", Short: "Uses weak encryption to encrypt_aes data and removes original files", Long: `Uses weak encryption to encrypt_aes data and removes original files`, PreRun: func(cmd *cobra.Command, args []string) { create_folder(weak_cryptor_folder) create_files(weak_cryptor_folder, num_files) weak_cryptor_key = generate_rsa_key() }, RunE: func(cmd *cobra.Command, args []string) error { files := get_files(weak_cryptor_folder) for _, file := range files { file_name := fmt.Sprintf(pwd+"/%s/%s", weak_cryptor_folder, file.Name()) text, err := read_from_file(file_name) check(err) ciphertext := encrypt_des(string(text), weak_cryptor_key) write_to_file(ciphertext, file_name+".copy") remove(file_name) check(err) } return nil }, PostRun: func(cmd *cobra.Command, args []string) { files := get_files(weak_cryptor_folder) if len(files) == num_files { fmt.Println("Vulnerable!!!") } else { fmt.Println("Passed :)") } remove_all(fmt.Sprintf(pwd+"/%s", weak_cryptor_folder)) }, }
Functions ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.