crypt 를 사용한 암호화 도움부탁드립니다.

익명 사용자의 이미지

안녕하십니까? 저는 요즘 보안에 관심이 많은데요..
보안툴중에서 패스워드 크랙하는 프로그램들 많이 있잖아요. 이런 프로그램들 대부분 이 임의의 단어를 암호화해서
그 암호환 결과가 /etc/shadow 에 두번 째 필드에 있는
암호랑 글씨모양이 같으면 그 임의의 단어를 패스워드로 추정하게끔 작성이 되어 있잖아요..

대표적인 프로그램이 c로 작성한 john the Ripper 라든가, perl 로 작성한 xcrack 라든가??

저의 의문의 출발점은 어차피 c로 작성한다면, 파일 입출력함수와 암호화 함수를 잘만 사용하면, 초보적인 패스워드 크랙 프로그램 만들 수 있겠구나 라고 생각했습니다. 근데 생각처럼 쉽지가 않더라구요.

gun c library 에서 대충 소스는 구했는데
에러만 나고 잘 되지 않네요..

인용해보겠습니다.

---------------------------------------------
The next program shows how to verify a password. It prompts the user for a password and prints "Access granted." if the user types GNU libc manual.

#include
#include
#include
#include

int
main(void)
{
/* Hashed form of "GNU libc manual". */
const char *const pass = "$1$/iSaq7rB$EoUw5jJPPvAPECNaaWzMK/";

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. */
ok = strcmp (result, pass) == 0;

puts(ok ? "Access granted." "Access denied.");
return ok ? 0 1;
}

--------------------------------------------
참고로 저는 레드햇 7.2 를 사용하고 있습니다.

컴파일하면 이런 에러가 납니다. 제가 이제 c/c++ 기본문법만 마스터 한 상태라 힘이 드네요

[root@abc root]# cc -o test3 test3.c
/tmp/cchYVBjJ.o In function `main'
/tmp/cchYVBjJ.o(.text+0x24) undefined reference to `crypt'
collect2 ld returned 1 exit status

이런 에러 메시지가 뜨는데요..

어떻게 해야 되는건지.. 제가 전반적인 gcc 환경이나
함수라이브러리를 몰라서 그런것 같기두 하고요..

도움 부탁드립니다.

익명 사용자의 이미지

Sun OS에서는 별 무리 없이 컴파일이 되는군요...warnning이 하나
발생하긴 하지만 실행도 잘 되구요. 그런데

result = crypt(getpass("Password"), pass);

저 부분에서

result = crypt((char *)getpass("Password"), pass);

라고 캐스팅을 하니 warnning도 없이 잘 컴파일 됩니다.
참고하세요.

익명 사용자의 이미지

-lcrypt 옵션을 주고 link 해보세요.

익명 사용자의 이미지


답변에 감사드리면서,, 제가 기초가 얼마나 부족한지 알게 되었습니다.

gcc 환경을 모르고 하려니 힘이 들었네요..

감사합니다.

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.