1

I am making a program in Kali Linux, and I want to make it work only in Kali. I can use C to do it, just like :

#if defined(_WIN32) || defined(_WIN64)
   #define os_platform THISisWINDOWS

For checking if the OS of the user is windows and later in the script checking the defined variable os_platform, but I searched Google and everywhere, but I just can't find the macro for Kali Linux. If I do :

#if defined(__linux__)
   #define os_platform THISisLINUX

It can be any type of Linux, like Ubuntu, and Linuxes like those. What is the macro for Kali Linux?

ivan_pozdeev
  • 33,874
  • 19
  • 107
  • 152
  • 2
    Just because I feel curious today : why? – schaiba Dec 15 '17 at 09:33
  • Since different Linux installations (from similar release time) are (often) binary compatible, especially inside distribution families, doing this as a compile time check with `#ifdef` is probably not a good approach. Why would a binary be compiled differently on Kali than on Ubuntu or plain Debian, when it can then run on all of them? – hyde Dec 21 '17 at 08:29

2 Answers2

2

There's no macro for distributions. You can only do a "sniff test" to see what distribution it is by looking in /etc for particular files, and even then it can be faked.

The reason the macros exist in the first place is because Linux is radically different from BSD and Windows, so it's a necessary distinction. The difference between Kali and Debian is pretty subjective, Kali is based on Debian. Most Linux distributions are actually quite similar as far as compilers are concerned because they all use the same kernel and headers.

Things like /etc/redhat-release are distribution specific, so look for something like that. This can't be tested as an #ifdef though, it's something you'll need to put in your configure script.

tadman
  • 208,517
  • 23
  • 234
  • 262
  • Thanks! Never thought about that. I was way too in macros... I would just have to see if /etc/shadow/ exists! –  Dec 15 '17 at 00:03
  • 3
    Think about restricting your app in terms of features you need, or libraries you must have, not a distribution you're forcing. Maybe Kali forks some day and although it's 99.9% the same you're rejecting compilation because the name is different. Check for dependencies, and if they're met, no reason you can't at least try and compile it. – tadman Dec 15 '17 at 17:16
0

Probably You can check /etc/issue file for particular distribution Name and then using file pointers extract the exact name & then Compare If it's a Ubuntu or Kali or any other Linux Machine.

C0deDaedalus
  • 361
  • 1
  • 4
  • 19