Ludovic Frank - Freelance developer

The hacker spirit or Joe the hacker...

ionicons-v5-k Ludovic Frank May 9, 2022
84 reads Level: Confirmed

Oh no, did he say hacker, like too dark, behind black screens and all?

Actually, no, in people's minds, a "hacker" is malicious and does some pretty uncool stuff, but actually, no.
Hackers are already divided into "white hats" and "black hats", the former being harmless, while the latter are not so nice.

This week, we're going to talk about the "hacker spirit". Of course, that's my own definition, and others will have other visions?

My definition of the hacker spirit

A hack is a "do-it-yourself" approach, a way of doing things that's a little out of the ordinary, not something that's completely framed or well thought-out beforehand. Imagine you've got a problem to solve, but you don't have 15 engineers on hand, you've only got yourself and your little head... and what's more, your time isn't infinite...

In that case, you're going to come up with some hacks?
How can I achieve my goals without the means?

From an architectural / code point of view, it's going to be DISGUSTING, but... it'll do the job! And sometimes, right from the start, a hack is clean. Yes, yes, I swear?

Most "side projects" are hacks. Basically, they're there to solve a problem you're having, but over time you realize that they can be of service to others, so you improve your initial tinkering to make something nice.

Basically, hacking is tinkering... and we LOVE it... the hacker spirit is the tinkering spirit.

Personally, I love it, because it's during these moments that I learn the most. During my teenage years, I wrote an enormous amount of code just to learn.

It's not impossible that the start of my entrepreneurial/freelance activity was due to a hack... after all, the hearsay, you know...?

Some of my "personal" hacks

Here, I'm going to get wet and describe some of the things I've tinkered with, either to learn or because I felt like it

A game server with pocket money ...

I must have been about 13 or 14 years old, everything was going well in the best of worlds, but I loved "Team Fortress 2". It was 2008 and the game had just come out, so I had some online friends to play with, but we didn't have a server!

At the time, there was VeryGame, but you had to pay for servers by the number of slots, and that quickly became pretty expensive, so it wasn't an option. I had a maximum budget of 10 euros / month for the server.

What could I do? Host the server on my crappy ADSL connection with a recovery machine in my room? With 15kb/s upload, it's going to be HOT!

OVH had just launched the "RPS", for "real personal server", the idea being that all the components were inside the machine except the hard disk...

So I took one for a test drive, and it didn't work too badly for hosting, but to host a server on the source engine (CSS engine, TF2 ... etc.), it wasn't crazy, and the time it took to load the map file was like 3 minutes... not viable in the long term.

So, should we give up? Or wait 4 minutes for the map to change?
As you can imagine, I WANTED to find a solution! There were no other options, not possible.

The hack to solve this problem has one word: TMPFS.

I made a small mount point of the "maps" folder of the game servers in RAM, with only a few maps in it (yes, I didn't have much RA% on these machines), the others remained on the machine's "hard disk".

Then, using "Metamod Source" and "SourceMod", I wrote two scripts:
The first allowed admins to request the RAM loading of a particular maps file. If, for example, during a game, you wanted to change maps, the admin could use this menu to request the ram loading of the desired maps file, which was just the "cp" command from the "source" file to the ramdisk (tmpfs). Once the transfer was complete, the admin would receive a notification in his chat saying "OK bro, the map change will be instant".
The second was a modification of an existing feature, the "votemap": 10 minutes before the end of the game, when the players had chosen what the next map would be, I simply copied it into the TMPFS.

It had its limits, of course, an admin making a wild map change and BIM a time out at the map change ... but hey. With not a penny to our name, we had a lot of fun on TF2 with a server that performed well.

Bonus: As I'm telling you this, I have another memory that comes to mind. I remember that on the servers that ran on source, there was a time when something was very annoying:
When a client typed a command in its client console, it would "freeze" the server process, and it would restart, WELL RELOU when on top of that it took 4 minutes to load your map...
You know how I fixed that. You're going to laugh, Hex Workshop, does that mean anything to you?

In fact, I opened the ".so" (I can't remember which one exactly) with a hexadecimal editor, searched for the command string, then edited it with another word that only I knew.

After that, when some smart aleck wanted to crash "Command not found", big shot method, but it works.

Understanding Win32 APIs, The Hook and in-memory patches

This was done with BestPig.

Wow, that's hardcore ... and the source code is still available on Github.

In fact, a patch written in Delphi (a language I loved at the time) for steam.dll was lying around on the Internet.

This patch modified the function that takes a game's "AppId" as an argument and responds "true" or "false". Now you know what this function was for.

One day I said to myself "yes, but physically patching the file isn't much fun, how about doing it in memory".

So I started writing this and, as you can see on the github, it was a bit of a DIY project. As a reminder, I was 16, so bear with me!

We injected a DLL into the process, our code looked for the function to patch and then replaced it "in memory", but that's not what's interesting here...

(By the way, if you want to understand more about loading libs on Windows, our friend Sh0ck has written a great article).

What I wanted to do was "full in memory".
The thing is, when you patch a DLL physically, it's reloaded by each new process (the games).

In my case, it was forbidden to touch the original .dll, so once the game process was launched, it loaded the original DLL (on disk) with the original function... It doesn't work well...

How do you fix it ?
Actually, it's easy: when Steam launches a game, it uses the CreateProcessA function in Kernel32.dll ...

You've got it? Windows APIs? They're just DLLs too ... except that they're at "system level".

In fact, in Windows there were CreateProcessA and CreateProcesW, the difference between the two being the encoding of the strings to be sent... So imagine what I've done...

If "I overwrite CreateProcessA in memory", that means I no longer have access to it (since it's now my function), but I still have access to CreateProcessW.

In fact, my patched "CreateProcessA" function converted strings and called CreateProcessW while retrieving its response before giving it back to Steam. Steam, which gave me privileged access to the newly created process... from there I injected my code, which took care of patching the functions needed in this process (the game).

The method was completely ugly ... but it worked and, above all, the only thing that mattered to me at that moment was that I had understood how the OS launches processes. and "what's a process? "

Proof that it was great? I'm telling you about it from memory 14 years later (and I'm enjoying it too, because today this code is completely obsolete). I haven't done any research, preferring to go by "what I remember".

Final word on these baby hacks

The two hacks presented here never made me a single cent, in fact, they made me lose money, but that doesn't matter, I took the head and I learned a lot ... ?

Hacks become big projects

Well, well, well, that's enough about my own projects, now it's time to talk about the projects that weren't really that big ... then ...

The Linux kernel

Today, the Linux kernel is everywhere, ¾ of the websites you visit run on a server that uses this kernel, when you use an Android phone, you're using Linux. Even if it's not directly visible to the general public, it's everywhere.

In fact, Linux was originally just a hobby, a do-it-yourself project. In fact, Torvalds couldn't afford Unix, so he created his own (in the very early days).So he created his own (at the very beginning, the idea was to call it "Freax").

In his announcement e-mail, he says that it's not as big and professional as GNU, and that his software will probably never support anything other than hardware similar to his own.

It's quite amusing to know that today, when you see what Linux has become, and yet it wasn't all that professional in the first place... ?

VLC

You're bound to know this one, you know, the player that can play your completely rotten video files. Nobody knows how it does it, but only HIM can play files that are completely shattered on the ground...

The world's most famous traffic cone was born in Châtenay-Malabry...

You need a good network to play Doom...

The students at Ecole Centrale Paris wanted to be able to play Doom in peace and quiet, because in life, there are goals, and you can't screw them up!

So they asked their schools for "a new network", "it's for work, you understand? "But the school says "we can't, we're not in charge of the campus...", so there you go... no network and that's it...

Do you seriously believe that geeks are going to let themselves be taken for a ride? No.
To cut a long story short, the students say to themselves "we'll go and see some companies to finance all this", and they end up going to see the people at TF1, because they're starting to get interested in satellite TV (who's still using satellite TV in 2022???).

So they were told something like (I don't know, I wasn't there!): if you can broadcast video on the network, then we'll fund your network...
And so began the VideoLAN project.

A few years later, they made a 30-second video demo, and it worked (well, legend has it that it "crashed" after 40 seconds, so things are really well done, aren't they?)

For the rest, from VideoLAN to VLC, I leave you to watch this video

All this to say that VLC was originally designed for students who wanted to play video games?

Bitcoin

We're not going to talk about the course here, we don't care, we're just going to talk about the tech that enables the exchange of value over P2P without a "trusted third party".

Whether you love Bitcoin or hate it, today, everyone has heard the word at least once, I mean, even my 85-year-old great aunt said to me "Ludo, what's Bitcoin?"

Behind Bitcoin, there's no big company, no big groups, just one guy by himself or a group of guys, we don't know.

The guy or guys had an idea, they wrote a program, a "white paper" of why it exists and what problem it solves.
He worked on developing it for a few years, then disappeared...

Whatever we say in 2022, Bitcoin is making a lot of ink flow, and, I'm convinced, this is just the beginning!

KODI

Formerly XMBC (for Xbox Media Center), KODI is basically a homebrew for the first XBOX.

The software was born out of the "console hack" scene, enabling the console to be transformed into a multimedia player. It has since evolved and is now available on a whole host of platforms, including Apple TV (although this is a very closed platform).

A final word on these projects

I haven't included the whole story for each of these projects here, for a very simple reason: each of these projects (and many others) would deserve an entire article (or even several).
If you find one project more intriguing than the others, don't hesitate to check out its story?

A word to all DIY enthusiasts

If you've made it this far, it's because you understand what I'm talking about. Maybe you're a DIY enthusiast yourself, either in your spare time or to solve a little problem?

Well then! Go on, I sincerely believe that it's all these little initiatives, all these little tinkerings, all these little feedbacks that make the world of computing so great?

The little project you tinker with on a rainy Sunday afternoon that allows you to have fun, help your friends or even help more people, that's great?

Conclusion

I've come to the end of my little article, the aim of which was to introduce you to the world of "little hacks".
which, in my opinion, represent an entire chapter in the history of computing and the Internet.

By the way, where did the Internet and HTTP come from in the first place?

418, I'm a teapot...

Have a great week.
See you next week?