Skip to content

Instantly share code, notes, and snippets.

@xntrik
Created June 23, 2015 08:18
Show Gist options
  • Select an option

  • Save xntrik/ca2c5aef167873f894b2 to your computer and use it in GitHub Desktop.

Select an option

Save xntrik/ca2c5aef167873f894b2 to your computer and use it in GitHub Desktop.
def test_1_dns_spoof
url = 'http://beefproject.com'
mount = '/beefproject'
dns_spoof = true
json = {:url => url, :mount => mount, :dns_spoof => dns_spoof}.to_json
domain = url.gsub(%r{^http://}, '')
response = RestClient.post("#{RESTAPI_SENG}/clone_page?token=#{@@token}",
json,
@@headers)
check_response(response)
# Send DNS request to server to verify that a new rule was added
dns_address = @@config.get('beef.extension.dns.address')
dns_port = @@config.get('beef.extension.dns.port')
dig_output = IO.popen(["dig", "@#{dns_address}", "-p", "#{dns_port}", "-t",
"A", "+short", "#{domain}"], 'r+').read.strip!
foundmatch = false
# Iterate local IPs (excluding loopbacks) to find a match to the 'dig'
# output
assert_block do
Socket.ip_address_list.each { |i|
if !(i.ipv4_loopback? || i.ipv6_loopback?)
return true if i.ip_address.to_s.eql?(dig_output.to_s)
end
}
end
# assert(foundmatch)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment