Advertisement
Kresha7

MikScanner v0.1

Jul 26th, 2011
323
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.83 KB | None | 0 0
  1. #! /usr/bin/python
  2. from telnetlib import Telnet
  3. from datetime import datetime
  4. import socket,os,sys
  5. def main():
  6.     ClearCLI()
  7.     About()
  8.     strFile = raw_input("Please enter the filename:")
  9.     blnSave = raw_input("Save result [y/n]?:")
  10.  
  11.     if os.path.exists(strFile):
  12.         if len(strFile) != 0:
  13.             File = open(strFile,'r+')
  14.             Buffer = File.readlines()
  15.             List = []
  16.             print('\n[+]Scanning started!')
  17.             print('[+]Current Time: ' + str(datetime.now()) + '\n')
  18.             print('**********************************************')
  19.             for lines in Buffer:
  20.             try:
  21.                tn = Telnet(lines.strip(), 23)
  22.                strTemp = tn.read_some()
  23.  
  24.                if len(strTemp) != 0:
  25.                    if strTemp.find('MikroTik') != -1:
  26.                    if blnSave == 'y':
  27.                        List.append(lines)                              
  28.                    print('[+]Found Mikrotik on: {0}\n'.format(lines.strip())),
  29.                    print('[>]Header: {0}\n'.format(strTemp.strip()))
  30.                    else:
  31.                    print('[-]No Mikrotik found on: {0}\n'.format(lines.strip()))
  32.                tn.close()
  33.        
  34.             except socket.timeout:
  35.                    print('[-]Timeout on: {0}\n'.format(lines.strip()))
  36.                    pass
  37.             except socket.error:
  38.                   print('[-]Telnet port closed on: {0}\n'.format(lines.strip()))
  39.                   pass
  40.             File.close()
  41.  
  42.             if len(List) != 0:
  43.             File = open('Found Servers.txt','w')
  44.             for ips in List:
  45.                 File.write(ips)
  46.             File.close()
  47.             print('**************Scanning finished!**************\n')
  48.                 sys.stdin.read(1)
  49.     else:
  50.             print('[-]File not found please check your filename again')
  51.             sys.stdin.read(1)  
  52.  
  53. def About():#Information about the Script and Author.
  54.     print('#----------------------------------------------------------------------#')
  55.     print('# Script Name : MikScanner v0.1                                        #')
  56.     print('# Author      : Kreshnik Hasanaj                                       #')
  57.     print('# Mail        : kresha7@hotmail.com                                    #')
  58.     print('# WebPage     : http://selftaughtgeek.info                             #')
  59.     print('# Purpose     : Scans a list of ips for Mikrotik Server                #')
  60.     print('# Usage       : At your own risk                                       #')
  61.     print('# Requirements: Python 2.7                                             #')
  62.     print('#----------------------------------------------------------------------#\n')
  63.  
  64. def ClearCLI():#Checking what platform we're running on to perform CLI cleaning.
  65.     if sys.platform == ('win32' or 'win64'):
  66.             os.system('cls')
  67.             os.system('title MikScanner v0.1')
  68.     elif sys.platform == ('linux' or 'linux2'):
  69.             os.system('clear')
  70.                    
  71. if __name__ == '__main__':main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement