rar to zip
This commit is contained in:
parent
113cc82825
commit
6daa8e03fa
27
crargo.go
27
crargo.go
@ -2,7 +2,6 @@ package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
@ -10,39 +9,35 @@ import (
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
"github.com/mholt/archiver"
|
||||
"github.com/yeka/zip"
|
||||
)
|
||||
|
||||
func crack(tid int, file []byte, fn string, passwords []string, found **string, stop *bool, total *uint64, exited *int32) {
|
||||
fmt.Println("Thread", tid, ": starting with", len(passwords), "passwords...")
|
||||
|
||||
rar := archiver.NewRar()
|
||||
rar.ContinueOnError = false
|
||||
rar.ImplicitTopLevelFolder = true
|
||||
rar.OverwriteExisting = true
|
||||
rar.MkdirAll = false
|
||||
r, err := zip.OpenReader(fn)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
f := r.File[len(r.File)-1]
|
||||
fmt.Println("Filename:", f.Name)
|
||||
for i := 0; i < len(passwords); i++ {
|
||||
if *stop {
|
||||
goto end
|
||||
}
|
||||
|
||||
cur_pass := passwords[i]
|
||||
rar.Password = cur_pass
|
||||
reader := bytes.NewReader(file)
|
||||
f.SetPassword(cur_pass)
|
||||
|
||||
err := rar.Open(reader, 0)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
_, err = rar.Read()
|
||||
r, err := f.Open()
|
||||
if err == nil {
|
||||
|
||||
*found = &passwords[i]
|
||||
r.Close()
|
||||
goto end
|
||||
}
|
||||
|
||||
rar.Close()
|
||||
atomic.AddUint64(total, 1)
|
||||
}
|
||||
end:
|
||||
|
2
go.mod
2
go.mod
@ -10,4 +10,6 @@ require (
|
||||
github.com/pierrec/lz4 v2.6.1+incompatible // indirect
|
||||
github.com/ulikunitz/xz v0.5.10 // indirect
|
||||
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect
|
||||
github.com/yeka/zip v0.0.0-20180914125537-d046722c6feb // indirect
|
||||
golang.org/x/crypto v0.0.0-20220427172511-eb4f295cb31f // indirect
|
||||
)
|
||||
|
4
go.sum
4
go.sum
@ -16,3 +16,7 @@ github.com/ulikunitz/xz v0.5.10 h1:t92gobL9l3HE202wg3rlk19F6X+JOxl9BBrCCMYEYd8=
|
||||
github.com/ulikunitz/xz v0.5.10/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14=
|
||||
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 h1:nIPpBwaJSVYIxUFsDv3M8ofmx9yWTog9BfvIu0q41lo=
|
||||
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8/go.mod h1:HUYIGzjTL3rfEspMxjDjgmT5uz5wzYJKVo23qUhYTos=
|
||||
github.com/yeka/zip v0.0.0-20180914125537-d046722c6feb h1:OJYP70YMddlmGq//EPLj8Vw2uJXmrA+cGSPhXTDpn2E=
|
||||
github.com/yeka/zip v0.0.0-20180914125537-d046722c6feb/go.mod h1:9BnoKCcgJ/+SLhfAXj15352hTOuVmG5Gzo8xNRINfqI=
|
||||
golang.org/x/crypto v0.0.0-20220427172511-eb4f295cb31f h1:OeJjE6G4dgCY4PIXvIRQbE8+RX+uXZyGhUy/ksMGJoc=
|
||||
golang.org/x/crypto v0.0.0-20220427172511-eb4f295cb31f/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||
|
Loading…
Reference in New Issue
Block a user