Created
February 8, 2017 06:02
-
-
Save rustamtolipov/69e233ac2d1b4942d27161255baf35c8 to your computer and use it in GitHub Desktop.
Tasix networks parser
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'net/http' | |
require 'uri' | |
def parseme(text) | |
text.each_line do |l| | |
l.gsub!(/[^\d.\/\s]/, '') | |
if l.match(/\d+\.\d+\.\d+\.\d+/) | |
if !l.match(/^[[:blank:]]{3,}/) | |
l.strip! | |
l = l.split[0] | |
if !l.match(/\//) | |
l = l + '/24' | |
end | |
puts l | |
end | |
end | |
end | |
end | |
uri = URI.parse("http://mrlg.tas-ix.uz/index.cgi") | |
request = Net::HTTP::Post.new(uri) | |
request.content_type = "application/x-www-form-urlencoded" | |
request["Referer"] = "http://mrlg.tas-ix.uz/index.cgi" | |
request["Origin"] = "http://mrlg.tas-ix.uz" | |
request["User-Agent"] = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36" | |
request.set_form_data( | |
"router" => "cisco", | |
"pass1" => "", | |
"query" => "1", | |
"arg" => "", | |
) | |
req_options = { | |
use_ssl: uri.scheme == "https", | |
} | |
response = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http| | |
http.request(request) | |
end | |
# response.code | |
parseme(response.body) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment