Está en la página 1de 6

<%@ page language="c#" autoeventwireup="true" %>

<%@ import namespace="system.collections" %>


<%@ import namespace="system.threading" %>
<%@ import namespace="system.net.sockets" %>

<script runat="server">
//author : kj021320(nonamed)
//blog : [url]http://blog.csdn.net/kj021320/[/url]
static arraylist threadscheduler = new arraylist();//job scheduler
public class jobconsole
{
public arraylist subthreadspool = new arraylist();//sub threads pool
public int startport;//��ʼ�˿�
˿
public int port;//ѭ����
public int endport;//����˿�
public int state = 0;//0���� 1��ͣ 2ֹͣ

public string host;//ip��ַ


public string errmsg = "";//������
public stringbuilder succmsg = new stringbuilder();//�ɹ���
public int threadcount = 0;
public void start()
{
for (int c = 1; c <= threadcount; c++)
{
thread thread = new thread(new threadstart(this.run));
subthreadspool.add(thread);
thread.start();
thread = null;
}
}
//��� �
public void run()
{

int localport = 0;
while (localport <= endport)
{

while (state == 1) { thread.sleep(5000);}


if (state == 2) { return; }
lock (this) { localport = port++; }
try
{
tcpclient tcpclient = new tcpclient();
tcpclient.connect(host, localport);
lock (succmsg)
{
succmsg.append(localport + ",");
}
tcpclient.close();
}
catch (socketexception se)
{
if (se.errorcode == 10051 || se.errorcode == 10052 ||
se.errorcode == 10014)
{
this.state = 2;
}
errmsg = se.message;
}
}
state = 2;
}
}

</script>
<%

string action=request.querystring["action"];
if (action!=null && !"".equals(action)) {
if("addtoscan".equals(action))
{
string host = request.querystring["host"];//ȡ���������
string port = request.querystring["port"];//ȡ�ÿ�ʼport
string endport = request.querystring["endport"];//ȡ�ý���port
string thread = request.querystring["thread"];//ȡ��� �
jobconsole jc = new jobconsole();
jc.host = host;
jc.port = convert.toint32(port);
jc.startport = jc.port;
jc.endport = convert.toint32(endport);
jc.threadcount = convert.toint32(thread);
threadscheduler.add(jc);
jc.start();
jc = null;
}else if ("del".equals(action))
{
string id = request.querystring["id"];
if (id != null)
{
int num = convert.toint32(id);
jobconsole jc = (jobconsole)threadscheduler[num];
jc.state = 2;//���̬‫״‬Ϊstop
threadscheduler.removeat(num);//�Ƴ������Ķ���
jc.subthreadspool.clear();//��� ̳����������� �
jc = null;
}
}
else if ("run".equals(action))
{
string id = request.querystring["id"];
if(id!=null)
{
int num = convert.toint32(id);
jobconsole jc = (jobconsole)threadscheduler[num];
jc.state = 0;//running ̬‫״‬
jc.port = jc.startport;
jc.start();//���¿�ʼ
jc = null;
}
}
else if ("pause".equals(action))
{
string id = request.querystring["id"];
if (id != null)
{
int num = convert.toint32(id);
jobconsole jc = (jobconsole)threadscheduler[num];
jc.state = 1;//pause ̬‫״‬
jc = null;
}
}else if ("continue".equals(action))
{
string id = request.querystring["id"];
if (id != null)
{
int num = convert.toint32(id);
jobconsole jc = (jobconsole)threadscheduler[num];
jc.state = 0;//running ̬‫״‬
jc = null;
}
}else
{
response.write("<table><tr><td>job</td><td>thread</td><td>state</td><td>host
</td><td>scanning...</td><td>end port</td><td>succ msg</td><td>err
msg</td><td>action</td></tr>");
int count=threadscheduler.count;
for(int i=0;i<count;i++){
threadscheduler.trimtosize();
jobconsole jc=(jobconsole)threadscheduler[i];
string scanstate="";
string operate="";
if(jc!=null)
{
switch(jc.state){
case 0:scanstate="running";operate="<input type=button value=pause
onclick=\"threadoperate('pause',"+i+")\">";break;
case 1:scanstate="pause";operate="<input type=button value=continue
onclick=\"threadoperate('continue',"+i+")\">";break;
case 2:scanstate="stop";operate="<input type=button value=run
onclick=\"threadoperate('run',"+i+")\">";break;
}

response.write("<tr><td>"+i+"</td><td>"+jc.threadcount+"</td>");
response.write("<td>"+scanstate+"</td><td>"+jc.host+"</td><td>"+(jc.port
-1)+"</td><td>"+jc.endport+"</td>");
response.write("<td>"+jc.succmsg+"</td><td>"+jc.errmsg+"</td><td><input
type=button value=drop onclick='dropthread("+i+");'>"+operate+"</td></tr>");
jc=null;
}
}
response.write("<tr><td></td><td></td><td></td><td></td><td></td></tr>
</table>");
}
gc.collect();
response.end();
return;
}

%>
<html xmlns:v="urn:schemas-microsoft-com:vml">
<head>
<title>isto extreme .netscanning 1.0</title>
<style type="text/css">
v\:*{behavior:url(#default#vml);position:absolute;}
body,td{font-size: 12px;}
body,td{font-size:12px;}
table{t:expression(this.border='1',this.bordercolorlight='black',this.bordercolord
ark='white');}
input,select{font-size:12px;color:#000000;}
input{border-color:"#000000";color:#008800;background-color:#333333;}
body{margin-left:0px;margin-top:0px;margin-right:0px;margin-bottom:0px;}
td{white-space:nowrap;}
a{color:black;text-decoration:none; color:#008800;}
</style>
<script language="javascript">
//common
string.prototype.trim = function()
{
return this.replace(/(^\s*)|(\s*$)/g, "");
}
string.prototype.ltrim = function()
{
return this.replace(/(^\s*)/g, "");
}
string.prototype.rtrim = function()
{
return this.replace(/(\s*$)/g, "");
}
function createxmlhttprequest(){//create ajax consoles
if(window.activexobject){
xmlhttp=new activexobject("msxml2.xmlhttp");
}else if(window.xmlhttprequst){
xmlhttp=new xmlhttprequst();
}
}
//ref��Ҫ�� ����
function getthemessage(ref){
if(xmlhttp.readystate==4){
if(xmlhttp.status==200){
var replacestr;
replacestr=xmlhttp.responsetext;
replacestr=replacestr.trim();
if(replacestr!=""&&ref){
ref.innerhtml=replacestr;
}
return replacestr;
}else{
return "";
}
}else{
return "";
}
}
//str:connection http url
//code:eval the code
function openurlxmlhttprequsteval(str,code){
url=str;
createxmlhttprequest();
xmlhttp.open("get",url,true);
xmlhttp.onreadystatechange=function tmp(){eval(code);};
xmlhttp.send();
}
//str:connection http url
//ref:replace the html consoles
function openurlxmlhttprequstreplace(str,ref){
url=str;
createxmlhttprequest();
xmlhttp.open("get",url,true);
xmlhttp.onreadystatechange=function tmp(){getthemessage(ref);};
xmlhttp.send();
}
</script>
<script language="javascript">
//user define functions
//add to scan
function post(){
if(s.host.value!=""){
if(!isnan(s.endport.value)&&parseint(s.endport.value)<=65535){
if(!isnan(s.port.value)&&parseint(s.port.value)<=parseint(s.endport.value)&&pars
eint(s.port.value)>0){
var
url="?action=addtoscan&host="+s.host.value+"&thread="+s.thread.value+"&port="+s.po
rt.value+"&endport="+s.endport.value+"&"+math.random();
openurlxmlhttprequsteval(url,"");s.port.value="";
s.host.value="";s.endport.value="";
alert("add success");
}else{
alert("set start port error");
}
}else{
alert("set end port error");
}
}else{
alert("host can't empty");
}
}
//view pool
function viewschedulerpool(){
openurlxmlhttprequstreplace("?action="+math.random(),document.all.pool);
}
//drop the scanning thread
function dropthread(num){
if(confirm('are u sure?')){
var url="?action=del&id="+num+"&"+math.random();
openurlxmlhttprequsteval(url,"");
}
}
function threadoperate(ope,id){
if(confirm('are u sure?')){
var url="?action="+ope+"&id="+id+"&"+math.random();
openurlxmlhttprequsteval(url,"");
}
}
setinterval("viewschedulerpool()",3000);
</script>
</head>
<body text="#00ff00" vlink="#008000" alink="#008000" link="#008000"
bgcolor="#000000">
<center>
scheduler pool:
<div id="pool"></div>
<hr />
<form method="post" name='s'>
host:<input type="text" name="host" />
start port:<input type="text" name="port" size="4" maxlength="5" />
end port:<input type="text" name="endport" size="4" maxlength="5" />
thread:<select name="thread"><option value="1">1</option><option
value="2">2</option><option value="3">3</option><option
value="4">4</option><option value="5">5</option><option
value="6">6</option><option value="7">7</option><option
value="8">8</option><option value="9">9</option><option
value="10">10</option></select>
<input type="button" value="addtoscan" name="action" onclick="post();" />
</form>
</center>
<v:textbox id=istufullname style='font-size:30;z-
index:3201;filter:alpha(opacity=100,style=2) blur(add=0,direction=14,strength=5)
wave(add=1,freq=,lightstrength=5,phase=5,strength=2)
glow(color=#d9f281,strength=3) ;left:10%;color:#f17a35;font-
family:@����;Top:35%' inset='5pt,5pt,5pt,5pt'> - = information security
technology organization = - </v:textbox>
<a onclick="javascript:window.open('http://www.isto.cn');">
<v:textbox id=istu style="font-size:80;z-
index:3177;filter:alpha(opacity=100,style=2) blur(add=0,direction=14,strength=5)
wave(add=1,freq=,lightstrength=5,phase=5,strength=8)
glow(color=#cbb749,strength=1) invert;left:23%;color:black;word-break:break-
all;font-family:arial black;top:45%" inset="5pt,5pt,5pt,5pt" print="false">-=
i.s.t.o =-</v:textbox>
</a>
</body>
</html>

También podría gustarte