Working directory encryption!
This commit is contained in:
8
crypt.go
8
crypt.go
@ -9,7 +9,7 @@ import (
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"strings"
|
||||
"path/filepath"
|
||||
|
||||
"crypto/aes"
|
||||
"crypto/cipher"
|
||||
@ -59,11 +59,11 @@ func EncryptTarXZip(source, password string) error {
|
||||
}
|
||||
file, err := os.OpenFile(source+".tar.xz", os.O_RDWR, 0)
|
||||
if err != nil {
|
||||
log.Println("Error:", err)
|
||||
log.Println("Open File Error:", err)
|
||||
}
|
||||
info, err := file.Stat()
|
||||
if err != nil {
|
||||
log.Println("Error:", err)
|
||||
log.Println("File Stat Error:", err)
|
||||
}
|
||||
bytes := info.Size()
|
||||
file.Truncate(0)
|
||||
@ -76,7 +76,7 @@ func EncryptTarXZip(source, password string) error {
|
||||
}
|
||||
|
||||
func UnTarXzip(source string) error {
|
||||
target := strings.Replace(source, ".tar.xz", "", 1)
|
||||
target := filepath.Dir(source)
|
||||
txz := archiver.NewTarXz()
|
||||
txz.Tar.OverwriteExisting = true
|
||||
txz.Tar.ContinueOnError = true
|
||||
|
18
main.go
18
main.go
@ -118,15 +118,6 @@ func main() {
|
||||
usage()
|
||||
}
|
||||
flag.Parse()
|
||||
if *clearnet {
|
||||
*mirror = "http://dist.torproject.org/torbrowser/"
|
||||
}
|
||||
if *snowflake {
|
||||
go Snowflake()
|
||||
}
|
||||
if *destruct {
|
||||
defer OverwriteDirectoryContents(*directory)
|
||||
}
|
||||
if *password != "" {
|
||||
log.Println("Looking for directory with password")
|
||||
DecryptTarXZifThere(*directory, *password)
|
||||
@ -144,6 +135,15 @@ func main() {
|
||||
}
|
||||
}()
|
||||
}
|
||||
if *clearnet {
|
||||
*mirror = "http://dist.torproject.org/torbrowser/"
|
||||
}
|
||||
if *snowflake {
|
||||
go Snowflake()
|
||||
}
|
||||
if *destruct {
|
||||
defer OverwriteDirectoryContents(*directory)
|
||||
}
|
||||
tbget.WORKING_DIR = *directory
|
||||
if filename == "i2pbrowser" {
|
||||
log.Println("Starting I2P in Tor Browser")
|
||||
|
17
rmdir.go
17
rmdir.go
@ -1,7 +1,6 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
)
|
||||
@ -11,22 +10,20 @@ func OverwriteDirectoryContents(directory string) {
|
||||
//and zero-out the files to the length of the file
|
||||
filepath.Walk(directory, func(path string, info os.FileInfo, err error) error {
|
||||
go func() {
|
||||
if err != nil {
|
||||
log.Println("Error:", err)
|
||||
}
|
||||
if info.IsDir() {
|
||||
log.Println("Error:", err)
|
||||
}
|
||||
if err == nil {
|
||||
if !info.IsDir() {
|
||||
file, err := os.OpenFile(path, os.O_RDWR, 0)
|
||||
if err != nil {
|
||||
log.Println("Error:", err)
|
||||
}
|
||||
} else {
|
||||
defer file.Close()
|
||||
bytes := info.Size()
|
||||
file.Truncate(0)
|
||||
file.Write(make([]byte, bytes))
|
||||
log.Println("Error:", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}()
|
||||
return nil
|
||||
})
|
||||
os.RemoveAll(directory)
|
||||
}
|
||||
|
@ -22,6 +22,9 @@ var shutdown = false
|
||||
|
||||
func Password() string {
|
||||
require_password := os.Getenv("TOR_MANAGER_REQUIRE_PASSWORD")
|
||||
if !PluginStat() {
|
||||
require_password = "true"
|
||||
}
|
||||
if require_password == "true" || require_password == "1" {
|
||||
passwd, err := zenity.Entry(
|
||||
"Enter a password if you want to encrypt the working directory",
|
||||
@ -103,9 +106,12 @@ func onReady() {
|
||||
}
|
||||
|
||||
func onExit() {
|
||||
onSnowflakeExit()
|
||||
if *snowflake {
|
||||
snowflakeProxy.Stop()
|
||||
}
|
||||
if *password != "" {
|
||||
log.Println("Encrypting directory with password")
|
||||
os.Remove(*directory + ".tar.xz")
|
||||
EncryptTarXZip(*directory, *password)
|
||||
}
|
||||
if shutdown {
|
||||
|
Reference in New Issue
Block a user