99
\$\begingroup\$

This is the cops' thread. The robbers' thread is here.

Your challenge is to make a program that runs forever without halting1, unless it gets a particular input or inputs2. If it receives that input, it must terminate in a finite amount of time3. This is , so the shortest answer that has not been cracked by a robber within one week of posting wins. After the week has passed, please mark your answer as safe and show the halting input (in a > ! spoiler quote). If a robber cracks your submission, please mark it as cracked and show the halting input (in a > ! spoiler quote).

Submissions are preferred be runnable & crackable on TIO. Submissions not runnable or crackable on TIO are allowed, but please include instructions to download / run them.

Please make your input deterministic, and uniform across all runs. See this meta post for details.

Please, don't "implement RSA" or anything mean to the robbers. Use obscure languages and features, not boring encryption and hashing. I can't enforce this with rules, but you can expect torrential downvotes if all you do is sha(input) === "abcd1234".


1Assuming that the computer doesn't get shut down, break, get engulfed by the sun, overheat in the universe's heat death, or hit the TIO timeout of 60s.

2The program must halt on at least one input. As long as it loops forever on one input and halts on another, it works.

3This must be < 60 seconds, so that the code can be tested on TIO.


Looking for uncracked submissions?

fetch("https://api.stackexchange.com/2.2/questions/135363/answers?order=desc&sort=activity&site=codegolf&filter=!.Fjs-H6J36vlFcdkRGfButLhYEngU&key=kAc8QIHB*IqJDUFcjEF1KA((&pagesize=100").then(x=>x.json()).then(data=>{var res = data.items.filter(i=>!i.body_markdown.toLowerCase().includes("cracked")).map(x=>{const matched = /^ ?##? ?(?:(?:(?:\[|<a href ?= ?".*?">)([^\]]+)(?:\]|<\/a>)(?:[\(\[][a-z0-9/:\.]+[\]\)])?)|([^, ]+)).*[^\d](\d+) ?\[?(?:(?:byte|block|codel)s?)(?:\](?:\(.+\))?)? ?(?:\(?(?!no[nt][ -]competing)\)?)?/gim.exec(x.body_markdown);if(!matched){return;}return {link: x.link, lang: matched[1] || matched[2], owner: x.owner}}).filter(Boolean).forEach(ans=>{var tr = document.createElement("tr");var add = (lang, link)=>{var td = document.createElement("td");var a = document.createElement("a");a.innerHTML = lang;a.href = link;td.appendChild(a);tr.appendChild(td);};add(ans.lang, ans.link);add(ans.owner.display_name, ans.owner.link);document.querySelector("tbody").appendChild(tr);});});
<html><body><h1>Uncracked Submissions</h1><table><thead><tr><th>Language</th><th>Author</th></tr></thead><tbody></tbody></table></body></html>

\$\endgroup\$
9
  • 1
    \$\begingroup\$ @LuisMendo assuming infinite memory is fine \$\endgroup\$
    – user58826
    Jul 24, 2017 at 16:29
  • 1
    \$\begingroup\$ @programmer5000 Thanks for clarifying. You should incorporate all this into the challenge text. Answerers are not expected to read all comments \$\endgroup\$
    – Luis Mendo
    Jul 24, 2017 at 16:48
  • 7
    \$\begingroup\$ Can we restrict the input to, say, an integer? A robber could pass in some malformed or mistyped input to terminate the program immediately. I'd either have to do lots of careful input validation, or use a language that can catch arbitrary errors. \$\endgroup\$
    – xnor
    Jul 24, 2017 at 18:37
  • 3
    \$\begingroup\$ @xnor I think you're supposed to have to do the input checking. \$\endgroup\$
    – Stephen
    Jul 24, 2017 at 18:49
  • 1
    \$\begingroup\$ @StepHen That works if the malformed input is still able to be parsed by the interpreter. If I enter an illegal string, R errors immediately, without even entering the function to crack. I would argue that that doesn't count as actually terminating the function. \$\endgroup\$
    – JAD
    Jul 26, 2017 at 5:02

115 Answers 115

1 2 3
4
1
\$\begingroup\$

Python 3, 226 bytes, cracked by hyper-neutrino (intended solution)

Not really golfed.

def f(x):
    to_be = x == x
    while to_be or not to_be:
        pass
    while True:
        pass
    while 1:
        pass
    i = input()
    s = '!@#$%^&*()_+'
    if all(c in i for c in s):
        exec(i[0xf91ea8222d])

Try it online! Super simple, but I just wanted to make that reference. Also, since this is a function, you can't pass input to STDIN.

\$\endgroup\$
5
  • \$\begingroup\$ I'm not too familiar with this challenge. I don't suppose something like this would be allowed? \$\endgroup\$
    – hyper-neutrino
    May 20, 2021 at 20:41
  • 1
    \$\begingroup\$ @hyper-neutrino That is exactly it! Go ahead and post that on the robbers' thread \$\endgroup\$
    – Makonede
    May 20, 2021 at 20:42
  • \$\begingroup\$ There's also this \$\endgroup\$ May 20, 2021 at 20:42
  • \$\begingroup\$ @cairdcoinheringaahing Yeah that works too \$\endgroup\$
    – Makonede
    May 20, 2021 at 20:43
  • \$\begingroup\$ Cracked. I thought it would be crackable with inputting NaN at first until I took a closer look :P \$\endgroup\$
    – hyper-neutrino
    May 20, 2021 at 20:44
1
\$\begingroup\$

Javascript, 125 bytes, cracked

f=y=>{while(x=Object.prototype.hasOwnProperty)try{1+(x.call(y||{},'toString')||x.call(y||{},'valueOf')?1:y)}catch(y){return}}

Try it online!

Solution:

We want an input that will throw when cast to a string or a primitive value, the easiest such input is Object.create(null).

\$\endgroup\$
6
  • \$\begingroup\$ So, we're meant to throw an error with a non-object... \$\endgroup\$
    – emanresu A
    May 22, 2021 at 0:35
  • \$\begingroup\$ @Ausername The first iteration I wrote of this was easier, but in my opinion a bit too easy, I tried to make it an interesting challenge. :) \$\endgroup\$
    – Etheryte
    May 22, 2021 at 0:41
  • \$\begingroup\$ Researching Javascript oddities... \$\endgroup\$
    – emanresu A
    May 22, 2021 at 0:49
  • \$\begingroup\$ Cracked, although I don't think you intended this. \$\endgroup\$
    – emanresu A
    May 22, 2021 at 0:59
  • \$\begingroup\$ @Ausername Nice! Indeed not what I had in mind, but still a very creative take on it. If you're interested in the original solution, I've added it in a spoiler. \$\endgroup\$
    – Etheryte
    May 22, 2021 at 1:15
0
\$\begingroup\$

JavaScript (Node.js), 123 bytes, Cracked

x=>y=>{try{console.assert(/3$/.test(x));n=y*321;c=x===n.toString().replace(/2$/,3)&&+x===n;if(c)return;}catch(e){}for(;;);}

Try it online!

\$\endgroup\$
1
0
\$\begingroup\$

JavaScript (Node.js), 26 bytes (Cracked, not intended solution)

x=>{while(x.constructor);}

Try it online!

\$\endgroup\$
2
0
\$\begingroup\$

JavaScript in Firefox console (on blank.org), 7,987 bytes (cracked)

Not contending to win, but this should be fun.

f=B=>{eval("if(typeof B!='number')B=0;if(typeof Β!='number')Β=0;".repeat(4).repeat(2));while(B<=0||B==1||B==2||B==3||B==4||B==5||B==6||B==7||B==8||B==9||B==10||B==11||B==12||B==13||B==14||B==15||B==16||B==17||B==18||B==19||B==20||B==21||B==22||B==23||B==24||B==25||B==26||B==27||B==28||B==29||B==30||B==31||B==32||B==33||B==34||B==35||B==36||B==37||B==38||B==39||B==40||B==41||B==42||B==43||B==44||B==45||B==46||B==47||B==48||B==49||B==50||B==51||B==52||B==53||B==54||B==55||B==56||B==57||B==58||B==59||B==60||B==61||B==62||B==63||B==64||B==65||B==66||B==67||B==68||B==69||B==70||B==71||B==72||B==73||B==74||B==75||B==76||B==77||B==78||B==79||B==80||B==81||B==82||B==83||B==84||B==85||B==86||B==87||B==88||B==89||B==90||B==91||B==92||B==93||B==94||B==95||B==96||B==97||B==98||B==99||B==100||B==101||B==102||B==103||B==104||B==105||B==106||B==107||B==108||B==109||B==110||B==111||B==112||B==113||B==114||B==115||B==116||B==117||B==118||B==119||B==120||B==121||B==122||B==123||B==124||B==125||B==126||B==127||B==128||B==129||B==130||B==131||B==132||B==133||B==134||B==135||B==136||B==137||B==138||B==139||B==140||B==141||B==142||B==143||B==144||B==145||B==146||B==147||B==148||B==149||B==150||B==151||B==152||B==153||B==154||B==155||B==156||B==157||B==158||B==159||B==160||B==161||B==162||B==163||B==164||B==165||B==166||B==167||B==168||B==169||B==170||B==171||B==172||B==173||B==174||B==175||B==176||B==177||B==178||B==179||B==180||B==181||B==182||B==183||B==184||B==185||B==186||B==187||B==188||B==189||B==190||B==191||B==192||B==193||B==194||B==195||B==196||B==197||B==198||B==199||B==200||B==201||B==202||B==203||B==204||B==205||B==206||B==207||B==208||B==209||B==210||B==211||B==212||B==213||B==214||B==215||B==216||B==217||B==218||B==219||B==220||B==221||B==222||B==223||B==224||B==225||B==226||B==227||B==228||B==229||B==230||B==231||B==232||B==233||B==234||B==235||B==236||B==237||B==238||B==239||B==240||B==241||B==242||B==243||B==244||B==245||B==246||B==247||B==248||B==249||B==250||B==251||B==252||B==253||B==254||B==255||B==256||B==257||B==258||B==259||B==260||B==261||B==262||B==263||B==264||B==265||B==266||B==267||B==268||B==269||B==270||B==271||B==272||B==273||B==274||B==275||B==276||B==277||B==278||B==279||B==280||B==281||B==282||B==283||B==284||B==285||B==286||B==287||B==288||B==289||B==290||B==291||B==292||B==293||B==294||B==295||B==296||B==297||B==298||B==299||B==300||B==301||B==302||B==303||B==304||B==305||B==306||B==307||B==308||B==309||B==310||B==311||B==312||B==313||B==314||B==315||B==316||B==317||B==318||B==319||B==320||B==321||B==322||B==323||B==324||B==325||B==326||B==327||B==328||B==329||B==330||B==331||B==332||B==333||B==334||B==335||B==336||B==337||B==338||B==339||B==340||B==341||B==342||B==343||B==344||B==345||B==346||B==347||B==348||B==349||B==350||B==351||B==352||B==353||B==354||B==355||B==356||B==357||B==358||B==359||B==360||B==361||B==362||B==363||B==364||B==365||B==366||B==367||B==368||B==369||B==370||B==371||B==372||B==373||B==374||B==375||B==376||B==377||B==378||B==379||B==380||B==381||B==382||B==383||B==384||B==385||B==386||B==387||B==388||B==389||B==390||B==391||B==392||B==393||B==394||B==395||B==396||B==397||B==398||B==399||B==400||B==401||B==402||B==403||B==404||B==405||B==406||B==407||B==408||B==409||B==410||B==411||B==412||B==413||B==414||B==415||B==416||B==417||B==418||B==419||B==420||B==421||B==422||B==423||B==424||B==425||B==426||B==427||B==428||B==429||B==430||B==431||B==432||B==433||B==434||B==435||B==436||B==437||B==438||B==439||B==440||B==441||B==442||B==443||B==444||B==445||B==446||B==447||B==448||B==449||B==450||B==451||B==452||B==453||B==454||B==455||B==456||B==457||B==458||B==459||B==460||B==461||B==462||B==463||B==464||B==465||B==466||B==467||B==468||B==469||B==470||B==471||B==472||B==473||B==474||B==475||B==476||B==477||B==478||B==479||B==480||B==481||B==482||B==483||B==484||B==485||B==486||B==487||B==488||B==489||B==490||B==491||B==492||B==493||B==494||B==495||B==496||B==497||B==498||B==499||B==500||B==501||B==502||B==503||B==504||B==505||B==506||B==507||B==508||B==509||B==510||B==511||B==512||B==513||B==514||B==515||B==516||B==517||B==518||B==519||B==520||B==521||B==522||B==523||B==524||B==525||B==526||B==527||B==528||B==529||B==530||B==531||B==532||B==533||B==534||B==535||B==536||B==537||B==538||B==539||B==540||B==541||B==542||B==543||B==544||B==545||B==546||B==547||B==548||B==549||B==550||B==551||B==552||B==553||B==554||B==555||B==556||B==557||B==558||B==559||B==560||B==561||B==562||B==563||B==564||B==565||Β==566||B==567||B==568||B==569||B==570||B==571||B==572||B==573||B==574||B==575||B==576||B==577||B==578||B==579||B==580||B==581||B==582||B==583||B==584||B==585||B==586||B==587||B==588||B==589||B==590||B==591||B==592||B==593||B==594||B==595||B==596||B==597||B==598||B==599||B==600||B==601||B==602||B==603||B==604||B==605||B==606||B==607||B==608||B==609||B==610||B==611||B==612||B==613||B==614||B==615||B==616||B==617||B==618||B==619||B==620||B==621||B==622||B==623||B==624||B==625||B==626||B==627||B==628||B==629||B==630||B==631||B==632||B==633||B==634||B==635||B==636||B==637||B==638||B==639||B==640||B==641||B==642||B==643||B==644||B==645||B==646||B==647||B==648||B==649||B==650||B==651||B==652||B==653||B==654||B==655||B==656||B==657||B==658||B==659||B==660||B==661||B==662||B==663||B==664||B==665||B==666||B==667||B==668||B==669||B==670||B==671||B==672||B==673||B==674||B==675||B==676||B==677||B==678||B==679||B==680||B==681||B==682||B==683||B==684||B==685||B==686||B==687||B==688||B==689||B==690||B==691||B==692||B==693||B==694||B==695||B==696||B==697||B==698||B==699||B==700||B==701||B==702||B==703||B==704||B==705||B==706||B==707||B==708||B==709||B==710||B==711||B==712||B==713||B==714||B==715||B==716||B==717||B==718||B==719||B==720||B==721||B==722||B==723||B==724||B==725||B==726||B==727||B==728||B==729||B==730||B==731||B==732||B==733||B==734||B==735||B==736||B==737||B==738||B==739||B==740||B==741||B==742||B==743||B==744||B==745||B==746||B==747||B==748||B==749||B==750||B==751||B==752||B==753||B==754||B==755||B==756||B==757||B==758||B==759||B==760||B==761||B==762||B==763||B==764||B==765||B==766||B==767||B==768||B==769||B==770||B==771||B==772||B==773||B==774||B==775||B==776||B==777||B==778||B==779||B==780||B==781||B==782||B==783||B==784||B==785||B==786||B==787||B==788||B==789||B==790||B==791||B==792||B==793||B==794||B==795||B==796||B==797||B==798||B==799||B==800||B==801||B==802||B==803||B==804||B==805||B==806||B==807||B==808||B==809||B==810||B==811||B==812||B==813||B==814||B==815||B==816||B==817||B==818||B==819||B==820||B==821||B==822||B==823||B==824||B==825||B==826||B==827||B==828||B==829||B==830||B==831||B==832||B==833||B==834||B==835||B==836||B==837||B==838||B==839||B==840||B==841||B==842||B==843||B==844||B==845||B==846||B==847||B==848||B==849||B==850||B==851||B==852||B==853||B==854||B==855||B==856||B==857||B==858||B==859||B==860||B==861||B==862||B==863||B==864||B==865||B==866||B==867||B==868||B==869||B==870||B==871||B==872||B==873||B==874||B==875||B==876||B==877||B==878||B==879||B==880||B==881||B==882||B==883||B==884||B==885||B==886||B==887||B==888||B==889||B==890||B==891||B==892||B==893||B==894||B==895||B==896||B==897||B==898||B==899||B==900||B==901||B==902||B==903||B==904||B==905||B==906||B==907||B==908||B==909||B==910||B==911||B==912||B==913||B==914||B==915||B==916||B==917||B==918||B==919||B==920||B==921||B==922||B==923||B==924||B==925||B==926||B==927||B==928||B==929||B==930||B==931||B==932||B==933||B==934||B==935||B==936||B==937||B==938||B==939||B==940||B==941||B==942||B==943||B==944||B==945||B==946||B==947||B==948||B==949||B==950||B==951||B==952||B==953||B==954||B==955||B==956||B==957||B==958||B==959||B==960||B==961||B==962||B==963||B==964||B==965||B==966||B==967||B==968||B==969||B==970||B==971||B==972||B==973||B==974||B==975||B==976||B==977||B==978||B==979||B==980||B==981||B==982||B==983||B==984||B==985||B==986||B==987||B==988||B==989||B==990||B==991||B==992||B==993||B==994||B==995||B==996||B==997||B==998||B>=999);}

There's another crack out there, waiting to be found... Cracks:

- NaN (unintended)
- decimals

\$\endgroup\$
2
0
\$\begingroup\$

JavaScript, cracked

x=>{try{for(;x.x||!x.x;);}catch(e){for(;;);}}

Try it online!

\$\endgroup\$
1
0
\$\begingroup\$

Befunge-98, 34 bytes, Possibly cracked

> #;de+294&:0\`#;_3*+*\-\0pqk$#q_

Unfortunately I couldn't get this to halt in TIO or CCBI, but it works in BefungeSharp. (If you can find a way to make it halt on TIO, mock me mercilessly) @ovs figured one out which depends on the fact that...

TIO does not implement the = instruction, making it behave like r. When the reversed IP encounters p, it deletes > from the program start, allowing the IP to run backwards to q_. This could be fixed by adding a leading space to the program (and replacing de+ with ee+).

To run the program:

  1. Save the above code to a file somewhere
  2. Run BefungeSharp (it will probably work under Wine)
  3. Press 2 (open file) and find the file you saved from before
  4. (Press any key to continue)
  5. Press a key from F2 to F5 to run (F2 = slow, F5 = fast)
  6. Hit F12 to stop execution, and alt-R to reload

The program won't halt on TIO or CCBI. (I blame ambiguous Funge-98 specs.) Inputs which crash BefungeSharp do not count.

& asks for a number, so input a number. To save you some time, the program ignores negatives.

\$\endgroup\$
4
  • \$\begingroup\$ It halts for 1 on TIO, but I don't think this is the intended solution. \$\endgroup\$
    – ovs
    Jul 25, 2017 at 11:39
  • \$\begingroup\$ Indeed, it is not, @ovs. Since I can't reproduce that in BefungeSharp, it's very difficult to figure out what's going on. I think that = causes the instruction pointer to reverse delta (proper way for an interpreter to handle unimplemented instructions). I hadn't thought of that, but I suppose it's valid! \$\endgroup\$
    – Hactar
    Jul 25, 2017 at 11:51
  • \$\begingroup\$ Does this have something to do with integer overflow? \$\endgroup\$ Jul 30, 2017 at 3:08
  • \$\begingroup\$ @ppperry Nope. Just pure arithmetic and ASCII \$\endgroup\$
    – Hactar
    Jul 30, 2017 at 10:43
0
\$\begingroup\$

JavaScript (ES6), 119 bytes, Cracked

x=>{try{while(typeof x!="string");x=x.trim();while(!(x.length==6&&x[4]==" "&&eval(x)===undefined));}catch(e){for(;;);}}

While cracking this with the usual JavaScript prototype changing and object stuff is probably possible, the intended solution is a regular old string.

"void 0" evaluates to undefined.

Try it online!

\$\endgroup\$
1
  • \$\begingroup\$ Cracked. Is this the intended solution? \$\endgroup\$
    – user58826
    Jul 25, 2017 at 15:21
0
\$\begingroup\$

JavaScript, 52 bytes (Cracked again)

x=>{while(1){try{if(x&&1+x!==1+x)break;}catch(e){}}}
\$\endgroup\$
1
  • 1
    \$\begingroup\$ Cracked. \$\endgroup\$
    – Veedrac
    Jul 25, 2017 at 20:36
0
\$\begingroup\$

JavaScript, 28 bytes (Cracked here and here)

x=>{while(!(x&&1+x!==1+x));}

Both cracks were unexpected and I find them very clever (that's why I love this site). The crack I intended was {valueOf: function(){}}.

\$\endgroup\$
3
  • \$\begingroup\$ Cracked (the lazy way). \$\endgroup\$
    – Veedrac
    Jul 25, 2017 at 19:26
  • \$\begingroup\$ @Veedrac Great job! Although not exactly what I had in mind. I've added error handling - can you beat level 2? :) \$\endgroup\$ Jul 25, 2017 at 20:13
  • \$\begingroup\$ Another Crack \$\endgroup\$
    – tsh
    Jul 26, 2017 at 5:37
0
\$\begingroup\$

Python 3, 67 characters (cracked)

An easy one, though this one is actually worth knowing so I thought I'd throw it in anyway.

import shutil,sys
while 1:shutil.copyfileobj(sys.stdin,sys.stdout)

Input goes in stdin.

\$\endgroup\$
2
  • \$\begingroup\$ Am I correct to assume that this will only work with certain locales? If so, cracked. \$\endgroup\$
    – Dennis
    Jul 27, 2017 at 3:32
  • \$\begingroup\$ @Dennis Yeah, I would have specified but I figured a hint wasn't needed on a question this simple. \$\endgroup\$
    – Veedrac
    Jul 27, 2017 at 3:43
0
\$\begingroup\$

R, 134 bytes (cracked)

f=function(x)if(tryCatch(!is.function(x)|identical(x,q)|identical(x,quit)|identical(x,is.list)|!x(list()),error=function(e)1))repeat{}
\$\endgroup\$
4
  • \$\begingroup\$ Cracked? \$\endgroup\$
    – Mischa
    Jul 26, 2017 at 14:41
  • \$\begingroup\$ @MischaBehrend Not the intended solution, and arguably not even a solution, since the quitting happens in the definition of the argument, not while executing the function. \$\endgroup\$
    – JAD
    Jul 27, 2017 at 7:31
  • \$\begingroup\$ Cracked? by @CriminallyVulgar. \$\endgroup\$ Jul 27, 2017 at 13:01
  • \$\begingroup\$ Cracked. I didn't consider that option. Since my intended solution isn't found, I'll make a new version without showing it here. \$\endgroup\$
    – JAD
    Jul 27, 2017 at 13:12
0
\$\begingroup\$

CPython 3.6, 634 bytes, Cracked

Fixed a misplaced try: statement that allowed 1/0 and even no input to break things. Original.

try:j=input();__builtins__.__dict__["__import__"]=eval(j);import random,functools,itertools,zlib;exec("@functools.lru_cache(None)\ndef f():i=input();return(all(x is y for x,y in itertools.zip_longest((x for x in sorted(dir(eval(i[::2])))if'_'not in x),sorted{}))\nand all(x is y for x,y in itertools.zip_longest((x for x in sorted(dir(eval(i[1::2])))if'_'not in x),sorted{}))and 8 and zlib.crc32(bytes(i,'ASCII'))==zlib.crc32(bytes(j,'ASCII')))".format(*eval('('+"(tuple(''.join(random.choice('abcdefghijklmnopqrstuvwxyz')for x in range%s)for x in range%s),),"%(("(random.randint(1,9))",)*2)*2+')')));f()
except:f=bool
while not f():8
\$\endgroup\$
4
  • \$\begingroup\$ Nice try, but cracked \$\endgroup\$ Jul 26, 2017 at 15:48
  • \$\begingroup\$ @ppperry That is indeed a valid solution. \$\endgroup\$
    – wizzwizz4
    Jul 26, 2017 at 15:54
  • \$\begingroup\$ @wizzwizz4 From the question: If a robber cracks your submission, please mark it as cracked and show the halting input (in a > ! spoiler quote). (this will make the included snippet behave correctly) \$\endgroup\$
    – Maya
    Jul 27, 2017 at 17:06
  • \$\begingroup\$ @NieDzejkob Oops! I forgot to do that. Fixed. \$\endgroup\$
    – wizzwizz4
    Jul 27, 2017 at 17:21
0
\$\begingroup\$

Befunge 93, 13 bytes, cracked by ovs

13 bytes: if you crack me you will get bad luck forever!!! ~Spooky~

~345**-0/#v_@

Unfortunately this one's pretty crackable.

\$\endgroup\$
1
  • \$\begingroup\$ Cracked \$\endgroup\$
    – ovs
    Jul 28, 2017 at 6:34
0
\$\begingroup\$

C (gcc), 144 bytes (Cracked)(Cracked 2) (Intended Crack)

This should be an easy one. Compile without optimizations.

#include <stdio.h>
char*a="abcd";char b[256];fun(){char c['\b'];char*d=a;fgets(c,'\f',stdin);snprintf(b,sizeof(c),c,d);}
main(){while(1)fun();}

Try it online!

\$\endgroup\$
3
0
\$\begingroup\$

Python, 19 bytes (cracked)

while(lambda:1)():0

How to input:

Write any code above this statement, following some simple restrictions against low-hanging fruit:

  • The line must be reached, unconditionally. A solution must reach this line even in unlikely scenarios.
  • No threads or processes may be spawned,
  • The solution must run on Python 2 (CPython and PyPy) and Python 3 (CPython).

Try it online (Python 2, CPython).
Try it online (Python 2, PyPy).
Try it online (Python 3, CPython).

\$\endgroup\$
1
0
\$\begingroup\$

Python 2, 143 bytes (cracked)

from sys import*
def l(*_):
 while 1:1
t=lambda*_:l;p=lambda*_:_[1][1]=="_"and l()or settrace(t)
def k(f):
 setprofile(p)
 try:f()
 finally:l()

The warmup was handled faster than expected, so let's go straight to the deep end. Pass one argument to k by appending code to this program. That argument may be initialized imperatively.

  • Don't modify k or its dependencies before calling it; you must break k from within. Similarly, don't call sys.setprofile or perform other interpreter modifications when initializing the argument.

  • No threads or processes may be spawned,

  • The solution must run on CPython and PyPy,

Try it online (CPython).
Try it online (PyPy).

\$\endgroup\$
3
  • \$\begingroup\$ cracked \$\endgroup\$ Jul 31, 2017 at 2:41
  • \$\begingroup\$ @Veedrac I know you from here, and I never thought I'd see another person with such obscure overlapping interests (SMM2 and code golf)! \$\endgroup\$
    – pxeger
    Feb 14, 2021 at 8:51
  • \$\begingroup\$ @pxeger There's a difference? \$\endgroup\$
    – Veedrac
    Feb 14, 2021 at 11:24
0
\$\begingroup\$

BASIC, 8 bytes (Cracked)

1input x

Meets the conditions of the OP completely, other than TIO which was a request not a condition.

Try it.

It'll hang forever (machine stability required) and terminate predictably within << a second of any input. Probably not what the OP meant but perfectly fair. Alls fair in love and golf!

\$\endgroup\$
3
  • 1
    \$\begingroup\$ Hey! Don't give away what the input is. Other people are meant to guess it! (Also, apostrophe.) \$\endgroup\$
    – wizzwizz4
    Jul 26, 2017 at 15:04
  • \$\begingroup\$ Heheeeee! Shall we tell them? After all, anyone inspecting it can work it out. \$\endgroup\$
    – Stilez
    Jul 26, 2017 at 15:09
  • \$\begingroup\$ Cracked! \$\endgroup\$
    – Maya
    Jul 26, 2017 at 15:58
0
\$\begingroup\$

Lua, 107 Bytes, Cracked

I hate how verbose lua is - getting inputs takes up almost half the program.

x=tonumber(io.read())or 2 y=tonumber(io.read())or 2 if y^(x%5)+x*y+y~=x^3-(x-120)*x then while 1 do end end 

I tried to account for all trivial solutions - hopefully this works.

\$\endgroup\$
5
  • \$\begingroup\$ Is this harder than solving an equation? Cracked. \$\endgroup\$
    – DELETE_ME
    Jul 29, 2017 at 14:19
  • \$\begingroup\$ Just for fun, here's my attempt at golfing the code :) \$\endgroup\$
    – tehtmi
    Aug 6, 2017 at 9:51
  • \$\begingroup\$ @tehtmi Wow! I didn't try hard to golf this one, but I definitely couldn't have done what you did. I'm still on Lua 5.1, can you explain the "..." to me? \$\endgroup\$
    – Nico A
    Aug 6, 2017 at 18:28
  • \$\begingroup\$ ... is used for "vararg" functions. E.g. function myprint(category,...)print("My Print ["..category.."]:",...)end. If ... is used at the end of an expression list (arguments or assignment), it is like arg1, arg2, arg3, -- and so on. x,y=... is like x,y=arg1,arg2. When running from the command line, the outer-level of the script is implicitly a function and the command line arguments are passed to it. E.g. lua my_script.lua arg1 arg2. The arguments are also in a table called arg which also includes the others components of the command line call at arg[0], arg[-1], etc. \$\endgroup\$
    – tehtmi
    Aug 6, 2017 at 19:27
  • \$\begingroup\$ @tehtmi Wow, I knew that, but I never thought of taking input from command line... this really helps one of the programs I'm working on. Thank you! \$\endgroup\$
    – Nico A
    Aug 7, 2017 at 0:52
0
\$\begingroup\$

Swift 3, 77 bytes (safe)

extension Bool{prefix static func !(b:Bool)->Bool{return true}}
while !true{}

To solve this, put your code before or after this statement.

  • Your solution must:
    • keep this statement intact, without modifying its code
    • actually let this statement run
      • Simply commenting it out, calling fatalError(), etc. before it doesn't count.
    • modify the behavior of this statement to prevent it from looping forever
  • The solution does not involve crashing the program.

This code is a refinement of my previous (cracked) attempt, here.

The first line of this code exists solely to prevent the exploit found by @Veedrac.
true in while !true is not actually a Bool. It's a boolean literal. Any type that conforms to ExpressibleByBooleanLiteral can be initialized from a boolean literal. Usually, the correct ExpressibleByBooleanLiteral to be instantiated is inferred from the context where it's needed. If, such as in this case, the context does not provide any type information as to the kind of ExpressibleByBooleanLiteral needed, the compiler falls back to choosing BooleanLiteralType as the default.

By default, the value of BooleanLiteralType is Bool. This makes sense. In the absence of contextual type information, true and false are both used to initialize instances of Bool. Interestingly, BooleanLiteralType can be overridden locally. My solution exploits this by creating a ExploitBool type, and sets it to be the preferred type for boolean literals, so the true in while !true is actually an instance of ExploitBool. I then define a prefix ! operator, so that for all instances x of ExploitBool, x returns true as a Bool.


    // First, set up the exploitive data type we need:
    struct ExploitBool: ExpressibleByBooleanLiteral {
        init(booleanLiteral _: Bool) {
            // ignore booleanLiteral, we don't care about it
        }

// Define the prefix ! as an operator that acts on a ExploitBool, // and always just returns false (as a regular Bool) prefix static func !(b: ExploitBool) -> Bool { return false } }
// Then, set it as the preferred type to instantiated from //boolean literals in the absense of other contextual type information. typealias BooleanLiteralType = ExploitBool
extension Bool{prefix static func !(b:Bool)->Bool{return true}} while !true{}

\$\endgroup\$
0
\$\begingroup\$

BrainF - Cracked

,[->+>+<<]>>[-<<+>>]<<[->+<]>------------------------------------------------------------------------------------------------[.]

Should be easy to reverse engineer it.

\$\endgroup\$
3
  • \$\begingroup\$ Cracked \$\endgroup\$ Dec 19, 2018 at 3:29
  • 2
    \$\begingroup\$ What's BrainF? Do you mean brainfuck? \$\endgroup\$
    – Jo King
    Dec 19, 2018 at 3:48
  • 1
    \$\begingroup\$ Yes I do, but I do not like cursing. \$\endgroup\$
    – MilkyWay90
    Dec 20, 2018 at 0:12
0
\$\begingroup\$

PowerShell, 27 bytes, (Cracked by @DominicVanEssen in comments)

while([int]($args[0])+1){1}

Try it online!

Should be very easy to crack!

\$\endgroup\$
2
  • 2
    \$\begingroup\$ Er, -1.....? Or is there something I didn't get? \$\endgroup\$ Mar 7, 2021 at 17:32
  • \$\begingroup\$ @DominicVanEssen yes it is! You have cracked my answer! \$\endgroup\$
    – Wasif
    Mar 8, 2021 at 5:23
0
\$\begingroup\$

Python 3, 46 bytes, cracked by EasyAsPi

def f(x):
 while isinstance(type(x),type):pass

I only ask that the function must actually be called: i.e., you can't just pass an object that calls exit() in __init__, because that would exit before execution of f began.

\$\endgroup\$
4
  • \$\begingroup\$ Cracked. Not sure if it counts, though. \$\endgroup\$
    – EasyasPi
    May 22, 2021 at 1:52
  • \$\begingroup\$ @EasyasPi my understanding of the challenge is that you find (or create) an input to the function that halts it. If that is the case, then you haven't actually cracked it. you are very much on the right track though. \$\endgroup\$
    – hakr14
    May 22, 2021 at 2:11
  • 1
    \$\begingroup\$ like this?? \$\endgroup\$
    – EasyasPi
    May 22, 2021 at 2:46
  • \$\begingroup\$ @EasyasPi almost verbatim my solution. Well done! \$\endgroup\$
    – hakr14
    May 22, 2021 at 3:21
0
\$\begingroup\$

Golfscript, 23 bytes (Safe)

'\\'/)2<'" '.@@++~{.}do

I hope I blocked everything except my intended solution... :)

Try it online!

Edit:

This solution is technically 'safe', but I think it doesn't deserve it.

First, the challenge was posted 3 years ago, so it was relatively inactive. Moreover, Golfscript is quite esoteric, so fewer people would have had to try solving it.

Below is the solution anyways. Please check it out to evaluate it yourself! :D

Using the string interpolation trick, '#{' will generate an error.

\$\endgroup\$
-1
\$\begingroup\$

CPython 3.6, 635 634 bytes Cracked

j=input()
__builtins__.__dict__["__import__"]=eval(j)
import random,functools,itertools,zlib
exec("@functools.lru_cache(None)\ndef f():i=input();return(all(x is y for x,y in itertools.zip_longest((x for x in sorted(dir(eval(i[::2])))if'_'not in x),sorted{}))\nand all(x is y for x,y in itertools.zip_longest((x for x in sorted(dir(eval(i[1::2])))if'_'not in x),sorted{}))and 8 and zlib.crc32(bytes(i,'ASCII'))==zlib.crc32(bytes(j,'ASCII')))".format(*eval('('+"(tuple(''.join(random.choice('abcdefghijklmnopqrstuvwxyz')for x in range%s)for x in range%s),),"%(("(random.randint(1,9))",)*2)*2+')')))
try:f()
except:f=bool
while not f():8

Try it online!

It probably works in some other versions too, but I haven't tested it in them. Golfing advice welcome.

Note that triggering an EOFError is cheaty - this program expects streams to remain open!

I also have an ungolfed version, complete with terrible, terrible ASCII art, prettified output and probable cryptographic security.

import_input = input()
__builtins__.__dict__["__import__"] = eval(import_input)

import secrets
import functools
import itertools
import zlib
import base64

code = b"""
             GA2
   A      LGA  2     AL1ad        >eG
  @ >T   )Ec#  6     *  C       WM 2 +0    4.            ^1
 +   5  i      T    m   \'     J   ]   7  g                q
 e  `   -+     D V_4W  a ,    :C<  G  E*t
3   GW0P0V/bkg iU>       o    %hb  &  CM_
n      Y 1!SHJIUjh^     iZ    Ol5  %  =n4   Q`b   21   Z>A
R    l& j       iSDh  c>j  ;#  @h  E  ?l    B  W h  # u
di-90o @\\O"t6XNM8boo1T   /JHW     c        Y,@  H    N Ok
                        ?pDT:)     (        (    `    %  F
3<uEZ_BZ"\\hNA)a.1W_9\\)/e%/ROb    2        V     ?5   3q
c5g^O89kP>iuQ3`*GZHb>#u0%gcC_6(    i
L                           Es/    V
6                           >qD    m       H              6
,                           D;$    J        K            ,
                             :K    O              U   ?
                                 I0L(#               d
                                 =   C              9
                                                   `
f$g3<"""

alphabet = "abcdefghijklmnopqrstuvwxyz"
make_keyword = lambda l:"".join(secrets.choice(alphabet) for x in range(l))
exec(zlib.decompress(base64.a85decode(code)[::-1]).decode("ASCII").format(
    *eval('('+"(tuple(make_keyword(secrets.randbelow(20)+1)"
                "for x in range(secrets.randbelow(20)+1)),),"*2+')')))

try:
    f()
except:
    f = bool

while not f():
    print(secrets.randbelow(2), end="")

for byte in itertools.zip_longest(
    *(iter(bin(int.from_bytes(code, "big"))[2:]),) * 8, # bits in a byte
    fillvalue = 0):
    print("".join(byte), end="")

Try it online!

\$\endgroup\$
3
  • \$\begingroup\$ cracked \$\endgroup\$ Jul 26, 2017 at 15:18
  • 2
    \$\begingroup\$ evaling code directly from input without error handling is a trivial way to get cracked \$\endgroup\$ Jul 26, 2017 at 15:20
  • \$\begingroup\$ @ppperry Rematch? \$\endgroup\$
    – wizzwizz4
    Jul 26, 2017 at 15:36
1 2 3
4

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.