Kali Linux on Virtualbox and using Python code

Discussions related to using VirtualBox on Linux hosts.
Post Reply
coolcassie
Posts: 1
Joined: 10. Nov 2019, 06:06

Kali Linux on Virtualbox and using Python code

Post by coolcassie »

Hi,

This is my first time posting on the forum so I wasn't entirely sure if this was in the right section of the forums.

I'm doing work for an assignment and have been using Kali Linux on VirtualBox. The part I'm unsure of is using Python coding in this and how to call the file to run the Python code.
We've been given instructions to create a Bin folder which I've done and these are the other instructions for the first part:

Create the file "listip.py" in the "bin" folder and enter the text from above into that file.
Set the execute permission on that file with the command: chmod o+x ~/bin/listip.py
Test to see if it works using the command: ~bin/listip.py x.x.x.x/n
(where x.x.x.x/n is the IP address of your target virtual machine)

This is the code they've given for the first one:

Code: Select all

#!/bin/python
import sys, os
if len(sys.argv) == 2 :
 os.system("nmap -n -sn -oG - " + sys.argv[1] + "|head -n -1|tail -n +2|cut -d' ' -f2")
exit()
Is there anything wrong with the code maybe?

There is more parts to this but wanted to try and work out how to do this part first.

Can anyone help or suggest what I should try out?
socratis
Site Moderator
Posts: 27329
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: Kali Linux on Virtualbox and using Python code

Post by socratis »

coolcassie wrote:This is my first time posting on the forum so I wasn't entirely sure if this was in the right section of the forums.
Welcome! And don't worry, we can move things around to place them where they belong... ;)
coolcassie wrote:The part I'm unsure of is using Python coding in this and how to call the file to run the Python code.
You got to understand that we can't be helping you with your assignment, or your Python programming, this is a VirtualBox site. If we were to start giving advice on things like that, the situation would get out of had really quickly. All we could help you with is VirtualBox related questions.
coolcassie wrote:This is the code they've given for the first one
Your Python script in a sense is trying to run:
  • nmap -n -sn -oG - N.N.N.N
coolcassie wrote:Is there anything wrong with the code maybe?
Not the place to ask, you should try a Python forum in general, and/or an "nmap" forum, again generally speaking.

I don't see a VirtualBox-related question in your post. Is there anything that I'm missing?
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
fth0
Volunteer
Posts: 5677
Joined: 14. Feb 2019, 03:06
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Linux, Windows 10, ...
Location: Germany

Re: Kali Linux on Virtualbox and using Python code

Post by fth0 »

coolcassie wrote:Set the execute permission on that file with the command: chmod o+x ~/bin/listip.py
Test to see if it works using the command: ~bin/listip.py x.x.x.x/n
In the 2nd line quoted above, there is a '/' missing in the underlined part.
Post Reply