Tell us what’s happening:
Hello Commnity, How you guys doing? Im having a little bit of trouble with my port scan challenge…
Edit:
Hello guys, i’ve improve my code and he is finally finding the open ports and written in a list ! YEAH!!
The problem is now with the verbose mode. I cannot compare with the dict provide! Can you guys take a look at my code?
Thank you!
Hi @ebusinesstoken,
I have had a look to your code and I’ll make a few suggestions hoping you wouldn’t mind.
I see you are .insert 'ing port numbers into the open_ports list. This is frankly overdoing it and a recipe for disaster. Instead, why don’t you just .append them? Then, when you need to look-up the names of the services you loop through this list (normal for port in open_ports structure and access common_ports.ports_and_services[port] to append it to your verbose output.
By doing this, you will not duplicate code. You check for a port number, append it to the list, you’ll deal with the verbose output later.
Also, you can refactor your code and place your function portScannerVerbose outside of the main function, get_open_ports. Although it is possible to cram function definitions in the middle of your code, it is not pleasant to debug.
Hope this helps clearing a few things for later improvements. Let me know how it goes.