iOS安全攻防(六)使用class-dump導出Frameworks頭文件

我的原創,轉帖請註明來源:cnblogs.com/jailbreakerapi

class_dump這個工具,能夠導出sdk中似有api的頭文件,也能夠導出別人的app中使用的頭文件,工具是開源的,做者網站:http://stevenygard.com/projects/class-dump/app

去網站下載後 dmg後 打開並把 class-dump copy 到 /usr/bin/ 目錄下(這是個人bin目錄,可能和你本身的路徑不一樣),能夠是使用 open -a finder /usr/bin  命令打開。工具

接着修改下 class-dump 權限,終端輸入 chmod 777 /usr/bin/class-dump網站

網上有個perl寫的腳本(DumpFrameworks.pl),能夠直接導出Frameworks 和 PrivateFrameworks 的頭文件,2個Frameworks的路徑更改下,我直接貼上DumpFrameworks.pl的源碼。ui

 

#!/usr/bin/perl
#
# 24 November 2008
# Framework Dumping utility; requires class-dump
#
 
use strict;
 
use Cwd;
use File::Path;
 
my $HOME = (getpwuid($<))[7] || $ENV{'HOME'} 
  ordie"Could not find your home directory!";
 
# This command must be in your path.
# http://www.codethecode.com/projects/class-dump/
my $CLASS_DUMP = 'class-dump'; 
 
# Public Frameworks
dump_frameworks('/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk/System/Library/Frameworks',
'Frameworks');
 
# Private Frameworks
dump_frameworks('/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk/System/Library/PrivateFrameworks',
'PrivateFrameworks');
 
sub dump_frameworks
{
  my($dir, $subdir) = @_;
 
  opendir(my $dirh, $dir) ordie"Could not opendir($dir) - $!";
 
  # Iterate through each framework found in the directory
  foreach my $file (grep { /\.framework$/ } readdir($dirh))
  {
    # Extract the framework name
    (my $fname = $file) =~ s/\.framework$//;
    print"Framework: $fname\n";
 
    my $headers_dir = "$HOME/Headers/$subdir/$fname";
 
    # Create the folder to store the headers
    mkpath($headers_dir);
 
    # Perform the class-dump
    my $cwd = cwd();
    chdir($headers_dir) ordie"Could not chdir($headers_dir) - $!";
 
    system($CLASS_DUMP, '-H', "$dir/$file");
   
   if($? == -1)
    {
      die"Could not execute $CLASS_DUMP - $!\n";
    }
    
    chdir($cwd) ordie"Could not chdir($cwd) - $!";
  }
}

保存好以後,終端進入DumpFrameworks.pl所在的目錄 執行命令  ./DumpFrameworks.pl spa

命令執行完,在用戶目錄下 會出現 Headers,裏面包括了咱們導出的Frameworks 和PrivateFrameworks 文件夾,見下圖:code

NewImage

相關文章
相關標籤/搜索