Package: hellolan
hellolanIntuitive port scanning! This module is just a couple functions that wrap nmap and are exposed as command line tools.Basically, I made this because I often need to scan for raspberry pi's on my local network and was always frustrated about remembering the correct commands. Then I needed to do some automated scanning in Python, so I just wrapped it all up in a few python functions with a cli.Install# macbrewinstallnmap# linuxapt-getinstallnmap

pipinstallhellolanUsage# by default, we scan ports 21-443hellolanscan# there are some presets toohellolanssh# --port=22hellolanweb# --port=80,443Example output:$ hellolan ssh
hostname           ip             ports
-----------------  -------------  -------
                   192.168.1.127  [22]
node-b827e9j315hf  192.168.1.236  [22]
-
Took 3.3 secondsIf you run withsudo, you can also see the mac address and vendor.$ sudo hellolan ssh --watch
hostname                ip             ports    mac                vendor
----------------------  -------------  -------  -----------------  ---------------------------

raspberrypi  192.168.1.242  [22]     DC:A6:32:C4:F4:A3  Raspberry Pi Trading
raspberrypi  192.168.1.65   [22]     DC:A6:32:A9:F0:82  Raspberry Pi Trading
             192.168.1.66   [22]     52:D4:F7:18:5F:74
             192.168.1.67   [22]     00:1A:62:03:F3:FF  Data Robotics, Incorporated
Scan 1 finished at Tue Jan 19 23:08:55 2021. took 10.2s. Found 4 hosts.There's more:# you can filter the results toohellolansshnode-# match a partial hostnamehellolanssh'host*'--ignore='badhost-*'# matching globhellolanssh192.168.1.84# match an exact ip# NOTE: lmk if you'd prefer regex over fnmatch# you can change the net hosts to scan.# by default it's the local router subnet --net=192.168.1.0/24# so it's not exclusively for lan ...!! helloevbody!hellolanscan--net=scanme.nmap.org
hellolanscan--net=198.116.0-255.1-127
hellolanscan--net=216.163.128.20/20# you can also poll localhost:# here I'm checking what I have for jupyter lab instances running.# they autoincrement ports as 8888 + i. I'm assuming I don't have# more than 7.hellolanscan--net=localhost--port=8888-8893# Outputs:#     hostname    ip         ports#     ----------  ---------  ------------#     localhost   127.0.0.1  [8888, 8889]#     -#     Took 11.4 secondsYou can print it out in more parseable formats$hellolanssh-ip# 192.168.1.127# 192.168.1.236$hellolanssh-ip-json# ["192.168.1.127", "192.168.1.236"]$hellolanssh-json# [{"hostname": "", "ip": "192.168.1.127", "ports": [22]}, {"hostname": "raspberrypi", "ip": "192.168.1.236", "ports": [22]}]Now you can use the command to directly ssh into a device !!!How it works - it will split by the '@' symbol, poll for a device who's host matches 'abc' and replaces 'abc' with the found ip address.hellolanssh-user@abcSo for example:mbp$hellolanssh-user@abc## Multiple hosts found:#     hostname  ip             ports# --  --------  -------------  -------#  0  abcdejkl  192.168.1.127  [22]#  1  abcdefgh  192.168.1.236  [22]## Which host to use? [0]: >> 1# Using host: abcdefgh## ---------------------# Starting SSH Session: $ ssh sonyc@192.168.1.236# ---------------------## Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent# permitted by applicable law.# Last login: Wed Apr 15 18:40:32 2020 from 192.168.1.214user@abcdefgh:~$hostname
abcdefgh
user@abcdefgh:~$exitlogoutConnectionto192.168.1.236closed.## -------------------# Ended SSH Session. (ssh sonyc@192.168.1.236)# -------------------#mbp$It's also importable!importhellolanfordinhellolan.scan(port='21-22'):print('{hostname}({ip}) -{ports}'.format(**d))Notesthis uses the defaultnmap.PortScanner().scan(host, ports=ports)setup. I'm not sure I'm knowledgeable enough to pick better defaults, but there may be ways to speed it up.Update: after playing around with settings, there are indeed ways of speeding it up.I made version checking optional. nmap.PortScanner.scan does version checking by default (-sV). I removed that and now you can re-enable it using--services. I haven't seen any lost information and the queries are now waaaay faster.if you are trying to speed up--services, you can specify version intensity (--intensity 0-9) with0using fewer checks (faster) and9using the most (comprehensive). I noticed significant decrease in runtime when using--serviceswith--intensity 0You can specify how many of the top ports to use (default is--top 200), fewer is faster, (nmap default is1000).