Cody

# Problem 1752. Get me! v4 (Cody hacking challenge)

Solution 290694

Submitted on 26 Jul 2013 by Alfonso Nieto-Castanon
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Pass
%% % Clean workspace !/bin/cp get_me.m safe !/bin/rm *.* !/bin/mv safe get_me.m !/bin/rm @* % Clean user's function from some known jailbreaking mechanisms functions = {'!','feval','str2func','regex','system','dos','unix','perl','java','fopen','write','save','setenv','path'}; fid = fopen('get_me.m'); st = char(fread(fid)'); for n = 1:numel(functions) st = regexprep(st, functions{n}, 'error(''No fancy functions!''); %', 'ignorecase'); end fclose(fid) % Force a function header, and comment first code's line (the supposedly users' function header) st = sprintf('function y = get_me()\n%%%s', st); fid = fopen('get_me.m' , 'w'); fwrite(fid,st); fclose(fid) % Release the Kraken! get_me() % Try to cleanup the mess !/bin/cp get_me.m safe !/bin/rm *.* !/bin/mv safe get_me.m !/bin/rm @* path(pathdef) % undo any change on search path assert(isequal(ans,now))

/bin/rm: cannot remove `@*': No such file or directory ans = 0 ans = 0 [Warning: Function /users/msssystem2/assert.m has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [ In get_me at 4 In verifyCode>evaluateCode at 227 In verifyCode at 40 In fevalJSON at 14 In workspacefunc at 7] [Warning: Function /users/msssystem2/assert.m has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [ In get_me at 4 In verifyCode>evaluateCode at 227 In verifyCode at 40 In fevalJSON at 14 In workspacefunc at 7] [Warning: Function /users/msssystem2/assert.m has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In verifyCode>evaluateCode at 227 In verifyCode at 40 In fevalJSON at 14 In workspacefunc at 7] /bin/rm: cannot remove `@*': No such file or directory ans = assert with no properties.

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!