是否可以在输入中嵌套 ' 字符。像这样:
<input type="hidden" name="breakme" value="" onfocus='alert(\'1\');' autofocus="true" />
我知道你可以做类似的事情
<input type="hidden" name="breakme" value="" onfocus="alert('1');" autofocus="true" />
但我特别需要用嵌套的 '
EDIT 为了清楚起见,我专门尝试演示 XXS 攻击,因此不能有其他脚本,并且必须在此输入中完成。我正在注入(inject)另一个输入
<input type="text" name="breakme" value="<?php echo @$_POST['breakme'] ?>">
所以它不能是 "并且必须使用 '。因为我想注入(inject)的东西(调用如 'google.com?' + 'hi'
我需要能够嵌套'
最佳答案
on*
属性是完全正常的 HTML,因此您可以使用 '
或 '
之类的字符引用来对撇号进行编码:
<input type="hidden" name="login" value="" onfocus='alert('1');' autofocus="true" />
'
也是由 HTML5 定义的,但请注意它在 IE8 中不起作用。
关于javascript - HTML: 在字符串中嵌套 ',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45269714/