IOSRE常用命令

Cycript

显示app窗口结构:

 [[UIApp keyWindow] recursiveDescription].toString()

微信历史版本

微信历史版本可以pp助手越狱版(apt.25pp.com)里历史版本里找到。

# Reveal 破解版下载

爱情守望者->Reveal

在cydia源里

cleanmymac 破解版下载 

LLDB

iOS逆向工程之Hopper+LLDB调试第三方App

使用LLDB调试程序

bash

组合键Ctrl+r 进入reverse-i-search模式,可以命令的前面几个字母来查找 如果匹配了多个条目的话可以用上下键来选择 比如下面,用k字就匹配到了上面一条命令

5C01:/Library/Logs/CrashReporter root# killall backboardd
(reverse-i-search)`k': killall backboardd

rvictl

此命令可以开启远程虚拟接口进行wireless抓包 参数为设置的UDID

Remote Virtual Interface Tool starts and stops a remote packet capture instance 
for any set of attached mobile devices. It can also provide feedback on any attached 
devices that are currently relaying packets back to this host. 

Options:
	-l, -L		List currently active devices
	-s, -S		Start a device or set of devices
	-x, -X		Stop a device or set of devices

SSH

ssh-copy-id命令可以把本地主机的公钥复制到远程主机的authorized_keys文件上,ssh-copy-id命令也会给远程主机的用户主目录(home)和~/.ssh, 和~/.ssh/authorized_keys设置合适的权限。

ssh-copy-id [-i [identity_file]] [user@]machine

1、把本地的ssh公钥文件安装到远程主机对应的账户下:

ssh-copy-id user@server
ssh-copy-id -i ~/.ssh/id_rsa.pub user@server

ObjectiveC中打印Call Stack的若干方法

NSLog(@"%@", [NSThread callStackSymbols]);

通过backtrace_symbols_fd

#import <execinfo.h>
#import <unistd.h>

void PrintCallStack() {
  void *stackAdresses[32];
  int stackSize = backtrace(stackAdresses, 32);
  backtrace_symbols_fd(stackAdresses, stackSize, STDOUT_FILENO);
}

通过NSException

@catch (NSException *exception)
{
    NSLog(@"%@", [exception callStackSymbols]);
}
当然也可以在UncaughtExceptionHandler中拿到NSException
NSSetUncaughtExceptionHandler(&uncaughtExceptionHandler);
void uncaughtExceptionHandler(NSException *exception)
{
    NSLog(@"reason:%@ exception nanme:%@",[exception reason], [exception name]);
    NSLog(@"call stack:%@",[exception callStackSymbols]); } [iOS安全–使用introspy追踪IOS应用](http://www.blogfshare.com/ioss-introspy.html)

刚刚试用snoopit ,结果它在IOS8里面出BUG,把我的/Applications文件夹都删了。

还好我还有一台IOS8.2的设备,把里面的文件拷到这个机器上,再把文件的权限设置一下,又可以跑了。

cydia 自动源

/private/etc/apt/sources.list.d/cydia.list

更新bash_profile

source ~/.bash_profile

Stripping Unwanted Architectures From Dynamic Libraries In Xcode

APP_PATH="${TARGET_BUILD_DIR}/${WRAPPER_NAME}"

# This script loops through the frameworks embedded in the application and
# removes unused architectures.
find "$APP_PATH" -name '*.framework' -type d | while read -r FRAMEWORK
do
    FRAMEWORK_EXECUTABLE_NAME=$(defaults read "$FRAMEWORK/Info.plist" CFBundleExecutable)
    FRAMEWORK_EXECUTABLE_PATH="$FRAMEWORK/$FRAMEWORK_EXECUTABLE_NAME"
    echo "Executable is $FRAMEWORK_EXECUTABLE_PATH"

    EXTRACTED_ARCHS=()

    for ARCH in $ARCHS
    do
        echo "Extracting $ARCH from $FRAMEWORK_EXECUTABLE_NAME"
        lipo -extract "$ARCH" "$FRAMEWORK_EXECUTABLE_PATH" -o "$FRAMEWORK_EXECUTABLE_PATH-$ARCH"
        EXTRACTED_ARCHS+=("$FRAMEWORK_EXECUTABLE_PATH-$ARCH")
    done

    echo "Merging extracted architectures: ${ARCHS}"
    lipo -o "$FRAMEWORK_EXECUTABLE_PATH-merged" -create "${EXTRACTED_ARCHS[@]}"
    rm "${EXTRACTED_ARCHS[@]}"

    echo "Replacing original executable with thinned version"
    rm "$FRAMEWORK_EXECUTABLE_PATH"
    mv "$FRAMEWORK_EXECUTABLE_PATH-merged" "$FRAMEWORK_EXECUTABLE_PATH"

done

ipainstaller 安装ipa到用户空间

postinst 脚本用  > /dev/null   true 来隐藏错误返回

清空日志文件

可以通过cat /dev/null > /var/log/syslog来清空它

禁用Xcode的代码签名功能

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOSx.x.sdk/SDKSettings.plist

CODE_SIGNING_REQUIRED YES 改为 NO

重启Xcode

备注:这里可能会遇到系统提示【“SDKSettings.plist” is locked for editing……】,这是因为文件读写的权限问题,解决办法如下:

首先,修改文件夹权限,此时我们所在目录是iPhoneOS8.0.sdk,如果输入指令“cd ..”返回上级目录,“ls -al”查看所有文件,会发现系统显示iPhoneOS8.0.sdk -> iPhoneOS.sdk,这表示iPhoneOS8.0.sdk是指向iPhoneOS.sdk的快捷方式,所以我们要修改的真正文件夹是iPhoneOS.sdk,指令如下:

1 sudo chmod -R 777 iPhoneOS.sdk

然后,修改文件夹内所有文件的读写权限:

1 sudo chmod 777 *

现在双击打开SDKSettings.plist,你会发现,刚才不能修改的属性可以修改了!

清空iOS日志

用iTunes同步。

iOS10.0.2 yalu越狱之后无法使用openssh的问题

具体方法: 1.卸载手机上的OpenSSL和Openssh 2.添加源:http://cydia.ichitaso.com/test 3.进入上面这个源里重新下载:dropbear 4.安装完毕,执行ssh root@deviceIP,默认密码为alpine(也可以在iPhone里下载ssh软件进行连接测试) 5.成功后,再重新安装openssh和OpenSSL了(经测试不会影响SSH连接iPhone)。 参考链接:https://www.jianshu.com/p/91e0c22a6ea7

如果在cycript里遇到 @”\xe7\xbd\x91\xe9\xa1\xb5\xe5\xbe\xae\xe4\xbf\xa1\xe5\xb7\xb2\xe7\x99\xbb\xe5\xbd\x95” 这种显示形式的字符串 

echo -e “\xe7\xbd\x91\xe9\xa1\xb5\xe5\xbe\xae\xe4\xbf\xa1\xe5\xb7\xb2\xe7\x99\xbb\xe5\xbd\x95”

网页微信已登录

iOS9,10 去掉 NO SIM Alert

iOS8里有个插件NoNoSim,在iOS9里可以用下面的方法

%hook SBSIMLockManager
-(BOOL)_shouldSuppressAlert { return YES; } 
%end

iOS10 用yalu越狱之后无法使用ssh scp 的问题

1.卸载手机上的OpenSSL和Openssh 2.添加源安装 http://cydia.ichitaso.com/test 重新安装dropbear

openssh 在iOS10上有兼容问题,所以yalu的作者使用了安全性更好的dropbear。

因为没有scp所以,可以在安装OPENSSH之后把scp 依赖的库/usr/lib/libcrypto.0.9.8.dylib拷贝一份。 再从OPENSSH的依赖项里把openssl去掉。

这样即可以用ssh又可以用scp了。

怎么修改deb包之后又打包回去

dpkg-deb -X 释放普通文件 dpkg-deb -e 释放控制文件 置于DEBIAN 文件夹里 dpkg-deb -b 打包回去

下载cydia里的deb 文件

爬虫网站 http://ipod-touch-max.ru/cydia/index.php?cat=package&id=32694 http://cydiaupdates.com/ app https://github.com/borishonman/cydownload/releases

wireshark 抓包时出现 you don’t have permission to capture on that device

https://stackoverflow.com/questions/41126943/wireshark-you-dont-have-permission-to-capture-on-that-device-mac

确认/dev/bpf0 到 /dev/bpf9 权限都是 liaogang:admin 而不是 root:wheel

iOS Runtime Headers

xcode 调试第三方应用 

http://iosre.com/t/xcode/8567

直接在设备上用ldid给app/exec中的授权证书添加如下字段即可:

    <key>get-task-allow</key>
    <true/>

查看exec加载了哪些符号 

otool -L exec

获取设备UDID

https://www.jianshu.com/p/9d059c17481d

应用程序包路径

沙盒路径: /var/mobile/Containers/Data/Application/8CF3DA4E-BF8E-4509-93D7-D131E12F7176 bundle路径: /var/containers/Bundle/Application/5044D35F-ECB1-4E00-872C-7805F8C14AD8/Aweme.app/Aweme

在SpringBoard里使用定时器不是一个好的做法

使用dispatch_after来代替

多个Tweak钩一个类的同一个方法

除了第一个钩住的,后面的都会失效?

##sqlite 数据导出为excel表格格式

首先用sqlite3命令导出sqlite表为cvs文件。再用numbers打开,导出为excel order by a limite 0,1000

sqlite3 c:/sqlite/chinook.db sqlite> .headers on sqlite> .mode csv sqlite> .output data.csv sqlite> SELECT customerid, …> firstname, …> lastname, …> company …> FROM customers; sqlite> .quit

–select userID,min(rowid) from Collected_Account –select * from Collected_Account where userID is ‘105184085394’ –select distinct userID from Collected_Account –select * from Collected_Account where userID in (select distinct userID from Collected_Account)

–select userID from Collected_Account group by userID having count() >= 2 –delete from Collected_Account where rowid in (select rowid from Collected_Account group by userID having count() >= 2) delete from Collected_Account where userID is ‘99744665393’

IDAPro F5出现too big function 解决

修改配置文件IDA 7.0\cfg\hexrays.cfg

MAX_FUNCSIZE            = 64        // Functions over 64K are not decompiled
 
// 修改为:
MAX_FUNCSIZE            = 1024        // Functions over 64K are not decompiled