Skip to content
Open
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
File renamed without changes.
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
graft fwtool/data/
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,19 @@ A python tool to unpack Sony camera firmware images, ported from [nex-hack's fwt
* Known file system images are extracted

## Usage ##
Download the [latest release](https://github.com/ma1co/fwtool.py/releases/latest) (Windows or OS X) or clone this repository. Run `fwtool --help` for more information.
Download the [latest release](https://github.com/ma1co/fwtool.py/releases/latest) (Windows or OS X) or clone this repository. Run `fw-tool --help` for more information.

To install on Linux simply run ``` pip install git+https://github.com/ma1co/fwtool.py.git@master ``` and **fw-tool** will be avaiable in your shell.

### Unpack a firmware image ###
fwtool unpack -f Update_ILCE_V100.exe -o outDir
fw-tool unpack -f Update_ILCE_V100.exe -o outDir

The following files are accepted as input (*-f* flag):
* A Windows firmware updater executable (.exe file)
* The *FirmwareData.dat* file extracted from an updater
* A firmware dump created by running `dd if=/dev/nflasha of=dump.dat` on the camera

### Decode Backup.bin ###
fwtool print_backup -f Backup.bin
fw-tool print_backup -f Backup.bin

This will list all properties defined in Backup.bin, the settings file used on Sony cameras. In firmware updates, you can find different variants this file in the *0110_backup* directory.
5 changes: 2 additions & 3 deletions fwtool.py → fw-tool
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@

from fwtool import archive, pe, zip
from fwtool.sony import backup, bootloader, dat, fdat, flash, wbi

scriptRoot = getattr(sys, '_MEIPASS', os.path.dirname(__file__))
from fwtool.data import DEVICES_YML

def mkdirs(path):
try:
Expand Down Expand Up @@ -84,7 +83,7 @@ def constructMapping(loader, node):
self.add_constructor(yaml.resolver.BaseResolver.DEFAULT_MAPPING_TAG, constructMapping)

def getDevices():
with open(scriptRoot + '/devices.yml', 'r') as f:
with open(DEVICES_YML, 'r') as f:
return yaml.load(f, OrderedSafeLoader)


Expand Down
4 changes: 2 additions & 2 deletions fwtool.spec
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ suffix = {'linux2': '-linux', 'win32': '-win', 'darwin': '-osx'}
output = 'fwtool-' + subprocess.check_output(['git', 'describe', '--always', '--tags']).decode('ascii').strip() + suffix.get(sys.platform, '')

# Analyze files
a = Analysis(['fwtool.py'], excludes=['bz2', 'cffi', 'Crypto', 'doctest', 'encodings.idna', 'lzma', 'plistlib', 'py_compile', 'socket', 'tempfile', 'tracemalloc'], datas=[('devices.yml', '.')])
a = Analysis(['fw-tool'], excludes=['bz2', 'doctest', 'encodings.idna', 'lzma', 'plistlib', 'py_compile', 'socket', 'tracemalloc'], datas=[('fwtool/data/devices.yml', 'fwtool/data')])

# Generate executable
pyz = PYZ(a.pure, a.zipped_data)
exe = EXE(pyz, [('', 'fwtool.py', 'PYSOURCE')], a.binaries, a.zipfiles, a.datas, name=output)
exe = EXE(pyz, [('', 'fw-tool', 'PYSOURCE')], a.binaries, a.zipfiles, a.datas, name=output)
2 changes: 2 additions & 0 deletions fwtool/data/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import os
DEVICES_YML = os.path.dirname(__file__) + '/devices.yml'
File renamed without changes.
6 changes: 6 additions & 0 deletions fwtool/io/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ def __init__(self, file, offset=0, size=-1):
self.size = size
self.pos = 0

def seekable(self):
if self.file:
return self.file.seekable()
else:
return False

def seek(self, pos, ref=os.SEEK_SET):
if ref == os.SEEK_SET:
self.pos = pos
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
pycryptodomex
pyinstaller
pyyaml
62 changes: 62 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
from __future__ import print_function
import os
from glob import glob
from subprocess import check_output

from setuptools import setup, find_packages

PKG_DIR = os.path.dirname(os.path.realpath(__file__))

def git_cmd(p, args):
g = ['git', '-C', p]
return check_output(g + args).decode('UTF-8').strip().lstrip('v')

def git_version(p):
ver_all = git_cmd(p, ['describe', '--tags', '--dirty=.dirty'])
ver_tag = git_cmd(p, ['describe', '--tags', '--abbrev=0'])
return ver_tag + ver_all[len(ver_tag):].replace('-', '.dev', 1).replace('-', '+', 1)

with open('README.md') as f:
long_description = f.read()

with open('requirements.txt') as f:
requirements = f.read().splitlines()

if os.path.exists('version.txt'):
with open('version.txt') as f:
version = f.read().strip()
else:
version = git_version(PKG_DIR)

setup(
name='Sony-fwtool',
version=version,
install_requires=requirements,
author='ma1co',
author_email='ma1co@users.noreply.github.com',
packages=find_packages(exclude=('build', 'dist',)),
include_package_data=True,
url='https://github.com/ma1co/fwtool.py',
license='MIT',
description='A tool to unpack Sony camera firmware images',
long_description=long_description,
scripts=['fw-tool'],
classifiers=[
'Development Status :: 3 - Alpha',
'License :: OSI Approved :: MIT License',
'Operating System :: POSIX',
'Intended Audience :: Developers',
'Natural Language :: English',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Topic :: Software Development :: Libraries',
'Topic :: Software Development :: Libraries :: Python Modules',
'Topic :: Utilities',
],
)