- mongodb - 在 MongoDB mapreduce 中,如何展平值对象?
- javascript - 对象传播与 Object.assign
- html - 输入类型 ="submit"Vs 按钮标签它们可以互换吗?
- sql - 使用 MongoDB 而不是 MS SQL Server 的优缺点
有几个资源可以解释 Chrome 中的沙盒是如何工作的,以及它如何保护用户免受恶意代码的侵害。
Chromium Blog
Chromium Developer Documentation
Sandbox FAQ
太好了,我喜欢他们采用的以操作系统为中心的设计(有点像“操作系统可能比我们知道如何更好地保护自己,所以我们让它”的方法。)他们还在几个地方提到沙盒本身被设计为不依赖于 Chrome 而是或多或少独立的地方,因此理论上任何进程都可以被沙盒化,只要程序的架构是兼容的(沙盒代码必须作为它自己的进程运行作为非沙盒父级的子级。)
我碰巧有一个应用程序,其设计使其适合沙盒,并且能够让父/子进程使用它。我有 Chromium 代码,但……不知道下一步该做什么。
有没有人真的用这个沙箱化了任何东西?是否有任何资源记录它的使用或 API?我想它应该很简单,但我不知道从哪里开始。
编辑:我在下面的答案中发现!
最佳答案
好的,这就是我发现的关于使用 Chrome 的沙盒代码的内容。
首先,您需要前往 get the chromium source code .这是大,需要一段时间才能获得,但我还没有找到任何可靠的结帐快捷方式,仍然可以产生可用的结果。 Alos,非常重要的是,您必须非常密切地遵循该页面上的说明。 Google 工作人员知道他们在做什么,并且不热衷于无用的步骤。该页面上的所有内容都是必要的。是的。一切。
现在,一旦您获得了源代码,您实际上就不必完全构建 chrome(这可能需要数小时!)来使用沙盒。相反,它们已经很好地为您提供了一个可以独立构建的单独的沙盒解决方案(在沙盒文件夹中找到)。构建这个项目并确保一切都可以编译。如果是这样,那就太好了!如果没有,您没有按照构建页面上的步骤进行操作,对吗?羞愧地低下头,这次真的去做吧。别着急,我等着……
现在一切都建立了您的主要兴趣点是 sandbox_poc 项目(“poc” = 概念证明)。这个项目基本上是一个围绕沙箱的最小 GUI 包装器,它将在沙箱环境中的给定入口点启动任意 dll。它显示了创建和使用沙盒所需的所有步骤,并且是您获得的最佳引用。经常引用!
当您查看代码时,您可能会注意到它实际沙箱化的代码就是它自己。这在所有沙盒示例中很常见,according to this thread (可能已过时)可能是目前沙盒的唯一工作方式。该线程描述了理论上如何将一个单独的进程沙箱化,但我还没有尝试过。不过,为了安全起见,拥有一个自调用应用程序是“已知良好”的方法。
sandbox_proc 包含大量静态库,但它们似乎主要用于他们构建的示例 UI。我发现最小沙箱似乎需要的唯一条件是:
sandbox.lib base.lib dbghelp.lib
虽然从项目的角度来看,还有另一种依赖关系并不完全明显,但这是我了解时间最长的。当您构建沙盒解决方案时,其中一个输出文件应该是“wowhelper.exe
”。虽然它从未在任何地方提及,但必须将该文件复制到与您正在沙盒化的可执行文件相同的目录中!如果不是,您对代码进行沙箱化的尝试将始终失败,并出现一般的“找不到文件”错误。如果您不知道发生了什么,这可能会非常令人沮丧!现在,我正在 Windows 7 64 位上进行开发,这可能与 wowhelper 要求有关(WOW 是 16/32/64 位之间互操作应用程序的常见首字母缩写词),但我没有很好的测试方法马上。如果其他人发现更多信息,请告诉我!
以上就是环境的全部内容,这里有一些简单的代码可以帮助您开始!请注意,虽然我在这里的子进程中使用了 wcout,但是在沙箱中运行时,您看不到任何控制台输出。任何类似的事情都需要通过 IPC 传达给父进程。
#include <sandbox/src/sandbox.h>
#include <sandbox/src/sandbox_factory.h>
#include <iostream>
using namespace std;
int RunParent(int argc, wchar_t* argv[], sandbox::BrokerServices* broker_service) {
if (0 != broker_service->Init()) {
wcout << L"Failed to initialize the BrokerServices object" << endl;
return 1;
}
PROCESS_INFORMATION pi;
sandbox::TargetPolicy* policy = broker_service->CreatePolicy();
// Here's where you set the security level of the sandbox. Doing a "goto definition" on any
// of these symbols usually gives you a good description of their usage and alternatives.
policy->SetJobLevel(sandbox::JOB_LOCKDOWN, 0);
policy->SetTokenLevel(sandbox::USER_RESTRICTED_SAME_ACCESS, sandbox::USER_LOCKDOWN);
policy->SetAlternateDesktop(true);
policy->SetDelayedIntegrityLevel(sandbox::INTEGRITY_LEVEL_LOW);
//Add additional rules here (ie: file access exceptions) like so:
policy->AddRule(sandbox::TargetPolicy::SUBSYS_FILES, sandbox::TargetPolicy::FILES_ALLOW_ANY, "some/file/path");
sandbox::ResultCode result = broker_service->SpawnTarget(argv[0], GetCommandLineW(), policy, &pi);
policy->Release();
policy = NULL;
if (sandbox::SBOX_ALL_OK != result) {
wcout << L"Sandbox failed to launch with the following result: " << result << endl;
return 2;
}
// Just like CreateProcess, you need to close these yourself unless you need to reference them later
CloseHandle(pi.hThread);
CloseHandle(pi.hProcess);
broker_service->WaitForAllTargets();
return 0;
}
int RunChild(int argc, wchar_t* argv[]) {
sandbox::TargetServices* target_service = sandbox::SandboxFactory::GetTargetServices();
if (NULL == target_service) {
wcout << L"Failed to retrieve target service" << endl;
return 1;
}
if (sandbox::SBOX_ALL_OK != target_service->Init()) {
wcout << L"failed to initialize target service" << endl;
return 2;
}
// Do any "unsafe" initialization code here, sandbox isn't active yet
target_service->LowerToken(); // This locks down the sandbox
// Any code executed at this point is now sandboxed!
TryDoingSomethingBad();
return 0;
}
int wmain(int argc, wchar_t* argv[]) {
sandbox::BrokerServices* broker_service = sandbox::SandboxFactory::GetBrokerServices();
// A non-NULL broker_service means that we are not running the the sandbox,
// and are therefore the parent process
if(NULL != broker_service) {
return RunParent(argc, argv, broker_service);
} else {
return RunChild(argc, argv);
}
}
希望这足以让任何其他好奇的编码人员进入沙盒!祝你好运!
关于c++ - 使用 Google Chrome 沙盒,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1590337/
我在网上搜索但没有找到任何合适的文章解释如何使用 javascript 使用 WCF 服务,尤其是 WebScriptEndpoint。 任何人都可以对此给出任何指导吗? 谢谢 最佳答案 这是一篇关于
我正在编写一个将运行 Linux 命令的 C 程序,例如: cat/etc/passwd | grep 列表 |剪切-c 1-5 我没有任何结果 *这里 parent 等待第一个 child (chi
所以我正在尝试处理文件上传,然后将该文件作为二进制文件存储到数据库中。在我存储它之后,我尝试在给定的 URL 上提供文件。我似乎找不到适合这里的方法。我需要使用数据库,因为我使用 Google 应用引
我正在尝试制作一个宏,将下面的公式添加到单元格中,然后将其拖到整个列中并在 H 列中复制相同的公式 我想在 F 和 H 列中输入公式的数据 Range("F1").formula = "=IF(ISE
问题类似于this one ,但我想使用 OperatorPrecedenceParser 解析带有函数应用程序的表达式在 FParsec . 这是我的 AST: type Expression =
我想通过使用 sequelize 和 node.js 将这个查询更改为代码取决于在哪里 select COUNT(gender) as genderCount from customers where
我正在使用GNU bash,版本5.0.3(1)-发行版(x86_64-pc-linux-gnu),我想知道为什么简单的赋值语句会出现语法错误: #/bin/bash var1=/tmp
这里,为什么我的代码在 IE 中不起作用。我的代码适用于所有浏览器。没有问题。但是当我在 IE 上运行我的项目时,它发现错误。 而且我的 jquery 类和 insertadjacentHTMl 也不
我正在尝试更改标签的innerHTML。我无权访问该表单,因此无法编辑 HTML。标签具有的唯一标识符是“for”属性。 这是输入和标签的结构:
我有一个页面,我可以在其中返回用户帖子,可以使用一些 jquery 代码对这些帖子进行即时评论,在发布新评论后,我在帖子下插入新评论以及删除 按钮。问题是 Delete 按钮在新插入的元素上不起作用,
我有一个大约有 20 列的“管道分隔”文件。我只想使用 sha1sum 散列第一列,它是一个数字,如帐号,并按原样返回其余列。 使用 awk 或 sed 执行此操作的最佳方法是什么? Accounti
我需要将以下内容插入到我的表中...我的用户表有五列 id、用户名、密码、名称、条目。 (我还没有提交任何东西到条目中,我稍后会使用 php 来做)但由于某种原因我不断收到这个错误:#1054 - U
所以我试图有一个输入字段,我可以在其中输入任何字符,但然后将输入的值小写,删除任何非字母数字字符,留下“。”而不是空格。 例如,如果我输入: 地球的 70% 是水,-!*#$^^ & 30% 土地 输
我正在尝试做一些我认为非常简单的事情,但出于某种原因我没有得到想要的结果?我是 javascript 的新手,但对 java 有经验,所以我相信我没有使用某种正确的规则。 这是一个获取输入值、检查选择
我想使用 angularjs 从 mysql 数据库加载数据。 这就是应用程序的工作原理;用户登录,他们的用户名存储在 cookie 中。该用户名显示在主页上 我想获取这个值并通过 angularjs
我正在使用 autoLayout,我想在 UITableViewCell 上放置一个 UIlabel,它应该始终位于单元格的右侧和右侧的中心。 这就是我想要实现的目标 所以在这里你可以看到我正在谈论的
我需要与 MySql 等效的 elasticsearch 查询。我的 sql 查询: SELECT DISTINCT t.product_id AS id FROM tbl_sup_price t
我正在实现代码以使用 JSON。 func setup() { if let flickrURL = NSURL(string: "https://api.flickr.com/
我尝试使用for循环声明变量,然后测试cols和rols是否相同。如果是,它将运行递归函数。但是,我在 javascript 中执行 do 时遇到问题。有人可以帮忙吗? 现在,在比较 col.1 和
我举了一个我正在处理的问题的简短示例。 HTML代码: 1 2 3 CSS 代码: .BB a:hover{ color: #000; } .BB > li:after {
我是一名优秀的程序员,十分优秀!