有的项目因为是二次开发,有一定概率会被ios审核为重复的换皮项目,因而被拒绝.
在程序结尾加入垃圾代码,可改变输出的二进制文件,不是很确定c++在编译的时候,这类没有调用的方法以及声明的变量,会不会加入编译,之前一个被拒的项目,后面使用这个方法提交过两次,但是中间自己做过代码混淆
代码是c#写的,直接在vs新建控制台程序,替换类即可使用:
class Program
{
//config
//随机代码块
static int _blockCount = 50;
//声明参数
static int _argCount = 100;
static void Main(string[] args)
{
string path = "";
while (true)
{
Console.WriteLine("input the cpp file path:");
path = Console.ReadLine();
path = path.Trim();
if(path.Length == 0)
{
continue;
}
List<FileInfo> files = GetFilesInDic(path);
int count = 0;
foreach (FileInfo file in files)
{
if (file.Extension == ".cpp")
{
Console.WriteLine("写入:" + file.FullName);
StreamWriter sw = new StreamWriter(file.FullName, true);
string writeStr = GetMethodAllStr();
sw.WriteLine(writeStr);
sw.Close();
count += writeStr.Length;
}
}
Console.WriteLine("完成!\r\n" + "共写入:" + count.ToString() + "字");
}
}
static List<FileInfo> GetFilesInDic(string path)
{
List<FileInfo> list = new List<FileInfo>();
DirectoryInfo root = new DirectoryInfo(path);
FileInfo[] files = root.GetFiles();
DirectoryInfo[] dics = root.GetDirectories();
list.AddRange(files);
foreach(DirectoryInfo info in dics)
{
list.AddRange(GetFilesInDic(info.FullName));
}
return list;
}
static string lineStr = "\r\n";
static string specialStr = "_";
static Random rd = new Random();
static List<string> strList = new List<string>()
{
"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z",
"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"
};
static List<string> argTypeList = new List<string>() { "float" , "int" ,"string" };
static List<string> blockMethod = new List<string>() {
"if(!true){}",
"if(!false){}",
"if(true){}",
"if(false){}"
};
static string GetMethodAllStr()
{
string randomType = GetRandomType();
string str = randomType + " ";
//方法名
str += GetName();
//方法参数
str += "(" + GetRandomType() + " " + GetName() + " )" + lineStr;
str += "{" + lineStr;
//获取随机代码块
str += GetRandomBlock(GetRandomNum(_blockCount));
//定义随机变量
List<string> namelist = new List<string>();
string argContent = "";
int argCount = GetRandomNum(_argCount);
for (int i = 0; i < argCount; ++i)
{
argContent += randomType;
string argName = GetName();
namelist.Add(argName);
argContent += (" " + argName + " = ");
argContent += GetContentByType(randomType);
argContent += lineStr;
}
str += argContent + lineStr;
string rtnArgName = GetName();
string headName = randomType + " " + rtnArgName;
headName += " = ";
for(int i = 0; i< namelist.Count;++i)
{
headName += namelist[i];
if(i == namelist.Count - 1)
{
headName += ";";
}
else
{
headName += "+";
}
}
str += headName;
str += lineStr;
str += "return " + rtnArgName + ";";
str += lineStr;
str += "}";
return str;
}
//根据类型获取随机内容
static string GetContentByType(string _type)
{
string str = "";
if(_type == "float")
{
str += GetRandomNum(100);
str += ".";
str += GetRandomNum(100);
str += ";";
}
else if(_type == "int")
{
str += GetRandomNum(1000);
str += ";";
}
else if(_type == "string")
{
str += "\"";
str += GetName();
str += "\"";
str += ";";
}
return str;
}
//固定长度特殊字符
static string GetSpecialStr(int count)
{
string str = "";
for(int i = 0;i< count; ++i)
{
str += specialStr;
}
return str;
}
//随机数
static int GetRandomNum(int maxNum)
{
int rInt = rd.Next();
return (rInt % maxNum + 1);
}
//固定长度随机字符串
static string GetRandomStr(int length)
{
string str = "";
for(int i = 0; i< length; ++i)
{
str += strList[GetRandomNum(strList.Count-1)];
}
return str;
}
//名字
static string GetName()
{
string str = "";
str += GetSpecialStr(GetRandomNum(5));
str += GetRandomStr(GetRandomNum(5));
return str;
}
//参数类型
static string GetRandomType()
{
return argTypeList[GetRandomNum(argTypeList.Count - 1)];
}
//指定数量随机代码块
static string GetRandomBlock(int count)
{
string str = "";
for (int i = 0; i < count; ++i)
{
str += blockMethod[GetRandomNum(blockMethod.Count - 1)];
str += lineStr;
}
return str;
}
}
输出的代码: