Catch up on stories from the past week (and beyond) at the Slashdot story archive

 



Forgot your password?
typodupeerror
Check out the new SourceForge HTML5 internet speed test! No Flash necessary and runs on all devices. ×
Programming

Mimic, the Evil Script That Will Drive Programmers To Insanity (github.com) 246

JustAnotherOldGuy writes: Mimic implements a devilishly sick idea floated on Twitter by Peter Ritchie: "Replace a semicolon (;) with a Greek question mark (;) in your friend's C# code and watch them pull their hair out over the syntax error." There are quite a few characters in the Unicode character set that look, to some extent or another, like others – homoglyphs. Mimic substitutes common ASCII characters for obscure homoglyphs. Caution: using this script may get you fired and/or beaten to a pulp.
This discussion has been archived. No new comments can be posted.

Mimic, the Evil Script That Will Drive Programmers To Insanity

Comments Filter:
  • Simple (Score:5, Insightful)

    by Anonymous Coward on Saturday October 24, 2015 @03:59PM (#50794561)

    git revert [commit]

    "Your commit broke the build. Fix it."

    Bonus points if your continuous integration build server catches it automatically.

    Then have a talk with the author of this non-sense commit about wasting corporate resources.

    • Re:Simple (Score:5, Interesting)

      by Rei ( 128717 ) on Saturday October 24, 2015 @04:32PM (#50794741) Homepage

      Time-delayed or rarely-occurring "evil" can often be better. There's a number of examples here [github.com], although some would be harder to sneak past code review than others. Unless your code review system is lax, or (best) if you have write access to the repository. But some of the aforementioned ideas (or variants thereof) would be just brilliantly evil, to the point that the code works fine when you leave, but say three months later it starts rarely breaking at random times and locations, and the "code plague" just gets more and more common with time.

      One case where Mimic could sneak past the compiler (and code review) but still cause problems would be inside strings. For example, there's a number of characters that render like spaces but are actually multibyte unicode characters. Same with dashes, underscores, and many other characters. Using them would cause the length of the string to not be what the user thinks it is. And string operations could accidentally break up the unicode characters. Such errors could slip code review by and cause random inexplicable runtime errors for quite some time. And the nice thing about those kinds of errors are that you can chock them up to accidents. "Oh, I'm so sorry! I was just copying some code off the net, the character must have gotten mucked up..."

      • > --
        > It's not the 1990s, Slashdot; fix your unicode support. It's ridiculous that I can't type a thorn here.

        Bwaa-haa-haa. Maybe they know better than you.

    • Re:Simple (Score:5, Insightful)

      by Opportunist ( 166417 ) on Saturday October 24, 2015 @04:42PM (#50794783)

      Besides, anyone here who can honestly say he never did the "magic" thing, i.e. delete a line and retype it only to have it suddenly work for no good reason whatsoever?

      I dare say that most programmers would simply delete the offending line and retype it once everything that does actually make sense has been tried.

      Black magic. Do it. I get the candles, Fred brings the voodoo doll, you can start chanting.

      • Re:Simple (Score:4, Informative)

        by Anonymous Coward on Saturday October 24, 2015 @05:22PM (#50794941)

        This happens a lot with Russian programmers due to Latin C and Cyrillic Es homoglyphs that happen to be on the same key, and it's very easy to forget which keyboard layout is currently selected and type the wrong letter.

      • Re:Simple (Score:4, Interesting)

        by Megane ( 129182 ) on Saturday October 24, 2015 @07:41PM (#50795463) Homepage

        A few years ago I had a problem when I would use OS X TextEdit to edit code. Somehow, I never figured out how, it would occasionally insert a control-P character into the text. Of course it was invisible. Other than looking at the file in a hex editor, the only way that I could find it was to use the arrow keys and note when the cursor didn't move. Or the error message from trying to compile/assemble the code.

        I haven't seen this in a long time, and I currently still use 10.6.8, so maybe it was a problem in 10.5 that got fixed in 10.6.

        And I have had other times where I had to retype a visually good line of code more than once. Not to mention the times when the font and my less than perfect eyesight make commas and periods hard to tell apart.

      • That's true, I've accidentally inserted invisible characters into files before, that prevented my code from compiling. Annoying, but somehow I figured it out.
      • by lorinc ( 2470890 )

        Besides, anyone here who can honestly say he never did the "magic" thing, i.e. delete a line and retype it only to have it suddenly work for no good reason whatsoever?

        I dare say that most programmers would simply delete the offending line and retype it once everything that does actually make sense has been tried.

        Black magic. Do it. I get the candles, Fred brings the voodoo doll, you can start chanting.

        It's not black magic at all! It happens all the time with my students: they copy/paste some code from the pdf containing the exercises and then scream for help as the compiler complains. Truth is, they pasted some non-printable characters. When I tell them what happened, that they should never copy/paste code for whatever reason, erase the faulty lines and advise them to type their own version, they almost always seem so disappointed. It's amazing how the young people can be lazy...

      • Besides, anyone here who can honestly say he never did the "magic" thing, i.e. delete a line and retype it only to have it suddenly work for no good reason whatsoever?

        It's practically standard practice in python coding where you might copy/paste another line which gets converted into tabs instead of 3 spaces or 3 spaces instead of tabs depending on your IDE.

      • Besides, anyone here who can honestly say he never did the "magic" thing, i.e. delete a line and retype it only to have it suddenly work for no good reason whatsoever?

        Yeah, except for the last part. I always feel like an idiot when it doesn't work. Well of course it doesn't work, I just retyped the same very thing!

        • Of course this should only happen if you know for a fact that what you typed was correct. Retyping wrong code, I give you that, is useless.

    • Re:Simple (Score:4, Insightful)

      by tomhath ( 637240 ) on Saturday October 24, 2015 @05:19PM (#50794931)

      Then have a talk with the author of this non-sense commit about wasting corporate resources.

      Stern talk, as in "Clean out your desk." I would have zero tolerance for childish pranks like this.

      • by KGIII ( 973947 )

        As all of our code was internal, I might have giggled a little if it was done on the dev end (not in production) and on the 1st of April. We were pretty lax during that one day of the year. It hampered productivity but, in return, we got people with honed skills and insights. So, there's that. I don't think they ever used this but they did use others. Before I turned my code over and stopped working on it myself I had an "I'm drunk" menu nested in and unfinished. Fortunately, I hired professionals. They had

    • Alternatively improve compilers to warn against these specific symbols or treat them as equivalent?

    • by tlhIngan ( 30335 )

      git revert [commit]

      "Your commit broke the build. Fix it."

      Bonus points if your continuous integration build server catches it automatically.

      Then have a talk with the author of this non-sense commit about wasting corporate resources.

      That's if someone checks in non-building code, which should happen almost never. After all, rarely is it true it builds on one machine and not another if your build environment is properly set up.

      This trick is good for someone who can't seem to get their code to compile for no goo

  • not.
    • Re:funny. (Score:5, Insightful)

      by 93 Escort Wagon ( 326346 ) on Saturday October 24, 2015 @05:04PM (#50794863)

      It's probably funny to people who don't have to earn a living. I expect I'd have considered it hilarious back in high school... but now, if a colleague did this, I'd probably demand he be fired.

      • It's funny to me as a theoretical thing. As a practical one, it's pointless and not a workable prank. Proving that a code change compiles is part of the review process. If someone checks in broken code anyhow, it'll cause the build gate to fail, and won't be pushed to the main repository. Release engineering and QA will get upset with them, and they'll have to fix it anyhow. No one else will be inconvenienced; releng will just have to track down who caused the problem, and QA might have to wait an extra day
        • I work for a university department. We don't have large development teams nor the same formal review process - a lot of times one person will handle a particular project from start to finish. One of my coworkers could, if they chose to, go onto a server and mess with a perl or python script.
          Fortunately while I have coworkers that like to joke around, no one would consider this acceptable.

          • Having worked in several university settings, I know how small and undisciplined dev teams in academia can be.

            Having moved to commercial web development, I also know how easy it is to set up a VCS for a small team.

            Once any repo is managed in a VCS (like git and GitHub), it's fairly straightforward to check a project's history and discover when and where the project stopped working as expected.

            If you're not using a VCS, you should seriously consider doing so given the small overhead of setting it up and the

      • It's probably funny to people who don't have to earn a living. I expect I'd have considered it hilarious back in high school... but now, if a colleague did this, I'd probably demand he be fired.

        It's hysterical.

        Yes, on April 1st I would do that to you and replace the ";" on just one of your source files. I would only do it for about 30 minutes or so and chuckle and see if you can find out what I did etc.

        Notice I would not do a find and replace all and take a whole project done and miss a deadline. But I do have a sense of humor. If you did it to me I would be amazed and pissed laughing it off at the same time for being super genius. I would not demand you would be fired. Now if you did this for a w

        • If my hashes changed in directories I had not touched, I'd call IT ands raise merry hell. You would be found and punished.

      • >It's probably funny to people who don't have to earn a living. I expect I'd have considered it hilarious back in high school... but now, if a colleague did this, I'd probably demand he be fired.

        Great. You just fired young Steve Wozniak. I heard him talk a couple weeks ago, and the man was an inveterate prankster. He also encouraged all the young kids in the audience to try to think up clever pranks to pull on people as a way of honing their mental skills.

        • And it'd be right firing him. He was fantastic when working on his own, on projects he could hold in his head. And while he's as nice as they come, he was not a team player of the kind needed in a project based environment. And he would have hated working in one as well. It'd be a waste of everyone's time to keep him in one.

  • Somebody reverts your code.

    At least Slashdot will never fall victim to this.

    • Somebody reverts your code.

      You are assuming this was done through Git. But the best way to pull a prank like this is to paste it directly into a co-worker's editor when they get up to go to the toilet.

      • by rthille ( 8526 )

        You (well, people like you) are the reason I lock my workstation every time I leave my desk.

        • And, really, anybody who doesn't do this at their place of work is probably both violating corporate security policies, and is likely an idiot.

          If you're in an office full of people and not locking your computer and your personal items, you are simply asking for trouble.

          Not saying trust nobody but ... well, actually, yes. I am saying that a healthy level of distrust is a good idea in general.

          Sooner or later someone will reinforce that notion for you.

  • by Mr. Sketch ( 111112 ) <mister.sketch@nOspAM.gmail.com> on Saturday October 24, 2015 @04:04PM (#50794597)

    Wouldn't they see your change to the file in the history/blame for the line?

    Or do they suggest you hack your co-workers machine to run this script on their system?

    • You'd never get to submit the code to the trunk if there's even a minimal build gate for submissions -- it wouldn't compile. So, yeah, it would have to be on someone's computer.

  • by Anonymous Coward

    is reserved for these kind of people...

  • by BitterOak ( 537666 ) on Saturday October 24, 2015 @04:05PM (#50794609)

    One thing that always drove me crazy was the Unix "make" command because of the syntax of the Makefiles. The problem was, unlike just about every other language, Makefiles distinguish between TAB and SPACE characters, and they can look indistinguishable in printouts. I always avoided make for that reason and just wrote shell scripts to compile my code. I've also stayed away from Python because of its use of indentation to indicate the scope of control structures. Too easy to screw up by mixing tabs and spaces. In many fonts used in early terminals and printers, zeros were drawn with a slash through them so they wouldn't be confused with uppercase O's. Now with Unicode replacing ASCII as the encoding for source code in most languages, let the nightmares begin!

    • Many editors, such as Sublime Text, have an option to display tabs and spaces differently.

      Example [sublimetexttips.com]
      • Exactly. One of the first things I do when setting up my text editor is turn on displaying leading whitespace. And many IDEs even have an option to convert one to the other.
      • by Xtifr ( 1323 )

        Emacs highlights space/tab related errors in its Makefile mode. I believe vim does the same.

    • Git filters can convert tabs to spaces automatically (or vice versa); chances are your editor (or a plugin) can too. Unicode may be a bit more challenging, but I'd suggest an office policy that anyone who uses unicode outside a string gets impaled on a rusty lawnmower blade.

      • Git filters can convert tabs to spaces automatically

        Shockingly, not everyone uses git (even if they should).

        Even more shocking, a fair number of small code shops don't use any kind of real version control software (even if they should).

        I don't think this was meant to be a tool to subvert code, just a sneaky way to piss off coworkers. That said, I'd never mess with this thing in any kind of actual work environment.

      • by rthille ( 8526 )

        I just committed code with unicode characters in it for the first time. I've been programming since the '80s. It was for a test. It still made me feel dirty :-)

      • What about comments? Greek character are very useful in comments.

        Right! Anyone who uses unicode outside of strings and comments gets impaled on a rusty lawnmower blade.

    • by thhamm ( 764787 )
      Yeah, bit me many times, but i got used to it. Guess it's CTRL-i in VI for me, JED too, so i 'edit' plain textfiles for my systems with one of those tools. With python i never got comfortable with the whole indentation stuff ... Yeah i'm gettin' old.
    • In my freshman year of college, before I knew anything about Unix-like operating systems, we were forced to program C exercises in a text editor that actually represented SHIFT-SPACE as a different character than SPACE. The character looked no different than space, but broke the compiler.

      And of course, the C compiler told us something completely useless, like "missing parenthesis at end of file", which had no correlation at all to where the erroneous character resided.

      I can't tell you how many times I had

  • That is certainly good to be reminded of. In case of weird errors, pass your code through something that checks for characters beyond ASCII.

    In fact, I am often bitten by something similar on Macs: when typing the pipe character on my keyboard (Alt-7), followed by a space, I end up typing Alt-space, which ends up as a nicode non-breaking space or something. It took me a while to get used to and understand the error saying "-bash: grep: command not found".

  • Bad compiler, then (Score:4, Informative)

    by Lorens ( 597774 ) on Saturday October 24, 2015 @04:17PM (#50794667) Journal

    My students regularly copy-paste from an otherwise excellent source in which plain vertical double quotes have been auto-replaced with pretty slanted quotes. GCC complains about the illegal character on line XXX, I usually have to explain, and that's it. No hair-pulling involved, only git pulling.

  • similar than the non-standard MS symbols, which still hunt me sometimes. Since more than a decade, I use https://www.fourmilab.ch/webto... [fourmilab.ch] to get rid of nonstandard Latin 1. There is nothing more frustrating than have two versions of a program, which both look the same, but only one actually does the right thing.
    • the non-standard MS symbols, which still hunt me sometimes

      This sounds like a case for gun-emoji control.

  • by gweihir ( 88907 ) on Saturday October 24, 2015 @04:26PM (#50794717)

    Unicode in code is for people that do not understand what they are doing.

    • Re: (Score:2, Flamebait)

      by TeknoHog ( 164938 )

      Unicode in code is for people that do not understand what they are doing.

      This. To me it's the same argument as keeping domain names in plain ASCII -- portability. If I cannot type a domain name on any random keyboard, then it has no place on the _inter_net. Code should be similarly universal for a number of reasons, even if it's restricted to one organization; it's like math notation.

      (My native language has a few non-Latin characters and I also use Hanzi occasionally, but I like having some common ground with other people.)

    • not everyones' alphabet fits in the ASCII codeset.

  • that Revision Control instantly beats this bullshit.

  • by PPH ( 736903 ) on Saturday October 24, 2015 @04:33PM (#50794743)

    .... but I'm sticking with Perl.

  • SomeScriptKiddie writes:

    Mimic rehashes an old idea that we all thought died out with MSN: "Replace normal characters like a semicolon (;) with a Greek question mark (;) in your friend's batch files and watch them pull out the previous branch from version control." There are quite a few characters in the Unicode character set that look, to some extent or another, like others – so almost homoglyphs, but not quite. Mimic is a horribly convoluted implementation of what is essentially search & replace. Caution: using this script may get you laughed at and/or promoted to entry level computer hardware mover.

    • promoted to entry level computer hardware mover

      If it's up to me, the new title will be "exit-level developer".

    • by HiThere ( 15173 )

      Well, once you suspect it, it's easy to detect. Just use a font that only displays in ASCII.

  • In the late 1980s as a student I spent several hours feverishly debugging an inscrutable syntax error on a green monochrome monitor at a school lab. I just managed to make the deadline, because on that crappy monitor with its crappy font, ( and { looked too much alike. This took enough time away so that I lost points for not properly formatting my output; but at that point I was happy just to *have* output.

  • by gurps_npc ( 621217 ) on Saturday October 24, 2015 @04:52PM (#50794823) Homepage
    I understand perfectly that other languages have different symbols. But when those symbols are effectively identical to an existing symbol, JUST USE THAT SYMBOL. What idiot decided they had to make a different Unicode character for the greek questionmark, rather than simply using the semicolon? What, the dot above the comma in the greek questionmark is more squarish? Big deal
    • Re: (Score:3, Insightful)

      by Anonymous Coward

      The symbols are visually identical but have different meanings. For a human reading the text, with the human understanding of context and the weird, fuzzy logic that our brains do, that's not a problem. For a computer processing the text, however, it is important to be able to distinguish a semicolon (sentence not finished, or end of coding line, or terminator in a list containing commata) from a Greek question mark (interrogative sentence finished), especially in a text mixing Greek and Latin or English

      • by rthille ( 8526 )

        I think his point was, if the glyph is visually indistinguishable, why is there another character in unicode for it?

        • Probably because it's trying to avoid ambiguity with computers reading the texts eventually. This doesn't really answer the question, given that it might have been more sensible to set it so glyphs with the same meaning shared a code point, and you treated any variations as alternate forms of it, which is something the Unicode standard seems to have already though I've no idea how well it works nor how well-supported it is.

      • Homonyms. I will lead you to the lead mine. Wind your watch before the wind blows you over. The bass player would like to eat a bass for dinner. We write for humans, not for computers. Any software sophisticated enough to need to know the difference between a semicolon and a greek questionmark should also be sophisticated enough to recognize which is which.
    • by Dutch Gun ( 899105 ) on Saturday October 24, 2015 @06:28PM (#50795231)

      See: Han Unification, and all the problems it's caused. Because of this, the Japanese need to jump through hoops if they wish to write a Chinese name in an otherwise Japanese section of text. Since few other western languages have this problem, many Japanese were rather upset at this decision of the Unicode consortium.

      TL;DR: Semantics matter.

      • by Alsee ( 515537 ) on Saturday October 24, 2015 @09:02PM (#50795719) Homepage

        Han Unification:
        Han shot at the same time.

        -

    • I understand perfectly that other languages have different symbols. But when those symbols are effectively identical to an existing symbol, JUST USE THAT SYMBOL.

      Well said! And this should apply as well to the "smart quotes" non-sense. If you want a quote, just store a quote, and nothing else.

  • This would only work on people who don't understand how syntax errors work. Any time an error occurs that I feel is impossible I examine the ordinal values of the characters, or I will delete and retype the line. No real programmer is going to be stumped by this for longer than 5 minutes.

  • ...when editors were so very incompetent at displaying non-printing characters that "try deleting the line and retyping it" was a standard debugging technique. It worked often enough to stay in the toolbox. (Helping this was one compiler bug that occasionally wrote into the source file.)

    I like to think that we have passed that stage. For many years, I believe that was true. Perhaps the dark times are about to return.

    Some things are eternal, though; if you're editing machine code in hex or octal, you're prob

  • 1976 - Our high school ran time shared BASIC on a PDP-8. We wrote a program that would read in a program source file, and randomly replace one or two zeros with letter O, commas with semi colons and round brackets with square brackets. Not all of them, just a few. Drove our well deserving victims nuts.
     
    A classic trick, but hardly new.

  • It is much easier to destroy than to create.

    Values of "destroy" range from petty theft, vandalism, gaming the system, being a jerk, apathy and sloth, active sabotage, and outright war.

    Be nice, even if nobody is watching. Looters should be shot.
    • by snadrus ( 930168 )

      It's important that children destroy: It teaches them that they're an influence on the world around them & they have impact.
      Then at some later point they should be taught (or just realize) the value of creating over destruction.

      This kind of thing is for people who never make it fully through that 2nd psychological development step.

  • Helvitica font displays lowercase l capital I identically. Do this trick on the co worker who leaves the work station unguarded. The code will compile and throw up run time errors. They are lot more fun to watch.
  • by Tom ( 822 )

    It's funny or not, but it does illustrate a real problem. We've seen the discussion about whether or not URLs should have unicode support. Yes it's nice to non-western languages. But it introduces the same kind of problems and suddenly you are not on the website you think you are on anymore.

    The more I look at it, the more I decide that Unicode is simply evil.

  • Back in my highschool days, we had no Unicode, but we did have monitors whose picture was so poor that you could had to look twice to distinguish semicolons and colons.

    So we made a DOS TSR program that hooked in the keyboard interrupt, and if it detected that it was called from Turbo Pascal, and that the sequence for compilation was keyed in, it would locate Turbo Pascal's editor buffer and randomly change a couple of semicolons to colons.

    This was both annoying as hell (plenty of syntax errors), and diffi

  • the oldest solution to this 'mimic bug' is a hex editor. also many 'reveal codes' in complex word processors will show the actual data as to which character is in use, it is only the novice who are going to be tricked by this stuff!

The opossum is a very sophisticated animal. It doesn't even get up until 5 or 6 PM.

Working...