-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This project enhances system stability and security by monitoring processes, identifying high-memory usage, and detecting potential threats. Utilizing Python scripts and modules (os, getpass, socket, datetime), it generates detailed reports, improves IT infrastructure performance, and ensures robust security protocols against unauthorized access and malware threats.
- Loading branch information
1 parent
c1bbd1b
commit 1ece1ed
Showing
7 changed files
with
194 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
USERNAME:- mukuljoshi | ||
|
||
COMPUTER NAME : - ubuntu | ||
|
||
Today is 20-11-2021 | ||
|
||
Current time is 19: 08(min):02(seconds) | ||
|
||
TOTAL NUMBER OF PROCESSES RUNNING ON THE SYSTEM ARE :- 276 | ||
|
||
|
||
---------------LIST OF TOP 10 PROCESSES RUNNING AND CONSUMING MOST MEMORY--------------------- | ||
|
||
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND | ||
root 355 7.0 0.7 59636 30100 ? S<s 19:07 0:00 /lib/systemd/systemd-journald | ||
root 747 3.0 0.4 270564 17196 ? Ssl 19:08 0:00 /usr/sbin/NetworkManager --no-daemon | ||
root 769 6.0 0.3 38936 15100 ? Rs 19:08 0:00 /usr/bin/python3 /usr/bin/networkd-dispatcher --run-startup-triggers | ||
root 788 2.0 0.3 321544 13596 ? Dsl 19:08 0:00 /usr/lib/udisks2/udisksd | ||
systemd+ 700 4.0 0.2 23772 11948 ? Ss 19:08 0:00 /lib/systemd/systemd-resolved | ||
root 834 0.0 0.2 178340 11880 ? Ssl 19:08 0:00 /usr/sbin/cups-browsed | ||
root 1 23.6 0.2 167312 11164 ? Rs 19:07 0:01 /sbin/init auto noprompt | ||
mukuljo+ 819 0.0 0.2 27656 10424 ? S 19:08 0:00 /usr/bin/python3 /home/mukuljoshi/sysadminreal.py | ||
root 713 1.0 0.2 58776 10408 ? Ss 19:08 0:00 /usr/bin/VGAuthService |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#Importing the socket module | ||
import socket | ||
soc = socket.socket() | ||
|
||
#Making the connection to the windows workstation using the port 5800 | ||
soc.connect(("192.168.184.156",5800)) | ||
|
||
#Specifying that file "myfinalfile.txt" should be opened in the read bytes mode | ||
|
||
file_to_be_opened = open("/home/mukuljoshi/myfinalfile.txt", "rb") | ||
|
||
#Data is being read into the bytes | ||
file_in_bytes = file_to_be_opened.read(1024) | ||
|
||
#Giving the user confirmation that the file is being sent to the workstation | ||
print("File is being sent to the windows workstation") | ||
|
||
|
||
while (file_in_bytes): | ||
soc.send(file_in_bytes) | ||
file_in_bytes = file_to_be_opened.read(1024) | ||
|
||
#Giving the user confirmation that file has been sent successfully | ||
print("File has been sent successfully") | ||
|
||
#Closing the socket | ||
soc.close() | ||
|
||
#Priting the final message that Connection has been closed | ||
print("Connection has been closed.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
USERNAME:- mukuljoshi | ||
|
||
COMPUTER NAME : - ubuntu | ||
|
||
Today is 20-11-2021 | ||
|
||
Current time is 19: 08(min):02(seconds) | ||
|
||
TOTAL NUMBER OF PROCESSES RUNNING ON THE SYSTEM ARE :- 276 | ||
|
||
|
||
---------------LIST OF TOP 10 PROCESSES RUNNING AND CONSUMING MOST MEMORY--------------------- | ||
|
||
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND | ||
root 355 7.0 0.7 59636 30100 ? S<s 19:07 0:00 /lib/systemd/systemd-journald | ||
root 747 3.0 0.4 270564 17196 ? Ssl 19:08 0:00 /usr/sbin/NetworkManager --no-daemon | ||
root 769 6.0 0.3 38936 15100 ? Rs 19:08 0:00 /usr/bin/python3 /usr/bin/networkd-dispatcher --run-startup-triggers | ||
root 788 2.0 0.3 321544 13596 ? Dsl 19:08 0:00 /usr/lib/udisks2/udisksd | ||
systemd+ 700 4.0 0.2 23772 11948 ? Ss 19:08 0:00 /lib/systemd/systemd-resolved | ||
root 834 0.0 0.2 178340 11880 ? Ssl 19:08 0:00 /usr/sbin/cups-browsed | ||
root 1 23.6 0.2 167312 11164 ? Rs 19:07 0:01 /sbin/init auto noprompt | ||
mukuljo+ 819 0.0 0.2 27656 10424 ? S 19:08 0:00 /usr/bin/python3 /home/mukuljoshi/sysadminreal.py | ||
root 713 1.0 0.2 58776 10408 ? Ss 19:08 0:00 /usr/bin/VGAuthService |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#Importing the scoket module | ||
import socket | ||
soc=socket.socket() | ||
|
||
#Binding the socket to the port 5800 | ||
soc.bind(("192.168.184.156",5800)) | ||
soc.listen(5) | ||
|
||
#Printing to terminal that "Connection is being made" | ||
print("Connection is in progress ") | ||
|
||
#Accepting the connection which is being made by the socket | ||
|
||
conn ,addr=soc.accept() | ||
|
||
#Opening the file( Finalfile.txt) in wb (write bytes) mode which will be having the data which is being transfered | ||
|
||
newfile=open("FinalFile.txt","wb") | ||
|
||
#Giving the confirmation to the user that connection has been successfuly established | ||
|
||
print("Connection has been successfully established") | ||
|
||
#Setting up loop for constantly reading the bytes from the file and recieving it over from the python workstation | ||
|
||
while True: | ||
print("Data is being collected") | ||
data_transfered=conn.recv(1024) #bytes | ||
|
||
#If data is available in the file a new file named (FinalFile.txt) will be created | ||
if data_transfered: | ||
newfile.write(data_transfered) | ||
|
||
#If there is nothing in the file the loop will break and code will exit | ||
else: | ||
break | ||
|
||
#Closing the socket | ||
|
||
soc.close() | ||
|
||
#Closing the file | ||
|
||
newfile.close() | ||
|
||
#Giving the confirmation that file has been succesfully transferred and the file is created on the desktop | ||
|
||
print(" Connection has been successfully Closed") | ||
print(" File has been created on the desktop. It is having the data which is transferred ") | ||
print(" Thanks for using the script and have a nice day ") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import os | ||
import getpass | ||
import socket | ||
import datetime | ||
|
||
#Creating the file which will be having all the required details | ||
|
||
file=open('myfinalfile.txt','w') | ||
|
||
#Getting the username | ||
|
||
username=getpass.getuser() | ||
|
||
#Writing the username to the file | ||
|
||
file.write(" USERNAME:- " + username ) | ||
|
||
#Adding a new line for clarity purposes | ||
|
||
file.write("\n \n") | ||
|
||
#Fetching the computer name | ||
|
||
file.write("COMPUTER NAME : - "+ str(socket.gethostname()) ) | ||
file.write("\n \n ") | ||
|
||
#Getting the date | ||
|
||
date=datetime.date.today() | ||
|
||
#Getting the time | ||
|
||
time=datetime.datetime.now() | ||
|
||
#Using the str function to format the date and time | ||
|
||
formated_date=date.strftime(" %d-%m-%Y ") | ||
file.write("Today is " + formated_date) | ||
file.write("\n \n ") | ||
|
||
#Formating the time | ||
|
||
formated_time=time.strftime("%H: %M(min):%S(seconds)") | ||
file.write("Current time is " + formated_time) | ||
file.write("\n \n ") | ||
|
||
#Command used for fetching the total number of processes | ||
total_processes=os.popen("ps aux | wc -l").read() | ||
|
||
#Getting the count of the total number of processes running in the system | ||
|
||
file.write("TOTAL NUMBER OF PROCESSES RUNNING ON THE SYSTEM ARE :- " + total_processes) | ||
file.write("\n \n") | ||
|
||
#Getting the top 10 processes which are consuming most memory | ||
|
||
file.write("---------------LIST OF TOP 10 PROCESSES RUNNING AND CONSUMING MOST MEMORY--------------------- ") | ||
file.write("\n \n") | ||
file.close() | ||
|
||
|
||
#Appending to the file | ||
|
||
os.system("ps aux --sort=-%mem | head >> myfinalfile.txt") | ||
|
||
|
||
|
||
|