Sapient Posted November 21, 2010 Share Posted November 21, 2010 (edited) Here is the source code for a program to detect and kill any Google Incognito windows that pop-up. This is useful for people who are relying on extensions such as Chrome Nanny to help the users be more productive. To set it up, save the code as "SpyVsSpy.au3" then open the code with SciTE Editor and Build the executabe (Tools->Build), then schedule it through Windows Task Scheduler. (If you think of a better way to run it in the background to prevent non-admin task kill, let me know.) expandcollapse popup; author: Patrick Parker <patrick_x99 (email at) hotmail.com> ; this code is provided free for personal use and provided as-is with no warranty or promise of fitness for any purpose #NoTrayIcon #include <Misc.au3> if _Singleton("SpyVsSpy",1) = 0 Then Exit ; already running EndIf $loop = 1 While $loop $wins = WinList("[REGEXPCLASS:Chrome.*; REGEXPTITLE:.* - Google Chrome]") For $i = 1 to $wins[0][0] $win = $wins[$i][1] ; save the handle If IsVisible($win) and IsActive($win) Then $dim = WinGetPos($win) If IsMaximized($win) Then $x = $dim[0] + ($dim[2] - 49) ; x = window x + (window width - 49) $y = $dim[1] + 40 ; y = window y + (40 if maximized) Else $x = $dim[0] + ($dim[2] - 45) ; x = window x + (window width - 45) $y = $dim[1] + 48 ; y = window y + (48 if not maximized) EndIf $color = Hex(PixelGetColor( $x , $y , $win), 6) If $color = "FFFFFF" Then ; MsgBox(0, "Details", "Title=" & $wins[$i][0] & @LF & "Handle=" & $win & @LF & "The hex color is " & $color & " at position " & $x & "," & $y) WinKill($win) ; $loop = 0 EndIf EndIf Next Sleep(500) ; 1/2 second WEnd Func IsVisible($handle) If BitAnd( WinGetState($handle), 2 ) Then Return 1 Else Return 0 EndIf EndFunc Func IsActive($handle) If BitAnd( WinGetState($handle), 8 ) Then Return 1 Else Return 0 EndIf EndFunc Func IsMaximized($handle) If BitAnd( WinGetState($handle), 32) Then Return 1 Else Return 0 EndIf EndFunc {edit: note, a new and improved version of this code has been posted below. continue reading the thread for details } Edited February 11, 2011 by Sapient Link to comment Share on other sites More sharing options...
James Posted November 21, 2010 Share Posted November 21, 2010 This is useful for people who are relying on extensions such as Chrome Nanny to help the users be more productive. But surely if they had the willpower not to be in Incognito mode whilst using Google Nanny, they wouldn't need this. And if they did need this, they'd still be able to disable it and so we're in a cycle. Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
Sapient Posted November 21, 2010 Author Share Posted November 21, 2010 But surely if they had the willpower not to be in Incognito mode whilst using Google Nanny, they wouldn't need this. And if they did need this, they'd still be able to disable it and so we're in a cycle.If you are someone who uses Chrome Nanny extension then you are aware that the user CAN disable it, but it requires prolonged conscious effort to do so (typing out a long series of keystrokes). However, they can work around the whole thing with one click by entering incognito mode, which makes it take almost no time or conscious thought. This is an attempt to fix that.If there is no value in such an approach to you, then fine, but I assure you some people (maybe a small minority) who do find it useful and you can read the feedback on that extension for more details. Now I'm no expert on human psychology but I do know that some people find it useful. If you don't, then that's fine, don't download it. Your choice. Link to comment Share on other sites More sharing options...
UEZ Posted November 21, 2010 Share Posted November 21, 2010 Spy vs. Spy - hmmm an old C64 game... Br, UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
Werty Posted November 21, 2010 Share Posted November 21, 2010 Spy vs. Spy - hmmm an old C64 game...Br,UEZSpy vs Spy was from MAD magazine, which was made into a computer game, I read the mags and played the game, not on C64 but on ZX Spectrum. http://en.wikipedia.org/wiki/Spy_vs._Spy Some guy's script + some other guy's script = my script! Link to comment Share on other sites More sharing options...
James Posted November 21, 2010 Share Posted November 21, 2010 If there is no value in such an approach to you, then fine, but I assure you some people (maybe a small minority) who do find it useful and you can read the feedback on that extension for more details. Now I'm no expert on human psychology but I do know that some people find it useful. If you don't, then that's fine, don't download it. Your choice.Sorry, I didn't mean to offend you.The code is nice and does what it's intended to do. But I just see it as another thing to turn off before I can continue my wrong doings on the Internet whilst I should be working.I really didn't mean to hurt you. Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
snowboarder1087 Posted January 2, 2011 Share Posted January 2, 2011 (edited) Thanks a million for making this!! I had avoided using ChromeNanny simply because anytime I would want to "crack" ChomeNanny all I had to do was hit control + shift + n and bam I could circumvent ChromeNanny and then procrastinate all I wanted.The problem is I'm not hugely programmer savvy... I mean I downloaded the "single file executable called Sc1 (610K)" hereOnce downloaded I end up with a file called "Sc223.exe" which opens fine, I can open the "SpyVsSpy.au3" in it which had created by copying your script into Notepad and saving it as "SpyVsSpy.au3" obviously. I also tried saving it in SciTE Editor - (neither notepad nor SciTE have an option to choose .au3 as the file extension though.)Once I select Tools>Build I get the following:C:\program files\autoit3\aut2exe\aut2exe.exe /in "C:\Users\Phillip\Downloads\SpyVsSpy.au3"'C:\program' is not recognized as an internal or external command,operable program or batch file.>Exit code: 1What did I do wrong?? -- Edit: Also sorry for bringing back a thread that was a little over a month old, but I really need help! Edited January 2, 2011 by snowboarder1087 Link to comment Share on other sites More sharing options...
snowboarder1087 Posted January 2, 2011 Share Posted January 2, 2011 (edited) I`m sorry, but I feel like I`ve done everything correctly now. Downloaded SciTE4AutoIt3.exe Created the SpyVsSpy.au3 file. Built the SpyVsSpy.exe Application in SciEditor. Even whitelisted it in my Spyware programs so it wasn`t marked as malware. Opened Task scheduler, created a task and named it Disable Incognito (configured for Windows 7, Windows Server 2008 R2), Set the trigger for it to run at System Startup. Set the action to be `Start a program` and the program to start being ``C:\Users\Phillip\Documents\SpyVsSpy.exe`` with no Conditions set for it. But I can still hit Control + Shift + n and get incognito... Edited January 2, 2011 by snowboarder1087 Link to comment Share on other sites More sharing options...
snowboarder1087 Posted January 5, 2011 Share Posted January 5, 2011 Bump... Anyone know why I can't get this script to work and block my ability to use Chrome incognito? Link to comment Share on other sites More sharing options...
Sapient Posted January 13, 2011 Author Share Posted January 13, 2011 (edited) Bump... Anyone know why I can't get this script to work and block my ability to use Chrome incognito?Hey snowboarder. Sorry I just noticed this reply.Looks like you've done everything correctly so far, but the Task Scheduler in Windows 7 is a pain to configure correctly (I know because I'm also using Windows 7). My guess is that SpyVsSpy.exe isn't even running.Try double-clicking SpyVsSpy.exe to run it, so that way you at least know it is running.Then see if you can launch incognito windows.This way you can isolate the problem to the script or the task scheduler.I'm not an expert on the Windows Task Scheduler so I will only be able to give limited advice on it, but there are other resources and forums out there if that is the issue.I will say to make sure you turn off all conditions that disable the task, for example when on battery power, when idle, etc. I set it to run every five minutes and at logon. Edited January 13, 2011 by Sapient Link to comment Share on other sites More sharing options...
rmkbow Posted February 1, 2011 Share Posted February 1, 2011 it looks like it's attempting to find the incognito head on the right side of the browser instead of the left side. could you fix this? Link to comment Share on other sites More sharing options...
TheDarkLord Posted February 10, 2011 Share Posted February 10, 2011 Hey Sapient, great post. It was exactly what I was looking for, but I'm stuck right now. The part where you have to Build the .exe file...I get this: >C:\program files\autoit3\aut2exe\aut2exe.exe /in "C:\Users\Admin\Documents\Vignesh\SpyVsSpy.au3" 'C:\program' is not recognized as an internal or external command, operable program or batch file. >Exit code: 1 Could anyone help me on what I'm doing wrong? I'm not much of a programmer or anything.. Link to comment Share on other sites More sharing options...
jvanegmond Posted February 10, 2011 Share Posted February 10, 2011 Hey Sapient, great post. It was exactly what I was looking for, but I'm stuck right now. The part where you have to Build the .exe file...I get this: >C:\program files\autoit3\aut2exe\aut2exe.exe /in "C:\Users\Admin\Documents\Vignesh\SpyVsSpy.au3" 'C:\program' is not recognized as an internal or external command, operable program or batch file. >Exit code: 1 Could anyone help me on what I'm doing wrong? I'm not much of a programmer or anything.. if you have AutoIt installed, right click the Source code (SpyVsSpy.au3) and press Compile script. github.com/jvanegmond Link to comment Share on other sites More sharing options...
jvanegmond Posted February 10, 2011 Share Posted February 10, 2011 (edited) The post by rmkbow suggests that it checks the presence of the incognito head. That is not the case at all. It checks how far the address bar stretches to the right side of the window. The address bar width is affected by the presence of any addons, that place buttons next to the wrench. Like this one: Extensions are by default disabled in incognito mode as seen here:So, in order for to work:1. You must have an extension installed that will place a button next to the wrench.2. The extension must be disabled when the browser enters incognito mode (default).This breaks when:1. You disable all extensions (closes the window all the time)2. You allow extensions to work in incognito mode (never closes the window)All of this explains the comment in the first post: "useful for people who are relying on extensions such as Chrome Nanny". Because Chrome Nanny adds a similar button.Proposed solution: Check the presence of the incognito mode head instead. Edited February 10, 2011 by Manadar github.com/jvanegmond Link to comment Share on other sites More sharing options...
TheDarkLord Posted February 10, 2011 Share Posted February 10, 2011 if you have AutoIt installed, right click the Source code (SpyVsSpy.au3) and press Compile script.No, I don't have AutoIt installed.. Could you tell me where I could install it from?Thanks for the help. Link to comment Share on other sites More sharing options...
jvanegmond Posted February 11, 2011 Share Posted February 11, 2011 No, I don't have AutoIt installed.. Could you tell me where I could install it from?Thanks for the help.From the AutoIt website. There is a downloads page here: http://www.autoitscript.com/site/autoit/downloads/ github.com/jvanegmond Link to comment Share on other sites More sharing options...
Sapient Posted February 11, 2011 Author Share Posted February 11, 2011 (edited) Proposed solution: Check the presence of the incognito mode head instead. Thanks for the feedback. I went with that simplistic approach because I didn't want to worry about all the possible skins out there or potential artistic tweaks to the incognito icon which may be pushed with future google updates. However, here is version 2.2 below and it does address your concerns (and detects another vulnerability you didn't mention yet). expandcollapse popup; SpyVsSpy.au3, version: 2.2 ; author: Patrick Parker <patrick_x99 (email at) hotmail.com> ; this code is provided free for personal use and provided as-is with no warranty or promise of fitness for any purpose #NoTrayIcon #include <Misc.au3> #include <Math.au3> if _Singleton("SpyVsSpy",1) = 0 Then Exit ; already running EndIf $loop = 1 $hat_fails = 0 $ref_fails = 0 While $loop $wins = WinList("[REGEXPCLASS:Chrome.*; REGEXPTITLE:.* - Google Chrome]") For $i = 1 to $wins[0][0] $win = $wins[$i][1] ; save the handle If IsVisible($win) and IsActive($win) Then $dim = WinGetPos($win) If IsMaximized($win) Then $hat_x = 20 $hat_y = 2 $ref_x = 75 $ref_y = 28 Else $hat_x = $dim[0] + 25 $hat_y = $dim[1] + 15 $ref_x = $dim[0] + 80 $ref_y = $dim[1] + 44 EndIf $checksum = PixelChecksum($hat_x, $hat_y, $hat_x+8, $hat_y+5, 1, $win) ; MsgBox(0, "Details", "Title=" & $wins[$i][0] & @LF & "Handle=" & $win & @LF & "The color checksum is " & $checksum) ; Exit If $checksum = 3044775763 Then $hat_fails = $hat_fails+1 ; detected checksum of incognito hat, as sampled from Chrome 9.0.597.94 Else $hat_fails = 0 EndIf $colordiff = ColorDiff(PixelGetColor( $ref_x , $ref_y , $win), PixelGetColor( $ref_x , $ref_y+11 , $win)) ; MsgBox(0, "Details", "Title=" & $wins[$i][0] & @LF & "Handle=" & $win & @LF & "The color 0x" & Hex(PixelGetColor($ref_x,$ref_y,$win),6) & " at " & $ref_x & "," & $ref_y & " is " & $colordiff & " shades different from color 0x" & Hex(PixelGetColor($ref_x,$ref_y+11,$win),6) & " at " & $ref_x & "," & ($ref_y+11)) ; Exit If $colordiff < 31 Then $ref_fails = $ref_fails+1 ; unable to sample pixels because active window is obscured Else $ref_fails = 0 EndIf If $hat_fails > 0 Or $ref_fails > 4 Then WinKill($win) $hat_fails = 0 $ref_fails = 0 EndIf EndIf Next Sleep(500) ; 1/2 second WEnd Func IsVisible($handle) If BitAnd( WinGetState($handle), 2 ) Then Return 1 Else Return 0 EndIf EndFunc Func IsActive($handle) If BitAnd( WinGetState($handle), 8 ) Then Return 1 Else Return 0 EndIf EndFunc Func IsMaximized($handle) If BitAnd( WinGetState($handle), 32) Then Return 1 Else Return 0 EndIf EndFunc Func ColorDiff($color1, $color2, $min_return = 0) If $color1 = $color2 Then Return $min_return EndIf Return ColorDiff(BitShift($color1,8), BitShift($color2,8), _Max($min_return, Abs(BitAnd($color1, 0xFF) - BitAnd($color2, 0xFF)))) EndFunc Edited February 12, 2011 by Sapient Link to comment Share on other sites More sharing options...
maddhater Posted April 25, 2011 Share Posted April 25, 2011 Sapient, The running the compiled executable closes all chrome windows, regardless if they were incognito or not. Is this an issue you've heard or seen before? Is there a fix or workaround? Thanks ~madd Link to comment Share on other sites More sharing options...
Sapient Posted April 25, 2011 Author Share Posted April 25, 2011 (edited) Sapient,The running the compiled executable closes all chrome windows, regardless if they were incognito or not.Is this an issue you've heard or seen before? Is there a fix or workaround?Thanks~maddHi, that could happen for a couple of reasons. You could be using an odd skin that makes it fail the color reference checks. Or your computer is very slow and so it can't sample a valid color reference within the allowed threshold of time. Or your version of chrome renders the browser differently from mine.The first thing I would try is go back to the default skin and increase the $ref_fails threshold. Find the line where it says $ref_fails > 4 and increase that number to 8, then recomopile.If that doesn't solve your problem then uncomment both of the MsgBox lines, recompile, and let me know what messages pop up.Also, remember you have to kill the running SpyVsSpy program and restart it for the changes to take effect.If it turns out the problem was the skin, please let me know which skin you were using so I can adjust the algorithm. So far it works for all the ones I tested. Edited April 26, 2011 by Sapient Link to comment Share on other sites More sharing options...
PAEz Posted August 14, 2011 Share Posted August 14, 2011 Dont want to spoil your fun or anything, but theres a more Chrome way of doing this..... http://dev.chromium.org/administrators/policy-list-3#IncognitoEnabled ....so on windows (only tested in xp) you can create a reg entry to disable incognito. Create a text file called noIncognito.reg and enter this as its text..... Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Google\Chrome] "IncognitoEnabled"=dword:00000000 ....save it and then double click the file to launch it and it should enter the right reg key and then you wont be able to open incognito mode. Another useful policy for this sort of thing is the force install policy, this is good if you want to runny nanny software and dont want your kids getting past it...... http://dev.chromium.org/administrators/policy-list-3#ExtensionInstallForcelist ...the extension cant be installed before adding this policy, or just uninstall the extension after adding the policy and it will install the extension and they wont be able to uninstall or disable it. These settings will apply to all instances of chrome regardless of what profile they are using. ctl 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now