inital release
This commit is contained in:
33
.github/workflows/go.yaml
vendored
Normal file
33
.github/workflows/go.yaml
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
name: Go
|
||||
|
||||
on:
|
||||
create:
|
||||
tags:
|
||||
- v*
|
||||
|
||||
jobs:
|
||||
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v4
|
||||
with:
|
||||
go-version: '1.23'
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
go build .
|
||||
go get github.com/mitchellh/gox
|
||||
/home/runner/go/bin/gox -osarch="linux/amd64 linux/arm darwin/amd64 windows/amd64" --output "build/{{ .Dir }}_{{.OS}}_{{.Arch}}"
|
||||
|
||||
- name: Release
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
files: |
|
||||
build/photok-recovery_darwin_amd64
|
||||
build/photok-recovery_windows_amd64.exe
|
||||
build/photok-recovery_linux_amd64
|
||||
build/photok-recovery_linux_arm
|
||||
14
README.md
Normal file
14
README.md
Normal file
@@ -0,0 +1,14 @@
|
||||
# Photok Backup Recovery
|
||||
## Description
|
||||
|
||||
This utility allows you to restore data from backups created by the Photok application without needing an Android phone. Easily access and recover your files directly from your computer.
|
||||
|
||||
## Usage
|
||||
|
||||
1. Go to the Releases page.
|
||||
2. Download the executable file for your platform.
|
||||
3. Run the utility using the command:
|
||||
```bash
|
||||
photok-recovery --password <your_password> --file <path_to_backup>
|
||||
```
|
||||
Replace <your_password> with your actual password and <path_to_backup> with the path to your backup file.
|
||||
101
main.go
Normal file
101
main.go
Normal file
@@ -0,0 +1,101 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"archive/zip"
|
||||
"crypto/aes"
|
||||
"crypto/cipher"
|
||||
"crypto/sha256"
|
||||
"flag"
|
||||
"io"
|
||||
"log"
|
||||
"os"
|
||||
"strings"
|
||||
"sync"
|
||||
)
|
||||
|
||||
func main() {
|
||||
password := flag.String("password", "", "photok password")
|
||||
backupFile := flag.String("file", "", "path to backup file")
|
||||
numWorkers := flag.Int("worker", 10, "number of workers")
|
||||
flag.Parse()
|
||||
|
||||
var wg sync.WaitGroup
|
||||
|
||||
jobs := make(chan *zip.File)
|
||||
|
||||
for i := 0; i < *numWorkers; i++ {
|
||||
wg.Add(1)
|
||||
|
||||
go worker(*password, jobs, &wg)
|
||||
}
|
||||
|
||||
r, err := zip.OpenReader(*backupFile)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer r.Close()
|
||||
|
||||
for _, f := range r.File {
|
||||
if !strings.HasSuffix(f.Name, ".tn") && strings.HasSuffix(f.Name, ".photok") {
|
||||
jobs <- f
|
||||
}
|
||||
}
|
||||
|
||||
close(jobs)
|
||||
|
||||
wg.Wait()
|
||||
}
|
||||
|
||||
func worker(password string, jobs <-chan *zip.File, wg *sync.WaitGroup) {
|
||||
defer wg.Done()
|
||||
|
||||
key := photokKey(password)
|
||||
iv := photokIV(password)
|
||||
|
||||
block, err := aes.NewCipher(key)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
aesgcm, err := cipher.NewGCMWithNonceSize(block, 16)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
for file := range jobs {
|
||||
reader, err := file.Open()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
ciphertext, err := io.ReadAll(reader)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
plaintext, err := aesgcm.Open(nil, iv, ciphertext, nil)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if err := os.WriteFile(file.Name+".plaintext", plaintext, 0o644); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func photokKey(password string) []byte {
|
||||
h := sha256.New()
|
||||
h.Write([]byte(password))
|
||||
|
||||
return h.Sum(nil)
|
||||
}
|
||||
|
||||
func photokIV(password string) []byte {
|
||||
iv := make([]byte, 16)
|
||||
for i := 0; i < 16 && i < len(password); i++ {
|
||||
iv[i] = password[i]
|
||||
}
|
||||
|
||||
return iv
|
||||
}
|
||||
Reference in New Issue
Block a user