출처: http://www.hahwul.com/2015/03/xss-html-event-handler-xsscross-site.html
XSS 테스트 시 많이 사용하는 방법인 이벤트 핸들러를 사용하는 방법입니다.
주로 < > 에 대한 필터링이 적용되어 있거나 싱글쿼터, 더블쿼터에 대한 필터링이 없을 경우 이벤트 핸들러를 이용하여 XSS 구문 삽입을 시도할 수 있습니다.
예를 들어 아래와 같이 Request에 대해 Response가 도착한다면 이벤트 핸들러를 이용한 공격방법을 구상해볼 수 있습니다.
Request
/test.html?search=test&no=aaa<br>111"11
Response
<input type="image" value="aaa<br>111"11" src="123.jpg">
Attack Code
/test.html?search=test&no=" onload=alert(45)
onload를 이용하여 해당 구간(이미지)가 정상 로드 되었을 때 값이 실행되며 스크립트가 실행됩니다. 이미지 로드가 실패하는 구간이라면 onerror를 통해서도 가능하며, white list 기반 필터링이 아니라면 시도해 볼 수 있는 이벤트 핸들러는 매우 많습니다. (#1 참조)
테스트를 하다보면 삽입구간에서 hidden type 을 만나게 되는 경우도 많습니다.
< > 가 필터링되지 않는다면 "><script></script> 형태로 구문을 사용하여서 XSS에 성공할 수 있지만 그렇지 않은 경우 이벤트 핸들러로도 제어가 불가능한 부분이 많습니다.
<input value="" type="hidden">
위 같은 경우 hidden 속성으로 인해 사용 불가능한 속성이 다수 존재합니다.
다만 재미있는 경우는 type 속성이 삽입되는 구간보다 뒤에 있다면 type을 변조하여 쉽게 제어가 가능합니다.
Attack Request
/test.html?search=test&no=" type="text" onfocus=alert(45) autofocus test="
Response
<input value="" type="text" onfocus=alert(45) autofocus test="" type="hidden">
Reflected XSS 뿐만 아니라 Stored XSS에서도 이벤트 핸들러를 이용하는 경우도 많이 존재합니다.
새로운 공격 기술이나 취약점은 아니지만 다른 누군가에게는 도움이 될 수 있을거라 생각하여 작성해보았습니다.
짧은 글이지만 재미있게 보셨다면 좋겠네요.
감사합니다 :)
#1 이벤트 핸들러 리스트(OWASP XSS Filter Evasion Cheat Sheet 내 일부)
FSCommand()
(attacker can use this when executed from within an embedded Flash object)onAbort()
(when user aborts the loading of an image)onActivate()
(when object is set as the active element)onAfterPrint()
(activates after user prints or previews print job)onAfterUpdate()
(activates on data object after updating data in the source object)onBeforeActivate()
(fires before the object is set as the active element)onBeforeCopy()
(attacker executes the attack string right before a selection is copied to the clipboard - attackers can do this with theexecCommand("Copy")
function)onBeforeCut()
(attacker executes the attack string right before a selection is cut)onBeforeDeactivate()
(fires right after the activeElement is changed from the current object)onBeforeEditFocus()
(Fires before an object contained in an editable element enters a UI-activated state or when an editable container object is control selected)onBeforePaste()
(user needs to be tricked into pasting or be forced into it using theexecCommand("Paste")
function)onBeforePrint()
(user would need to be tricked into printing or attacker could use theprint()
orexecCommand("Print")
function).onBeforeUnload()
(user would need to be tricked into closing the browser - attacker cannot unload windows unless it was spawned from the parent)onBeforeUpdate()
(activates on data object before updating data in the source object)onBegin()
(the onbegin event fires immediately when the element's timeline begins)onBlur()
(in the case where another popup is loaded and window looses focus)onBounce()
(fires when the behavior property of the marquee object is set to "alternate" and the contents of the marquee reach one side of the window)onCellChange()
(fires when data changes in the data provider)onChange()
(select, text, or TEXTAREA field loses focus and its value has been modified)onClick()
(someone clicks on a form)onContextMenu()
(user would need to right click on attack area)onControlSelect()
(fires when the user is about to make a control selection of the object)onCopy()
(user needs to copy something or it can be exploited using theexecCommand("Copy")
command)onCut()
(user needs to copy something or it can be exploited using theexecCommand("Cut")
command)onDataAvailable()
(user would need to change data in an element, or attacker could perform the same function)onDataSetChanged()
(fires when the data set exposed by a data source object changes)onDataSetComplete()
(fires to indicate that all data is available from the data source object)onDblClick()
(user double-clicks a form element or a link)onDeactivate()
(fires when the activeElement is changed from the current object to another object in the parent document)onDrag()
(requires that the user drags an object)onDragEnd()
(requires that the user drags an object)onDragLeave()
(requires that the user drags an object off a valid location)onDragEnter()
(requires that the user drags an object into a valid location)onDragOver()
(requires that the user drags an object into a valid location)onDragDrop()
(user drops an object (e.g. file) onto the browser window)onDragStart()
(occurs when user starts drag operation)onDrop()
(user drops an object (e.g. file) onto the browser window)onEnd()
(the onEnd event fires when the timeline ends.onError()
(loading of a document or image causes an error)onErrorUpdate()
(fires on a databound object when an error occurs while updating the associated data in the data source object)onFilterChange()
(fires when a visual filter completes state change)onFinish()
(attacker can create the exploit when marquee is finished looping)onFocus()
(attacker executes the attack string when the window gets focus)onFocusIn()
(attacker executes the attack string when window gets focus)onFocusOut()
(attacker executes the attack string when window looses focus)onHashChange()
(fires when the fragment identifier part of the document's current address changed)onHelp()
(attacker executes the attack string when users hits F1 while the window is in focus)onInput()
(the text content of an element is changed through the user interface)onKeyDown()
(user depresses a key)onKeyPress()
(user presses or holds down a key)onKeyUp()
(user releases a key)onLayoutComplete()
(user would have to print or print preview)onLoad()
(attacker executes the attack string after the window loads)onLoseCapture()
(can be exploited by thereleaseCapture()
method)onMediaComplete()
(When a streaming media file is used, this event could fire before the file starts playing)onMediaError()
(User opens a page in the browser that contains a media file, and the event fires when there is a problem)onMessage()
(fire when the document received a message)onMouseDown()
(the attacker would need to get the user to click on an image)onMouseEnter()
(cursor moves over an object or area)onMouseLeave()
(the attacker would need to get the user to mouse over an image or table and then off again)onMouseMove()
(the attacker would need to get the user to mouse over an image or table)onMouseOut()
(the attacker would need to get the user to mouse over an image or table and then off again)onMouseOver()
(cursor moves over an object or area)onMouseUp()
(the attacker would need to get the user to click on an image)onMouseWheel()
(the attacker would need to get the user to use their mouse wheel)onMove()
(user or attacker would move the page)onMoveEnd()
(user or attacker would move the page)onMoveStart()
(user or attacker would move the page)onOffline()
(occurs if the browser is working in online mode and it starts to work offline)onOnline()
(occurs if the browser is working in offline mode and it starts to work online)onOutOfSync()
(interrupt the element's ability to play its media as defined by the timeline)onPaste()
(user would need to paste or attacker could use theexecCommand("Paste")
function)onPause()
(the onpause event fires on every element that is active when the timeline pauses, including the body element)onPopState()
(fires when user navigated the session history)onProgress()
(attacker would use this as a flash movie was loading)onPropertyChange()
(user or attacker would need to change an element property)onReadyStateChange()
(user or attacker would need to change an element property)onRedo()
(user went forward in undo transaction history)onRepeat()
(the event fires once for each repetition of the timeline, excluding the first full cycle)onReset()
(user or attacker resets a form)onResize()
(user would resize the window; attacker could auto initialize with something like:<SCRIPT>self.resizeTo(500,400);</SCRIPT>
)onResizeEnd()
(user would resize the window; attacker could auto initialize with something like:<SCRIPT>self.resizeTo(500,400);</SCRIPT>
)onResizeStart()
(user would resize the window; attacker could auto initialize with something like:<SCRIPT>self.resizeTo(500,400);</SCRIPT>
)onResume()
(the onresume event fires on every element that becomes active when the timeline resumes, including the body element)onReverse()
(if the element has a repeatCount greater than one, this event fires every time the timeline begins to play backward)onRowsEnter()
(user or attacker would need to change a row in a data source)onRowExit()
(user or attacker would need to change a row in a data source)onRowDelete()
(user or attacker would need to delete a row in a data source)onRowInserted()
(user or attacker would need to insert a row in a data source)onScroll()
(user would need to scroll, or attacker could use thescrollBy()
function)onSeek()
(the onreverse event fires when the timeline is set to play in any direction other than forward)onSelect()
(user needs to select some text - attacker could auto initialize with something like:window.document.execCommand("SelectAll");
)onSelectionChange()
(user needs to select some text - attacker could auto initialize with something like:window.document.execCommand("SelectAll");
)onSelectStart()
(user needs to select some text - attacker could auto initialize with something like:window.document.execCommand("SelectAll");
)onStart()
(fires at the beginning of each marquee loop)onStop()
(user would need to press the stop button or leave the webpage)onStorage()
(storage area changed)onSyncRestored()
(user interrupts the element's ability to play its media as defined by the timeline to fire)onSubmit()
(requires attacker or user submits a form)onTimeError()
(user or attacker sets a time property, such as dur, to an invalid value)onTrackChange()
(user or attacker changes track in a playList)onUndo()
(user went backward in undo transaction history)onUnload()
(as the user clicks any link or presses the back button or attacker forces a click)onURLFlip()
(this event fires when an Advanced Streaming Format (ASF) file, played by a HTML+TIME (Timed Interactive Multimedia Extensions) media tag, processes script commands embedded in the ASF file)seekSegmentTime()
(this is a method that locates the specified point on the element's segment time line and begins playing from that point. The segment consists of one repetition of the time line including reverse play using the AUTOREVERSE attribute.)
(OWASP)
'프로젝트 관련 조사 > 모의 해킹' 카테고리의 다른 글
XSS(Cross Site Script)와 XFS(Cross Frame Script)의 차이 (0) | 2016.10.27 |
---|---|
HEX Encoding을 이용한 XSS 필터링 우회 (1) | 2016.10.27 |
HIDDEN:XSS - XSS in hidden field input(input -> hidden에서의 XSS) (0) | 2016.10.27 |
CODEBLACK SQL Injection Cheat Sheet v1.0 (0) | 2016.10.27 |
무료 SQL 인젝션 스캐너 15 제품 요약 정리 (0) | 2016.10.27 |