Skip to content
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
32 changes: 31 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Available Commands:
init Configure saferwall CLI credentials
scan Upload and scan files
rescan Rescan an existing file using its hash
view View scan results for a file by its SHA256 hash
download Download a sample (and its artifacts)
souk Populate malware-souk database
version Version number
Expand All @@ -44,9 +45,30 @@ Available Commands:
Upload and scan files. Supports scanning a single file or an entire directory.

```sh
saferwall-cli scan -p /path/to/sample
# Scan a single file
saferwall-cli scan /path/to/sample

# Scan an entire directory
saferwall-cli scan /path/to/directory

# Scan with parallel uploads
saferwall-cli scan -p 4 /path/to/directory

# Force rescan if the file already exists
saferwall-cli scan -f /path/to/sample

# Enable detonation with custom timeout and OS
saferwall-cli scan -d -t 30 -o win-7 /path/to/sample
```

| Flag | Short | Default | Description |
|------|-------|---------|-------------|
| `--force` | `-f` | `false` | Force rescan if the file already exists |
| `--parallel` | `-p` | `1` | Number of files to scan in parallel |
| `--enableDetonation` | `-d` | `false` | Enable detonation (dynamic analysis) |
| `--timeout` | `-t` | `15` | Detonation duration in seconds |
| `--os` | `-o` | `win-10` | Preferred OS for detonation (`win-7` or `win-10`) |

### Rescan

Rescan an existing file by its SHA256 hash, or rescan a batch of hashes from a text file.
Expand All @@ -55,6 +77,14 @@ Rescan an existing file by its SHA256 hash, or rescan a batch of hashes from a t
saferwall-cli rescan <sha256>
```

### View

View scan results for a file by its SHA256 hash. Displays file identification (hashes, size), properties (format, packer, timestamps), classification verdict, and antivirus detection results. For archive files, it shows a summary table of all contained files.

```sh
saferwall-cli view <sha256>
```

### Download

Download a sample by its SHA256 hash, or provide a text file with one hash per line to download in batch.
Expand Down
2 changes: 1 addition & 1 deletion cmd/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ var downloadCmd = &cobra.Command{
webSvc := webapi.New(cfg.Credentials.URL)
token, err := webSvc.Login(cfg.Credentials.Username, cfg.Credentials.Password)
if err != nil {
log.Fatalf("failed to login to saferwall web service")
log.Fatalf("failed to authenticate: %v", err)
}

hashes := collectHashes(arg)
Expand Down
2 changes: 1 addition & 1 deletion cmd/rescan.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ var reScanCmd = &cobra.Command{
webSvc := webapi.New(cfg.Credentials.URL)
token, err := webSvc.Login(cfg.Credentials.Username, cfg.Credentials.Password)
if err != nil {
log.Fatalf("failed to login to saferwall web service")
log.Fatalf("failed to authenticate: %v", err)
}

arg := args[0]
Expand Down
2 changes: 1 addition & 1 deletion cmd/scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ var scanCmd = &cobra.Command{
webSvc := webapi.New(cfg.Credentials.URL)
token, err := webSvc.Login(cfg.Credentials.Username, cfg.Credentials.Password)
if err != nil {
log.Fatalf("failed to login to saferwall web service")
log.Fatalf("failed to authenticate: %v", err)
}

scanFile(webSvc, args[0], token)
Expand Down
14 changes: 7 additions & 7 deletions cmd/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ var viewCmd = &cobra.Command{
webSvc := webapi.New(cfg.Credentials.URL)
_, err := webSvc.Login(cfg.Credentials.Username, cfg.Credentials.Password)
if err != nil {
log.Fatalf("failed to login: %v", err)
log.Fatalf("failed to authenticate: %v", err)
}

var file entity.File
Expand All @@ -46,12 +46,12 @@ func init() {

// Styles for the report output.
var (
titleStyle = lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color("12"))
headerStyle = lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color("14"))
keyStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("8"))
detectStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("1"))
cleanStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("2"))
avNameStyle = lipgloss.NewStyle().Width(24)
titleStyle = lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color("12"))
headerStyle = lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color("14"))
keyStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("8"))
detectStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("1"))
cleanStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("2"))
avNameStyle = lipgloss.NewStyle().Width(24)
)

func printFileReport(file entity.File, webSvc webapi.Service) {
Expand Down