Skip to content

Commit e234132

Browse files
committed
fix!: switch from CFB to CTR cipher
CFB cipher is deprecated and insecure, see: https://pkg.go.dev/crypto/cipher#NewCFBDecrypter Because of the way goploader works, files created with the CFB cipher can't be decrypted using the CTR cipher. If you plan on upgrading, use a different path for your database and files. BREAKING CHANGE: this will effectively invalidate all uplodaded files that used the CFB cipher.
1 parent 3862533 commit e234132

File tree

3 files changed

+22
-36
lines changed

3 files changed

+22
-36
lines changed

.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,11 @@ client/client
22
client/client*
33
client/misc/
44
client/testfiles/
5-
server/my.db
65
server/*.back
76
server/*.db
87
server/up/
98
server/server
109
server/conf.yml
11-
server/rice-box.go
1210
server/ssl
1311
releases
1412
server/data/
@@ -17,5 +15,4 @@ vendor/
1715
docs/env/
1816
docs/site/
1917
.vscode/
20-
2118
dist/

README.md

Lines changed: 18 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
[![forthebadge](https://forthebadge.com/images/badges/made-with-go.svg)](https://forthebadge.com)[![forthebadge](https://forthebadge.com/images/badges/contains-technical-debt.svg)](https://forthebadge.com)[![forthebadge](https://forthebadge.com/images/badges/built-with-love.svg)](https://forthebadge.com)
44

55
![Go Version](https://img.shields.io/badge/go-1.18-brightgreen.svg)
6-
[![Go Report Card](https://goreportcard.com/badge/github.com/Depado/goploader)](https://goreportcard.com/report/github.com/Depado/goploader)
6+
[![Go Report Card](https://goreportcard.com/badge/github.com/depado/goploader)](https://goreportcard.com/report/github.com/depado/goploader)
77
[![codebeat badge](https://codebeat.co/badges/0faefc03-91a4-41e7-a955-ccd8c1b096cd)](https://codebeat.co/projects/github-com-depado-goploader)
8-
[![Maintainability](https://api.codeclimate.com/v1/badges/af3e40751fb9d01d4627/maintainability)](https://codeclimate.com/github/Depado/goploader/maintainability)
9-
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/Depado/goploader/blob/master/LICENSE)
10-
[![Say Thanks!](https://img.shields.io/badge/Say%20Thanks-!-1EAEDB.svg)](https://saythanks.io/to/Depado)
8+
[![Maintainability](https://api.codeclimate.com/v1/badges/af3e40751fb9d01d4627/maintainability)](https://codeclimate.com/github/depado/goploader/maintainability)
9+
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/depado/goploader/blob/master/LICENSE)
10+
[![Say Thanks!](https://img.shields.io/badge/Say%20Thanks-!-1EAEDB.svg)](https://saythanks.io/to/depado)
1111

1212
> [!WARNING]
1313
> This repository is maintained as is but most of the tech used for this project
@@ -22,49 +22,35 @@ Goploader's ultimate goal is to make file sharing easy and painless. This projec
2222

2323
## Build from source
2424

25-
Make sure you have Go installed on your machine.
25+
Make sure you have go installed on your machine.
2626

2727
### Client
2828

2929
```shell
30-
$ go get github.com/Depado/goploader/client
31-
$ go build -o $GOPATH/bin/goploader github.com/Depado/goploader/client
30+
$ git clone https://github.com/depado/goploader.git
31+
$ cd goploader
32+
$ go build -o gpldr ./client/
3233
```
3334

3435
### Server
3536

3637
```shell
37-
$ # Move to a new directory that will be used to run the server
38-
$ go get github.com/Depado/goploader/server
39-
$ # The following steps are optional
40-
$ # Execute those if you wish to embed the assets and templates into the binary
41-
$ go get github.com/GeertJohan/go.rice/rice
42-
$ rice embed-go -i=github.com/Depado/goploader/server
43-
$ # End of the optional steps
44-
$ go build github.com/Depado/goploader/server
45-
$ # If you did not embed the resources, make sure to copy the assets and templates directories
46-
$ cp -r $GOPATH/src/github.com/Depado/goploader/server/{assets,templates} .
47-
$ # Execute the binary a first time to trigger the setup
48-
$ # Or write your own conf.yml file
49-
$ ./server
38+
$ git clone https://github.com/depado/goploader.git
39+
$ cd goploader
40+
$ go build -o goploader-server ./server/
41+
$ ./goploader-server
5042
```
5143

5244
## Downloads
5345

54-
All the downloads are available at [gpldr.in](https://gpldr.in) in the [clients](https://gpldr.in/#client-downloads) and [server](https://gpldr.in/#server-downloads) sections.
55-
56-
### Client
57-
58-
| Linux | FreeBSD | Mac OS | Windows |
59-
| ------------- |---------|------------|----------|
60-
| [Linux 64bit](https://gpldr.in/releases/clients/client_linux_amd64) | [FreeBSD 64bit](https://gpldr.in/releases/clients/client_freebsd_amd64) | [Mac OS 64bit](https://gpldr.in/releases/clients/client_darwin_amd64) | [Windows 64bit](https://gpldr.in/releases/clients/client_windows_amd64.exe) |
61-
| [Linux 32bit](https://gpldr.in/releases/clients/client_linux_386) | [FreeBSD 32bit](https://gpldr.in/releases/clients/client_freebsd_386) | [Mac OS 32bit](https://gpldr.in/releases/clients/client_darwin_386) | [Windows 32bit](https://gpldr.in/releases/clients/client_windows_386.exe) |
62-
| [Linux ARMv7](https://gpldr.in/releases/clients/client_linux_arm) | | | | |
46+
All the downloads are available in the [releases tab](https://github.com/depado/goploader/releases)
47+
of this repository.
6348

6449
## Documentation
6550

66-
All the documentation is available at [gpldr.in](https://docs.gpldr.in). I intend to write a proper `README.md` file, but it takes a lot of work to transpose the existing documentation to the markdown format. So, work in progress.
67-
51+
All the documentation is available at [depado.github.io/goploader/](https://depado.github.io/goploader/).
6852

6953
## License
70-
All the software in this repository is released under the MIT License. See [LICENSE](https://github.com/Depado/goploader/blob/master/LICENSE) for details.
54+
55+
All the software in this repository is released under the MIT License. See
56+
[LICENSE](https://github.com/depado/goploader/blob/master/LICENSE) for details.

server/models/resources.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func (r Resource) NewStreamWriter(fd *os.File, key []byte) (*cipher.StreamWriter
6363
return nil, err
6464
}
6565
var iv [aes.BlockSize]byte
66-
stream := cipher.NewCFBEncrypter(block, iv[:])
66+
stream := cipher.NewCTR(block, iv[:])
6767
return &cipher.StreamWriter{S: stream, W: fd}, nil
6868
}
6969

@@ -81,17 +81,20 @@ func (r *Resource) WriteEncrypted(fd multipart.File) (string, error) {
8181
return "", err
8282
}
8383
defer file.Close()
84+
8485
k := uniuri.NewLen(conf.C.KeyLength)
8586
kb := []byte(k)
8687
sw, err := r.NewStreamWriter(file, kb)
8788
if err != nil {
8889
return "", err
8990
}
91+
9092
wr, err := io.Copy(sw, bufio.NewReaderSize(fd, 512))
9193
if err != nil {
9294
os.Remove(path.Join(conf.C.UploadDir, r.Key))
9395
return "", err
9496
}
97+
9598
r.Size = wr
9699
return k, nil
97100
}

0 commit comments

Comments
 (0)