27일차

27일차

홈으로 돌아가기

웹의 취약점
로그인 부분의 무차별 대입공격
CSRF 요청변조
XSS 게시판에 HTML 코드 삽입
보통 서버는 80,443만 열려있다
예) hanatour.com naeiltour.co.kr
서버에 침투하는 방법은?

웹쉘 제작
웹에서 작동하는 악성코드 (php,asp,jsp,py..)

업로드 자동 공격 코드 만들기
192.168.0.127의 업로드 취약점은 어디인가?
http://192.168.0.127/board/board.cgi?j=form
본인의 이니셜로된 웹쉘 만들기
업로드된 파일 위치 기억하기
http://192.168.0.127/~board/cool/board.html?code=test
업로드 실패의 원인을 찾고 업로드 가능하도록 조치하시오


Attack.py에 업로드 자동 공격 코드 추가하기

SQL인젝션


update test ./test/hwg.php where name='hwg';

UPDATE test
SET user_file = './test/hwg.php'
WHERE name = 'hwg';

coolboard 파일 확장자 php만 막아둠 Php등으로 업로드 가능

board.cgi 

Line 1353

Line 1201
sub view {


}


$cig_url
$file_name
813
2616
sub upload_file {
   .txt
   .txt
}

업로드 위치 
img src="./id/test/files/3.jpg" 
alt="다운받으시려면 그림 위에서 마우스 오른쪽 버튼을 누르신뒤 다른이름으로 그림저장(익스플로러).. 
Save Images As(넷스케이프)를 선택하세요..."

719 
down_file {

}

http://192.168.0.127/spboard/board.cgi?id=test&page=1&action=view&number=4.cgi&img=ok

spboard 는 업로드의 저장위치를 숨겨놓음
파일 업로드는 가능하지만 파일의 실행위치를 파악하지 못함
링크 클릭시 파일 실행은 되지 않음
파일의 실제 저장 위치를 파악하는게 중요함 > 사진을 업로드하여 위치를 파악할 수 있음
또는 동일한 소스 코드를 다운받아 소스 분석시 파일 저장 위치 파악 가능함
> 사진에 대한 조치가 없기때문에 사진은 절대경로로 올라감

대표적인 오픈소스 게시판
제로보드 > xpressEngine 
xpress 설치법 https://www.xpressengine.com/guide/getting-started/installation
그누보드 > 그누보드
그누보드 설치법 https://sir.kr/manual/g5
워드프레스 > 킴스보드

보드 전용 리눅스

create database sir;
create user sir@localhost identified by '123456';
grant all on sir.* to sir@localhost;
flush privileges;

create user sir@192.168.0.104 identified by '123456';
grant all on sir.* to sir@192.168.0.104;
flush privileges;

그누보드
https://sir.kr/manual/g5 (그누보드 설치법)

파일명 암호화
$upload[$i]['file'] =md5(sha1($_SERVER['REMOTE_ADDR'])).'_'.substr($shuffle,0,8).'_'.replace_filename($filename);
파일명 치환
lib -> common.lib.php
function replace_filename($name)