• Earn real money by being active: Hello Guest, earn real money by simply being active on the forum — post quality content, get reactions, and help the community. Once you reach the minimum credit amount, you’ll be able to withdraw your balance directly. Learn how it works.

Ruby [Ruby] LocateIP 0.3

Status
Not open for further replies.

Doddy

Leech
User
Joined
Apr 1, 2012
Messages
169
Reputation
0
Reaction score
406
Points
63
Credits
0
‎13 Years of Service‎
57%
Un simple script en Ruby para localizar una IP y sus DNS.

Version consola :

Code:
>
#!usr/bin/ruby
#LocateIP 0.3
#(C) Doddy Hackman 2015

require "open-uri"
require "net/http"  
require "resolv"

# Functions 

def get_ip(hostname)
begin
	return Resolv.getaddress(hostname) 
rescue
	return "Error"
end
end

def toma(web)
begin
	return open(web, "User-Agent" => "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:25.0) Gecko/20100101 Firefox/25.0").read
rescue
	return "Error"
end
end

def response_code(web)
begin
	return Net::HTTP.get_response(URI(web)) .code 
rescue
	return "404"
end
end

def tomar(web,arg)
begin
	headers = {"User-Agent" => "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:25.0) Gecko/20100101 Firefox/25.0"}
	uri = URI(web)
	http = Net::HTTP.new(uri.host, uri.port)
	return http.post(uri.path,arg, headers).body
rescue
	return "Error"
end
end

def uso 
print "\n[+] Sintax : ruby locateip.rb \n"
end

def  head
print "\n\n-- == LocateIP 0.3 == --\n\n"
end

def copyright
print "\n\n-- == (C) Doddy Hackman 2015 == --\n\n"
end

def locateip(target)

print "\n[+] Getting IP ...\n"

ip = get_ip(target)

print "\n[+] IP : "+ip+"\n"

web = "http://www.melissadata.com/lookups/iplocation.asp"
print "\n[+] Locating ...\n\n"

code = tomar(web,"ipaddress="+ip+"&btn=Submit")

if code=~/City<\/td>(.*)<\/b><\/td>/
	print "[+] City : "+$2+"\n"
else
	print "[+] City : Not Found\n"
end

if code=~/Country<\/td>(.*)<\/b><\/td>/
	print "[+] Country : "+$2+"\n"
else
	print "[+] Country : Not Found\n"
end

if code=~/State or Region<\/td>(.*)<\/b><\/td>/
	print "[+] State or Region : "+$2+"\n";
else
	print "[+] State of Region : Not Found\n"
end

print "\n[+] Getting DNS ...\n\n"

control = "0"

code = toma("http://www.ip-adress.com/reverse_ip/"+ip)

dnss = code.scan(/whois\/(.*?)\">Whois/)

dnss.flatten.each do |dns|
	begin
		if dns != ""
			control = "1"
			print "[+] DNS Found : "+dns
		end
	end
end

if control=="0"
	print "\n[-] DNS Not Found\n"
end
end

target = ARGV[0]

head()

if !target
uso()
else
locateip(target)
end

copyright()

#The End ?
Version Tk :

Code:
>
#!usr/bin/ruby
#LocateIP 0.3
#(C) Doddy Hackman 2015

require "tk"
require "open-uri"
require "net/http" 
require "resolv"

# Functions 

def get_ip(hostname)
begin
	return Resolv.getaddress(hostname) 
rescue
	return "Error"
end
end

def toma(web)
begin
	return open(web, "User-Agent" => "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:25.0) Gecko/20100101 Firefox/25.0").read
rescue
	return "Error"
end
end

def response_code(web)
begin
	return Net::HTTP.get_response(URI(web)) .code 
rescue
	return "404"
end
end

def tomar(web,arg)
begin
	headers = {"User-Agent" => "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:25.0) Gecko/20100101 Firefox/25.0"}
	uri = URI(web)
	http = Net::HTTP.new(uri.host, uri.port)
	return http.post(uri.path,arg, headers).body
rescue
	return "Error"
end
end

#

window = TkRoot.new { title "LocateIP 0.3 (C) Doddy Hackman 2015" ; background "black" }
window['geometry'] = '300x300-20+10'

TkLabel.new(window) do
background "black"
foreground "yellow"
text "    Target : "
place('relx'=>"0.1",'rely'=>"0.1")
end

target = TkEntry.new(window){
background "black"
foreground "yellow"
width 25
place('relx'=>0.3,'rely'=>0.1)
}

TkLabel.new(window) do
background "black"
foreground "yellow"
text "Console"
place('relx'=>0.4,'rely'=>0.2)
end

console =TkText.new(window) do
background "black"
foreground "yellow"
width 30
height 10
place('relx'=>0.1,'rely'=>0.3)
end

TkButton.new(window) do
text "Search"
       background "black"
foreground "yellow"
width 17
activebackground "yellow"
highlightbackground  "yellow"
command proc{

	target = target.value.to_s

	console.insert("end",  "[+] Getting IP ...\n")

	ip = get_ip(target)

	web = "http://www.melissadata.com/lookups/iplocation.asp"

	console.insert("end", "\n[+] Locating ...\n\n")

	code = tomar(web,"ipaddress="+ip+"&btn=Submit")

	if code=~/City<\/td>(.*)<\/b><\/td>/
		console.insert("end", "[+] City : "+$2+"\n")
	else
		console.insert("end", "[+] City : Not Found\n")
	end

	if code=~/Country<\/td>(.*)<\/b><\/td>/
		console.insert("end","[+] Country : "+$2+"\n")
	else
		console.insert("end", "[+] Country : Not Found\n")
	end

	if code=~/State or Region<\/td>(.*)<\/b><\/td>/
		console.insert("end", "[+] State or Region : "+$2+"\n")
	else
		console.insert("end","[+] State of Region : Not Found\n")
	end

	console.insert("end","\n[+] Getting DNS ...\n\n")

	control = "0"

	code = toma("http://www.ip-adress.com/reverse_ip/"+ip)

	dnss = code.scan(/whois\/(.*?)\">Whois/)

	dnss.flatten.each do |dns|
		begin
			if dns != ""
				control = "1"
				console.insert("end", "[+] DNS Found : "+dns)
			end
		end
	end

	if control=="0"
		console.insert("end","\n[-] DNS Not Found\n")
	end

	console.insert("end","\n\n[+] Finished")
	
}
place('relx'=>0.3,'rely'=>0.9)
end

Tk.mainloop

#The End ?
Una imagen :

locateip_ruby.jpg


Eso es todo.

 
Status
Not open for further replies.
Back
Top