1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Crypt MD5 on KLD

Discussion in 'FreeBSD Development' started by victormenegusso, Nov 19, 2011.

  1. victormenegusso

    victormenegusso New Member

    Messages:
    9
    Likes Received:
    0
    Hello everybody, I create a new syscall follow the examples.
    http://www.hailang.me/index.php/tech/freebsd/freebsd-kernel-rootkit-design-howtos-%E2%80%93-3-system-call-first-kernel-service-application/

    The syscall works fine, but I need to use a function to crypt some characters.
    I found http://www.freebsd.org/cgi/man.cgi?query=crypt&sektion=3&apropos=0&manpath=FreeBSD+8.2-RELEASE:
    Code:
    char *crypt(const char *key, const char *salt);
    I can use the "crypt" in user space, but in syscall I can't compile.
    example
    Code:
    #include <stdio.h>
    #include <string.h>
    #include <unistd.h>
    #include <crypt.h>
    
    int
    main(void)
    {
    /* Hashed form of "GNU libc manual". */
    const char *const pass = "$1$J5yALG57$";
    
    char *result;
    int ok;
    
    /* Read in the user's password and encrypt it,
      passing the expected password in as the salt. */
    result = crypt(getpass("Password:"), pass);
    
    /* Test the result. */
    printf("%s\n",result);
    ok = strcmp (result, pass) == 0;
    
    puts(ok ? "Access granted." : "Access denied.");
    return ok ? 0 : 1;
    }
    cc teste.c -lcrypt

    On KLD how to crypt some string to MD5?
    Thanks