-
Notifications
You must be signed in to change notification settings - Fork 0
/
fake_escape.c
43 lines (39 loc) · 1023 Bytes
/
fake_escape.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*
* @Author: [email protected]
* @Date: 2023-02-17 15:10:05
* @LastEditors: Zhang Yeda
* @LastEditTime: 2023-03-09 15:59:09
* @FilePath: /test-svirt/fake_escape.c
* @Description: Licensed under the Apache License, Version 2.0, January 2004.
*
* Copyright (c) 2023 by Zhang Yeda, All Rights Reserved.
*/
#include<selinux/selinux.h>
#include<stdlib.h>
#include<stdio.h>
#include<unistd.h>
int main(int argc, char const* argv[])
{
//set selinux lable
const char *strlabel="system_u:system_r:svirt_t:s0:c97,c105";
int res = 0;
int exec_res = 0;
res = setexeccon(strlabel);
if (res == -1) {
printf("Set selinux context failed!\n");
}
else
{
printf("Set selinux context success!\n");
// exec fake attack
exec_res = system("/root/test-svirt/fake_attack");
if (exec_res != 0) {
printf("Exec attack failed!\n");
exec_res = -1;
} else {
printf("Exec attack success!\n");
printf("---------------------------------------------------------------------\n");
}
}
return exec_res;
}