mirror of
https://github.com/HACKERALERT/Picocrypt.git
synced 2024-05-14 00:51:19 +00:00
Compare commits
7 commits
77aea6a8e4
...
f6a4f0e920
Author | SHA1 | Date | |
---|---|---|---|
f6a4f0e920 | |||
a8e8a92002 | |||
613ab8232d | |||
c73fba2250 | |||
bbe5ee979a | |||
1b4998d4e2 | |||
97bde62236 |
17
.github/workflows/codeql-analysis.yml
vendored
17
.github/workflows/codeql-analysis.yml
vendored
|
@ -5,9 +5,12 @@ on:
|
|||
- "src/*.go"
|
||||
- "src/go.mod"
|
||||
- "src/go.sum"
|
||||
- "cli/picocrypt/*.go"
|
||||
- "cli/picocrypt/go.mod"
|
||||
- "cli/picocrypt/go.sum"
|
||||
- "cli/v1/picocrypt/*.go"
|
||||
- "cli/v1/picocrypt/go.mod"
|
||||
- "cli/v1/picocrypt/go.sum"
|
||||
- "cli/v2/picocrypt/*.go"
|
||||
- "cli/v2/picocrypt/go.mod"
|
||||
- "cli/v2/picocrypt/go.sum"
|
||||
- "web/*.go"
|
||||
- "web/go.mod"
|
||||
- "web/go.sum"
|
||||
|
@ -27,12 +30,12 @@ jobs:
|
|||
language: ['go']
|
||||
steps:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v2
|
||||
uses: github/codeql-action/init@v3
|
||||
with:
|
||||
languages: ${{ matrix.language }}
|
||||
- name: Autobuild
|
||||
uses: github/codeql-action/autobuild@v2
|
||||
uses: github/codeql-action/autobuild@v3
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v2
|
||||
uses: github/codeql-action/analyze@v3
|
||||
|
|
|
@ -28,10 +28,8 @@ import (
|
|||
"golang.org/x/term"
|
||||
)
|
||||
|
||||
var KiB = 1 << 10
|
||||
var MiB = 1 << 20
|
||||
var GiB = 1 << 30
|
||||
var TiB = 1 << 40
|
||||
var rs5, _ = infectious.NewFEC(5, 15)
|
||||
var rs16, _ = infectious.NewFEC(16, 48)
|
||||
var rs24, _ = infectious.NewFEC(24, 72)
|
||||
|
@ -47,7 +45,10 @@ func rsEncode(rs *infectious.FEC, data []byte) []byte {
|
|||
return res
|
||||
}
|
||||
|
||||
func rsDecode(rs *infectious.FEC, data []byte) ([]byte, error) {
|
||||
func rsDecode(rs *infectious.FEC, data []byte, fast bool) ([]byte, error) {
|
||||
if rs.Total() == 136 && fast {
|
||||
return data[:128], nil
|
||||
}
|
||||
tmp := make([]infectious.Share, rs.Total())
|
||||
for i := 0; i < rs.Total(); i++ {
|
||||
tmp[i].Number = i
|
||||
|
@ -81,6 +82,7 @@ func work() int {
|
|||
}
|
||||
paranoid := flag.Bool("p", false, "")
|
||||
reedsolo := flag.Bool("r", false, "")
|
||||
fix := flag.Bool("f", false, "")
|
||||
flag.Parse()
|
||||
|
||||
mode := ""
|
||||
|
@ -103,6 +105,12 @@ func work() int {
|
|||
}
|
||||
}
|
||||
}
|
||||
for _, v := range flag.Args() {
|
||||
if v == "-p" || v == "-r" || v == "-f" {
|
||||
fmt.Println("Flags are only accepted before arguments!")
|
||||
return 1
|
||||
}
|
||||
}
|
||||
|
||||
var password, cpassword []byte
|
||||
var err error
|
||||
|
@ -327,16 +335,16 @@ func work() int {
|
|||
errs := make([]error, 10)
|
||||
version := make([]byte, 15)
|
||||
fin.Read(version)
|
||||
_, errs[0] = rsDecode(rs5, version)
|
||||
_, errs[0] = rsDecode(rs5, version, !(*fix))
|
||||
tmp := make([]byte, 15)
|
||||
fin.Read(tmp)
|
||||
tmp, errs[1] = rsDecode(rs5, tmp)
|
||||
tmp, errs[1] = rsDecode(rs5, tmp, !(*fix))
|
||||
commentsLength, _ := strconv.Atoi(string(tmp))
|
||||
fin.Read(make([]byte, commentsLength*3))
|
||||
total -= int64(commentsLength) * 3
|
||||
flags := make([]byte, 15)
|
||||
fin.Read(flags)
|
||||
flags, errs[2] = rsDecode(rs5, flags)
|
||||
flags, errs[2] = rsDecode(rs5, flags, !(*fix))
|
||||
*paranoid = flags[0] == 1
|
||||
*reedsolo = flags[3] == 1
|
||||
padded = flags[4] == 1
|
||||
|
@ -349,25 +357,25 @@ func work() int {
|
|||
}
|
||||
salt = make([]byte, 48)
|
||||
fin.Read(salt)
|
||||
salt, errs[3] = rsDecode(rs16, salt)
|
||||
salt, errs[3] = rsDecode(rs16, salt, !(*fix))
|
||||
hkdfSalt = make([]byte, 96)
|
||||
fin.Read(hkdfSalt)
|
||||
hkdfSalt, errs[4] = rsDecode(rs32, hkdfSalt)
|
||||
hkdfSalt, errs[4] = rsDecode(rs32, hkdfSalt, !(*fix))
|
||||
serpentIV = make([]byte, 48)
|
||||
fin.Read(serpentIV)
|
||||
serpentIV, errs[5] = rsDecode(rs16, serpentIV)
|
||||
serpentIV, errs[5] = rsDecode(rs16, serpentIV, !(*fix))
|
||||
nonce = make([]byte, 72)
|
||||
fin.Read(nonce)
|
||||
nonce, errs[6] = rsDecode(rs24, nonce)
|
||||
nonce, errs[6] = rsDecode(rs24, nonce, !(*fix))
|
||||
keyHashRef = make([]byte, 192)
|
||||
fin.Read(keyHashRef)
|
||||
keyHashRef, errs[7] = rsDecode(rs64, keyHashRef)
|
||||
keyHashRef, errs[7] = rsDecode(rs64, keyHashRef, !(*fix))
|
||||
keyfileHashRef := make([]byte, 96)
|
||||
fin.Read(keyfileHashRef)
|
||||
_, errs[8] = rsDecode(rs32, keyfileHashRef)
|
||||
_, errs[8] = rsDecode(rs32, keyfileHashRef, !(*fix))
|
||||
authTag = make([]byte, 192)
|
||||
fin.Read(authTag)
|
||||
authTag, errs[9] = rsDecode(rs64, authTag)
|
||||
authTag, errs[9] = rsDecode(rs64, authTag, !(*fix))
|
||||
for _, err := range errs {
|
||||
if err != nil {
|
||||
fin.Close()
|
||||
|
@ -487,7 +495,7 @@ func work() int {
|
|||
src = nil
|
||||
if len(dst) == MiB/128*136 {
|
||||
for i := 0; i < MiB/128*136; i += 136 {
|
||||
tmp, err := rsDecode(rs128, dst[i:i+136])
|
||||
tmp, err := rsDecode(rs128, dst[i:i+136], !(*fix))
|
||||
if err != nil {
|
||||
fin.Close()
|
||||
fout.Close()
|
||||
|
@ -503,7 +511,7 @@ func work() int {
|
|||
} else {
|
||||
chunks := len(dst)/136 - 1
|
||||
for i := 0; i < chunks; i++ {
|
||||
tmp, err := rsDecode(rs128, dst[i*136:(i+1)*136])
|
||||
tmp, err := rsDecode(rs128, dst[i*136:(i+1)*136], !(*fix))
|
||||
if err != nil {
|
||||
fin.Close()
|
||||
fout.Close()
|
||||
|
@ -513,7 +521,7 @@ func work() int {
|
|||
}
|
||||
src = append(src, tmp...)
|
||||
}
|
||||
tmp, err := rsDecode(rs128, dst[int(chunks)*136:])
|
||||
tmp, err := rsDecode(rs128, dst[int(chunks)*136:], !(*fix))
|
||||
if err != nil {
|
||||
fin.Close()
|
||||
fout.Close()
|
||||
|
@ -570,7 +578,15 @@ func work() int {
|
|||
fin.Close()
|
||||
fout.Close()
|
||||
os.Remove(fout_)
|
||||
fmt.Println("The input volume is damaged or modified.")
|
||||
fmt.Println("\nThe input volume is damaged or modified.")
|
||||
if *reedsolo {
|
||||
if !(*fix) {
|
||||
fmt.Println("Fortunately, this volume is encoded with Reed-Solomon.")
|
||||
fmt.Println("Try again using the '-f' flag to repair the corruption.")
|
||||
} else {
|
||||
fmt.Println("The corruption could not be fixed with Reed-Solomon.")
|
||||
}
|
||||
}
|
||||
return 1
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue