首页 > 代码库 > 扫描局域网中Gogs服务器脚本(ruby)
扫描局域网中Gogs服务器脚本(ruby)
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个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。