ios使用私有api被拒

2018-02-27 11:29:30来源:oschina作者:RayChow_周小睿人点击

分享
简介

直接被拒,被拒原因如下图.Your app uses or references the following non-public APIs:PrivateFrameworks/WebCore.framework.The use of non-public APIs is not permitted on the App Store because it can lead to a poor user experience should these APIs change.

什么都没说就是一个坑,所以要彻底排查.

输入图片说明


备注
暂时未确定处理后是否解决问题,年后继续跟进问题..
参考解决
【iOS】私有API的使用
iOS-私有API与runtime
iOS逆向工程三:苹果私有API的获取
私有Api检测
处理思路
使用class-dump导出 PrivateFrameworks/WebCore 库里的所有api,
使用grep全局扫描整个项目
//导出*.h文件
class-dump -H /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/WebCore.framework -o ./WebCore
//grep 且用法
grep -Rnis "$keyword1" $projectPath/* | grep "$keyword2" | grep "$keyword3" | grep "$keyword4>> $searchFuntcionNameResultPath" | grep "$keyword5>> $searchFuntcionNameResultPath" >> $searchFuntcionNameResultPath
//grep 或用法
grep -Rnis -E "$tmpfilterKeyword|=====" $searchFuntcionNameResultPath >> $filterResultPath处理脚本
文件路径如下,其中WebCore是导出framework的*.h

输入图片说明


具体扫描脚本,分开扫描方法和扫描类名,在此基础上,还需要小部分人工辨别.
#!/bin/sh
projectPath=/Users/zhouqirui/Desktop/Ios/TouchTV
#所有api名字
functionListPath=./allFunctionList.txt
#类名路径
classKeyWordPath=./classKeyworkResult.txt
searchClassResultPath=./classSearchResult.txt
#方法名路径
functionNameKeyWordPath=./nameKeyworkResult.txt
searchFuntcionNameResultPath=./nameSearchResult.txt
#过滤路径
filterResultPath=./filterFinshList.txt
filterKeyword=web
#过滤关键字
function filterList(){
tmpfilterResultPath=$1
tmpfilterKeyword=$2
rm $tmpfilterResultPath | true
grep -Rnis -E "$tmpfilterKeyword|=====" $searchFuntcionNameResultPath >> $filterResultPath
}#grep -Rnis 'setResult:' *
#遍历方法名
function searchFuntcionName(){
rm $searchFuntcionNameResultPath | true
path=$1
totalText=""
echo "path:$path"
cat $path | while read line
do
keyword=${line%>>>*}
if [[ $totalText=~ $keyword ]]
then
echo "已处理keyword:$keyword"
else
totalText="$totalText$keyword"
echo "keyword:$keyword"

echo "">> $searchFuntcionNameResultPath
echo "==========================================keyword:$line==========================================" >> $searchFuntcionNameResultPath

OLD_IFS="$IFS"
IFS=","
arr=($keyword)
IFS="$OLD_IFS"

keyword1=${arr[0]}
keyword2=${arr[1]}
keyword3=${arr[2]}
keyword4=${arr[3]}
keyword5=${arr[4]}

count=${#arr[@]}
if [[ $count== 1 ]]
then
grep -Rnis "$keyword1" $projectPath/* >> $searchFuntcionNameResultPath
elif [[ $count== 2 ]]
then
grep -Rnis "$keyword1" $projectPath/* | grep "$keyword2">> $searchFuntcionNameResultPath
elif [[ $count== 3 ]]
then
grep -Rnis "$keyword1" $projectPath/* | grep "$keyword2" | grep "$keyword3">> $searchFuntcionNameResultPath
elif [[ $count== 4 ]]
then
grep -Rnis "$keyword1" $projectPath/* | grep "$keyword2" | grep "$keyword3" | grep "$keyword4>> $searchFuntcionNameResultPath" >> $searchFuntcionNameResultPath
elif [[ $count== 5 ]]
then
grep -Rnis "$keyword1" $projectPath/* | grep "$keyword2" | grep "$keyword3" | grep "$keyword4>> $searchFuntcionNameResultPath" | grep "$keyword5>> $searchFuntcionNameResultPath" >> $searchFuntcionNameResultPath
else
echo "$line"
#echo "aaaaa====="${keyword}
#echo "aaa:----$keyword1 bbb:----$keyword2 ccc:----$keyword3 ddd:----$keyword4"
#grep -Rnis "$keyword" $projectPath/* >> $searchFuntcionNameResultPath
#grep -Rnis 'setResult:' *
fi
fi
done
}
function searchClassName(){
rm $searchClassResultPath | true
path=$1
totalText=""
echo "path:$path"
cat $path | while read line
do
keyword=${line%>>>*}
if [[ $totalText=~ $keyword ]]
then
echo "已处理keyword:$keyword"
else
totalText="$totalText$keyword"
echo "keyword:$keyword"

echo "">> $searchClassResultPath
echo "==========================================keyword:$line==========================================" >> $searchClassResultPath
grep -Rnis -E "$keyword" $projectPath/*>> $searchClassResultPath

fi
done
}
function findClassKeyWord(){
line=$1
res=""
if [[ $line=~ "@interface" ]]
then

if [[ $line=~ " (" ]]
then
tmp=${line%)*}
param1=${tmp#*(}
res=$param1
else
tmp=${line% : *}
param1=${tmp#*@interface }
param2=""
if [[ $line=~ "<" ]]
then
tmp=${line%>*}
param2=${tmp#*<}
param2=${param2// /}
fi

if [[ $param2 != "" ]]
then
res="$param1,$param2"
else
res="$param1"
fi
res=${res//,/|}
fi
#elif [[ $line =~ "@class" ]]
#then
# echo "不处理$line"
elif [[ $line =~ "@protocol" ]]
then

tmp=${line% : *}
param1=${tmp#*@protocol }
param1=${param1#*<}
param1=${param1//;/}
param1=${param1// /}

#echo "line====="${line}
#echo "aaa:----$param1 bbb:----$param2 ccc:----$param3 ddd:----$param4"
fi

if [[ $res!= "" ]]
then
echo "$res>>>$line" >> $classKeyWordPath
fi

}
#单个文件转关键字
function findFunctionNameKeyWord(){
line=$1
res=""

if [[ $line=~ "arg4" ]]
then
tmp=${line%:(*}
tmp2=${tmp%:(*}
tmp3=${tmp2%:(*}
param1=${tmp3%:(*}

tmp=${line%:(*}
tmp2=${tmp%:(*}
tmp3=${tmp2%:(*}
param2=${tmp3#*rg1 }

tmp=${line%:(*}
tmp2=${tmp%:(*}
param3=${tmp2#*rg2 }

tmp=${line%:(*}
param4=${tmp#*rg3 }

res="$param1,$param2,$param3,$param4"
#echo "line====="${line}
#echo "aaa:----$param1 bbb:----$param2 ccc:----$param3 ddd:----$param4"
#echo "mmmm:----$res"
elif [[ $line=~ "arg3" ]]
then
#tmp=${line%:(*}
#tmp2=${tmp%:(*}
#res=${tmp2%:(*}

tmp=${line%:(*}
tmp2=${tmp%:(*}
param1=${tmp2%:(*}

tmp=${line%:(*}
tmp2=${tmp%:(*}
param2=${tmp2#*rg1 }

tmp=${line%:(*}
param3=${tmp#*rg2 }

res="$param1,$param2,$param3"

elif [[ $line=~ "arg2" ]]
then
tmp=${line%:(*}
param1=${tmp%:(*}

tmp=${line%:(*}
param2=${tmp#*rg1 }

res="$param1,$param2"

elif [[ $line=~ "arg1" ]]
then
res=${line%:(*}
fi

res=${res#*)}

if [[ $res!= "" ]]
then
echo "$res>>>$line" >> $functionNameKeyWordPath
fi
}
#读取单个文件每一行
function readLine(){
#echo $1
echo "==========================================" >> $functionListPath
echo "$1" >> $functionListPath
totalText=""
cat $1 | while read line
do
#if [[ ($line=~ "- (" || $line=~ "+ (") && ($line=~ ")_") ]]
if [[ ($line=~ "- (" || $line=~ "+ (" ) ]]
then
#echo "${line}"
echo "${line}" >> $functionListPath
findFunctionNameKeyWord "$line"
elif [[ ($line =~ "@interface" || $line =~ "@class" || $line =~ "@protocol") ]]
then
echo "${line}" >> $functionListPath
findClassKeyWord "$line"
fi
#echo "File:${line}"

done
}
#递归获取所有文件路径
function getdir(){
echo $1
for file in $1/*
do
if test -f $file
then
#echo $file
readLine $file
arr=(${arr[*]} $file)
else
getdir $file
fi
done
}
#移除 函数名关键字列表文档
rm $functionListPath | true
rm $functionNameKeyWordPath | true
#移除 类名关键字列表文档
rm $searchClassResultPath | true
rm $classKeyWordPath | true
getdir ./WebCore
#搜索方法名
searchClassName "$classKeyWordPath"
#搜索类名
searchFuntcionName "$functionNameKeyWordPath"
#过滤部分结构
#filterList "$filterResultPath" "$filterKeyword"

原文:http://raychow.linkfun.top/2018/02/14/archives/1_ios/privateApi/index/

最新文章

123

最新摄影

闪念基因

微信扫一扫

第七城市微信公众平台