Apple repeat application problem (machine audit)

Source: Internet
Author: User

Apple arraignment, by 4.3 repeated application is very common (such as the vest bag, etc.), and the first step is to face the machine audit, our approach is to write tools to generate some garbage code to avoid the Apple machine audit, the following is the entire implementation:

Using Luaframework;
Using Unityeditor;
Using System;
Using System.Text;
Using System.IO;

File definition: Garbage code generator
First, Design points:
1. Generate MD5 characters with the current time + generate code sequence number, name the class name, method name, variable name, etc. with MD5 character
2, a random paradigm, with the generated class name and so on as parameters to generate the pattern code
3. Generate Garbagecodemanager class to invoke all generated code
Second, the main points of the formation of paradigms:
1. Write code in normal C #
2. Use the changeclassfile2codecreatetool.py http://www.cnblogs.com/ChengShuKaiShi/p/7750557.html tool to turn the normal code into the code that generated the code (class name , method name, and so on have been replaced with parameters)
Third, the game call
1. Call the generated code in Main.cs via the Unity_iphone && SDK macro control call Garbagecodemanager.callallgarbagecode ()
Green _ Tree
Date: 2017/10/20

public class Garbagecodetool
{
Private Const string namespacename = "Luaframework"; Generate Code namespaces
Private Const string garbagecodemanagername = "Garbagecodemanager"; Manage file names with junk code
private static string Mstcreatecodefilepath; Generate Code Path
Private Const int maxfilecount = 100; Number of spam codes
Private Const int tplcount = 1; Number of generated garbage code paradigms

Paradigm Delegate: namespace, class name, entry method name, entry method parameter 1, ingress method parameter 2, ingress method parameter 3
Private delegate bool Generatecodehandle (string namespacename,string classname,string methonname,string param1, string Param2, string param3);
private static generatecodehandle[] arrgeneratecodehandle;

Generate code
[MenuItem ("Tools/generategarbagecode")]
static void Generategarbagecode () {
Initialize all paradigms
INITALLTPL ();

Delete old directory code
if (directory.exists (Mstcreatecodefilepath))
{
Directory.delete (Mstcreatecodefilepath, true);
}
Assetdatabase.refresh ();
Assetdatabase.saveassets ();

Re-create the catalog
Directory.CreateDirectory (Mstcreatecodefilepath);
Directory.CreateDirectory (Mstcreatecodefilepath + "/code");

String timenow = DateTime.Now.ToLongDateString ();
string[] Arrclassname = new String[maxfilecount];
string[] Arrmethonname = new String[maxfilecount];

Generate code
for (int i = 0; i < Maxfilecount; i++) {
Generates MD5 values based on the current time +i
string md5 = UTIL.MD5 (TimeNow + i.tostring ());
MD5 = "_" + MD5;

Generate file name, method name, parameter name with MD5 value
string className = MD5;
String methonname = MD5 + "M";
String param1 = MD5 + "a";
String param2 = MD5 + UnityEngine.Random.Range (0, 100);
String param3 = MD5 + "C";

Randomly generate a paradigm file
int randnum = UnityEngine.Random.Range (0, Tplcount);
if (arrgeneratecodehandle[randnum]! = NULL)
{
BOOL issuccess = Arrgeneratecodehandle[randnum] (namespacename, ClassName, Methonname, param1, param2, param3);
if (issuccess) {
Arrclassname[i] = ClassName;
Arrmethonname[i] = Methonname;
}
}
Else
{
Util.logerror ("Non-existent paradigm, index:" + randnum.tostring ());
}
}

Generates a file that calls all functions based on the generated file
String managerfilepath = Path.Combine (Mstcreatecodefilepath, Garbagecodemanagername + ". cs");
Creategarbagemanagerclass (Managerfilepath, Garbagecodemanagername,namespacename, ArrClassName, arrMethonName);

Assetdatabase.refresh ();
Assetdatabase.saveassets ();

Editorutility.displaydialog ("Generategarbagecode", "Build finished!" "," OK ");
}

//Initialize all paradigms
static void Initalltpl () {
Mstcreatecodefilepath = UnityEngine.Application.dataPath + "/ Luaframework/scripts/garbagecode ";
Arrgeneratecodehandle = new Generatecodehandle[tplcount];
Arrgeneratecodehandle[0] = CREATETPL1;
}

//Generate call all generated paradigm codes
public static void Creategarbagemanagerclass (String stsavefilepath, String className1, String Stnamespace,string[] allclassname,string[] allmethonname)
{
if (string. IsNullOrEmpty (Stsavefilepath))
{
return;
}
StringBuilder StringBuilder = new StringBuilder ();
if (!string. IsNullOrEmpty (stnamespace))
{
Stringbuilder.appendformat (string. Format ("namespace {0}\n", stnamespace));
Stringbuilder.appendline ("{");
}
Stringbuilder.appendline ("Using Unityengine;");
Stringbuilder.appendline ("Using System.Collections;");
Stringbuilder.appendline ("");
Stringbuilder.appendline ("namespace Luaframework {");
Stringbuilder.appendline ("//Junk Code Manager");
Stringbuilder.appendformat ("public class {0}\n", className1);
Stringbuilder.appendline ("{");
Stringbuilder.appendline ("//Call All spam Codes");
Stringbuilder.appendline ("public static void Callallgarbagecode () {");


//Call all garbage codes
for (int i = 0; i < allclassname.length; i++) {
String className = Allclassname[i];
Stri ng methonname = allmethonname[i];
if (ClassName = = "" | | Methonname = = "") {
continue;
}
int Randa = UnityEngine.Random.Range (0, 1000);
int randb = UnityEngine.Random.Range (0, 1000);
int RANDC = UnityEngine.Random.Range (0, 1000);
Stringbuilder.appendformat ("{0} _{1} = new {2} () \ n", ClassName, ClassName, className);
if (Randc >)
{
Stringbuilder.appendformat ("_{0}.{ 1} ({2},{3}); \ n ", ClassName, Methonname, Randa, randb);
}
Else
{
Stringbuilder.appendformat ("_{0}.{ 1} ({2},{3},{4}); \ n ", ClassName, Methonname, Randa, RANDB,RANDC);
}
Stringbuilder.appendline ("");
}


Stringbuilder.appendline ("}");
Stringbuilder.appendline ("}");
Stringbuilder.appendline ("}");
Stringbuilder.appendline ("");
if (!string. IsNullOrEmpty (Stnamespace))
{
Stringbuilder.appendline ("}");
}
File.writealltext (Stsavefilepath, stringbuilder.tostring ());
}

Template 1
public static bool CreateTpl1 (string namespacename, String className, String methonname, String param1, String param2, St Ring param3)
{
String fileName = Path.Combine (Mstcreatecodefilepath + "/code", ClassName + ". cs");
if (string. IsNullOrEmpty (FileName))
{
return false;
}
StringBuilder StringBuilder = new StringBuilder ();
if (!string. IsNullOrEmpty (NamespaceName))
{
Stringbuilder.appendformat (String. Format ("namespace {0}\n", namespacename));
Stringbuilder.appendline ("{");
}
Stringbuilder.appendline ("");
Stringbuilder.appendformat ("public class {0} \ n", className);
Stringbuilder.appendline ("{");
Stringbuilder.appendformat ("public int {0} (int {1},int {2},int {3} = 1)", Methonname, param1, param2, param3);
Stringbuilder.appendline ("{");
Stringbuilder.appendformat ("int test1 = {0}add ({1}, {2}); \ n", ClassName, param1, param2);
Stringbuilder.appendformat ("Return {0}sub (test1, {1}); \ n", ClassName, PARAM3);
Stringbuilder.appendline ("}");
Stringbuilder.appendline ("");
Stringbuilder.appendformat ("int {0}add (int a{1}b, int b{2}d)", ClassName, param1, param2);
Stringbuilder.appendline ("{");
Stringbuilder.appendformat ("A{0}b + = UnityEngine.Random.Range (0);", param1);
Stringbuilder.appendformat ("return a{0}b + b{1}d;", param1, param2);
Stringbuilder.appendline ("}");
Stringbuilder.appendline ("");
Stringbuilder.appendformat ("int {0}sub (int a{1}c, int b{2}e)", ClassName, param1, param2);
Stringbuilder.appendline ("{");
Stringbuilder.appendformat ("B{0}e *=", param2);
Stringbuilder.appendformat ("Return a{0}c-b{1}e;", param1, param2);
Stringbuilder.appendline ("}");
Stringbuilder.appendline ("}");
if (!string. IsNullOrEmpty (NamespaceName))
{
Stringbuilder.appendline ("}");
}
File.writealltext (FileName, stringbuilder.tostring ());
return true;
}
}

Apple repeat application problem (machine audit)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.