Learning FreeBSD

I have a general question. I would like to learn about these:

. internals of FreeBSD - the kernel, design, administration; etc
. programming - writing drivers, fixing things, writing C based applications; etc.
. security - the security features available, i would like to contribute as well, like scurity review, fixing; etc

I going through the handbook, currently.

Please suggest links, videos, blogs, books or anything I should look into.
 
. internals of FreeBSD - the kernel, design, administration; etc
"The design and implementation of the FreeBSD operating system". There's a first edition that's a little old, get the second edition. (it seems there's a third edition now too, if there is get that one).
 
If you can afford to buy multiple books, follow "The [ordered] Roadmap". Otherwise, start with following materials. Official books/articles are free!

1. RTFM (man 1-9) + studying /src + /ports
2. STFW
3. FreeBSD official books/article
4. grymoire.com
5. The C Programming Language 2nd by K&R
6. The Design and Implementation of the FreeBSD Operating system 2nd by McKusick

>>> The [ordered] Roadmap <<<

I. RTFM:
* man(1-9)
* pulled /src and /ports

I. STFW:
* site:forums.freebsd.org
* site:lists.freebsd.org
* site:bugs.freebsd.org
* site:github.com/freebsd

I. 101
1. Official FreeBSD Book: FreeBSD Handbook
2. Official FreeBSD Book: Frequently Asked Questions for FreeBSD
3. Official FreeBSD Article: Frequently Asked Questions About The FreeBSD Mailing Lists

II. Shell/Admin:
1. Beginning Portable Shell Scripting by Seebach
2. Official FreeBSD Article: Practical rc.d scripting in BSD
3. Official FreeBSD Book: FreeBSD Porter's Handbook
4. Official FreeBSD Article: Writing FreeBSD Problem Reports

III. C:
1. The C Programming Language 2nd by K&R
2. C A Reference Manual 5th by Harbison
3. Expert C Programming by Linden

IV. Architecture:
1. Official FreeBSD Book: Architecture Handbook
2. Official FreeBSD Book: Developers' Handbook
3. The Design and Implementation of the FreeBSD Operating system 2nd by McKusick
4. Official FreeBSD Article: FreeBSD Release Engineering
5. Official FreeBSD Article: Committer's Guide

V. Advanced/Security:
1. TCP/IP Illustrated vol.1 by Stevens
2. Advanced Programming in the Unix Environment by Stevens
3. UNIX Network Programming vol.1 by Stevens
4. Applied Cryptography 2nd by Schneier
5. Hacking The Art of Exploitation 2nd by Erickson

[ VI. Nice extra stuff! ]
1. UNIX System Administration by Hein
2. Sed and Awk by Robbins
3. Introduction to Algorithm by Cormen
4. The Practice of Programming by Keringhan
5. Modern Operating systems by Tanenbaum
 
The book "FreeBSD device drivers for the intrepid", unfortunately, hasn't been updated in a while. Many examples won't compile (be warned). I think it is somewhere on github as pdf.

Last year I was thinking about making a Video series on the FreeBSD Kernel, or on how to write device drivers. I thought of this order:
Introduction.
How download the source code.
how to use kldload, kldunload, memstat -m.
write a hello world driver.
Compilation issues.
introduce sysctls.
Introduce Makros such as DEV_MODULE, DRIVER_MODULE and the likes.
dev entries and MAKE_DEVICE.
Kernel buffer.
... and so on..

In the end, it is not difficult. All you need is c. Imo even a script kiddy can be taught to write drivers.
 
thank you very much to all.

I think I have to add few more clarity.

The internals, programing and security, I want to learn that is specific to the FreeBSD world.

I have been programming C for many years and my specialization is into Cyber security. My area of working is into malware analysis, security code review, writing fuzzing tools, conducting penetration testing.
 
My area of working is into malware analysis, security code review, writing fuzzing tools, conducting penetration testing.
In that case:

* I suppose you're familiar with gdb, gcc, strace, ELF, etc. Also malware analysis implies you should know things about binary analysis too.
* There're many books; most of them useless -- nearly all books on this planet is useless! I won't waste time to read one of those. I rather spend time on Number Theory -- helpful in crypt* ... .
* There're few useful blogs, which I'm sure you're familiar with it.
* There's zero benefit from watching videos and nearly all infosec(cringe word BTW) security-related websites are click-baiting ^C/^V SEO operations!
* BUT fortunately, most of the BSD-related blogs/websites, e.g. FreeBSD, OpenBSD, etc. are not in that camp. vermaden often posts under "Valuable News" title. You can follow those links and discover new BSD-related blogs/websites. He's not a slouch, he know what he's doing.

* You didn't mention which platform you're familiar with, and you didn't mention C++ either, so I think you're a [former-]Linux user not a Windows one. To shape your expertise toward FreeBSD: learn about CLANG and lldb. I prefer GDB! There's also dtrace, and you have to know ins and outs of ELF too -- but I'm sure you're already there, malware analysis (quote: "your area of working") demands that. Learn about ZFS, jail, FS and boot/partition in the context of FreeBSD. Unlike OpenBSD, building a custom kernel is a thing here. Learn how to do that. You need VMM, learn how to use bhyve.
 
Last edited:
What vigole is talking about - it's stuff like taking advantage of memory leaks in C++ to escape detection by security/snort3 and security/oinkmaster, the math behind the cryptography schemes, implementation of GOST (Yes, that is available on FreeBSD).

The usefulness of debuggers is to load a binary in and see which subroutines it tries to call. For example, when a security researcher at Kaspersky Labs loaded the Stuxnet binary into a debugger, it was under a MB worth of compiled code, and it while it was obviously designed to spread from one machine to to another, it took a team of such researchers a few days to figure out what in the world the virus was targeting.

Benefits of learning jails and bhyve - that sets up either a honeypot or a controlled environment that the virus can run rampant in. If your rules can contain it, great. If not - that's a problem that requires attention from you and your customer.
 
oh, and pen(etration) testing... People who actually do that for a living would not recommend it as a career. People, (especially the ones actually calling the shots at the shop), get awfully pissed about having their own security flaws exposed, and will sooner get you in jail for digital trespassing (and possibly getting in the way of productivity at work) than actually fix the flaws you discover. Good luck trying to use a pen testing contract as a legal defense, even if someone from that shop actually gave you money for performing the testing. Your client (Unless it's the shop's president) risks being fired himself if his boss discovers that the disruption was a result of hiring someone to hack the network. It's a bit of a gamble to wait until things cool off before confessing that a pen test was conducted, and these are the conclusions / recommendations drawn from that test.
 
thank you very much vigole. The entire malware industry is very much happening in the windows world. So in that aspect, I am coming from Windows domain. In fact, I started programming from MS DOS 4.01. I am familiar with OllyDBg, IDA static analysis and reverse engineering.

I would not say I am a Linux person, we I used Linux only for penetration testing purpose. However, I very much like the idea of open source and complete control over the system that is running. Since more than malware analysis and penetration testing, I started using computers because I like programming. So I was always interested to see the source code of kernel and other software. I started using Linux from Red Hat 7. I tried using FreeBSD and OpenBSD but didn't actively follow that, most probably the complexity was setting up drivers for my dial-up modems. No virtualization on those days, to try up.

Now I am fully into FreeBSD because, I have been hearning alot on the rock solid thing and I really like the documentation. How many times I struggled in Linux world, for various reasons.

Now my idea is to learn how to look into the FreeBSD kernel, understand the FreeBSD internals (esp from working and administration perspective). If I can, then would like to create tools and do bug fixes.

and obviously since i am coming from security, i would to learn and contribute to security in FreeBSD.

And the most of the things you mentioned, I agree. I am not a Kali linux guy, who uses tools. I am more like a gentoo linux guy, who loves to compile and create things in C and assembly.

I hope i have made things clear.
 
I'm a proponent of the Empirical Paradigm, preferring to get my hands on it to to see what makes things happen as opposed to reading about it. Unless it's something I need to study first to grasp the concept of.

I never got past the part about Ken Thompson in the front of The OpenSolaris Bible before I had a box set up to work with. I had to reference it once or twice but had OpenInidana, OpenSolaris and Solaris SysV boxen. Not to mention a perfectly good copy of The OpenSolaris Bible I've never read.


I do have a Kali Linux 2021.2 box on metal. I have several FreeBSD laptops and found room for Kali on one of them. Especially since Kali has Firewalk, which is no longer available in the ports tree:

For reference purposes of my wallpaper only. :rolleyes:

Kali_the_Kutter.png
 
  • Thanks
Reactions: a6h
hardworkingnewbie : you might want to post screenshots, rather than use tags for embedded media... This was actually discussed in the Music Thread since Thursday:
 
In fact, I started programming from MS DOS 4.01. I am familiar with OllyDBg, IDA static analysis and reverse engineering.
Another one to try is devel/radare2. It is basically like a TUI version of OllyDbg. It works on Windows, Linux and FreeBSD. I actually made the original port a while back when the tool was a *lot* simpler.

It now also supports patching binaries (My favorite feature of OllyDbg) so you don't need to hack at the binary with a separate hex editor any more ;).

My main use for it is NOP'ing out DRM (mainly cracking Unity3D for Linux and BX Pro) but I am sure there are more legitimate uses too!

(There is also devel/ghidra but I find it overrated)
 
  • Thanks
Reactions: a6h
thank you all.

Yes, Ollydbg is a wonderful tool to use. I think the tool was long stopped in development. Esp, when it comes to binaries written for x64, the latest x32dbg and x64dbg are used widely. Still the same interface like Olly but with lot more functionalities. Like in-memory patching; etc. I am not sure if it is available in FreeBSD.

Thanks for DMFR grahamperrin. I shall look into this.

I have not used radare2, but most of the time I use IDA Free (earlier versions) and mostly get into dynamic analysis using debugger.

I am very much interested to learn FreeBSD (esp the kernel and userspace) from performance and security perspective. thank you everyone for the guidance.

Why not, I might build a FreeBSD based OS used for security engineers. Sorry, if this was too much :).
 
Why not, I might build a FreeBSD based OS used for security engineers.
Release script in section 7.1.1 is a good place to start.
 
After mastering release.sh you will want to add packages to your image. Skip ahead to our appliance builders.

Learning make.conf and src.conf and kernel slimming you can get some very small images.
Starting at 100 Megabytes for the most bare basic image.
 
Back
Top