Difference between revisions of "Big-brother-is-watching"
Line 1: | Line 1: | ||
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. | 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 == | ==Contents of funny.bat== | ||
''@ECHO ON'' | ''@ECHO ON'' | ||
Line 14: | Line 14: | ||
'') Else msg /server:127.0.0.1 <insert your student ID number> "Eyes up, idiot!" && EXIT /b'' | '') Else msg /server:127.0.0.1 <insert your student ID number> "Eyes up, idiot!" && EXIT /b'' | ||
== Contents of no_connection.bat == | ==Contents of no_connection.bat== | ||
''call funny.bat'' | ''call funny.bat'' | ||
Line 20: | Line 20: | ||
==How they work== | ==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 itteration 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 | 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 itteration 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== | ==Github link== |
Revision as of 00:32, 14 May 2021
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 itteration 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/SirShronk/connection-detection
Netstat
Netstat explanation because Mr. Chamberlain said so: https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/netstat