Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(292)

Side by Side Diff: sandbox/win/sandbox_poc/pocdll/spyware.cc

Issue 1851213002: Remove sandbox on Windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix nacl compile issues Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « sandbox/win/sandbox_poc/pocdll/registry.cc ('k') | sandbox/win/sandbox_poc/pocdll/utils.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include <string>
6
7 #include "base/strings/string16.h"
8 #include "sandbox/win/sandbox_poc/pocdll/exports.h"
9 #include "sandbox/win/sandbox_poc/pocdll/utils.h"
10
11 // This file contains the tests used to verify the security of the system by
12 // using some spying techniques.
13
14 void POCDLL_API TestSpyKeys(HANDLE log) {
15 HandleToFile handle2file;
16 FILE *output = handle2file.Translate(log, "w");
17
18 if (RegisterHotKey(NULL, 1, 0, 0x42)) {
19 fprintf(output, "[GRANTED] successfully registered hotkey\r\n");
20 UnregisterHotKey(NULL, 1);
21 } else {
22 fprintf(output, "[BLOCKED] Failed to register hotkey. Error = %ld\r\n",
23 ::GetLastError());
24 }
25
26 fprintf(output, "[INFO] Logging keystrokes for 15 seconds\r\n");
27 fflush(output);
28 base::string16 logged;
29 DWORD tick = ::GetTickCount() + 15000;
30 while (tick > ::GetTickCount()) {
31 for (int i = 0; i < 256; ++i) {
32 if (::GetAsyncKeyState(i) & 1) {
33 if (i >= VK_SPACE && i <= 0x5A /*VK_Z*/) {
34 logged.append(1, static_cast<wchar_t>(i));
35 } else {
36 logged.append(1, '?');
37 }
38 }
39 }
40 }
41
42 if (logged.size()) {
43 fprintf(output, "[GRANTED] Spyed keystrokes \"%S\"\r\n",
44 logged.c_str());
45 } else {
46 fprintf(output, "[BLOCKED] Spyed keystrokes \"(null)\"\r\n");
47 }
48 }
49
50 void POCDLL_API TestSpyScreen(HANDLE log) {
51 HandleToFile handle2file;
52 FILE *output = handle2file.Translate(log, "w");
53
54 HDC screen_dc = ::GetDC(NULL);
55 COLORREF pixel_color = ::GetPixel(screen_dc, 0, 0);
56
57 for (int x = 0; x < 10; ++x) {
58 for (int y = 0; y < 10; ++y) {
59 if (::GetPixel(screen_dc, x, y) != pixel_color) {
60 fprintf(output, "[GRANTED] Read pixel on screen\r\n");
61 return;
62 }
63 }
64 }
65
66 fprintf(output, "[BLOCKED] Read pixel on screen. Error = %ld\r\n",
67 ::GetLastError());
68 }
OLDNEW
« no previous file with comments | « sandbox/win/sandbox_poc/pocdll/registry.cc ('k') | sandbox/win/sandbox_poc/pocdll/utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698