Created
February 25, 2019 05:23
-
-
Save safiire/c44ac6a7d72cdc697514982e8c4220d3 to your computer and use it in GitHub Desktop.
Grab Netstat from "hackback" box on HTB
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
#!/usr/bin/env ruby | |
require 'uri' | |
require 'net/http' | |
require 'json' | |
Url = 'http://hackback:6666/netstat' | |
puts "Grabbing #{Url}" | |
uri = URI.parse(Url) | |
https = Net::HTTP.new(uri.host, uri.port) | |
req = Net::HTTP::Get.new(uri.path) | |
res = https.request(req) | |
parsed = JSON.parse(res.body) | |
puts "netstat:" | |
parsed.each do |entry| | |
local_address = entry["LocalAddress"] | |
local_port = entry["LocalPort"] | |
pid = entry["OwningProcess"] | |
remote_address = entry["RemoteAddress"] | |
remote_port = entry["RemotePort"] | |
puts "pid:#{pid} - #{local_address}:#{local_port} -> #{remote_address}:#{remote_port}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://hackback:6666/netstat=> http://hackback.htb:6666/netstat