@@ -0,0 +1,2934 @@
+#!/usr/bin/python%0A# Aurthor : Edouard Fazenda %3Cedouard.fazenda@gmail.com%3E%0A# Date : 04 August 2015%0A# Get my AS Number (Autonomous System) via http://www.whatismyasn.org%0A%0A# The MIT License (MIT)%0A#%0A# Copyright (c) %3C2015%3E %3Cedouard.fazenda@gmail.com%3E%0A#%0A# Permission is hereby granted, free of charge, to any person obtaining a copy%0A# of this software and associated documentation files (the %22Software%22), to deal%0A# in the Software without restriction, including without limitation the rights%0A# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell%0A# copies of the Software, and to permit persons to whom the Software is%0A# furnished to do so, subject to the following conditions:%0A#%0A# The above copyright notice and this permission notice shall be included in%0A# all copies or substantial portions of the Software.%0A#%0A# THE SOFTWARE IS PROVIDED %22AS IS%22, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR%0A# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,%0A# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE%0A# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER%0A# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,%0A# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN%0A# THE SOFTWARE.%0A%0Aimport urllib2%0Aimport re%0Aimport argparse%0A%0Adef get_asn_detail(data):%0A%0A   as_path_regex = re.compile('%5EYour%5CsAS%5CsPath%5Csto%5Csthis%5Cssite%5Cswas:%5Cs(.*$)')%0A   as_number_regex = re.compile('%5EYour%5Csorigin%5CsAS%5Csis:%5Cs(.*$)')%0A%0A   for line in data:%0A      value = re.sub('%3C%5B%5E%3E%5D*%3E', '', line)%0A      as_path = as_path_regex.match(value)%0A   %0A      if as_path is not None and as_path != %22%22:%0A         print %22%5BINFO%5D : The AS Path is : %22, as_path.group(1)%0A   %0A      as_number = as_number_regex.match(value)%0A%0A      if as_number is not None and as_number != %22%22:%0A         print %22%5BINFO%5D : The AS name and number is : %22, as_number.group(1)%0A%0Adef verbose(response):%0A   %0A   print %22---------------------------------------------------------------------%22%0A   print %22%5BDEBUG%5D HTTP Code : %22, response.code%0A   print %22%5BDEBUG%5D The Server is :%22, response.info()%5B'server'%5D%0A   print %22%5BDEBUG%5D The Date is : %22, response.info()%5B'date'%5D%0A   print %22%5BDEBUG%5D The Content Type is : %22, response.info()%5B'content-type'%5D%0A   print %22%5BDEBUG%5D The Content Lenght is : %22, response.info()%5B'content-length'%5D%0A   print %22---------------------------------------------------------------------%22%0Aif __name__ == '__main__':%0A%0A   response = urllib2.urlopen('http://www.whatismyasn.org',None,10)%0A   data = response.readlines()%0A%0A   parser = argparse.ArgumentParser(description='Get Autonomous System Information')%0A   parser.add_argument('-v', '--verbose', action='store_true', help='Verbose Output')%0A   args = parser.parse_args()%0A%0A   print %22%5BINFO%5D : Getting data from : %22, response.geturl(), %22...%22%0A%0A   if args.verbose:%0A      verbose(response)%0A      get_asn_detail(data)%0A   else:%0A      get_asn_detail(data)%0A%0A

Add get_my_asn.py script (Script that get the AS name and number).