分页: 1 / 1

写了一个AJAX的webshell给大家玩玩

发表于 : 2012-03-15 21:46
MP3
可通过浏览器操控服务器,当然也包括手机浏览器

有两个小毛病:按clear按钮不能清屏,输出不能自动下滚,哪位帮改一下?

代码: 全选

#!/bin/sh

echo 'Content-Type: text/html'
echo

CMD=${QUERY_STRING##c=}
CMD=`echo -n $CMD | sed -e 's#%20# #g' -e 's#%2F#/#g'`
if [ -n "$CMD" ] ; then
	echo $CMD
	$CMD
	exit
fi

echo '<html>'
echo '<head>'
echo "<title>WebShell</title>"

cat <<'EOF'
<script type="text/javascript">
var xmlhttp;

function loadXMLDoc(url) {
	xmlhttp=null;
	if (window.XMLHttpRequest)
		xmlhttp=new XMLHttpRequest();
	else if (window.ActiveXObject)
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	if (xmlhttp!=null) {
		xmlhttp.onreadystatechange=state_Change;
		xmlhttp.open("GET", url, true);
		xmlhttp.send(null);
	} else
		alert("Your browser does not support XMLHTTP.");
}

function state_Change() {
	if (xmlhttp.readyState==4) {
		if (xmlhttp.status==200) {
			document.getElementById('output').innerHTML+=xmlhttp.responseText+'\n';
			ready();
		}
		else
			alert("Failed: " + xmlhttp.statusText);
	}
}

function run(thisform) {
	with (thisform) with (c)
		if (value!=null && value!="")
			loadXMLDoc("/cgi-bin/webshell?c="+encodeURIComponent(value));
	return false;
}

function ready() {
	c=document.getElementById('c');
	c.value="";
	c.focus();
}

function clear() {
	document.getElementById('output').innerHTML="";
}
</script>
EOF

echo '</head>'
echo '<body bgcolor="#E0E0E0" onload="ready()">'
echo '<textarea id="output" cols="120" rows="25" readonly="readonly">'
echo '</textarea>'
echo '<form method="GET" onsubmit="return run(this)">'
echo 'cmd: <input type="text" id="c" name="c" size="80" maxlength="80" />'
echo '<input type="submit" value="submit" />&nbsp;&nbsp'
echo '<input type="button" value="clear" onclick=clear() />'
echo '</form>'
echo '</body>'
echo '</html>'

Re: 写了一个AJAX的webshell给大家玩玩

发表于 : 2012-03-15 21:47
qy117121
我想想该说什么,还是路过吧

Re: 写了一个AJAX的webshell给大家玩玩

发表于 : 2012-03-15 21:49
MP3
错啦,手机浏览器好象不支持ajax

Re: 写了一个AJAX的webshell给大家玩玩

发表于 : 2012-03-15 21:50
qy117121
MP3 写了:错啦,手机浏览器好象不支持ajax
:em04

Re: 写了一个AJAX的webshell给大家玩玩

发表于 : 2012-03-15 22:08
灰色小狼
自动滚动的话抓取textarea的onchange事件

代码: 全选

<textarea id= "text" onchange="document.all.text.scrollTop=document.all.text.scrollHeight; ">

Re: 写了一个AJAX的webshell给大家玩玩

发表于 : 2012-03-15 22:17
lilydjwg
灰色小狼 写了:自动滚动的话抓取textarea的onchange事件

代码: 全选

<textarea id= "text" onchange="document.all.text.scrollTop=document.all.text.scrollHeight; ">
麻烦先去 w3school 学习下基本知识好不?HTML 属性的等号后边能有空格?document 哪来 all 属性?标准的 getElementById 不知道?this 关键字不会用?

再加句,change 事件只有在 blur 时才会发生。要输入时发生的话得用 input 事件。

Re: 写了一个AJAX的webshell给大家玩玩

发表于 : 2012-03-15 22:21
灰色小狼
哦,还有clear,不要用innerHTML,用text.value=""

Re: 写了一个AJAX的webshell给大家玩玩

发表于 : 2012-03-15 22:34
灰色小狼
lilydjwg 写了:
灰色小狼 写了:自动滚动的话抓取textarea的onchange事件

代码: 全选

<textarea id= "text" onchange="document.all.text.scrollTop=document.all.text.scrollHeight; ">
麻烦先去 w3school 学习下基本知识好不?HTML 属性的等号后边能有空格?document 哪来 all 属性?标准的 getElementById 不知道?this 关键字不会用?

再加句,change 事件只有在 blur 时才会发生。要输入时发生的话得用 input 事件。
ok,我就会google

Re: 写了一个AJAX的webshell给大家玩玩

发表于 : 2012-03-15 22:39
phoenixlzx
喔,看起来很好玩