Chú ý: nhớ tạo folder "result" và có quyền write để lưu kết quả sau khi hoàn thành nhéimport
sys
import
httplib
import
re
from
urlparse
import
urlparse
import
urllib
import
socket
appid
=
'8F0213E2A58E37683CEBB707DDE557F920F12806'
#_ML
webcount
=
50
def
http(method,url,params
=
'
',headers='
'):
url_parse
=
urlparse(url)
host
=
url_parse[
1
]
path
=
url_parse[
2
]
query
=
url_parse[
4
]
http
=
httplib.HTTPConnection(host)
if
method
=
=
'GET'
:
http.request(method,path
+
'?'
+
query)
elif
method
=
=
'POST'
:
http.request(method,path,params,headers)
res
=
http.getresponse()
result
=
res.read()
http.close()
return
result
def
retdomain(x):
parse_domain
=
urlparse(x)
return
parse_domain[
1
].replace(
'www.'
,'')
'-'
*
50
'# RevIP v1.0'
'# auth0r: _ML'
'-'
*
50
if
(
len
(sys.argv)>
1
):
target
=
sys.argv[
1
];
"Processing..."
ip
=
socket.gethostbyname(parsetarget[
1
])
target
+
' ==> '
+
ip
if
ip
=
=
'
': sys.exit('
failed')
list_result
=
[]
url
=
'http://api.bing.com/xml.aspx?Appid='
+
appid
+
'&query=ip:'
+
ip
+
'&sources=web&web.count='
+
str
(webcount)
+
'&web.offest=0'
page
=
http(
'GET'
,url)
total
=
re.search(
'<web:Total>([0-9]+)<\/web:Total>'
,page)
total
=
total.group(
1
)
totalpage
=
int
(total)
/
50
+
1
###################################################
'[-] target: '
+
target
for
i
in
range
(
0
,totalpage
+
1
):
url
=
'http://api.bing.com/xml.aspx?Appid='
+
appid
+
'&query=ip:'
+
ip
+
'&sources=web&web.count='
+
str
(webcount)
+
'&web.offest='
+
str
(webcount
*
i)
page
=
http(
'GET'
,url)
get_url
=
re.findall(r
'<web:Url>(.+?)<\/web:Url>'
,page)
for
g
in
get_url: list_result.append(retdomain(g))
result
=
set
(list_result)
i
=
0
parselog
=
urlparse(target)
fw
=
open
(
'./result/'
+
str
(parselog[
1
])
+
'.txt'
,
'a'
)
fw.write(
'[-] target: '
+
target
+
'\r\n\r\n'
)
for
r
in
result:
fw.write(
' ['
+
str
(i)
+
'] '
+
r
+
'\r\n'
)
' ['
+
str
(i)
+
'] '
+
r
i
+
=
1
fw.write(
'\r\n\r\n'
)
fw.close()
else
:
'usage: python revip.py #target(ip|domain)'
Code:
Example:
python revip.py http://victim.com
python revip.py 123.456.789.000
[Python] Reverse IP v1.0
Views:
0 comments:
Post a Comment