Question: Open server listening ports, running instances SimpleHTTPServer, and added IP aliases can add extra overhead and are a potential threat to the system. Thus, in

Open server listening ports, running instances SimpleHTTPServer, and added IP aliases can add extra overhead and are a potential threat to the system. Thus, in this section, we are going to do a little housekeeping and undo everything that we did in this lab.
Type gedit lab15/cleanUp.py to open the script (cleanup.py) into the gedit text editor. Press Enter.
sysadmin@ubuntu:~$ gedit lab15/cleanUp.py
Note: the code must be typed exactly right with the needed capitalization for the command to work.
image025.jpg
Within the script (lines 6 to 9), we are using the del argument to the Popen function to remove the aliased interfaces and deleting the IP addresses specified within the range function (10 to 15). Also, further down on line 14, we can see that once again we are using the Popen function with killall and python arguments to terminate all instances of the SimpleHTTPServer.
image026.jpg
Click the close button to exit gedit.
image027.jpg
Type lab15/./cleanUp.py to execute the script. Press Enter.
sysadmin@ubuntu:~$ lab15/./cleanUp.py
image028.jpg
CHALLENGE #3
Incorrect Please try again or skip the challenge.
What is last command that is show on the output?
os.system("ps -ef|grey python")
Skip
Note: Press the STOP button to complete the lab.
Conclusion
Python uses inheritance and modules as a way to organize code, where child classes inherit all properties and methods from the parent class and modules are scripts that essentially consist of any number of things (classes, methods, variables, etc.) and can be made available via the import statement. Python also has the ability to interact with other programming languages, such as Bash. The lab illustrated how both languages can perform automation, where Python has a big stake in the future.
Discussion Questions
In this lab, we used a method connect_ex((host,port)) for establishing a connection to a remote port. Why the double parentheses (()) is used?
In this lab, we used the response=subprocess.Popen([],stdout=).stdout.read(). What is stored in response if we dont use .stdout.read()?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!