bbarchivist API Documentation¶
Archivist module¶
-
bbarchivist.archivist.do_magic(osversion, radioversion, softwareversion, localdir, radios=True, compressed=True, deleted=True, hashed=True, crc32=False, adler32=False, sha1=True, sha224=False, sha256=False, sha384=False, sha512=False, md5=True, md4=False, ripemd160=False, whirlpool=False, cappath='cap.exe', download=True, extract=True, loaders=True, signed=True, compmethod='7z')[source]¶ Wrap around multi-autoloader creation code. Some combination of creating, downloading, hashing, compressing and moving autoloaders.
Parameters: - osversion (str) – OS version, 10.x.y.zzzz.
- radioversion (str) – Radio version, 10.x.y.zzzz.
- softwareversion (str) – Software release, 10.x.y.zzzz.
- localdir (str) – Working directory. Required.
- radios (bool) – Whether to create radio autoloaders. True by default.
- compressed (bool) – Whether to compress files. True by default.
- deleted (bool) – Whether to delete uncompressed files. True by default.
- hashed (bool) – Whether to hash files. True by default.
- crc32 (bool) – Whether to use CRC32. False by default.
- adler32 (bool) – Whether to use Adler-32. False by default.
- sha1 (bool) – Whether to use SHA-1. True by default.
- sha224 (bool) – Whether to use SHA-224. False by default.
- sha256 (bool) – Whether to use SHA-256. False by default.
- sha384 (bool) – Whether to use SHA-384. False by default.
- sha512 (bool) – Whether to use SHA-512. False by default.
- md5 (bool) – Whether to use MD5. True by default.
- md4 (bool) – Whether to use MD4. False by default.
- ripemd160 (bool) – Whether to use RIPEMD160. False by default.
- whirlpool (bool) – Whether to use Whirlpool. False by default.
- cappath (str) – Path to cap.exe. Default is local dir ‘cap.exe’.
- download (bool) – Whether to download bar files. True by default.
- extract (bool) – Whether to extract bar files. True by default.
- loaders (bool) – Whether to create autoloaders. True by default.
- signed (bool) – Whether to delete signed files. True by default.
- compmethod (str) – Compression method. Default is “7z” with fallback “zip”.
Archivist wrapper¶
Barutils module¶
-
bbarchivist.barutils.compress(filepath, method='7z', szexe='7za.exe')[source]¶ Compress all autoloader files in a given folder, with a given method.
Parameters: - filepath (str) – Working directory. Required.
- method (str) – Compression type. Default is “7z”. Defined in source.
- szexe (str) – Path to 7z executable, if needed.
-
bbarchivist.barutils.extract_bars(filepath)[source]¶ Extract .signed files from .bar files. Use system zlib.
Parameters: filepath (str) – Path to bar file directory.
-
bbarchivist.barutils.move_loaders(localdir, exedir_os, exedir_rad, zipdir_os, zipdir_rad)[source]¶ Move autoloaders to zipped and loaders directories in localdir.
Parameters: - localdir (str) – Local directory, containing files you wish to move.
- exedir_os (str) – Large autoloader .exe destination.
- exedir_rad (str) – Small autoloader .exe destination.
- zipdir_os (str) – Large autoloader archive destination.
- zipdir_rad (str) – Small autoloader archive destination.
Carrierchecker module¶
-
bbarchivist.carrierchecker.doMagic(mcc, mnc, device, download=False, upgrade=False, directory='X:\\bbndk\\workspace\\bbarchivist\\docs\\bbarchivist', export=False)[source]¶ Wrap around
bbarchivist.networkutilscarrier checking.Parameters: - mcc (int) – Country code.
- mnc (int) – Network code.
- device (str) – Device ID (SXX100-#)
- download (bool) – Whether or not to download. Default is false.
- upgrade (bool) – Whether or not to use upgrade files. Default is false.
- directory (str) – Where to store files. Default is local directory.
- export (bool) – Whether or not to write URLs to a file. Default is false.
Carrierchecker wrapper¶
-
bbarchivist.carrierchecker_wrap.main()[source]¶ Parse arguments from argparse/questionnaire.
Invoke
bbarchivist.carrierchecker.doMagic()with those arguments.
Escreens module¶
-
bbarchivist.escreens.calculate_escreens(pin, app, uptime, duration=30)[source]¶ Calculate key for the Engineering Screens based on input.
Parameters: - pin (str) – PIN to check. 8 character hexadecimal, lowercase.
- app (str) – App version. 10.x.y.zzzz.
- uptime (str) – Uptime in ms.
- duration (str) – 1, 3, 6, 15, 30 (days).
Escreens wrapper¶
-
bbarchivist.escreens_wrap.main()[source]¶ Parse arguments from argparse/questionnaire.
Invoke
bbarchivist.escreens.calculate_escreens()with arguments.
Hashwrapper wrapper¶
-
bbarchivist.filehasher_wrap.main()[source]¶ Parse arguments from argparse/questionnaire.
Invoke
bbarchivist.hashwrapper.verifier()with those arguments.
Filehashtools module¶
-
bbarchivist.filehashtools.adler32hash(filepath, blocksize=16777216)[source]¶ Return Adler32 checksum of a file.
Parameters: - filepath (str) – File you wish to verify.
- blocksize (int) – How much of file to read at once.
-
bbarchivist.filehashtools.crc32hash(filepath, blocksize=16777216)[source]¶ Return CRC32 checksum of a file.
Parameters: - filepath (str) – File you wish to verify.
- blocksize (int) – How much of file to read at once.
-
bbarchivist.filehashtools.md4hash(filepath, blocksize=16777216)[source]¶ Return MD4 hash of a file; depends on system SSL library.
Parameters: - filepath (str) – File you wish to verify.
- blocksize (int) – How much of file to read at once.
-
bbarchivist.filehashtools.md5hash(filepath, blocksize=16777216)[source]¶ Return MD5 hash of a file.
Parameters: - filepath (str) – File you wish to verify.
- blocksize (int) – How much of file to read at once.
-
bbarchivist.filehashtools.ripemd160hash(filepath, blocksize=16777216)[source]¶ Return RIPEMD160 hash of a file; depends on system SSL library.
Parameters: - filepath (str) – File you wish to verify.
- blocksize (int) – How much of file to read at once.
-
bbarchivist.filehashtools.sha1hash(filepath, blocksize=16777216)[source]¶ Return SHA-1 hash of a file.
Parameters: - filepath (str) – File you wish to verify.
- blocksize (int) – How much of file to read at once.
-
bbarchivist.filehashtools.sha224hash(filepath, blocksize=16777216)[source]¶ Return SHA-224 hash of a file.
Parameters: - filepath (str) – File you wish to verify.
- blocksize (int) – How much of file to read at once.
-
bbarchivist.filehashtools.sha256hash(filepath, blocksize=16777216)[source]¶ Return SHA-256 hash of a file.
Parameters: - filepath (str) – File you wish to verify.
- blocksize (int) – How much of file to read at once.
-
bbarchivist.filehashtools.sha384hash(filepath, blocksize=16777216)[source]¶ Return SHA-384 hash of a file.
Parameters: - filepath (str) – File you wish to verify.
- blocksize (int) – How much of file to read at once.
Hashwrapper module¶
-
bbarchivist.hashwrapper.verifier(workingdir, blocksize=16777216, crc32=False, adler32=False, sha1=True, sha224=False, sha256=False, sha384=False, sha512=False, md5=True, md4=False, ripemd160=False, whirlpool=False)[source]¶ For all files in a directory, perform various hash/checksum functions. Functions based on boolean arguments, writing the output to a .cksum file.
Parameters: - workingdir (str) – Path containing files you wish to verify.
- blocksize (int) – How much of file to read at once.
- crc32 (bool) – Use of CRC32. False by default.
- adler32 (bool) – Use of Adler-32. False by default.
- sha1 (bool) – Use of SHA-1. True by default.
- sha224 (bool) – Use of SHA-224. False by default.
- sha256 (bool) – Use of SHA-256. False by default.
- sha384 (bool) – Use of SHA-384. False by default.
- sha512 (bool) – Use of SHA-512. False by default.
- md5 (bool) – Use of MD5. True by default.
- md4 (bool) – Use of MD4. False by default. Depends on system.
- ripemd160 (bool) – Use of RIPEMD160. False by default. Depends on system.
- whirlpool (bool) – Use of Whirlpool. False by default. Depends on system.
Lazyloader module¶
-
bbarchivist.lazyloader.doMagic(osversion, radioversion, softwareversion, device, localdir, autoloader)[source]¶ Wrap the tools necessary to make one autoloader.
Parameters: - osversion (str) – OS version, 10.x.y.zzzz.
- radioversion (str) – Radio version, 10.x.y.zzzz.
- softwareversion (str) – Software version, 10.x.y.zzzz.
- device (int) – Device family to create loader for.
- localdir (str) – Working path. Default is local dir.
- autoloader (bool) – Whether to run loaders. Default is false. Windows-only.
Lazyloader wrapper¶
-
bbarchivist.lazyloader_wrap.main()[source]¶ Parse arguments from argparse/questionnaire.
Invoke
bbarchivist.lazyloader.doMagic()with those arguments.
Loadergen module¶
-
bbarchivist.loadergen.generate_lazy_loader(osversion, radioversion, device, cap='cap.exe', localdir='X:\\bbndk\\workspace\\bbarchivist\\docs\\bbarchivist')[source]¶ generate_loaders(), but for making one OS/radio loader.Parameters: - osversion (str) – OS version, 10.x.y.zzzz.
- radioversion (str) – Radio version, 10.x.y.zzzz.
- device (int) – Selected device, from
- cap (str) – Path to cap.exe. Default is local dircap.exe.
- localdir (str) – Working path. Default is local dir.
-
bbarchivist.loadergen.generate_loaders(osversion, radioversion, radios=True, cap='cap.exe', localdir='X:\\bbndk\\workspace\\bbarchivist\\docs\\bbarchivist')[source]¶ Create and properly label autoloaders. Leverages Python implementation of cap.exe.
Parameters: - osversion (str) – OS version, 10.x.y.zzzz.
- radioversion (str) – Radio version, 10.x.y.zzzz.
- radios (bool) – Whether to make radios or not. True by default.
- cap (str) – Path to cap.exe. Default is local dircap.exe.
- localdir (str) – Working path. Default is local dir.
Networkutils module¶
-
class
bbarchivist.networkutils.DownloadManager(download_dict, output_directory, thread_count=5)[source]¶ Bases:
objectClass that handles queued downloads. Based on: http://pipe-devnull.com/2012/09/13/queued-threaded-http-downloader-in-python.html
-
begin_downloads()[source]¶ Start
Downloaderthreads for queued downloads.
-
-
class
bbarchivist.networkutils.Downloader(queue, output_directory)[source]¶ Bases:
threading.ThreadDownloads files attached to supplied threads from DownloadManager. Based on: http://pipe-devnull.com/2012/09/13/queued-threaded-http-downloader-in-python.html
-
bbarchivist.networkutils.availability(url)[source]¶ Check HTTP status code of given URL. 200 or 301-308 is OK, else is not.
Parameters: url (str) – URL to check.
-
bbarchivist.networkutils.carrier_checker(mcc, mnc)[source]¶ Query BlackBerry World to map a MCC and a MNC to a country and carrier.
Parameters: - mcc (int) – Country code.
- mnc (int) – Network code.
-
bbarchivist.networkutils.carrier_update_request(mcc, mnc, device, download=False, upgrade=False)[source]¶ Query BlackBerry servers, check which update is out for a carrier.
Parameters: - mcc (int) – Country code.
- mnc (int) – Network code.
- device (str) – Hexadecimal hardware ID.
- download (bool) – Whether to download files. False by default.
- upgrade (bool) – Whether to use upgrade files. False by default.
Pseudocap module¶
-
bbarchivist.pseudocap.ghetto_convert(intsize)[source]¶ Convert from decimal integer to little endian hexadecimal string, padded to 16 characters with zeros.
Parameters: intsize (integer) – Integer you wish to convert.
-
bbarchivist.pseudocap.make_autoloader(filename, cap, firstfile, secondfile='', thirdfile='', fourthfile='', fifthfile='', sixthfile='', folder='X:\\bbndk\\workspace\\bbarchivist\\docs\\bbarchivist')[source]¶ Python implementation of cap.exe. Writes cap.exe, magic offset, signed files to a .exe file.
make_offset()is used to create the offset.Parameters: - filename (str) – Name of autoloader.
- cap (str) – Location of cap.exe file.
- firstfile (str) – First signed file. Required.
- secondfile (str) – Second signed file. Optional.
- thirdfile (str) – Third signed file. Optional.
- fourthfile (str) – Fourth signed file. Optional.
- fifthfile (str) – Fifth signed file. Optional.
- sixthfile (str) – Sixth signed file. Optional.
- folder (str) – Working folder. Optional.
-
bbarchivist.pseudocap.make_offset(cap, firstfile, secondfile='', thirdfile='', fourthfile='', fifthfile='', sixthfile='', folder='X:\\bbndk\\workspace\\bbarchivist\\docs\\bbarchivist')[source]¶ Create magic offset file for use in autoloader creation. Cap.exe MUST match separator version. Version defined in
bbarchivist.bbconstants._capversion.Parameters: - cap (str) – Location of cap.exe file.
- firstfile (str) – First signed file. Required.
- secondfile (str) – Second signed file. Optional.
- thirdfile (str) – Third signed file. Optional.
- fourthfile (str) – Fourth signed file. Optional.
- fifthfile (str) – Fifth signed file. Optional.
- sixthfile (str) – Sixth signed file. Optional.
- folder (str) – Working folder. Optional.
Utilities module¶
-
bbarchivist.utilities.escreens_duration(duration)[source]¶ Check if escreens duration is valid.
Parameters: duration (int) – Duration to check.
-
bbarchivist.utilities.escreens_pin(pin)[source]¶ Check if given PIN is valid (8 character hexadecimal)
Parameters: pin (str) – PIN to check.
-
bbarchivist.utilities.file_exists(file)[source]¶ Check if file exists. Used for parsing file inputs from command line.
Parameters: file (str) – Path to a file, including extension.
-
bbarchivist.utilities.get_core_count()[source]¶ Find out how many CPU cores this system has. Good for multicore compression.
-
bbarchivist.utilities.get_seven_zip(talkative=False)[source]¶ Return name of 7-Zip executable. On POSIX, it MUST be 7za. On Windows, it can be installed or supplied with the script.
win_seven_zip()is used to determine if it’s installed.Parameters: talkative (bool) – Whether to output to screen. False by default.
-
bbarchivist.utilities.positive_integer(inputint)[source]¶ Check if number > 0. Used for parsing integer inputs from command line.
Parameters: inputint (int) – Integer to check.
-
bbarchivist.utilities.prep_seven_zip()[source]¶ Check for presence of 7-Zip. On POSIX, checks for p7zip. On Windows, checks for 7-Zip. Returns False if not found, True if found.
-
bbarchivist.utilities.return_family(index)[source]¶ Return device family from selected HWID. Lists found in bbconstants module.
Parameters: index (int) – The index to look up.
-
bbarchivist.utilities.return_model(index)[source]¶ Return device model from selected HWID/variant index. Lists found in bbconstants module.
Parameters: index (int) – The index to look up.
-
bbarchivist.utilities.str2bool(v)[source]¶ Parse bool from string input.
Parameters: v (str) – String to check if it means True or False.
-
bbarchivist.utilities.win_seven_zip(talkative=False)[source]¶ For Windows, checks where 7-Zip is. Consults registry first for any installed instances of 7-Zip. If it’s not there, it falls back onto the supplied executables. If those aren’t there, return “error”.
Parameters: talkative (bool) – Whether to output to screen. False by default.