System and Network Tools Flashcards
socket, platform, os and psutil (34 cards)
Define Network Interface Cards (NIC)
hardware components allowing communication between network and machine
they implement physical and datalink layers
Most modern machines come with several NICs like
wireless, ethernet and bluetooth
virtual nics if VPN or VM is used
What address do NIC cards have
48-bit (12 hex) MAC address
However, since a NIC can have several virtual
interfaces, the OS needs other methods to identify these interfaces. On Windows, there
are four methods:
UUID (128-bits) (32 hex)
Name <type>_<index>
type like ethernet or wireless</index></type>
Friendly Name easier to remember than name
Description
On Windows 11, you can get full information about the system’s NICs through
what about unix?
SI -> C -> N -> Adapter
or
ipconfig /all
lshw or ip commands
This function is used to get a list of NICs, both physical and virtual, for the underlying
device.
socket.if_nameindex()
list of tuples (index, name)
If fails OSError
If you have a NIC name and you want the index, then you can use the following function:
To do the reverse index and get NIC name?
socket.if_nametoindex(nic_name)
socket.if_indextoname(index)
Define The platform Module
built-in python modules provides various system information about platform in which python is running
platform modules is defined under what category
generic os services
relevant platform functions
architecture()
machine()
processor()
node()
system()
platform()
win32_ver()
python_version()
python_implementation()
what does architecture () return
bits and linkage format
what does node () return
hostname
same as
socket.gethostname()
what does system() return
operating system
What does platform return
a single string representing the underlying platform
what does win32_ver() return
a tuple that contains some information about the windows system like release and version
what does python_version() return
a string with the version
The os module in Python is a very large module that contains a large number of functions
to perform:
Miscellaneous operating system interfaces
relevant os module functions
environ —-not function
getenv(key)
putenv(key)
getlogin()
listdrives()
stat(path)
system(command)
cpu_count()
What does environ do?
displays environment variables in the system
-> returns a mapping object where the key is a string of variable and the value is a string for its corresponding value.
what does getenv(key) do?
return the environment variable value for the key
what does putenv(key,val)
sets environment variable key to the value
getlogin() function
returns the name of the user logged in
whoami
what does listdrives() return
a list of the drives on a windows system
fsutil fsinfo drives in cmd
what does stat(path) return
information about a file
like file size, creation time