OLD | NEW |
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <string> | 5 #include <string> |
6 | 6 |
7 #include "base/strings/string16.h" | 7 #include "base/strings/string16.h" |
8 #include "sandbox/win/sandbox_poc/pocdll/exports.h" | 8 #include "sandbox/win/sandbox_poc/pocdll/exports.h" |
9 #include "sandbox/win/sandbox_poc/pocdll/utils.h" | 9 #include "sandbox/win/sandbox_poc/pocdll/utils.h" |
10 | 10 |
11 // This file contains the tests used to verify the security of the system by | 11 // This file contains the tests used to verify the security of the system by |
12 // using some spying techniques. | 12 // using some spying techniques. |
13 | 13 |
14 void POCDLL_API TestSpyKeys(HANDLE log) { | 14 void POCDLL_API TestSpyKeys(HANDLE log) { |
15 HandleToFile handle2file; | 15 HandleToFile handle2file; |
16 FILE *output = handle2file.Translate(log, "w"); | 16 FILE *output = handle2file.Translate(log, "w"); |
17 | 17 |
18 if (RegisterHotKey(NULL, 1, 0, 0x42)) { | 18 if (RegisterHotKey(NULL, 1, 0, 0x42)) { |
19 fprintf(output, "[GRANTED] successfully registered hotkey\r\n"); | 19 fprintf(output, "[GRANTED] successfully registered hotkey\r\n"); |
20 UnregisterHotKey(NULL, 1); | 20 UnregisterHotKey(NULL, 1); |
21 } else { | 21 } else { |
22 fprintf(output, "[BLOCKED] Failed to register hotkey. Error = %d\r\n", | 22 fprintf(output, "[BLOCKED] Failed to register hotkey. Error = %ld\r\n", |
23 ::GetLastError()); | 23 ::GetLastError()); |
24 } | 24 } |
25 | 25 |
26 fprintf(output, "[INFO] Logging keystrokes for 15 seconds\r\n"); | 26 fprintf(output, "[INFO] Logging keystrokes for 15 seconds\r\n"); |
27 fflush(output); | 27 fflush(output); |
28 base::string16 logged; | 28 base::string16 logged; |
29 DWORD tick = ::GetTickCount() + 15000; | 29 DWORD tick = ::GetTickCount() + 15000; |
30 while (tick > ::GetTickCount()) { | 30 while (tick > ::GetTickCount()) { |
31 for (int i = 0; i < 256; ++i) { | 31 for (int i = 0; i < 256; ++i) { |
32 if (::GetAsyncKeyState(i) & 1) { | 32 if (::GetAsyncKeyState(i) & 1) { |
(...skipping 23 matching lines...) Expand all Loading... |
56 | 56 |
57 for (int x = 0; x < 10; ++x) { | 57 for (int x = 0; x < 10; ++x) { |
58 for (int y = 0; y < 10; ++y) { | 58 for (int y = 0; y < 10; ++y) { |
59 if (::GetPixel(screen_dc, x, y) != pixel_color) { | 59 if (::GetPixel(screen_dc, x, y) != pixel_color) { |
60 fprintf(output, "[GRANTED] Read pixel on screen\r\n"); | 60 fprintf(output, "[GRANTED] Read pixel on screen\r\n"); |
61 return; | 61 return; |
62 } | 62 } |
63 } | 63 } |
64 } | 64 } |
65 | 65 |
66 fprintf(output, "[BLOCKED] Read pixel on screen. Error = %d\r\n", | 66 fprintf(output, "[BLOCKED] Read pixel on screen. Error = %ld\r\n", |
67 ::GetLastError()); | 67 ::GetLastError()); |
68 } | 68 } |
OLD | NEW |