-
Notifications
You must be signed in to change notification settings - Fork 2
/
describe-swf.ps1
44 lines (35 loc) · 1.07 KB
/
describe-swf.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
param (
# Where to find the SWF to describe
[string]$path
)
# Get the header information from this SWF file. This will also help
# us to validate that this is indeed a proper SWF file.
$bytes = Get-Content $path -Encoding byte -TotalCount 8
# The first 3 bytes have a required order. We'll use this for validation
$valid = $false
$compression = "Unknown"
# Convert from decimal to hex
$b0 = [String]::Format("{0:x}", $bytes[0])
$b1 = [String]::Format("{0:x}", $bytes[1])
$b2 = [String]::Format("{0:x}", $bytes[2])
# * 57 53 is the required format, so all valid SWF files will have
# hex 57 and hex 53 as their 2nd and 3rd bytes
if ($b1 -eq "57" -and $b2 -eq "53") {
$valid = $true
if ($b0 -eq "43") {
$compression = "Uncompressed"
}
elseif ($b0 -eq "47") {
$compression = "ZLIB Compression"
}
elseif ($b0 -eq "60") {
$compression = "LZMA Compression"
}
}
# Check if we had valid formats
if ($false -eq $valid) {
return "0", $compression
}
# the 4th byte is its version
$version = $bytes[3]
return $version, $compression