濮阳杆衣贸易有限公司

主頁(yè) > 知識(shí)庫(kù) > Go語(yǔ)言實(shí)現(xiàn)的簡(jiǎn)單網(wǎng)絡(luò)端口掃描方法

Go語(yǔ)言實(shí)現(xiàn)的簡(jiǎn)單網(wǎng)絡(luò)端口掃描方法

熱門(mén)標(biāo)簽:旅游廁所如何電子地圖標(biāo)注 外呼系統(tǒng)多少錢(qián)一年 工商信用卡外呼系統(tǒng)教程 經(jīng)常接到推銷(xiāo)電話機(jī)器人的電話 智能營(yíng)銷(xiāo)軟件 海外照相館地圖標(biāo)注入駐 滁州自建外呼系統(tǒng) 外呼系統(tǒng)如何接收服務(wù)密碼 客服級(jí)電銷(xiāo)機(jī)器人

本文實(shí)例講述了Go語(yǔ)言實(shí)現(xiàn)的簡(jiǎn)單網(wǎng)絡(luò)端口掃描方法。分享給大家供大家參考。具體實(shí)現(xiàn)方法如下:

復(fù)制代碼 代碼如下:
package main
import (
 "net"
 "fmt"
 "os"
 "runtime"
 "time"
 "strconv"
)

func loop(startport, endport int, inport chan int) {
  for i := startport; i = endport; i++{
   inport - i
  }
}

func scanner(inport, outport, out chan int, ip net.IP, endport int){
 for{
  in := - inport
  //fmt.Println(in)
  tcpaddr := net.TCPAddr{ip,in}
  conn, err := net.DialTCP("tcp", nil, tcpaddr)
  if err != nil {
   outport - 0
  }else{
   outport - in
  }
  conn.Close()
  if in == endport{
   out - in
  }
 }
}

func main() {
 starttime := time.Now().Unix()
 runtime.GOMAXPROCS(4)
 inport := make(chan int)
 outport := make(chan int)
 out := make(chan int)
 collect := []int{}
 if len(os.Args) != 4 {
  fmt.Println("Usage: scanner.exe IP startport endport")
  fmt.Println("Endport must be larger than startport")
  os.Exit(0)
 }
 ip := net.ParseIP(os.Args[1])
 if(os.Args[3] os.Args[2]) {
  fmt.Println("Usage: scanner IP startport endport")
  fmt.Println("Endport must be larger than startport")
  os.Exit(0)
 }
 startport, _:= strconv.Atoi(os.Args[2])
 endport, _ := strconv.Atoi(os.Args[3])
 go loop(startport, endport, inport)
 for{
  select {
   case -out:
    fmt.Println(collect)
    endtime := time.Now().Unix()
    fmt.Println("The scan process has spent ",endtime-starttime,"second")
    os.Exit(0)
   default:
    go scanner(inport, outport, out, ip, endport)
    port := - outport
    
    if port != 0{
     collect = append(collect, port)
    }
  }  
 }
}

希望本文所述對(duì)大家的Go語(yǔ)言程序設(shè)計(jì)有所幫助。

您可能感興趣的文章:
  • go語(yǔ)言制作端口掃描器
  • GO語(yǔ)言實(shí)現(xiàn)的端口掃描器分享
  • go 實(shí)現(xiàn)簡(jiǎn)易端口掃描的示例

標(biāo)簽:本溪 喀什 楚雄 湘潭 運(yùn)城 深圳 九江 晉城

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《Go語(yǔ)言實(shí)現(xiàn)的簡(jiǎn)單網(wǎng)絡(luò)端口掃描方法》,本文關(guān)鍵詞  語(yǔ)言,實(shí)現(xiàn),的,簡(jiǎn)單,網(wǎng)絡(luò),;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問(wèn)題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無(wú)關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《Go語(yǔ)言實(shí)現(xiàn)的簡(jiǎn)單網(wǎng)絡(luò)端口掃描方法》相關(guān)的同類(lèi)信息!
  • 本頁(yè)收集關(guān)于Go語(yǔ)言實(shí)現(xiàn)的簡(jiǎn)單網(wǎng)絡(luò)端口掃描方法的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    民县| 嘉义市| 门头沟区| 庆城县| 靖宇县| 武义县| 苏尼特左旗| 资溪县| 故城县| 天门市| 满洲里市| 太白县| 黎平县| 壶关县| 武定县| 上栗县| 东海县| 油尖旺区| 潜山县| 饶河县| 武夷山市| 和田市| 潮安县| 彰武县| 肥西县| 分宜县| 合作市| 新蔡县| 金坛市| 新干县| 临湘市| 盐源县| 中方县| 静乐县| 崇阳县| 盖州市| 屯门区| 新闻| 天长市| 丘北县| 兰溪市|