No video

Obfuscated C programs: Introduction

  Рет қаралды 187,308

Bisqwit

Bisqwit

Күн бұрын

If you program long enough, eventually you will run into a programming art category called "obfuscated code" or “code golf”. You can find these especially at IOCCC. In this video I introduce the concept and the basic ideas behind such design. More information below (click "Show more").
I realize the category is "obfuscated code", not "small code", but often trying to compress your code into the smallest size will also effectively obfuscate its function. I also realize that some of the individual changes I did in the video did actually not result in smaller program code size, but the opposite. But the end result is still the shortest I could manage, if you remove the "int", the "return", and the space after "include".
Actual obfuscation techniques include using small and meaningless variable names, using unusual syntax constructs, redefining reserved words, adding code that appears to do one thing but does something else (or nothing at all), creating a complex machinery (such as an interpreter) to do a different task, encryption, and so on.
Twitter: / realbisqwit
Patreon: / bisqwit (alternatives at iki.fi/bisqwit...)
Twitch: / realbisqwit
Homepage: iki.fi/bisqwit/
Source code:
bisqwit.iki.fi...
Music:
- Star Ocean :: Encounter :: Motoi Sakuraba (converted into MIDI and played through OPL3 emulation through homebrew software)
- Chrono Cross :: Jellyfish Sea :: Yasunori Mitsuda
Contribute subtitles:
www.youtube.co...
I got to use the word "defenestrate"!
#Bisqwit #Programming #ProgrammingPhilosophy #Tutorial #ObfuscatedCode #CProgramming

Пікірлер: 317
@ParadoxBassCube
@ParadoxBassCube 7 жыл бұрын
Idea/Question: is the obfuscated code faster than the normal code?
@Bisqwit
@Bisqwit 7 жыл бұрын
No, quite often it is slower. Mostly it just depends on the architecture and algorithms you have chosen, but compilers are designed to be much better at optimizing typical code than at optimizing weird code.
@ParadoxBassCube
@ParadoxBassCube 7 жыл бұрын
Interesting. Didn't expect that. Thanks for the fast reply!
@user-vn7ce5ig1z
@user-vn7ce5ig1z 5 жыл бұрын
It depends on how you obfuscate it. For example, if you replace a bunch of stuff with defines, then it would be transparent to the compile and run identically. If you replace some things with a bunch of function calls, then it would likely end up slightly slower because of the function-calling overhead.
@SG-kn2jl
@SG-kn2jl 5 жыл бұрын
Well yes, but actually no
@franchufranchu119
@franchufranchu119 4 жыл бұрын
The changing of the CASE statements bisquit did at the beginning was faster i think
@Kniffel101
@Kniffel101 8 жыл бұрын
This background music really makes the code even spookier than is already is! ^^
@Bisqwit
@Bisqwit 7 жыл бұрын
No it is not.
@cyancoyote7366
@cyancoyote7366 7 жыл бұрын
I absolutely love Bisqwit's replies. They're always so simple, yet they convey more meaning than even some books do. I like your videos Bisqwit, keep ut the amazing work :D
@safdarmahmood2182
@safdarmahmood2182 7 жыл бұрын
I was high when I watched this XD
@Bisqwit
@Bisqwit 7 жыл бұрын
+Safdar Mahmood: kzfaq.info/get/bejne/iqmqrNNlqd_ddoU.html
@spessspess4616
@spessspess4616 6 жыл бұрын
god spoke
@gubbin909
@gubbin909 7 жыл бұрын
I just discovered this, and I can only describe you as the Bob Ross of programming.
@Blue-Maned_Hawk
@Blue-Maned_Hawk 5 жыл бұрын
This is the first time I've heard someone honestly and casually use the word "defenestrate."
@cardboardconnoisseur9155
@cardboardconnoisseur9155 5 жыл бұрын
I had to replay that bit a couple of times because I couldn't believe how brilliant that one sentence was. It's like the English language equivalent what he's talking about doing in C.
@sebastianmorataboada9795
@sebastianmorataboada9795 5 жыл бұрын
0:45 _upgrade_ 0:54 _upgrade_ 1:16 Uhhh... _upgrade_ 1:33 Whatever. _upgrade_ 1:48 _🅱*_*_*_*_ _*_go BACK_* 1:57 *_aaaarghh my eyes_* 2:05 *_jFC_* 2:44 *_what the frigg did you just 🅱ring upon this cursed land_* 3:15 *_I͠t ͏i̡s ͡a̕l͏ready ̕too lat̸e.̵ T͟h̀e͜ ͟s̷ong ͝t͟ha͟t e̶ņd̸s̨ ͢th̀e̡ ͠w̧or͏l͝d̶ ̛h̸a̧s ̀alrea̡d̸y ̷bee̷n su͝ǹg.̨ ͝Em̢br͘ac͏e̢ th͜e v҉oįd̵. ҉He͝ ͢c̷om͢eeeȩs̛s̛_*
@hattrickster33
@hattrickster33 5 жыл бұрын
As someone with a background in Java and PHP, this is kinda how I felt when I tried to write a server in C for the first time, only 100x worse. It's like going from a power saw to a hand saw that cuts your hand off every time it isn't 100% level.
@okie9025
@okie9025 4 жыл бұрын
C really isn't as good as everyone implies
@hexagonist23
@hexagonist23 3 жыл бұрын
@@okie9025 No, C is the only good programming language. Just because it's too hard for you doesn't mean it's bad.
@okie9025
@okie9025 3 жыл бұрын
@@hexagonist23 C is probably the simplest, most rudimentary language that exists, and it shows.
@hexagonist23
@hexagonist23 3 жыл бұрын
@@okie9025 and thats a good thing.
@fabiocarreiro7768
@fabiocarreiro7768 3 жыл бұрын
@@hexagonist23 C is great, but isn't for everything. The simplicity can be a good thing when your software need to run very fast or use less space in memory, but when the development is more important than speed they are executed, C can be a headache, and time means money.
@TurbinationE
@TurbinationE 8 жыл бұрын
This is beautiful and disturbing.
@MrKristian252
@MrKristian252 5 жыл бұрын
I just found a random dude using the same profile picture as me
@OrangeC7
@OrangeC7 5 жыл бұрын
I don't know about anyone else, but for me there's a certain area between obfuscated code and readable code when the code seems so elegantly designed, where it doesn't use so many obfuscated concepts as to confuse whoever is seeing it, but it also is compacted in a way that makes everything flow together concisely but beautifully. But I don't know, I haven't seen enough programs to be sure.
@GenericInternetter
@GenericInternetter 5 жыл бұрын
you're right and i've seen the same too. Something like this? www.makeuseof.com/tag/basic-programming-principles/ i dabble in C# and generally what you describe comes in the form of everything being split into classes and functions neatly, always calling functions to pass values rather than tunneling through multiple classes with reference values ( i've heard this referred to as "agile coding"...?)
@denny141196
@denny141196 3 жыл бұрын
I used to code a fair amount for uni, and one of my favorite pastimes would be to align to readability for 99% of the code, then put one absurdly obfuscated line somewhere with no comment. Something like switch ( data>>(2*(3-i))&3 ) {
@thezipcreator
@thezipcreator 2 жыл бұрын
@@denny141196 good luck when you end up using a module from one project with an obfuscated line in something else three months later and you have to debug it
@rajatkaul751
@rajatkaul751 2 жыл бұрын
I think functional programming is what you're talking about
@blitzmensch
@blitzmensch Жыл бұрын
@@thezipcreatoryou do indeed need to write even a minimal comment just to have a bare understanding of what a line does. But I personally do not use a lot of comments as I tend to remember every bit of code I write
@oEQjet
@oEQjet 8 жыл бұрын
Great introduction and breakdown to basic obfuscation techniques. Thanks for the post!
@miszczklasykuw3025
@miszczklasykuw3025 5 жыл бұрын
do u realize that in business development u've got software/libraries to code obfuscation? xd doing it manually is just waste of time
@edwardfanboy
@edwardfanboy 5 жыл бұрын
​@@miszczklasykuw3025I don't think you're understanding the point of code obfuscation in C. When you develop a program in C, compile it, and send the compiled version to customers, they don't get access to the source code. Obfuscating the C source code is a terrible idea from a business perspective, whether you automate it or not: It doesn't make your program harder to reverse-engineer, it just makes it harder for developers to modify later. The sort of obfuscation described in this video is actually done for fun: To show off knowledge of the tiny details of C, or to see just how unreadable code can get while still maintaining functionality. If you automate that, you take the fun out of it.
@miszczklasykuw3025
@miszczklasykuw3025 5 жыл бұрын
@@edwardfanboy u dont have obfuscated code in system version control (otherwise u've got it in different branch) - the point is u run obfuscation script after release, so only customers don't have clear code.
@edwardfanboy
@edwardfanboy 5 жыл бұрын
@@miszczklasykuw3025 But you don't need to obfuscate your source code. The compiler does that for you simply by converting it into machine code.
@miszczklasykuw3025
@miszczklasykuw3025 5 жыл бұрын
@@edwardfanboy not if u write in example in javascript
@JTST1234
@JTST1234 5 жыл бұрын
This guy is legit trolling my knowledge of C.
@ewncilo
@ewncilo 4 жыл бұрын
as someone who study the c languague for more than 4 years this so stimulating and satisfying to me
@Sypaka
@Sypaka 5 жыл бұрын
**Obfuscation** Makes a 1st Person Shooter with 6 hours playtime using 30 lines of code, full HD, 3D, textured and sound.
@WeAreCameron
@WeAreCameron 5 жыл бұрын
my thoughts: 1. Huh. 2. Okay. 3. Sure. 4. Wh-- err.. wh-- ????
@MrAndyDick
@MrAndyDick 8 жыл бұрын
*brain explodes*
@dzonialucard
@dzonialucard 7 жыл бұрын
Wai wait, hold up So the dude wrote a program that gets the local time and responds accordingly - IN TWO LINES?? What dark sorcery is this?
@ETXAlienRobot201
@ETXAlienRobot201 6 жыл бұрын
In a sense, that's exactly what a raw binary code file is! Far as the computer is concerned, nothing ends It just follows instructions in the order given, and jumps to a different place when told to. No lines, just memory addresses, and memory is for all intents and purposes, 1 dimensional. Just my 2 cents
@okktok
@okktok 6 жыл бұрын
Actually, you can write almost any C program in 2 lines
@lupinedreamexpress
@lupinedreamexpress 5 жыл бұрын
The compiler definitely does not care about newline in code or white-space. Indeed you can. There is actually a term for this process that java programmers use, a process known as 'gulping'. It places an entire program on 1 line and uniquely identifies all variables, giving them sequential letter renaming (a, b, c... aa, ab, ac...) and combines them on a line (or at a configured maximum of 32768/65536/16384/... characters for parser capability differences, some text editors will crash when a file contains a line above certain limits aswell) Gulping is applicable to C and C++ but no one uses it because we'd like to avoid going insane. It is however a very useful process for creating code art, as gulping was designed to minimize the number of bytes in a php or javascript that are transmitted over the internet for running on the client machine, gulp contains a c and c++ parser and can minimize code to an extent like he does here manually. Its primary focus is to minimize the number of characters the program contains. For some builds of gulp, it will even rework program logic to find a better (and smaller, in bytes) solution.
@okie9025
@okie9025 5 жыл бұрын
You can do that easily in any language, like JavaScript
@givup_
@givup_ 5 жыл бұрын
@@okie9025 But for example not in python, where indentation is used instead of braces etc.
@EmielvanGoor
@EmielvanGoor 7 жыл бұрын
I don't understand the "AAAA########+++///9999AA " characters.. Why and how is this used? Do these characters mean something? edit: OK.. I understand now.. It translates into the offset.. (You even said it in your video..!)
@MA-nx3xj
@MA-nx3xj 5 жыл бұрын
I still don't quite understand it..can someone explain?
@ratkentheinfinity9841
@ratkentheinfinity9841 5 жыл бұрын
There was numb3rs before in array. So think of a number say 60. We add this to each number to the array 44440000000 etc. Then convert it to the ascii. Then it looks like that. Now switch the number we used before with real offsett
@Bisqwit
@Bisqwit 4 жыл бұрын
@Meowtresting For a computer, all it sees is numbers. Literally everything is numbers. Even characters, they are numbers. Text is numbers. Colors are numbers. Graphics is numbers. Audio is numbers. Video is numbers. Programs are numbers. Sequences upon sequences of numbers. Because all the computer has, is numbers. That’s why they are called _computers._ They compute. To process characters and text and strings, there are agreed conventions that describe how numbers are interpreted as characters. One of these is the ASCII, and it is almost universally used. In ASCII, numbers from 32 to 63 map to symbols !"#$%&'()*+,-./0123456789:;? respectively, numbers from 64 to 95 map to @ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_ respectively, and numbers 96 to 126 map to `abcdefghijklmnopqrstuvwxyz{|}~ respectively. In other words, 65 is the same as 'A', 66 is the same as 'B', 67 is the same as 'C', and so on. So, when in C you have a string of characters such as "HELLO", what you _really_ have is an array of numbers: 72, 45, 76, 76, 79. It’s just _represented_ as characters for your convenience. But it really is just a sequence of numbers. One implication of this is that when you _need_ an array of small numbers, you _can_ represent them as a string of characters. It’s not a good idea for real-world programming, but obfuscated programming is specifically about _not_ good ideas, so it’s perfect there! If the numbers you have don’t map to useful characters, you can use mathematical formula to change them. For example, if your array of numbers is 0,0,0,4,4,4,8,8,8, those numbers don’t really map into printable characters. But if you add 67 to those, you get 67,67,67,71,71,71,75,75,75, which maps to "CCCGGGKKK". Then you can just subtract 67, when reading the string of characters (which, again, is really just an array of numbers), to get the original value.
@pawmeowzing2906
@pawmeowzing2906 4 жыл бұрын
check this out fro those want graphical explanation: kzfaq.info/get/bejne/adZpermKkr2vcqs.html
@pawmeowzing2906
@pawmeowzing2906 4 жыл бұрын
@@Bisqwit is there any chance u can help to add my video link to your video description? It is java version
@GenericInternetter
@GenericInternetter 5 жыл бұрын
I love how his voice sounds like a computer. I like to imagine it's a computer teaching me about computers.
@kouvolaartschoolfinland9332
@kouvolaartschoolfinland9332 3 жыл бұрын
Its because he has a finnish accent
@ChrisTheCringe
@ChrisTheCringe 7 жыл бұрын
Just two lines? Are you god?
@happilicious
@happilicious 6 жыл бұрын
ChrisMC wait, you are everywhere :o
@osumatrix.
@osumatrix. 5 жыл бұрын
three
@LoCloud7
@LoCloud7 5 жыл бұрын
In C, you can compress the entirety of your code on a single line (except for preprocessor instructions), by just not using newline characters.
@not_herobrine3752
@not_herobrine3752 5 жыл бұрын
@@LoCloud7 Now imma try coding in c now.
@sebastianmorataboada9795
@sebastianmorataboada9795 5 жыл бұрын
Uhh, i really shouldn't be reading comments before ending to watch the video
@devjock
@devjock 8 жыл бұрын
Amazing explanation and application. Clear, concise, and to the point. Thanks for this!
@tomhijkl
@tomhijkl 8 жыл бұрын
I was blown away by this one, it took me quite a while to understand why that worked.
@mattr2238
@mattr2238 4 жыл бұрын
C was practically designed for obfuscation. Just use the define directive to replace all the keywords with random alphanumeric strings. You can do all kinds of meta programming to change the compiled binary as well.
@hikari_no_yume
@hikari_no_yume 8 жыл бұрын
But you missed out the big one: MACROS!
@Bisqwit
@Bisqwit 8 жыл бұрын
+TazeTSchnitzel Yeah, I know. I was trying to figure out a way to incorporate them into my video, but I couldn't. Well, you see a fair share of macros in the IOCCC showcases that flash near the beginning of the video :)
@DamianReloaded
@DamianReloaded 8 жыл бұрын
+TazeTSchnitzel I personally prefer no macros to see how far the language allows you to go without them
@DjVortex-w
@DjVortex-w 8 жыл бұрын
I think that preprocessor macros are considered kind of a cheap trick to "obfuscate" the code, requiring little to no talent to use. The only "legitimate" use of them is to use them to shape your code into some kind of ascii art, or to shorten the code, if that's a goal.
@chrono0097
@chrono0097 7 жыл бұрын
You used as background music for the video the music of two of the best video game composers ever, and better than that, you chosed chrono cross. I have a whole new level of respecto to you!
@Bisqwit
@Bisqwit 7 жыл бұрын
I did use Chrono Cross in some of my videos, but not in this one! Thanks for commenting. Although there is a little part from Chrono Cross at the end, because that is the music from the video in the lower-right corner, a Chrono Cross TAS: kzfaq.info?annotation_id=annotation_3207288859&feature=iv&list=PL95656014200AC3E7&src_vid=rwOI1biZeD8
@chrono0097
@chrono0097 7 жыл бұрын
It was so tiny and my youtube quality was so low i didn't see it in that corner, i apologise jajajajajaja Oh good! Im plaing it for the thrid time!
@ScipiPurr
@ScipiPurr 7 жыл бұрын
While this is obfuscation, this is really for a specific kind of programming challenge called Code Golf where you try to write a program using a few characters as possible. Some of my personal C/C++ code golf code: Reads its own source file(named 'm') and prints out occurrences of characters in ascii order: #include int main(){int a[256]{},i;auto f=fopen("m","r");while(i=~getc(f))a[~i]++;for(int x:a)x?printf("%c %d ",i,x):0,++i;} Conway's Game of Life for the GBA using the tonc library (with identifier names shortened): #include #define l for(x=0;++x
@Bisqwit
@Bisqwit 7 жыл бұрын
Yes, you are right in that this video covered the topic way too narrowly.
@ScipiPurr
@ScipiPurr 7 жыл бұрын
Perhaps a second video on the topic is in order? ;) ;)
@crimsun7186
@crimsun7186 7 жыл бұрын
One of the most entertaining of those was a similar contest, where you had to generate the largest error message with as little code as possible.
@threenplustwo9105
@threenplustwo9105 6 жыл бұрын
CrimSun Compiler error or any error?
@lupinedreamexpress
@lupinedreamexpress 5 жыл бұрын
I am glad that you said these are not best practices. I cringed when you removed your explicit type declarations but they do indeed still compile/work. This is a form of artwork that does indeed require some sacrifice. But to anyone else watching these are definitely not best practices, just a fun thing to do in your spare time.
@leeemattyrs4708
@leeemattyrs4708 8 жыл бұрын
HHAHAHAH no way :D Me and my friend literally discovered this yesterday :D (And we were wondering how it was done :P)
@bidyutchakraborty2433
@bidyutchakraborty2433 6 жыл бұрын
I, while trying to code a short program in C without using semicolon, came across your video and was really mesmerized. I have prepared a full length explanation of each step (... your explanations were sometimes just hints or there were no explanation at all, just like the use of & 7 instead of - '0'). I prepared this for teaching my students some very good C tricks. Thank you Bisqwit.
@Bisqwit
@Bisqwit 6 жыл бұрын
Nice. I do believe you need at least one semicolon though!
@bidyutchakraborty2433
@bidyutchakraborty2433 6 жыл бұрын
No. For some short programs you won't need any semicolon at all. However not every program can be written like that.
@Bisqwit
@Bisqwit 6 жыл бұрын
Please give an example of a program that does not need a single semicolon and that does something other than just terminate. Even if your program is just a single return statement, it still needs a semicolon. (Note: Using compiler -D options to create a #define that contains a semicolonis not a valid solution.)
@bidyutchakraborty2433
@bidyutchakraborty2433 6 жыл бұрын
Well, well. I will surely give you an example. Say you want one small program that just says "Hello there! I'm Bisqwit", your program's main logic should look like this: if(printf("Hello there! I am BIsquit")){} This is taking advantage of 'if' structure where no semicolon is required. You can extend this to a more bigger program by taking user input and based on that print something! I've decided to make a video on it and put it in KZfaq.
@Bisqwit
@Bisqwit 6 жыл бұрын
I stand corrected! I am ashamed of myself that I could not figure that one out (using for/if/while which do not need a semicolon, but another statement which can be a compound block).
@marceloescamilla8867
@marceloescamilla8867 5 жыл бұрын
did you said the word "defenestrated"? im freaking subscribing right now.
@tigeruby
@tigeruby 7 жыл бұрын
すごいね ...
@EidosGaming
@EidosGaming 3 жыл бұрын
The music makes it feel like I'm being pulled in the dark side
@xkernel
@xkernel 8 жыл бұрын
I really really love your videos! It's very mesmerizing!
@MrGreatDane2
@MrGreatDane2 8 жыл бұрын
You're a great programmor bisquit :)
@thogameskanaal
@thogameskanaal 3 жыл бұрын
Really falling in love with C!
@pet3590
@pet3590 5 жыл бұрын
Do you really need to obfuscate C code tho
@MrtinVarela
@MrtinVarela 5 жыл бұрын
Art is not supposed to be practical... or make sense at all.
@per-axelskogsberg3861
@per-axelskogsberg3861 7 жыл бұрын
Your videos are always entertaining and this one I kind of understood 😃 Thanks for producing content.
@BlizzetaNet
@BlizzetaNet 5 жыл бұрын
So I wrote the code, man it works well! now all I need to do is add it to my command lines so I can feel more positive!
@commitgit5889
@commitgit5889 2 жыл бұрын
Also, you can remove the “int” from the declaration of main as well. This will produce warnings but it will still compile.
@Bisqwit
@Bisqwit 2 жыл бұрын
True. In this video I tried to focus on techniques that don’t rely on the compiler accepting non-compliant code (implicit ‘int’ return type was permitted in C89, but not since C99).
@wwhhooami
@wwhhooami 8 жыл бұрын
Very usefull video. Do more!
@Bisqwit
@Bisqwit 8 жыл бұрын
+Delighter Thanks!
@ADRENELINEDUDE
@ADRENELINEDUDE 7 жыл бұрын
The Mario is very distracting
@le9038
@le9038 2 жыл бұрын
god.... Imagine someone tries to maintain that code after you pass it on...
@typedef_
@typedef_ 7 жыл бұрын
Can you write a program that obfuscates its own source code over and over like some positive feedback system ?
@Bisqwit
@Bisqwit 7 жыл бұрын
Yes -- it is possible to do that infinitely --, although it would not discover new algorithms. It would just keep applying the same formulas. For example, make an interpreter. Then convert that interpreter into its own language, and add an interpreter. Then convert that interpreter into its own language, and add an interpreter.
@blusterhash
@blusterhash 8 жыл бұрын
Nice! What editor do you use?
@mysticduck7846
@mysticduck7846 7 жыл бұрын
It's called Joe's Own editor, I think. It can be modified.
@Reth_Hard
@Reth_Hard 7 жыл бұрын
Everything can be modified... Did you mean, it's open source? I was also curious to know more about his editor. It seems to be supporting UTF-8 and Unicode! Wow! I wasn't expecting this, and there's so many features. Unfortunately, you can't use it on windows unless you are using Cygwin.
@xGOKOPx
@xGOKOPx 5 жыл бұрын
@@Reth_Hard What so special about it supporting unicode? Is it because it's in the terminal? If so, then vim supports unicode, emacs supports unicode, nano supports unicode...
@luiswirth
@luiswirth 6 жыл бұрын
This is crazy! Nice work.
@DvDick
@DvDick 5 жыл бұрын
Machine language: *exists* Smart people: We should make it easier for humans to do stuff with it *invent programming languages* Programmer: *writes mess that somehow works* Smart people: *surprised Pikachu face*
@u.v.s.5583
@u.v.s.5583 3 жыл бұрын
I am able to go one step further. I can obfuscated a program in any language to the point where not only nobody can decipher it, but it even does not work!
@machitoons
@machitoons 5 жыл бұрын
as someone who only knows a bit of python this looks like black magic
@moth.monster
@moth.monster 5 жыл бұрын
It is
@andymac3614
@andymac3614 5 жыл бұрын
As someone who knows C and uses it as a main programming language, this looks like black magic
@edwardfanboy
@edwardfanboy 5 жыл бұрын
People sometimes criticize Python for its mandated use of whitespace, but it prevents you from the sort of descent into madness demonstrated in this video. If you want good, readable C code, clear usage of whitespace might as well be mandatory.
@BlazertronGames
@BlazertronGames 5 жыл бұрын
I can surprisingly understand it, and I wouldn't even say I know C. I understand the basics, but not much more than that. You just need to know how strings work in C, and know about ASCII. If you knew that, it's not hard to piece it together.
@andymac3614
@andymac3614 5 жыл бұрын
@@BlazertronGames I mean, when he does this, I understand it completely. Black magic is the ability to come up with this
@SG-kn2jl
@SG-kn2jl 5 жыл бұрын
Ur voice sounds like u r telling some horror story which happened to u when u were in the deep web...nice video
@TheFoxMcfat
@TheFoxMcfat 5 жыл бұрын
I don't know why, but i *love* your voice and accent
@Thesurvivour-yl3hd
@Thesurvivour-yl3hd 6 жыл бұрын
That is really impressive.
@shmuel-k
@shmuel-k 5 жыл бұрын
I learned a new word. Defenestrated.
@vuvffufg
@vuvffufg 8 жыл бұрын
Love ur programming videos, keep it up!
@0xDevelopers
@0xDevelopers 5 жыл бұрын
I wrote print("hello world") program in python shell 5 times just to make things okay again
@0nyr
@0nyr 2 жыл бұрын
Loving that ;)
@dennisunderscore
@dennisunderscore 5 жыл бұрын
I dont know C, but thanks youtube...
@blzahz7633
@blzahz7633 7 жыл бұрын
Is it cheating to include own header files?
@Bisqwit
@Bisqwit 7 жыл бұрын
Cheating implies rules. Which rules are you contesting?
@blzahz7633
@blzahz7633 7 жыл бұрын
The international contest mentioned 0:10, but I was just joking :D No joka tapauksessa, nää videot on mukavaa katseltavaa.
@Bisqwit
@Bisqwit 7 жыл бұрын
You can find the rules of the (as of now) most recent IOCCC at www.ioccc.org/2015/rules.txt . To be honest I cannot entirely ascertain how submissions that require supplied include files are treated as for the size limits.
@MrEdrftgyuji
@MrEdrftgyuji 7 жыл бұрын
Another tip - you can redefine standard library functions to accept different parameters for maximum unreadability. This can be used to avoid structure definitions and having to include system headers - e.g.: int time(int); int* localtime(int*); int main() { int t = time(0); return printf("Hour = %d ", localtime(&t)[2]); } (no need to include time.h) You can even drop the prototypes if the size of the return of the function is equal to sizeof(int) (or you don't care about stack corruption) - this is because C will assume that the return type of an undeclared function is int. int main() { int t = time(0); return printf("Hour = %d ", ((int*)localtime(&t))[2]); } (assumes sizeof pointer is the same as sizeof int - may not be the case!) You need to get the sizes of the return and parameters correct, or you will corrupt the stack :) (although intentionally corrupting the stack may have its own advantages...) It should also go without saying, but this code is not portable and you will need to work out the correct types / indexes for your system. You should never ever do this.
@Bisqwit
@Bisqwit 7 жыл бұрын
Of course, this will totally throw portability out of windows. In IOCCC, you would have to explain this in the submission and justify why you are doing it.
@PietroNardelli
@PietroNardelli 6 жыл бұрын
I liked your new thumbnails
@manvelbeaver520
@manvelbeaver520 4 жыл бұрын
Python has a nice package called Pyarmor which does this. I learned malware uses obfuscation to avoid being detected.
@Gunbudder
@Gunbudder 7 жыл бұрын
the comma operator will get you very far in writing mind bending code as well. my brain turns inside out when i find a comma operator hiding in C code because a ) was put in the wrong place. Even the old guys are like "... WHY DOES THIS COMPILE AT ALL???"
@Bisqwit
@Bisqwit 7 жыл бұрын
The comma operator outside e.g. function parameters is really quite a nasty hack / language quirk. If I had to label the worst design choice in C language, it would be the comma operator. I mean, the semicolon should do the same, and the for-statement should be redesigned.
@Gunbudder
@Gunbudder 7 жыл бұрын
Yeah, when we ran into the comma operator as a bug it blew our minds. i couldn't believe it was an intentional part of the language. GOTO gets a bad reputation, but the comma operator is the nastiest hack by far. great for obfuscation though, haha
@phildem414
@phildem414 2 жыл бұрын
So evil and so good at the same time 😈
@ashleybyrd2015
@ashleybyrd2015 3 жыл бұрын
Holy fuck I love this so much
@altairbueno5637
@altairbueno5637 3 жыл бұрын
Not sure if I should like or dislike this video
@ianpan0102
@ianpan0102 4 жыл бұрын
Not sure if you've mentioned this before in your livestreams, but I'm curious to know why the fonts seem to be changing a lot (sometimes narrower, and sometimes flatter, and sometimes -- even a different font style?).
@Bisqwit
@Bisqwit 4 жыл бұрын
I just do that.
@ianpan0102
@ianpan0102 4 жыл бұрын
@@Bisqwit oh okay haha
@KumailAhmed
@KumailAhmed 7 жыл бұрын
You are awesome!!
@POGOLAUNCHER
@POGOLAUNCHER 7 жыл бұрын
What font is that editor using?
@Bisqwit
@Bisqwit 7 жыл бұрын
Default VGA font, hardware-supplied (or in this case, emulator supplied because I am running DOSBox in the video).
@POGOLAUNCHER
@POGOLAUNCHER 7 жыл бұрын
Bisqwit Thanks for your reply. I'll go and find the default font or a replica for my editors.
@unebonnevie
@unebonnevie 6 жыл бұрын
what editor were you using? I really like it!
@ewncilo
@ewncilo 4 жыл бұрын
please do more😀
@Quasarbooster
@Quasarbooster 7 жыл бұрын
Coming from a Python background, everything made sense until the "custom character pointers". Would somebody kindly explain how that specific part of the code would translate into Python?
@Bisqwit
@Bisqwit 7 жыл бұрын
It is basically a substring that starts from the middle of the other string. But being a pointer, it owns no data nor clones it, just points to it. In Python, you would do that (without the sharing) with e.g.: s = "something" s2 = s[4:] print s, s2 The equivalent in C is: const char* s = "something"; const char* s2 = s + 4; printf("%s %s ", s, s2); Here, s2 is the "custom" character pointer (as opposed to one defined by the compiler by assigning it the start-address of a string constant). But the equivalescene in Python breaks if you try to make changes to s2. In Python, if you do that, changes to s2 will not be reflected in s. In C, changing the data pointed by s2 will also change data pointed by s, as long as they point to (sections of) the same data anyway. In this video though, data is not changed. And in fact, changing the contents of a string _constant_ would be undefined behavior.
@Quasarbooster
@Quasarbooster 7 жыл бұрын
Bisqwit thank you so much for the assistance. That all makes sense. I just have two questions now: 1. Wouldn't printing w+25 output "Good %s! ..." but also the other greetings too? How do those get removed? 2. I see that w[tm_hour] would get either "A" , "#", "+", "/", or "9". What do those pointers actually do? (And also, what is the "\0" doing in between the greetings?)
@Bisqwit
@Bisqwit 7 жыл бұрын
1) That’s what the \0 is there for. Printf and other C language string functions do not really know the length of any string, because a “string” is really just a pointer to (numeric address of) the start of some memory area that ostensibly contains characters. Instead, they just read forward as long as needed until they hit the first \0, and then they stop. Anything in the memory that follows \0 will be completely ignored, because it might just as well e.g. be some completely other type of data. 2) I think my answer also covers this question.
@Quasarbooster
@Quasarbooster 7 жыл бұрын
Bisqwit oh I get it now! Thanks for explaining all that
@T33K3SS3LCH3N
@T33K3SS3LCH3N 3 жыл бұрын
It blew my mind that the format string argument of printf can just be a pointer into the same char array as the subsequent arguments that get inserted into it. It should be obvious since C "strings" are just char pointers, but I never even considered that possibility. Must have gotten too used to languages like C# where strings are seperate types and the compiler checks the argument list of "interpolated strings" beforehand.
@Bisqwit
@Bisqwit 3 жыл бұрын
Yeah, C strings are just char pointers. Very, very, dumb and rudimentary.
@AKheon
@AKheon 8 жыл бұрын
It's an own kind of art form alright.
@Kaleidoscope-Illya
@Kaleidoscope-Illya 5 жыл бұрын
My head exploded.
@fredconcklin1094
@fredconcklin1094 2 жыл бұрын
Kabbalahtron vaht is Caesars code correctors?
@gowthamanv8740
@gowthamanv8740 5 жыл бұрын
Hey, someone help me, which resources is good to learn obfuscated c code. I searched all sites in the internet. I couldn't find any good resources. How do I start exploring code obfuscation. Please do reply.
@Inevitablerizzler
@Inevitablerizzler 6 жыл бұрын
Why did you change the thumbnail ? I think the first one was pretty good.
@Bisqwit
@Bisqwit 6 жыл бұрын
It was not very legible at small sizes.
@SteelHorseRider74
@SteelHorseRider74 5 жыл бұрын
I feel obfuscated now... o_O .... X-P
@FredM80
@FredM80 8 жыл бұрын
I really like these kind of videos explaining programming concept while code is quickly appearing. Which tool do you use to store all the inputs you type and replay it faster to make it as a video ?
@Bisqwit
@Bisqwit 8 жыл бұрын
+Fred M This tool: bisqwit.iki.fi/source/inputter.html
@FredM80
@FredM80 8 жыл бұрын
+Bisqwit Thank you :)
@huyvole9724
@huyvole9724 6 жыл бұрын
My god!!! Your weather -9.5C!! So cold
@anon89461
@anon89461 3 жыл бұрын
NICE
@Akimb321
@Akimb321 5 жыл бұрын
No horror movie can compete with this lol
@sznio
@sznio 8 жыл бұрын
If you want to obfuscate not the source but the assembly output, movfuscator is the best. It's a C compiler that compiles code into only mov statements. Because x86 is so bloated that mov is Turing complete.
@Bisqwit
@Bisqwit 8 жыл бұрын
+Dawid Pietrzak (ca1ek) Without looking it up, I presume it uses self-modifying code? I.e. it "mov"s into its own instruction space, replacing instructions to be executed. Otherwise I cannot see how it could possibly do e.g. unbounded loops.
@Bisqwit
@Bisqwit 7 жыл бұрын
I stand corrected. Looks like it does not do self-modifying code. Impressive. For an explanation, see this: kzfaq.info/get/bejne/iJ11eNKIzJypm58.html To be fair, this hardly qualifies as a statement of the condition of x86. With look-up tables and stuff (that movfuscator uses), the same could be done on ARM thumb code. Maybe even on 6502...
@alexistrinon4402
@alexistrinon4402 Жыл бұрын
I don't fully understand the part when you replace numbers by ASCII characters, the ASCII value of A is 65, so why did it return 4?
@Bisqwit
@Bisqwit Жыл бұрын
If you take the character value '4' and subtract the character value '0' from it, the result is the integer value 4. This holds true for all decimal digits. It similarly also works for alphabet, and gives the character distance (e.g. 'E' - 'C' = 2).
@alexistrinon4402
@alexistrinon4402 Жыл бұрын
Oh yes I understand now, I had just forgotten that there is no more table of numbers! Thank you for your response
@fataljulio
@fataljulio 8 жыл бұрын
i didnt understand the custom character pointer nor the last optimization to printf do you know of a good place i can learn that? :S
@Bisqwit
@Bisqwit 8 жыл бұрын
+juliocrivera Here are the clues necessary to piece the idea together: char*s = "abcdefgh"; printf(s+5); // Prints "fgh" char t = 5; char*s = "abcdefgh"; printf(s+t); // Still prints "fgh" char*s= "\5bcdefgh"; char t = *s; // Gets '\5', which is the same as 5 //char t = s[0]; // Same as above printf(s+t); // Still prints "fgh", because t is 5 char*s = "abcdefgh\0ijklmn"; printf(s+5); // Still prints "fgh", because printf stops reading string when it encounters \0.
@fataljulio
@fataljulio 8 жыл бұрын
+Bisqwit Oh Wow, thank you very much! that was super easy to understand haha
@fataljulio
@fataljulio 8 жыл бұрын
+Bisqwit Btw if you are so kind again how do the custom characters work? i mean the part Where it says AAA### I understood the numbers but not that
@Bisqwit
@Bisqwit 8 жыл бұрын
+juliocrivera Maybe this helps? upload.wikimedia.org/wikipedia/commons/thumb/1/1b/ASCII-Table-wide.svg/2000px-ASCII-Table-wide.svg.png 'A' is 65, '#' is 35, and so on.
@fataljulio
@fataljulio 8 жыл бұрын
+Bisqwit ah haha duh, thanks
@peppidesu
@peppidesu 4 жыл бұрын
you can also make things branchless if you really want to make people curse
@jacknapier8150
@jacknapier8150 5 жыл бұрын
what editor are you using?
@poetranoegraha6641
@poetranoegraha6641 7 жыл бұрын
awesome, subbed ;)
@DevinDTV
@DevinDTV 5 жыл бұрын
the one step i really didn't follow was how the string of numbers is used like the array was. there was a "- '0'" in there but I couldn't figure out what that did. i understand the concept but not the execution
@hawariam
@hawariam 5 жыл бұрын
In C, string is just a array of characters, so you can access it as a char array. For the " - '0' " part, it is used as an offset because character '4' is not equal to integer 4
@DevinDTV
@DevinDTV 5 жыл бұрын
@@hawariam ah i get it now, thanks
@magnusphilosophus506
@magnusphilosophus506 3 жыл бұрын
I am begginer c programmer, why I am here?
@informant09
@informant09 8 жыл бұрын
Are you planning to do more on this topic? :-)
@Bisqwit
@Bisqwit 8 жыл бұрын
I'm neither planning to make nor planning to not make. Though in retrospect I understand there's plenty I forgot to cover in this video. In this video I only dealt with code compaction, which is just one of obfuscation techniques.
@ScibbieGames
@ScibbieGames 5 жыл бұрын
There's always a creepy vibe to these videos.
@user-vn7ce5ig1z
@user-vn7ce5ig1z 5 жыл бұрын
The most confusing thing about this is that you consider 4am to be morning. 😕
@Bisqwit
@Bisqwit 5 жыл бұрын
I was a bus driver. In the regional traffic 3.30 am is when the day changes. Before that it's good night, after that it's good morning.
@Mike-gs7eo
@Mike-gs7eo 8 жыл бұрын
great video bisqwit, have you ever submitted an entry to ioccc?
@Bisqwit
@Bisqwit 8 жыл бұрын
+Mike Scott I can't honestly remember whether I have submitted to IOCCC or not. If I have, it was not recently. And even if I did submit, I did not win.
@aaronvr_
@aaronvr_ 4 жыл бұрын
bisqwit, the voice behind Stephen Hawking
@nikhilsrajan
@nikhilsrajan 4 жыл бұрын
you changed "- '0'" to "& 7"... That was one devil move. wow.
@nikhilsrajan
@nikhilsrajan 4 жыл бұрын
no, it gets more sinister later
@Bisqwit
@Bisqwit 4 жыл бұрын
It works because the digits 0…7 in ASCII are 00110000…00110111. In other words, only the lowest three bits matter. And I only needed to deal with numbers 0…4. Had this not been the case, I could have chosen a different representation for my numbers.
@Richard-xh5iw
@Richard-xh5iw 5 жыл бұрын
Hi how are you, I hope very well. go to the point, would you please tell me what recommendation you would give me to use a graphic libraries to make windows simple and at the same time somewhat complex, and not so much dedicated to the programming of games. only more for complex programs and not for games, well something dedicated to games but not so much in that. c ++ study
@Bisqwit
@Bisqwit 5 жыл бұрын
“to use a graphic libraries to make windows simple […], and not so much dedicated to the programming of games” Sorry, but I am having trouble parsing your comment. I think you are asking about a graphics library for making GUI applications. I think you might like wxWidgets. www.wxwidgets.org/downloads/ If you need a graphics rendering library, try SDL libsdl.org/ or SFML www.sfml-dev.org/ .
@zezkai7887
@zezkai7887 6 жыл бұрын
You don't need int main() Just use main()
@Bisqwit
@Bisqwit 6 жыл бұрын
That’s true, and you could also remove the “return” statement, but doing these generates eyesore compiler warnings.
@alfaalfa99
@alfaalfa99 3 жыл бұрын
It's like spaghetti code using LabVIEW.
@tweedle634
@tweedle634 7 жыл бұрын
not trying to be rude. from your videos it's my understanding you drive a bus and use sub par equipment, and all i can ask is WHY????????? your a genius A LEGIT genius you have mastered your craft to an extent not many people will ever reach, why not make 100k+ a year from it? Just a curious question from a money hungry engineering student who already has a business degree.
@Bisqwit
@Bisqwit 7 жыл бұрын
“not trying to be rude”, says the person with “FUCK OFF” as their name. You can’t eat money, nor can you keep any money with you when you die. You only need a certain amount in your life. People who see money (or power) as the ultimate pursuit in life are the cause of most of the world’s problems. That being said, there are more recent comments by me as for my employment status that you haven’t probably read.
@tweedle634
@tweedle634 7 жыл бұрын
thanks for responding, lots of respect to you, you're an inspiration
@Bisqwit
@Bisqwit 7 жыл бұрын
I kept thinking whether saying “you can’t eat money” was a mistake from my part since I lost my train of thought behind that particular sentence, but now I found this. i.imgur.com/lF3kUe8.png
@pchandu1995
@pchandu1995 8 жыл бұрын
can you make video on building a compiler/parser that can parse normal code into a artistic code ?
@Bisqwit
@Bisqwit 8 жыл бұрын
What would this artistic code be like in your opinion? How do you suppose the compiler/parser would define art?
@pchandu1995
@pchandu1995 8 жыл бұрын
will i asked a stupid question? to you about building a software that can just a make normal code to a obfuscated code , similar to bison, "you're the best programmer i ever seen you're skills are awesome".
@Bisqwit
@Bisqwit 8 жыл бұрын
You asked about a program that generates _artistic code_. Art is subjective. It depends on human psychology. I hoped that you would clarify your views on what would qualify as “artistic code” when generated by a computer program. If you meant to say “obfuscated code”, that is much easier. For Javascript language, you can find dozens of Javascript obfuscaters in the Internet by a simple search. For C++ it’s a bit more difficult than for Javascript, mostly because there is no eval(), but some similar approaches work, such as reducing all user-defined symbols to their minimal length, removing all whitespace, removing parenthesis were not necessary, and finally using #defines to compress identical subsequences of parser tokens.
@jozo035
@jozo035 8 жыл бұрын
Cool.
@wes8190
@wes8190 2 жыл бұрын
Ironically, I think most programmers could still infer what the program does by the words that stick out lol
Creating a DCPU-16 emulator in C++11
35:27
Bisqwit
Рет қаралды 53 М.
Zombie Boy Saved My Life 💚
00:29
Alan Chikin Chow
Рет қаралды 20 МЛН
طردت النملة من المنزل😡 ماذا فعل؟🥲
00:25
Cool Tool SHORTS Arabic
Рет қаралды 16 МЛН
Kind Waiter's Gesture to Homeless Boy #shorts
00:32
I migliori trucchetti di Fabiosa
Рет қаралды 14 МЛН
What are EXE files made of?
11:00
Bisqwit
Рет қаралды 145 М.
why do header files even exist?
10:53
Low Level Learning
Рет қаралды 394 М.
I wrote a Raytracer for DOS, 16 VGA colors
15:00
Bisqwit
Рет қаралды 895 М.
Which editor/IDE does Bisqwit use? Answers & some history.
14:23
ASMR Programming - Spinning Cube - No Talking
20:45
Servet Gulnaroglu
Рет қаралды 3,8 МЛН
Forbidden C++
33:07
javidx9
Рет қаралды 1 МЛН
25 nooby Python habits you need to ditch
9:12
mCoding
Рет қаралды 1,7 МЛН
Comparing C to machine language
10:02
Ben Eater
Рет қаралды 5 МЛН
Creating a Chip8 interpreter/emulator in C++14
10:51
Bisqwit
Рет қаралды 111 М.
Zombie Boy Saved My Life 💚
00:29
Alan Chikin Chow
Рет қаралды 20 МЛН