Skip to content

Instantly share code, notes, and snippets.

@EliteMasterEric
Last active April 23, 2023 20:07
Show Gist options
  • Save EliteMasterEric/5d501c0be48342f33d81d89aa9f46ab9 to your computer and use it in GitHub Desktop.
Save EliteMasterEric/5d501c0be48342f33d81d89aa9f46ab9 to your computer and use it in GitHub Desktop.
Haxe code to detect screen recording software.
/**
* A list of process names for several popular screen recording programs.
* Add more if you think of any.
*/
static final SCREEN_RECORDERS:Array<String> = [
"obs32.exe", "obs64.exe", "obs.exe",
"xsplit.core.exe", "livehime.exe", "pandatool.exe",
"yymixer.exe", "douyutool.exe", "huomaotool.exe"
];
/**
* Whether it is safe to share the user's IP on-screen.
* Returns false if the user is using a screen recorder. This prevents users from getting doxxed.
*/
public static function shouldUseRealIP() {
// Run the following code in the command line:
// `wmic process get Description`
var process:sys.io.Process = new sys.io.Process('wmic', ['process', 'get', 'Description']);
if (process.exitCode() != 0)
{
trace('Could not get process list, no way to know if it is unsafe to use real IP');
return false;
}
try {
while (true) {
// currentProcess is the name of an executable running on the current system.
// For example, `firefox.exe`.
var currentProcess:String = process.readLine();
if (SCREEN_RECORDERS.contains(currentProcess)) {
// If we have found a process which is a known screen recorder,
// we should not use real IP. Otherwise, the person might accidentally doxx themselves.
return false;
}
// Otherwise, go back to the start of the while loop and query the next line of the command output.
}
} catch( ex:haxe.io.Eof ) {
// This gets thrown when process.readLine() doesn't have anything else to output.
}
// If we get here, we haven't found a screen recorder.
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment