Giter VIP home page Giter VIP logo

swiftdump's Introduction

SwiftDump

SwiftDump is a command-line tool for retriving the Swift Object info from Mach-O file. Similar to class-dump, but the difference is that SwiftDump focus on swift 5 objects. For Mach-O files mixed with Objective-C and swift, you can combine class-dump with SwiftDump.

There is alos a Frida version named FridaSwiftDump.

You can either useSwiftDump for a Mach-O file or FridaSwiftDump for a foreground running app.

If you are curious about the Mach-O format, check the image at the bottom of this article.

demo

Usage

USAGE: SwiftDump [--debug] [--arch <arch>] <file> [--version]

ARGUMENTS:
  <file>                  MachO File

OPTIONS:
  -d, --debug             Show debug log.
  -a, --arch <arch>       Choose architecture from a fat binary (only support x86_64/arm64).
                          (default: arm64)
  -v, --version           Version
  -h, --help              Show help information.
  • SwiftDump ./TestMachO > result.txt
  • SwiftDump -a x86_64 ./TestMachO > result.txt

Features

  • Written entirely in swift, the project is tiny
  • Dump swift 5 struct/class/enum/protocol
  • Parse enum with payload case
  • Support inheritance and protocol
  • Since it is written in swift, the mangled names are demangled by swift's runtime function, such as swift_getTypeByMangledNameInContext and swift_demangle_getDemangledName.

Thanks to the runtime function, SwiftDump can demangle complex type, such as RxSwift variable. For example, RxSwift.Queue<(eventTime: Foundation.Date, event: RxSwift.Event<A.RxSwift.ObserverType.Element>)>

TODO

  • Parse swift function address
  • More

Compile

  1. Clone the repo
  2. Open SwiftDump.xcodeproj with Xcode
  3. Modify 'Signing & Capabilities' to use your own id
  4. Build & Run

The default Mach-O file path is Demo/test, you can change it in Xcode - Product - Scheme - Edit Scheme - Arguments

(Tested on Xcode Version 11.5 (11E608c), MacOS 10.15.5)

Credit

  • Machismo : Parsing of Mach-O binaries using swift.
  • swift-argument-parser : Straightforward, type-safe argument parsing for Swift.
  • Swift metadata : High level description of all the Swift 5 sections that can show up in a Swift binary.

License

MIT

Mach-O File Format

The following image shows how SwiftDump parse swift types from file Demo/test. You can open this file with MachOView.

demo

swiftdump's People

Contributors

mlkrisjohnson avatar neil-wu 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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

swiftdump's Issues

想咨询一下原理

你好作者,看了你的图,有些东西想咨询一下,0xfffffca8后面的0xfffffcc0也是一个type的address吗

解不了,直接报错了

MachO1 : [1] 3119 segmentation fault
MachO2: [1] 3153 illegal hardware instruction /Users/username/Project/Potatso/Tools/SwiftDump

如何获取字串?

您好,感谢您的贡献

请原谅新手的我可能询问了比较低级的问题

如图,使用您的工具dump出来之后,我该怎么利用Hopper工具获取字串?

我想寻找的字串写在extension enum里头。

十分感谢您的答复。

貼上的影像_2022_2_12_上午4_27.png

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.