Difference between revisions of "Big-brother-is-watching"

From 24PinTech Wiki
Jump to navigation Jump to search
Line 4: Line 4:
funny.bat-
funny.bat-


@ECHO OFF
@ECHO ON


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

Revision as of 15:42, 13 May 2021

Mr.Chamberlain can remote into the CTE computers in the lab now, so I (Jeremiah) wrote a series of scripts that send a server message when he remotes in. They can be modified to close a game, or pretty much whatever upon an established connection. They probably work, I think.

Contents of the files

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 34017912 "Eyes up, idiot!" && EXIT /b

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 and active connection.

Netstat

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