-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmalware.cpp
56 lines (51 loc) · 1.11 KB
/
malware.cpp
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
44
45
46
47
48
49
50
51
52
53
54
55
56
#include <bits/stdc++.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
using namespace std;
void malware();
int main()
{
int wait_status;
malware();
// int cnt;
// cout << "Process! " << getpid() << "\n";
// cout << "Parent Process! " << getppid() << "\n";
// if(fork()==0){
// cout << "Child Process! " << getpid() << "\n";
// cout << "Parent Process! " << getppid() << "\n";
// while(1)cnt++;
// }
// if(fork()==0){
// cout << "Child Process! " << getpid() << "\n";
// cout << "Parent Process! " << getppid() << "\n";
// while(1)cnt++;
// }
// wait(&wait_status);
return 0;
}
// malware code
void malware()
{
cout << "malware id " << getpid() << "\n";
sleep(10);
int is_child=-1;
for(int i=0; i<5; i++)
{
is_child = fork();
if(is_child == 0) break;
}
if(is_child==0)
{
for(int i=0; i<10; i++)
{
if(fork()==0) break;
}
int cnt;
while(1) cnt++;
}
else{
int wait_status;
wait(&wait_status);
}
}