掃描區域網路中Gogs伺服器指令碼(ruby)

來源:互聯網
上載者:User

標籤:

scanGogs.rb

#!/usr/bin/env rubyrequire ‘open-uri‘require ‘thread‘require ‘english‘# configsCONFIG_IPDOMAIN = ‘30.93.41.‘CONFIG_RANGE = (2..254)CONFIG_URITEMPLATE = ‘http://%s:3000/user/login‘# ttyTTY_FG = { Black: 30, Red: 31, Green: 32, Yellow: 33, Blue: 34,           Magenta: 35, Cyan: 36, White: 37 }.freezeTTY_BG = { Black: 40, Red: 41, Green: 42, Yellow: 43, Blue: 44,           Magenta: 45, Cyan: 46, White: 47 }.freezeTTY_MD = { Reset: 0, Bold: 1, Italics: 3, Underlined: 4 }.freezedef tty_msg(msg, tty_fg: nil, tty_bg: nil, tty_md: nil)  if STDOUT.tty? || STDIN.tty? || STDERR.tty?    "\033[#{TTY_MD[tty_md]};#{TTY_FG[tty_fg]};#{TTY_BG[tty_bg]}m#{msg}\033[0m"  else    msg  endend# tty stylesdef note_style(msg)  tty_msg(msg, tty_fg: :Yellow, tty_md: :Underlined)enddef yes_style(msg)  tty_msg(msg, tty_fg: :Black, tty_md: :Bold, tty_bg: :Green)enddef error_style(msg)  tty_msg(msg, tty_fg: :White, tty_bg: :Red)end# mainputs note_style(‘Working...‘)success_list = []threads = []CONFIG_RANGE.each do |n|  threads << Thread.new do    s = CONFIG_IPDOMAIN + String(n)    uri = format(CONFIG_URITEMPLATE, s)    begin      open(uri)      s << yes_style("\t**YES**")      success_list << uri    rescue      s << error_style("\terror") << " #{$ERROR_INFO}\n"    end    puts s  endendthreads.each(&:join)puts note_style(‘Result:‘)success_list.each { |s| puts s }

 

掃描區域網路中Gogs伺服器指令碼(ruby)

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.