PDA

View Full Version : Darkhog's challenge: Obfuscated drawing



Darkhog
17-07-2013, 07:42 PM
I've decided to live up this community a bit.

The challenge is following:
You need to draw following picture:
http://i.imgur.com/reEZ0LL.png

You CANNOT store it in anyway in program, it must be procedurally generated.

Image must appear EXACTLY as shown above.

You need to obfuscate ALL your code as you go. Only manual obfuscation allowed.

Binary AND source code COMBINED cannot exceed 300kb.

You can use any pascal-capable graphic library, including ports of C libraries. Be advised though, that any of DLLs used aside of stuff that comes with WinAPI or standard Linux APIs counts to size limit, even if it isn't written by you.

Deadline: Nov, 16th.

SilverWarior
17-07-2013, 08:42 PM
Image must appear EXACTLY as shown above.

For this you would either need to store the picture in your program, or use exactly smae steps to produce the image as you did and that is quite dificult withput knowing the steps you did.



Binary AND source code COMBINED cannot exceed 300kb.

This can be quite hard as some graphical libraries already exceeds this limit.
Also if I create a New Application with blank form in Delphi XE3 with default project options the executable size already Exceeds 10 MB. I gues to many libraries get linked into it even thou they are not even being used.
EDIT: Most of this space is being used by Debug information so if I compile that Application without debug information its size drops to some over 2MB in size.

EDIT2: Creating new LCL application in Lazarus without debug information also generates Executable whose size exceeds 1.5 MB.
So creating an executable with less than 300k in size would be a big challenge already. And this would probably draw pepole away from even atempting your challenge.

User137
17-07-2013, 09:16 PM
It's possible to make console application that small, to save such image in a file. But drawing on screen does close out any standard GUI methods. OpenGL, DirectX, SDL and Allegro are all out of question i assume.

And you couldn't have picked any more provocative base image ::)

pstudio
17-07-2013, 09:51 PM
You CANNOT store it in anyway in program, it must be procedurally generated.
I take that you mean that you cannot store the image as an exact bitmap? Obviously the image must be represented in the code somehow.



Binary AND source code COMBINED cannot exceed 300kb.

You can use any pascal-capable graphic library, including ports of C libraries. Be advised though, that any of DLLs used aside of stuff that comes with WinAPI or standard Linux APIs counts to size limit, even if it isn't written by you.

Deadline: Nov, 16th.
As mentioned by other users this seems as a strict requirement. Why even put a size limit? As I see it the interesting part is to generate the image and apparently make your code unreadable.

Darkhog
17-07-2013, 11:25 PM
Why size req? Because I want to see how much code you can squeeze into 300kb (combined sources and exe). You can add as many "bells and whistles" as you like as long as it performs task. Drawing this image doesn't need to be ONLY thing your code will perform, but it must be ONE OF THEM.

User137
17-07-2013, 11:57 PM
Why size req? Because I want to see how much code you can squeeze into 300kb (combined sources and exe). You can add as many "bells and whistles" as you like as long as it performs task. Drawing this image doesn't need to be ONLY thing your code will perform, but it must be ONE OF THEM.
We meant empty window application with no bells and whistles, that take more than 1Mb. To display image, you do need to create a window right, or are we allowed to call Windows specific command, to for example launch Windows Photo Viewer on saved image?

About the image complexity (120x120), it would be required to write a simple additional tool which generates some code. By the code i don't mean directly a pixelmap, but it can be different representation of it. I can't imagine anyone reading all the pixel-coordinates by hand.

I like similar challenges, but this doesn't seem thought through. Is the intention of this contest, to find out all possible ways to make small-executable visual demos?

Ñuño Martínez
18-07-2013, 10:38 AM
We meant empty window application with no bells and whistles, that take more than 1Mb. To display image, you do need to create a window right, or are we allowed to call Windows specific command, to for example launch Windows Photo Viewer on saved image?
The executable of the biggest Allegro.pas 4.4.4 example (ex3d, that shows how to create and display a bunch or 3D textured cubes) is 153'1 KiB (not counting the Allegro library). This is on Fedora 18 64bit. Can't remember if it's bigger on Windows. Not sure if it's "X file is ... KiB" or "X file has ... KiB". In Spanish it's "has".

About the challenge, now I'm too lazy so I'll wait. But may be I try...

User137
18-07-2013, 03:53 PM
But alleg44.dll is 790kB.

Darkhog
18-07-2013, 05:05 PM
I think you all are getting fixated on hi-level graphical APIs. There's one unit that would perfectly help with drawing B&W image.

Hint: It is there since Turbo Pascal and on FPC it pops a window.

pstudio
18-07-2013, 07:03 PM
We're not saying that it is impossible, but personally I don't find it interesting at all to try and make my executables as small as possible by using tools that I wont normally use. To me it seems like an unnecessary requirement for a challenge about drawing an image with obscure code.

I might give this challenge a try, but I wont bother about size limit, and I think many other would be put off as well about the size limit if they can't use the tools they are familiar with.

phibermon
25-07-2013, 04:37 PM
presumably if I do store the image in my code and binary but succeed in obfuscating the fact that I did, then I win some chocolate? The hand drawn image contains very little geometric repetition in which you can really push the boat out in terms of generation, any program that does this would be pretty much be scan-line based with fixed or obfuscated data describing filled blocks etc or otherwise break the image down into the smallest procedurally replicable parts.

I'd be up for an obfuscation challenge any day or night but if we're going to obfuscate the process of re-constructing an image then it'd be far nicer if that image had interesting structures to replicate.

Plus an obfuscation challenge is very subjective, what may be indecipherable to one pascal coder might be perfectly fine for the next. Unfortunately the language is a very poor choice for obfuscation as it's strongly typed by design. A lot of the fun of a C obfuscation challenge comes from throwing off the reader with obscure syntax or by deliberately exploiting the non-type safe design blunder of such languages.

I think it'd be a challenge just to write any obfuscated pascal code, at least in the classical, small code snippet sense. Obfuscation through sheer size (we've all done that ;) ) or macros used to redefine language keywords etc are boring.

User137
25-07-2013, 11:55 PM
Just out of curiosity i tried to draw some graphics in small executable. I managed to fit the compiled Lazarus exe and source code under 60kb (or actually under 50kb i guess), and it draws a full color pixel map in a WinAPI window.

Some limitations i noticed, is that simple types like TBitmap is not allowed. It uses interfaces which increases executable size by 1Mb or so. Anyway, it is doable.

(The only thing i have in uses list is Windows)

edit: I have finalized my entry. Up to you if i send it as private message or post public. I know it could be obfiscated to remove all line-change characters, but i left it at 137 lines :D

User137
26-07-2013, 11:10 AM
Under Darkhog's permission, i'll post my submission in this thread. That is under 50kb when extracted:
https://www.dropbox.com/s/nk8u6a0bwvscid8/window_obf.zip

Darkhog
29-07-2013, 09:52 PM
In source you are pretty much storing image in that big string. It isn't allowed.

You can save steps (e.g. draw line by line), but you can't store image itself. Nice try though.

User137
30-07-2013, 08:37 AM
Actually i stored line start and end indices, and for black lines only. So isn't that what we describe as steps? And if i compare my data to whole image PNG packed, the PNG is 1703 bytes, and string 2219 bytes. So it is quite compact.

Darkhog
30-07-2013, 03:30 PM
Ah, okay. If that's so, then it's good.