[11] XSS, webgoat, DOM XSS, AJAX Security

|


- 2015.03.23

 


임시 강사 수업

 

 


1. XSS


1)  간단 Paros 기능


Paros - Tools - Filter
   Replace HTTP response body using defined pattern 클릭
   ... - Pattern : 김정은, Replace with : 돼지새끼

 


* Cross Site Scripting (XSS) : 게시글 등에 악성코드를 심어 클릭 시 클라이언트에게 피해를 주는 것

 

 

 

2) webgoat googlecode


webgoat googlecode 검색하여 webgoat zip 파일 다운로드
압축 풀고 webgoat 실행 후 웹페이지에 localhost/WebGoat/attack 실행
guest/geust 로 로그인 - Start WebGoat   : 여러가지 공격 기법 실습 가능

 


http://testphp.vulnweb.com/
search art - <script>alert("test")</script>  해보면 알람 창이 뜬다.

 

 


3) XSS


[ ...WebGoat-5.4tomcatwebappsROOTxss.jsp ]


<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
<title>XXXXXX</title>
</head>
<body>


<%@page import="java.lang.*"%>
<%@page import="java.util.*"%>
<%@page import="java.io.*"%>
<%@page import="java.net.*"%>
<%
String name=request.getParameter("name");
%>
username : <%=name%>
</body>
</html>

 


이제 웹에서 아래 주소 입력


http://localhost/xss.jsp?name=<script>alert("test")</script>


=> 경고창이 뜬다. 만약 이상한 페이지가 나오면 확장자 확인 필요

 

 


4) DOM XSS


[ xss1.jsp ]


<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
<title>XXXXXX</title>
</head>
<body>


DOM XSS Testing....


<SCRIPT>
var position=document.URL.indexOF("age=")+4;
document.write(document.URL.substring(position.ducument.URL.length));
</SCRIPT>


</body>
</html>

 


http://localhost/xss1.jsp?age=21


이것으로 age의 값이 출력 된다면


http://localhost/xss1.jsp?age=<script>alert("teset")</script>


도 될 것이다.

 

 


5) AJAX Security


http://localhost/WebGoat/attack  들어가서 AJAX Security -> LAB: DOM-Based... 이동
( http://localhost/WebGoat/attack?Screen=49&menu=400 )


폼에 글씨를 쓰면 위에 자동으로 입력된다. 이것을 이용


소스보기 : 435 라인 복사
<a href="attack?Screen=7&menu=1900">Web Service SAX Injection</a>


이 소스를 방금의 폼에 입력하면 위쪽에 링크가 뜬다. 해당 링크를 누르면 해당 페이지로 이동.

 


* OWASP 에 보면 유행하는 웹의 취약점을 알 수 있다.

 


다시 아까의 http://localhost/WebGoat/attack  들어가서 AJAX Security -> LAB: DOM-Based...


여기 소스코드 중 581번줄


... Enter your name: <input value='' onKeyUp='displayGreeting(person.value)' name='person' type='TEXT'> ...


입력받은 값을 person으로 해서 displayGreeting 한다는 뜻이다.


DOMXSS.js 에 displayGreeting 이라는 함수의 구조가 있다.
( http://localhost/WebGoat/javascript/DOMXSS.js )

 

 

 

And


[10] Paros, Proxy, url 파라미터 변조

|


- 2015.03.20

 


임시 강사 수업

 


1. 사전 준비


1) paros 다운로드


http://sourceforge.net/projects/paros/files/Paros/Version%203.2.13/


exe. zip 파일 모두 받기

 

 


2) java se jdk 다운로드 - 32bit 용


http://oracle.com/technetwork/java/index.html


실습에선 7 버전을 사용
http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html

 

 


3) Paros - Proxy 설정


C:Program Files (x86)Javajdk1.7.0_75  에 java가 정상적으로 설치 되었는지 확인


시스템 - 고급 시스템 설정 - 고급 - 환경 변수 - Path
   - C:Program Files (x86)Javajdk1.7.0_75bin; - 확인 - 확인 - 확인


in cmd
   java -version   으로 자바가 정상 설치 되었는지 확인


바탕화면의 바로가기 실행했을 때 경로가 다르게 나왔다면
   C:Program Files (x86)Javajdk1.7.0_75binjavaw.exe  를 선택 해준다.

 


Paros에서 Tools - option - Local proxy  에서 localhost / 8080  인지를 확인


웹 브라우저 인터넷 옵션 - 연결 - LAN 설정 - 프록시서버 에 127.0.0.1 / 8080 기재 후 확인


이제 웹브라우저에서 사이트 이동을 하면 Paros에 목록이 뜬다.

 

 


4)


우측 메뉴 - Trap 아래쪽에  Trap request, Trap response 를 선택하면
Paros 에서 Continue를 누르며 웹페이지 이동하는데, 이 때 단계별로 내가 제어 가능하다.

 

 

 


2. URL 파라미터 변조


1) 동적 방식


원본
board/filedownload.asp?style=pds_etc&filename=bun.hwp&b_idx=1070


변조
board/filedownload.asp?style=pds_etc&filename=.....변조

 

 


2) Null Byte Injection


file name 뒤에 Null 값이 있는 것을 참조하여
../../../../etc/passwd NULL.jpg 등의 방법을 통해 시스템 파일을 다운로드

 

 


3) 멀티 파라미터 변조

 

 


4) 히스토리 파일을 통한 계정과 암호추출


각 사용자의 .bash_history 를 다운받아 분석하여 공격

 

 


5) 웹 로그를 통한 관리자 권한 획득


../../../../usr/...log/ 등을 통해 log를 보면


Get 방식이라면 아래와 같이 로그가 남음.
... /manage/login?&id=admin&pw=1234 ...

 

 


6) HTTP Header 값 변조를 통한 시스템 파일 접근

 

 

 

And


Linux swap 메모리 추가

|


Oracle XE를 리눅스에 설치하여 실습하려는데 SWAP 메모리 공간이 부족해서 설치가 안되었다.

그래서 SWAP 공간을 늘려주는 방법을 구글링을 통해 실행하였다.

 

 

출처 : http://faq.hostway.co.kr/?mid=Linux_ETC&page=8&document_srl=1443

 

 

swap영여을 확보하기 위해서는 2가지 방법이 있다.


- Swap 파일 생성
- Swap 파티션 구성

 

그 중 이 글은 위의 방법을 이용하는 글이다.

 

 

1. SWAP 파일 생성

 

1) 메모리 용량 확인
# swapon –s, free

 

 

2) swap 메모리로 사용할 파일 생성 (1G 생성)

# dd if=/dev/zero of=/home/swapfile bs=1024 count=1000000

(/home/swapfile 로 만들었다.)

 

 

3) swap 파일로 포맷

mkswap /home/swapfile

 

 

4) swap 파일을 swap 공간으로 활성화

swapon /home/swapfile

 

 

5) 부팅 시 활성화 되도록 rc.local에 등록

# vi /etc/rc.d/rc.local
      9 swapon /home/swapfile

 

혹은

재부팅 후에도 적용하려면 /etc/fstab에 아래의 값을 추가해준다.

# vi /etc/fstab

/swapfile swap swap defaults 1 1

(출처 : http://egloos.zum.com/zicman/v/3032298)

 

 

2. SWAP 공간 삭제

 

더이상 필요 없을 시엔 삭제하면 된다.

 

1) swap 비활성화

# swapoff /home/swapfile

 

 

2) 파일 삭제

#rm /home/swapfile

 

 

3) rc.local 정보 삭제

혹은 /etc/fstab 의 정보 삭제

 

 

 

And