TCP程式設計 埠掃瞄器與網遊客戶端

2021-10-10 16:52:19 字數 2930 閱讀 5377

二、編寫網遊客戶端

開啟visual studio,選擇windows 窗體應用

窗體設計

**實現

using system;

using system.windows.forms;

using system.net;

using system.net.sockets;

namespace scan1

private int port;

private string address;

private bool[

] done = new bool[

65536];

private int start;

private int end;

private bool ok;

private void

button1_click

(object sender, eventargs e)

private void

scan1()

while

(!ok)}}

listbox1.items.

add(

"掃瞄結束!");

}else

} private void

scan()

catch }}}

結果顯示

**實現:

using system;

using system.collections.generic;

using system.componentmodel;

using system.data;

using system.drawing;

using system.linq;

using system.text;

using system.threading.tasks;

using system.windows.forms;

using system.threading;

using system.net.sockets;

namespace scan2

private void

listbox1_selectedindexchanged

(object sender, eventargs e)

private void

label1_click

(object sender, eventargs e)

private void

start_port

(object sender, eventargs e)

catch

}//獲取結束埠

private void

end_port

(object sender, eventargs e)

catch

}//獲取ip位址

private void

get_ip

(object sender, eventargs e)

//ip檢驗

private bool judge_ip()

;int sum =0;

int j =0;

for(

int i =

0; i < n; i++)if

(j ==4||

(ip[i]

=='.'

&& ip[i +1]

=='.'))

sum = sum *10+

(ip[i]

-'0');

}if(j ==3)

}return true;

}return false;

} private void

scan()

);} catch

} private void

port_scan()

);"開始掃瞄……(該過程可能會等待一定時間!)");

for(

int i = startport; i <= endport; i++))

;}bool flag = true;

while

(flag)}if

(i == endport +1)

//執行緒暫停2000ms

system.threading.thread.

sleep

(2000);

} this.

invoke

((eventhandler)delegate

);"掃瞄結束!!!");

}else

}else

}//開始掃瞄

private void

button_click

(object sender, eventargs e)

//用單一程序測試埠掃瞄

private void

main_thread()

catch

}}private void

form1_load

(object sender, eventargs e)

private void

progressbar1_click

(object sender, eventargs e)

}}

結果顯示:

TCP程式設計 埠掃瞄器與網遊客戶端

1 建立工程 選擇型別 設定介面 記錄當前掃瞄的埠號 private string address 記錄掃瞄的系統位址 private bool done new bool 65536 記錄埠的開放狀態 private int start 記錄掃瞄的起始埠 private int end 記錄掃瞄的...

TCP程式設計 埠掃瞄器

對於單執行緒的埠掃瞄可參考如下 using system using system.windows.forms using system.net using system.net.sockets namespace portscan 自定義變數 private int port 記錄當前掃瞄的埠號 ...

TCP埠掃瞄器

乙個基於python3的tcp埠掃瞄器 原理 就是和不同的埠進行tcp連線,能連線成功就表示此埠是開放的,不能連線成就表示此埠是關閉的。import socket import re import threading import time lock threading.lock threads l...