[C#] 纯文本查看 复制代码
import win.ui;
import win.ui.menu;
import debug;
import debug.log;
import process;
/*DSG{{*/
mainForm = win.form(text="TCP端口扫描 吾爱破解@bc100";right=527;bottom=399;border="thin";max=false)
mainForm.add(
button={cls="button";text="开始";left=402;top=24;right=507;bottom=63;z=5};
checkbox={cls="checkbox";text="先清空";left=327;top=19;right=396;bottom=38;checked=1;z=12};
edit={cls="edit";text="2000";left=327;top=45;right=366;bottom=68;edge=1;num=1;z=13};
edit2={cls="edit";left=281;top=155;right=506;bottom=390;edge=1;multiline=1;z=7};
editIp1={cls="edit";left=60;top=17;right=184;bottom=38;edge=1;limit=15;z=1};
editIp2={cls="edit";left=194;top=17;right=318;bottom=38;edge=1;limit=15;z=2};
edtPort={cls="edit";left=59;top=45;right=318;bottom=68;autovscroll=false;edge=1;z=4};
listbox={cls="listbox";left=18;top=158;right=247;bottom=390;edge=1;items={};vscroll=1;z=10};
progress={cls="progress";left=19;top=101;right=507;bottom=124;edge=1;max=100;min=0;z=9};
static={cls="static";text="IP:
Port:";left=19;top=19;right=50;bottom=66;transparent=1;z=3};
static2={cls="static";text="开启:";left=19;top=135;right=60;bottom=151;notify=1;transparent=1;z=6};
static3={cls="static";text="状态";left=19;top=80;right=490;bottom=100;transparent=1;z=8};
static4={cls="static";text="关闭:";left=284;top=135;right=325;bottom=151;notify=1;transparent=1;z=11};
static5={cls="static";text="ms";left=370;top=47;right=388;bottom=64;transparent=1;z=14}
)
/*}}*/
mainForm.editIp1.text="192.168.1.2";
mainForm.editIp2.text="192.168.1.10";
mainForm.edtPort.text='5900\,3389';
import thread.works;
//io.open() //打开控制台
scanIp = function(task) {
import wsock.tcp.client;
var tcpClient = wsock.tcp.client();
var result={ ip = task.ip;port = task.port};
result.succeeded = !! tcpClient.connectTimeout(task.ip,task.port,task.timeout);
tcpClient.close();
return result;
}
//创建弹出菜单
mainForm.popmenu = win.ui.popmenu(mainForm);
mainForm.popmenu.add('用VNC连接',function(id){
process("vncviewer.exe","vncviewer.exe",mainForm.listbox.selText);
})
mainForm.popmenu.add('用RDP连接',function(id){
process("mstsc.exe","/v "+mainForm.listbox.selText);
})
mainForm.button.oncommand = function(id,event){
if(mainForm.checkbox.checked == true){
mainForm.listbox.clear()
mainForm.edit2.text = ''
}
if( !mainForm.worksScan ){
var ip11,ip12,ip13,ip14 = string.match(mainForm.editIp1.text,"(\d+)\.(\d+)\.(\d+)\.(\d+)");
var ip21,ip22,ip23,ip24 = string.match(mainForm.editIp2.text,"(\d+)\.(\d+)\.(\d+)\.(\d+)");
var portList = string.splitEx(mainForm.edtPort.text,"[\,]+")
var taskList={};
for(ip1=ip11;ip21) for(ip2=ip12;ip22) for(ip3=ip13;ip23) for(ip4=ip14;ip24){
for(i=1;#portList ){
table.push(taskList,{
ip=ip1+"."+ip2+"."+ip3+"."+ip4;
port = portList[ i ];
timeout = tonumber(mainForm.edit.text)/1000
});
}
}
if(#taskList){
mainForm.button.text='停止'
mainForm.worksScan = thread.works( 150,scanIp);
for(i=1;#taskList;1){
mainForm.worksScan.push(taskList[ i ]);
mainForm.static3.text= "正在扫描:"+ taskList[ i ].ip +":"+ taskList[ i ].port
mainForm.progress.pos = i / #taskList * 98
}
mainForm.static3.text= "扫描完毕!"
mainForm.worksScan.waitClose(function(task){
if(task.succeeded){
str = task.ip+":"+task.port;
mainForm.listbox.add(str);
mainForm.listbox.selIndex = mainForm.listbox.count;
}else {
mainForm.edit2.print(task.ip+":"+task.port);
}
})
mainForm.worksScan = null;
}
mainForm.button.text='开始'
mainForm.progress.pos = 100
}
else {
mainForm.button.disabled = true;
mainForm.button.text='正在取消...'
mainForm.worksScan.quit();
mainForm.worksScan = null;
mainForm.button.text='开始'
mainForm.static3.text= "扫描中止.."
mainForm.button.disabled =false;
}
}
var ipWndProc = function(hwnd,message,wParam,lParam){
if (message == 0x102/*_WM_CHAR*/) {
select(wParam) {
case >= '0'# {}
case <= '9'# {}
case '.'#, 0x8/*_VK_BACK*/, 0xD/*_VK_RETURN*/, 0x2E/*_VK_DELETE*/ { }
else { }
}
if( hwnd == mainForm.editIp1.hwnd ){
mainForm.setTimeout( function() mainForm.editIp2.text = mainForm.editIp1.text,500);
}
}
}
mainForm.listbox.oncommand = function(id,event){
if( event == 0x1/*_LBN_SELCHANGE*/ ){
mainForm.static3.text = string.format(
'您选中了第%d项,总计%d项,项文本:%s'
,mainForm.listbox.selIndex
,mainForm.listbox.count
,mainForm.listbox.selText
);
}
if( event == 0x2/*_LBN_DBLCLK*/ ){
process("vncviewer.exe","vncviewer.exe",mainForm.listbox.selText);
}
}
mainForm.editIp1.wndproc = ipWndProc;
mainForm.editIp2.wndproc = ipWndProc;
mainForm.listbox.wndproc = function(hwnd,message,wParam,lParam){
select( message ) {
case 0x205/*_WM_RBUTTONUP*/{
var x,y = win.getMessagePos();
var item = mainForm.listbox.hitTest(x,y,true);
if( item ){
mainForm.listbox.selIndex = item;
mainForm.popmenu.popup(x,y,true)
}
}
}
}
mainForm.show()
win.loopMessage();