Skip to content

Instantly share code, notes, and snippets.

@rustamtolipov
Created February 8, 2017 06:02
Show Gist options
  • Select an option

  • Save rustamtolipov/69e233ac2d1b4942d27161255baf35c8 to your computer and use it in GitHub Desktop.

Select an option

Save rustamtolipov/69e233ac2d1b4942d27161255baf35c8 to your computer and use it in GitHub Desktop.

Revisions

  1. rustamtolipov created this gist Feb 8, 2017.
    42 changes: 42 additions & 0 deletions tasix_parser.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,42 @@
    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)