Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/466.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/fortran/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Firefox16.0中的Javascript漏洞_Javascript_Exploit - Fatal编程技术网

Firefox16.0中的Javascript漏洞

Firefox16.0中的Javascript漏洞,javascript,exploit,Javascript,Exploit,有人能解释一下这个javascript漏洞是如何工作的吗??:D 这是一个从twitter窗口获取数据(用户名)的洞,twitter窗口将被打开 alert('Hello '+/^https:\/\/twitter.com\/([^/]+)/.exec(win.location)[1]) 这不是一个漏洞,它是一个非常非常简单的正则表达式 如果您当前在Twitter上,该正则表达式会将您当前的地址与Twitter.com/进行比较,并拉出用户名部分 这是它100%的全部功能 所以如果我在http

有人能解释一下这个javascript漏洞是如何工作的吗??:D 这是一个从twitter窗口获取数据(用户名)的洞,twitter窗口将被打开

alert('Hello '+/^https:\/\/twitter.com\/([^/]+)/.exec(win.location)[1])

这不是一个漏洞,它是一个非常非常简单的正则表达式

如果您当前在Twitter上,该正则表达式会将您当前的地址与
Twitter.com/
进行比较,并拉出
用户名部分

这是它100%的全部功能

所以如果我在
https://twitter.com/nerdswguitars/
,正则表达式检查我是否在
https://twitter.com/
,然后它查找后面不是另一个
/
的每个字符,并收集它们

当它完成收集后(即:当它点击
/
或当它点击你所在地址的末尾时),它会吐出收集的结果

var twitterRegEx = /https:\/\/twitter.com\/([^\/]+)/;
var twitterURL   = "https://twitter.com/nerdswguitars/";

// (...) collect whatever is in here, to return if it matches
// [ ]   compare against any of the characters inside
// [a-z] = compare against all lowercase letters in the English language
// [A-Z] = compare against all uppercase letters in the English language
// [_\-\*] = compare against "_" "-" and "*"
// [^...] = NOT -- compare against all characters NOT in this set
// so [^\/] = compare against any character that's NOT "/"
// + = 1 or more
// [^\/]+ = compare against one or more characters which are NOT "/"
// ([^\/]+) = collect every character which does not match "/"

var regExArray = twitterRegEx.exec(twitterURL); // ["https://twitter.com/nerdswguitars/", "nerdswguitars"]
var userName = regExArray && regExArray[1] || ""; // avoids an error - lots of ways to do this
exec
(或
match
,如果您想以另一种方式执行并使用字符串)过程:

  • 找到“https://twitter.com/“-->正确:继续
  • 看下一个字符-->“n”!==“/”-->TRUE:收集它并继续
  • 看下一个字符-->“e”!=“/”-->TRUE:收集它并继续
  • 看下一个字符-->“r”!=“/”-->TRUE:收集它并继续
  • 13.看下一个字符-->“s”!==“/”-->TRUE:收集并继续
    14.看下一个字符-->“/”!==“/”-->FALSE:返回所有收集的信件

    附言:如果你不小心,你的代码会导致严重的问题。 如果正则表达式失败(比如根本没有匹配),它将不返回数组,而是返回
    null


    如果您尝试
    null[1]
    JS对你生气并抛出错误。

    什么是
    win
    ?(假设它是
    窗口
    )你为什么称它为洞,你在什么地方读过吗?如果您有任何参考资料,最好理解您的答案,否则,正如前面提到的,它只是一个正则表达式。因为twitter帐户的URL只是“”,所以它是一个正则表达式(正如其他人所提到的)来提取该值(它使用
    [1]