Python Forum
Need Help To Improve my Network Scanner
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need Help To Improve my Network Scanner
#1
Hi, i am very new with python coding using version 2.7, i am trying to create a network scanner using nmap module.Need help to improve my scanner such that it should scan the network or ip_range and detect all operating systems with accuracy of 100% and should provide a count for how many os are on my network. for example os and count: windows 7,10, windows xp,0, windows 10,12 linux,13.

Further would want the output to be saved both to text file and screen for log purposes. Find my script below

import nmap

print """+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
| WELCOME TO MY NETWORK SCANNER |
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"""


###########################################
loop = 1
choice = 0
###########################################

nmScan = nmap.PortScanner()

text_file = open('ww.txt', 'w') #file where output is stored

def nmapScan(hosts, arguments="-O"):
nmScan = nmap.PortScanner()
hosts = raw_input('Enter IP address : ') #ip address or range input
nmScan.scan(hosts, arguments="-O")
if 'osmatch' in nmScan[hosts]:
for osmatch in nmScan[hosts]['osmatch']:
text_file.write('OsMatch.name : {0}'.format(osmatch['name'])) #output saved to text file
text_file.write('OsMatch.accuracy : {0}'.format(osmatch['accuracy']))
print('OsMatch.name : {0}'.format(osmatch['name'])) #output displayed on screen
print('OsMatch.accuracy : {0}'.format(osmatch['accuracy']))

print('out results saved to file....................')

while loop == 1:
print "Choose Network Scanning Options Below"
print "1) Scan Network"
print "2) Quit the program"
choice = input ("choose your option :")
if choice == 1:
nmapScan('hosts', arguments="-O")
if choice == 2:
loop = 0
print('!!!! done program closed !!!!')
Reply
#2
(Oct-20-2017, 04:18 PM)cybrary Wrote: i am very new with python coding using version 2.7

Why are you using Python 2.7 and not the latest 3.6.3?
If it ain't broke, I just haven't gotten to it yet.
OS: Windows 10, openSuse 42.3, freeBSD 11, Raspian "Stretch"
Python 3.6.5, IDE: PyCharm 2018 Community Edition
Reply
#3
Hi using python 2.7 because its the only one available, but will try to install the latest version. Would however appreciate your help on this code or a book that can help me improve my code skills.
Reply
#4
In order to get any help, repost with your code in code tags.
See BBcode help for more info.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Use Barcode Scanner With Python Extra 2 1,602 Jul-14-2022, 09:52 AM
Last Post: Gribouillis
  port scanner Than999 0 1,202 Feb-01-2022, 12:24 PM
Last Post: Than999
  Python BLE Scanner not detecting device alexanderDennisEnviro500 0 2,010 Aug-01-2021, 02:29 AM
Last Post: alexanderDennisEnviro500
  Windows Python Memory Scanner Awesometech 1 21,685 Oct-14-2020, 07:44 AM
Last Post: badengagen
  waiting for barcode scanner output, while main program continues to run lightframe109 3 4,651 Sep-03-2020, 02:19 PM
Last Post: DeaD_EyE
  keyboad scanner routine(linux and windows) 1885 0 1,910 Oct-26-2019, 03:34 PM
Last Post: 1885
  detect when scanner stops darter 1 2,403 Jun-29-2018, 10:07 PM
Last Post: Larz60+
  Brick Scanner Project DarkestShadowsX 2 3,297 Jan-08-2018, 01:36 PM
Last Post: DarkestShadowsX
  Port scanner needs review. RickyWilson 1 2,882 Dec-12-2017, 06:42 AM
Last Post: j.crater
  Barcode scanner with raspberry pi 3 rajanpandit 3 8,450 Jun-26-2017, 04:45 AM
Last Post: rajanpandit

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020