Big-brother-is-watching

From 24PinTech Wiki
Revision as of 15:42, 26 August 2021 by Jdeegan (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Mr.Chamberlain can remote into the CTE computers in the lab now, so I (Deegan) wrote a series of scripts that send a server message when he remotes in. They can be modified to close a program, or pretty much whatever upon an established connection. They probably work, aside from the netstat part taking up a disproportionate amount of time compared to the rest of the commands.

Contents of funny.bat

@ECHO ON

netstat |find "5900" |find "MHS118TW_MACPRO" |find "ESTABLISHED" > output.txt

set /p connection_status= < output.txt

del output.txt

IF "%connection_status%" == "" ( call no_connection.bat && EXIT /b

) Else msg /server:127.0.0.1 <insert your student ID number> "Eyes up, idiot!" && EXIT /b

Contents of no_connection.bat

call funny.bat

EXIT /B

How they work

Upon running funny.bat, it runs a netstat and checks for an established connection from Chamberlains computer, and sends the output to a text file. The contents of the file are then set as variable %connection_status and it checks if the variable is empty. If it's empty, it will call the no_connection.bat script which just restarts funny.bat and kills the original iteration of funny.bat, thus not allowing the script to progress to the final line. If the variable is not empty, the last line will send a server message to the loopback address and the final line will close the script. The last line can be modified to kill a process by changing th command that is run. "Taskkill /F /IM chrome.exe /T" for example would kill chrome upon an active connection.

Github link

https://github.com/thechudster1/connection-detection

Netstat

Netstat explanation because Mr. Chamberlain said so: https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/netstat