Code Monkey home page Code Monkey logo

go-apfs's Introduction

[WIP] go-apfs 🚧

Go Go Reference GitHub

APFS parser written in pure Go


Originally from this ipsw branch

Install

go get github.com/blacktop/go-apfs

apfs cli

Install

go install github.com/blacktop/go-apfs/cmd/apfs@latest

With Homebrew

brew install blacktop/tap/apfs

OR download from Releases

Build

git clone https://github.com/blacktop/go-apfs.git
cd go-apfs
make build

List files

Extract filesystem DMG from IPSW using ipsw

❯ ipsw extract --dmg IPSW
   • Extracting File System DMG
   • Created 018-62379-017.dmg

List the / directory

❯ apfs ls 018-62379-017.dmg

DT_DIR - 06Jun21 02:54:21 - .ba
DT_DIR - 06Jun21 02:54:22 - .mb
DT_DIR - 06Jun21 02:54:22 - Applications
DT_DIR - 06Jun21 02:54:54 - Developer
DT_DIR - 06Jun21 02:54:54 - Library
DT_DIR - 06Jun21 02:55:03 - System
DT_DIR - 06Jun21 03:01:39 - bin
DT_DIR - 06Jun21 03:01:39 - cores
DT_DIR - 06Jun21 03:01:39 - dev
DT_DIR - 06Jun21 03:01:39 - private
DT_DIR - 06Jun21 03:01:39 - sbin
DT_DIR - 06Jun21 03:01:39 - usr
DT_LNK - 06Jun21 03:01:39 - etc
DT_LNK - 06Jun21 03:01:39 - tmp
DT_LNK - 06Jun21 03:01:53 - var
DT_REG - 06Jun21 02:54:21 - .file

Cat files

❯ apfs cat APFS.dmg /System/Library/FeatureFlags/Global.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>SiriUI</key>
        <dict>
                <key>Pym</key>
                <dict>
                        <key>Enabled</key>
                        <true/>

Copy files

❯ apfs cp APFS.dmg /System/Library/Caches/com.apple.dyld/dyld_shared_cache_arm64e
❯ ls -lah dyld_shared_cache_arm64e

-rwxr-xr-x  1 blacktop  staff   1.4G Sep  9 23:56 dyld_shared_cache_arm64e

Spec

Supports up to version 2020-06-22 of the APFS specification

License

Apache 2.0 Copyright (c) 2020-2023 blacktop

go-apfs's People

Contributors

blacktop avatar crkatri avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

go-apfs's Issues

unknown compression type: CMP_ATTR_UNCOMPRESSED

Trying to extract small files from an iOS rootfs dmg gives this error:

$ apfs cp /data/038-44862-252.dmg /System/Library/FeatureFlags/Domain/Sharing.plist
   ⨯ unknown compression type: CMP_ATTR_UNCOMPRESSED

(This dmg is from iPhone_4.7_14.5_18E199_Restore.ipsw but any should work to reproduce the issue)

I speculate that it fails for the exact same set of files that also fail with apfs-fuse (giving "input/output error"), but I haven't done enough testing to be sure.

Support for dmgs extracted from IMG4

> tar -xf iPhone14,5_15.4.1_19E258_Restore.ipsw 078-29017-016.dmg                 

> file 078-29017-016.dmg 
078-29017-016.dmg: IM4P, ramdisk

> ipsw img4 extract 078-29017-016.dmg           
   • Parsing Im4p             
      • Exracting payload to file 078-29017-016.dmg.payload

> apfs ls 078-29017-016.dmg.payload                           
Error: found unexpected UDIFResourceFile signure: , expected: koly

As you can see from that, the dmgs extracted from an IM4P can be mounted by hdiutil but not parsed by go-apfs.

dpkg conflict with ipsw

Trying to install this alongside with ipsw from the debs results in the following dpkg error,

Building dependency tree
Reading state information... Done
Note, selecting 'go-apfs' instead of './go-apfs_1.0.16_linux_x86_64.deb'
The following NEW packages will be installed:
  go-apfs
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/2954 kB of archives.
After this operation, 6962 kB of additional disk space will be used.
Get:1 /home/haow6/go-apfs_1.0.16_linux_x86_64.deb go-apfs amd64 1.0.16 [2954 kB]
(Reading database ... 42651 files and directories currently installed.)
Preparing to unpack .../go-apfs_1.0.16_linux_x86_64.deb ...
Unpacking go-apfs (1.0.16) ...
dpkg: error processing archive /home/haow6/go-apfs_1.0.16_linux_x86_64.deb (--unpack):
 trying to overwrite '/usr/share/doc/ipsw/copyright', which is also in package ipsw 3.1.107
Errors were encountered while processing:
 /home/haow6/go-apfs_1.0.16_linux_x86_64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

dyld extraction failed on IOS 16 ipsw

Hi.
Thanks a lot for all of your work here !

Are you going to add support to the new compression method (LZBITMAP) ?
I'm failing extracting /root/System/Library/Caches/com.apple.dyld/dyld_shared_cache_arm64e.28.dyldlinkedit..

"Unexpected EOF" error

When extracting /System/Library/FeatureFlags/Global.plist from iPhone_4.7_14.5_18E199_Restore.ipsw rootfs (038-44862-252.dmg), I get an "unexpected EOF" error:

$ apfs cp 038-44862-252.dmg /System/Library/FeatureFlags/Global.plist
   ⨯ unexpected EOF           

Running with -V gives confusing log messages, like it was traversing an unrelated directory when the error happened...

Feature Request: `apfs cat`

Basically identical to cat(1) just so that I can see the contents of a file without having to run apfs cp.

Add recursive ls

I would like to get the entire filesystem tree of an APFS dmg. Currently apfs ls only shows a single directory, and running repeated apfs ls foo.dmg /some/directory for every subdirectory found on previous commands is extremely slow. It would be useful if ls had a recursive option. Or maybe a new sub-command...

Support for raw APFS

The new iOS 16.0 ipsws contain cryptexes for divided updates that are in raw APFS dmgs (I think).

iOS/ipsw/dmgs 
➜ file 078-37456-031.dmg
078-37456-031.dmg: Apple File System (APFS), blocksize 4096

iOS/ipsw/dmgs 
➜ apfs ls 078-37456-031.dmg                                               
Error: found unexpected UDIFResourceFile signure: , expected: koly

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.