Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release: Comprehensive Updates and Refinements to Project for July Release #356

Merged
merged 6 commits into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: build
name: Build

on:
push:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ jobs:
config: ./.typos.toml

- name: Lint
uses: golangci/golangci-lint-action@v4
uses: golangci/golangci-lint-action@v6
with:
version: latest
137 changes: 20 additions & 117 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,135 +1,38 @@
name: Release

on:
workflow_dispatch:

permissions:
contents: write
pull-requests: write

jobs:
build:
goreleaser:
runs-on: ubuntu-latest

steps:
- name: Checkout source
uses: actions/checkout@v4

- name: Use Golang
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.22.x"

- name: Build with xgo
uses: crazy-max/ghaction-xgo@v3
with:
xgo_version: latest
go_version: ${{ matrix.go_version }}
dest: build
prefix: hack-browser-data
pkg: cmd/hack-browser-data
targets: windows/amd64,windows/386,linux/386,linux/amd64,linux/arm,linux/arm64,darwin/amd64
# targets: windows/amd64,windows/386,darwin/amd64,linux/arm
v: true
x: false
race: false
ldflags: -s -w
buildmode: default

- name: Set Variable
run: |
echo "RELEASE_WIN32=hack-browser-data-${{ github.event.release.tag_name}}windows-32bit" >> $GITHUB_ENV
echo "RELEASE_WIN64=hack-browser-data-${{ github.event.release.tag_name}}windows-64bit" >> $GITHUB_ENV
echo "RELEASE_OSX=hack-browser-data-${{ github.event.release.tag_name}}osx-64bit" >> $GITHUB_ENV
echo "RELEASE_LinuxARM=hack-browser-data-${{ github.event.release.tag_name}}linux-arm" >> $GITHUB_ENV
echo "RELEASE_Linux386=hack-browser-data-${{ github.event.release.tag_name}}linux-386" >> $GITHUB_ENV
echo "RELEASE_LinuxARM64=hack-browser-data-${{ github.event.release.tag_name}}linux-arm64" >> $GITHUB_ENV
echo "RELEASE_LinuxAMD64=hack-browser-data-${{ github.event.release.tag_name}}linux-amd64" >> $GITHUB_ENV
- name: Build zip
run: |
mv build/hack-browser-data-windows*386.exe "$RELEASE_WIN32".exe
mv build/hack-browser-data-windows*amd64.exe "$RELEASE_WIN64".exe
mv build/hack-browser-data-darwin-*amd64 "$RELEASE_OSX"
mv build/hack-browser-data-linux-*arm-* "$RELEASE_LinuxARM"
mv build/hack-browser-data-linux-*arm64 "$RELEASE_LinuxARM64"
mv build/hack-browser-data-linux-*386 "$RELEASE_Linux386"
mv build/hack-browser-data-linux-*amd64 "$RELEASE_LinuxAMD64"
zip "$RELEASE_WIN32".zip "$RELEASE_WIN32".exe
zip "$RELEASE_WIN64".zip "$RELEASE_WIN64".exe
zip "$RELEASE_OSX".zip "$RELEASE_OSX"
zip "$RELEASE_LinuxARM".zip "$RELEASE_LinuxARM"
zip "$RELEASE_Linux386".zip "$RELEASE_Linux386"
zip "$RELEASE_LinuxAMD64".zip "$RELEASE_LinuxAMD64"
zip "$RELEASE_LinuxARM64".zip "$RELEASE_Linux386"


- name: Create Release
id: create_release
uses: release-drafter/release-drafter@v6
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Upload Release - Windows 64bit
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./${{ env.RELEASE_WIN64 }}.zip
asset_name: ${{ env.RELEASE_WIN64 }}.zip
asset_content_type: application/zip

- name: Upload Release - Windows 32bit
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./${{ env.RELEASE_WIN32 }}.zip
asset_name: ${{ env.RELEASE_WIN32 }}.zip
asset_content_type: application/zip
go-version: '1.22.x'

- name: Upload Release - Darwin amd64
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./${{ env.RELEASE_OSX }}.zip
asset_name: ${{ env.RELEASE_OSX }}.zip
asset_content_type: application/zip

- name: Upload Release - Linux arm
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Check out code
uses: actions/checkout@v4
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./${{ env.RELEASE_LinuxARM }}.zip
asset_name: ${{ env.RELEASE_LinuxARM }}.zip
asset_content_type: application/zip
fetch-depth: 0

- name: Upload Release - Linux amd64
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./${{ env.RELEASE_LinuxAMD64 }}.zip
asset_name: ${{ env.RELEASE_LinuxAMD64 }}.zip
asset_content_type: application/zip

- name: Upload Release - Linux 386
uses: actions/[email protected]
version: '~> v2'
args: release --clean --draft
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./${{ env.RELEASE_Linux386 }}.zip
asset_name: ${{ env.RELEASE_Linux386 }}.zip
asset_content_type: application/zip

- name: Upload Release - Linux arm64
uses: actions/[email protected]
update_release_draft:
needs: goreleaser
runs-on: ubuntu-latest
steps:
- uses: release-drafter/release-drafter@v6
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_name: ${{ env.RELEASE_LinuxARM64 }}.zip
asset_content_type: application/zip
asset_path: ./${{ env.RELEASE_LinuxARM64 }}.zip
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
name: Tests

on:
pull_request:
push:
branches:
- main
- dev
workflow_dispatch:

name: Tests
jobs:
test:
strategy:
Expand Down
60 changes: 60 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
version: 2

before:
hooks:
- go mod tidy

builds:
- id: "hack-browser-data"
main: ./cmd/hack-browser-data/main.go
binary: hack-browser-data
env:
- CGO_ENABLED=0
goos: [windows, linux, darwin]
goarch: [amd64, "386", arm, arm64]
ignore:
- goos: darwin
goarch: "386"
- goos: windows
goarch: "386"
- goos: windows
goarch: arm
flags:
- -trimpath
ldflags:
- -s -w

archives:
- id: "archive"
format: zip
builds: ["hack-browser-data"]
name_template: >-
hack-browser-data-
{{- if eq .Os "darwin" }}osx
{{- else if eq .Os "linux" }}linux
{{- else if eq .Os "windows" }}windows
{{- else }}{{ .Os }}{{ end }}-
{{- if eq .Arch "amd64" }}64bit
{{- else if eq .Arch "386" }}32bit
{{- else if eq .Arch "arm64" }}arm64
{{- else if eq .Arch "arm" }}arm
{{- else }}{{ .Arch }}{{ end }}

changelog:
sort: asc
filters:
exclude:
- "^docs:"
- "^test:"
- "^chore\\(deps\\):"
- "merge conflict"
- Merge pull request
- Merge remote-tracking branch
- Merge branch
- go mod tidy
checksum:
name_template: "checksums-v{{ .Version }}.txt"
algorithm: sha256

release:
prerelease: auto
8 changes: 4 additions & 4 deletions browser/browser.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ func pickChromium(name, profile string) []Browser {
if !fileutil.IsDirExists(filepath.Clean(profile)) {
slog.Error("find browser failed, profile folder does not exist", "browser", c.name)
}
chromiumList, err := chromium.New(c.name, c.storage, profile, c.dataTypes)
chromes, err := chromium.New(c.name, c.storage, profile, c.dataTypes)
if err != nil {
slog.Error("new chromium error", "err", err)
}
for _, b := range chromiumList {
slog.Warn("find browser success", "browser", b.Name())
browsers = append(browsers, b)
for _, chrome := range chromes {
slog.Warn("find browser success", "browser", chrome.Name())
browsers = append(browsers, chrome)
}
}
return browsers
Expand Down
32 changes: 24 additions & 8 deletions browser/chromium/chromium.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ package chromium
import (
"io/fs"
"log/slog"
"os"
"path/filepath"
"slices"
"strings"

"github.com/moond4rk/hackbrowserdata/browserdata"
Expand Down Expand Up @@ -50,12 +52,16 @@ func (c *Chromium) Name() string {
}

func (c *Chromium) BrowsingData(isFullExport bool) (*browserdata.BrowserData, error) {
items := c.dataTypes
// delete chromiumKey from dataTypes, doesn't need to export key
dataTypes := slices.DeleteFunc(c.dataTypes, func(i types.DataType) bool {
return i == types.ChromiumKey
})

if !isFullExport {
items = types.FilterSensitiveItems(c.dataTypes)
dataTypes = types.FilterSensitiveItems(c.dataTypes)
}

data := browserdata.New(items)
data := browserdata.New(dataTypes)

if err := c.copyItemToLocal(); err != nil {
return nil, err
Expand Down Expand Up @@ -107,10 +113,10 @@ func (c *Chromium) userDataTypePaths(profilePath string, items []types.DataType)
}
var keyPath string
var dir string
for userDir, v := range multiItemPaths {
for _, p := range v {
if strings.HasSuffix(p, types.ChromiumKey.Filename()) {
keyPath = p
for userDir, profiles := range multiItemPaths {
for _, profile := range profiles {
if strings.HasSuffix(profile, types.ChromiumKey.Filename()) {
keyPath = profile
dir = userDir
break
}
Expand All @@ -131,13 +137,23 @@ func (c *Chromium) userDataTypePaths(profilePath string, items []types.DataType)
// chromiumWalkFunc return a filepath.WalkFunc to find item's path
func chromiumWalkFunc(items []types.DataType, multiItemPaths map[string]map[types.DataType]string) filepath.WalkFunc {
return func(path string, info fs.FileInfo, err error) error {
if err != nil {
if os.IsPermission(err) {
slog.Warn("skipping walk chromium path permission error", "path", path, "err", err)
return nil
}
return err
}
for _, v := range items {
if info.Name() != v.Filename() {
continue
}
if strings.Contains(path, "System Profile") {
continue
}
if strings.Contains(path, "Snapshot") {
continue
}
profileFolder := fileutil.ParentBaseDir(path)
if strings.Contains(filepath.ToSlash(path), "/Network/Cookies") {
profileFolder = fileutil.BaseDir(strings.ReplaceAll(filepath.ToSlash(path), "/Network/Cookies", ""))
Expand All @@ -148,7 +164,7 @@ func chromiumWalkFunc(items []types.DataType, multiItemPaths map[string]map[type
multiItemPaths[profileFolder] = map[types.DataType]string{v: path}
}
}
return err
return nil
}
}

Expand Down
4 changes: 2 additions & 2 deletions browser/chromium/chromium_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (
"os/exec"
"strings"

"github.com/moond4rk/hackbrowserdata/crypto"
"github.com/moond4rk/hackbrowserdata/types"
"github.com/moond4rk/hackbrowserdata/utils/cryptoutil"
)

var (
Expand Down Expand Up @@ -49,7 +49,7 @@ func (c *Chromium) GetMasterKey() ([]byte, error) {
}
salt := []byte("saltysalt")
// @https://source.chromium.org/chromium/chromium/src/+/master:components/os_crypt/os_crypt_mac.mm;l=157
key := cryptoutil.PBKDF2Key(secret, salt, 1003, 16, sha1.New)
key := crypto.PBKDF2Key(secret, salt, 1003, 16, sha1.New)
if key == nil {
return nil, errWrongSecurityCommand
}
Expand Down
4 changes: 2 additions & 2 deletions browser/chromium/chromium_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
"github.com/godbus/dbus/v5"
keyring "github.com/ppacher/go-dbus-keyring"

"github.com/moond4rk/hackbrowserdata/crypto"
"github.com/moond4rk/hackbrowserdata/types"
"github.com/moond4rk/hackbrowserdata/utils/cryptoutil"
)

func (c *Chromium) GetMasterKey() ([]byte, error) {
Expand Down Expand Up @@ -69,7 +69,7 @@ func (c *Chromium) GetMasterKey() ([]byte, error) {
}
salt := []byte("saltysalt")
// @https://source.chromium.org/chromium/chromium/src/+/master:components/os_crypt/os_crypt_linux.cc
key := cryptoutil.PBKDF2Key(secret, salt, 1, 16, sha1.New)
key := crypto.PBKDF2Key(secret, salt, 1, 16, sha1.New)
c.masterKey = key
slog.Info("get master key success", "browser", c.name)
return key, nil
Expand Down
Loading
Loading