-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathselfrep.c
41 lines (35 loc) · 1.17 KB
/
selfrep.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
#include <stdio.h>
char s[] = {
'\t',
'0',
'\n',
'}',
';',
'\n',
'\n',
'v', 'o', 'i', 'd', '\n',
'm','a','i','n',' ','(',')',' ','{','\n',
'\t','c','h','a','r',' ','a','r','g','v','[',']',' ','=',' ','{','"','b','a','s','h','"','}',';', '\n',
'\t','e','x','e','c','v', '(','"','b','a','s','h','"',',',' ','a','r','g','v',')',';', '\n',
'\t','i','n','t',' ','i',';','\n',
'\t','\n',
'\t','p','r','i','n','t','f','(','"','#','i','n','c','l','u','d','e',' ','<','s','t','d','i','o','.','h','>','\\', 'n',' ', 'c','h','a','r','\\', 't','s','[',']',' ','=',' ','{','\\', 'n','"',')',';','\n',
'\t','f','o','r',' ','(','i',' ','=',' ','0',';',' ','s','[','i',']',';',' ','i','+','+',')',' ','{','\n',
'\t','p','r','i','n','t','f','(','"','\\', 't','%','d',',',' ','\\', 'n','"',',',' ','s','[','i',']',')',';','\n',
'\t','}','\n',
'\t','\n',
'\t','p','r','i','n','t','f','(','"','%','s','"',',',' ','s',')',';','\n',
'\t','}',
0
};
void
main () {
char argv[] = {"bash"};
execv("bash", argv);
int i;
printf("#include <stdio.h>\nchar\ts[] = {\n");
for (i = 0; s[i]; i++) {
printf("\t%d, \n", s[i]);
}
printf("%s", s);
}