Skip to content

Instantly share code, notes, and snippets.

@safiire
Created February 25, 2019 05:23
Show Gist options
  • Save safiire/c44ac6a7d72cdc697514982e8c4220d3 to your computer and use it in GitHub Desktop.
Save safiire/c44ac6a7d72cdc697514982e8c4220d3 to your computer and use it in GitHub Desktop.
Grab Netstat from "hackback" box on HTB
#!/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
@evandrix
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment