OS/Ubuntu

Ubuntu 24.04 python3-nmap install and test

강서버 2024. 8. 21. 04:15
반응형

$ sudo apt install python3-nmap

 

[ Execution log ]

gangserver@NT200B5C-A22R:~$ sudo apt install python3-nmap
[sudo] gangserver 암호: 
패키지 목록을 읽는 중입니다... 완료
의존성 트리를 만드는 중입니다... 완료
상태 정보를 읽는 중입니다... 완료        
다음의 추가 패키지가 설치될 것입니다 :
  liblinear4 libssh2-1t64 nmap nmap-common
제안하는 패키지:
  liblinear-tools liblinear-dev ncat ndiff zenmap
다음 새 패키지를 설치할 것입니다:
  liblinear4 libssh2-1t64 nmap nmap-common python3-nmap
0개 업그레이드, 5개 새로 설치, 0개 제거 및 5개 업그레이드 안 함.
6,068 k바이트 아카이브를 받아야 합니다.
이 작업 후 26.8 M바이트의 디스크 공간을 더 사용하게 됩니다.
계속 하시겠습니까? [Y/n] y
(... Log omitted ...)

 

 

[ test ]
gangserver@NT200B5C-A22R:~$ python
Python 3.12.3 (main, Jul 31 2024, 17:43:48) [GCC 13.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import nmap
>>> nm = nmap.PortScanner()
>>> nm.scan('127.0.0.1', '22-443')
{'nmap': {'command_line': 'nmap -oX - -p 22-443 -sV 127.0.0.1', 'scaninfo': {'tcp': {'method': 'connect', 'services': '22-443'}}, 'scanstats': {'timestr': 'Wed Aug 21 04:53:36 2024', 'elapsed': '0.23', 'uphosts': '1', 'downhosts': '0', 'totalhosts': '1'}}, 'scan': {'127.0.0.1': {'hostnames': [{'name': 'localhost', 'type': 'PTR'}], 'addresses': {'ipv4': '127.0.0.1'}, 'vendor': {}, 'status': {'state': 'up', 'reason': 'conn-refused'}}}}
>>> nm.command_line()
'nmap -oX - -p 22-443 -sV 127.0.0.1'
>>> nm.scaninfo()
{'tcp': {'method': 'connect', 'services': '22-443'}}
>>> nm.all_hosts()
['127.0.0.1']
>>> nm['127.0.0.1'].hostname()
'localhost'
>>> nm['127.0.0.1'].state()
'up'
>>> nm['127.0.0.1'].all_protocols()
[]

 

[ reference ]

https://xael.org/pages/python-nmap-en.html

 

python-nmap : nmap from python

python-nmap : nmap from python About python-nmap is a python library which helps in using nmap port scanner. It allows to easilly manipulate nmap scan results and will be a perfect tool for systems administrators who want to automatize scanning task and

xael.org

 

 

728x90
반응형