Drop broken and deprecated vmware-detect
authorMichael Prokop <mika@grml.org>
Fri, 1 Sep 2023 11:20:55 +0000 (13:20 +0200)
committerMichael Prokop <mika@grml.org>
Fri, 1 Sep 2023 11:20:55 +0000 (13:20 +0200)
It was reported that this tool no longer works as expected,
though virt-what and systemd-detect-virt exist nowadays.

Thanks: AndrĂ¡s Korn

compile/.gitignore
compile/Makefile
compile/vmware-detect.c [deleted file]
debian/overrides
debian/rules

index 5f8d282..c6f80a9 100644 (file)
@@ -1,4 +1,3 @@
 align
 dpkg_not_running
-vmware-detect
 grml-runtty
index a5d42c3..964ae3c 100644 (file)
@@ -1,4 +1,4 @@
-PROGS = vmware-detect dpkg_not_running grml-runtty
+PROGS = dpkg_not_running grml-runtty
 
 #ifndef CFLAGS
 CFLAGS = -O2 -Wall -s
@@ -14,9 +14,6 @@ CC = gcc
 
 all: $(PROGS)
 
-vmware-detect: vmware-detect.c
-       diet $(CC) $(CFLAGS) -o $@ $^
-
 dpkg_not_running: dpkg_not_running.c
        diet $(CC) $(CFLAGS) -o $@ $^
 
diff --git a/compile/vmware-detect.c b/compile/vmware-detect.c
deleted file mode 100644 (file)
index c99e36f..0000000
+++ /dev/null
@@ -1,143 +0,0 @@
-/* Filename:      vmware-detect.c
-*  Purpose:       Detect if running inside vmware
-*  Authors:       grml-team (grml.org), (c) Michael Gebetsroither <gebi@grml.org>
-*  Bug-Reports:   see http://grml.org/bugs/
-*  License:       This file is licensed under the GPL v2.
-*******************************************************************************/
-// return 0 if running inside vmware, 1 otherwise
-
-#include "string.h"
-#include "unistd.h"
-#include "stdio.h"
-#include "stdlib.h"
-#include "signal.h"
-
-#define WRITE(x) write(1, x, strlen(x))
-#define DWRITE(x) do{ \
-    if(debug) { \
-        WRITE(x); \
-    } \
-} while(0);
-#define FALSE 0
-#define TRUE !FALSE
-
-/* doc:
- * vmware IO backdoor: http://chitchat.at.infoseek.co.jp/vmware/backdoor.html
- * http://www.honeynet.org/papers/bots/botnet-code.html
- * http://www.codegurus.be/codegurus/Programming/virtualpc&vmware_en.htm
- */
-
-// from libowfat {{{
-static inline char tohex(char c) {
-  return c>=10?c-10+'a':c+'0';
-}
-
-unsigned int fmt_xlong(char *dest,unsigned long i) {
-  register unsigned long len,tmp;
-  /* first count the number of bytes needed */
-  for (len=1, tmp=i; tmp>15; ++len) tmp>>=4;
-  if (dest)
-    for (tmp=i, dest+=len; ; ) {
-      *--dest = tohex(tmp&15);
-      if (!(tmp>>=4)) break;
-    }
-  return len;
-}
-// }}}
-
-void printIdtr(const unsigned char* idtr, unsigned size)
-{
-    unsigned i;
-    for(i=0; i<size; ++i) {
-        char out[4] = {0};
-        fmt_xlong(out, idtr[i]);
-        if(strlen(out) == 1)
-            WRITE("0");
-        WRITE(out);
-    }
-    WRITE("\n");
-}
-
-// i386 and x86-64 {{{
-#if defined (__i386__) || defined (__x86_64__)
-int checkVmware(const int debug)
-{
-    unsigned char idtr[10] = {0};
-    asm("sidt %0" : "=m" (idtr));
-    if(debug)
-        printIdtr(idtr, sizeof(idtr));
-    // should normally be the case on amd64, but does not work
-    //return (0xff==idtr[9]) ? 1 : 0;
-    return (0xff==idtr[5]) ? 1 : 0;
-}
-int checkVmwareIO()
-{
-    unsigned int vmaj, vmin, magic, dout = 11;
-    __asm__ __volatile__(
-            "mov $0x564D5868, %%eax; /* magic number */"
-            "mov $0x3c6cf712, %%ebx; /* random number */"
-            "mov $0x0000000A, %%ecx; /* specifies command */"
-            "mov $0x5658, %%edx; /* VMware I/O port */"
-            "in %%dx, %%eax;"
-            "mov %%eax, %0;"
-            "mov %%ebx, %1;"
-            "mov %%ecx, %2;"
-            "mov %%edx, %3;"
-        : "=r"(vmaj), "=r"(magic), "=r"(vmin), "=r"(dout));
-#ifdef DEBUG
-    fprintf(stderr, "version: major=%x, minor=%x, magic=%x, dout=%x\n",
-            vmaj, vmin, magic, dout);
-#endif
-    return (0x564D5868 == magic) ? 1 : 0;
-}
-// }}}
-
-// others {{{
-#else
-// vmware runs only on the archs above
-int checkVmware(const int) { return 0; }
-int checkVmwareIO() { return 0; }
-#endif
-// }}}
-
-static int Killed = FALSE;
-
-// returns 0 if running inside vmware, 1 otherwise
-int main(int argc, char* argv[]) {
-    int debug = FALSE;
-    if(argc == 2 && !strcmp(argv[1], "--debug"))
-        debug = TRUE;
-
-    int a, b;
-    // known to be false positives
-    a = checkVmware(debug);
-    DWRITE("idt-check: ")
-    if(!a) {
-        DWRITE("false\n");
-        if(!debug)
-            return EXIT_FAILURE;
-    } else
-        DWRITE("true\n");
-
-    // never returns if not running under vmware
-    void dummy() { Killed=TRUE; DWRITE("false\n"); exit(1); }
-    signal(SIGSEGV, dummy);
-    DWRITE("ioport-check: ");
-    b = checkVmwareIO();
-    if(b) {
-        DWRITE("true\n");
-        return EXIT_SUCCESS;
-    } else {
-        if(!Killed) {
-            // check unusable or not implemented
-            DWRITE("false\n");
-            DWRITE("Check not implemented, yet!\n");
-            return a ? EXIT_SUCCESS : EXIT_FAILURE;
-        } else {
-            // never reached
-            WRITE("Error: IO check hasn't killed the program but no vmware found either!\n");
-            return EXIT_FAILURE;
-        }
-    }
-}
-// vim: foldmethod=marker
index 1785ad1..7ed3bef 100644 (file)
@@ -1,3 +1,2 @@
 grml-scripts: script-with-language-extension usr/bin/notifyd.py
-grml-scripts: statically-linked-binary usr/bin/vmware-detect
 grml-scripts: statically-linked-binary usr/sbin/dpkg_not_running
index b5632fe..d9bebef 100755 (executable)
@@ -39,7 +39,6 @@ install: build
        cp -a usr_bin/*         debian/grml-scripts/usr/bin/
        cp -a usr_sbin/*        debian/grml-scripts/usr/sbin/
        cp -a usr_share/*       debian/grml-scripts/usr/share/grml-scripts/
-       install -m 755 compile/vmware-detect          debian/grml-scripts/usr/bin/vmware-detect
        install -m 755 compile/dpkg_not_running       debian/grml-scripts/usr/sbin/dpkg_not_running
        install -m 755 compile/grml-runtty            debian/grml-scripts/sbin/grml-runtty
 
@@ -85,7 +84,7 @@ binary-arch: build install
                /usr/share/man/man1/grml-scripts.1.gz /usr/share/man/man1/pong.1.gz \
                /usr/share/man/man1/grml-scripts.1.gz /usr/share/man/man1/soundtest.1.gz \
                /usr/share/man/man1/grml-scripts.1.gz /usr/share/man/man1/unblacklist.1.gz \
-               /usr/share/man/man1/grml-scripts.1.gz /usr/share/man/man1/vmware-detect.1.gz
+
        dh_strip
        dh_compress
        mkdir -p $(CURDIR)/debian/grml-scripts/usr/share/lintian/overrides/