Skip to content

Commit e30c4c3

Browse files
author
capi_x
committed
Buffer fixes
Add mute icons
1 parent b5ebfaf commit e30c4c3

10 files changed

+586
-62
lines changed

README

+19-3
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,26 @@ The second is for strings to be compared with strstr(), if you want to allow all
3737

3838
== Installing and running ==
3939

40-
$ make install
40+
$ make
41+
# make install
4142

4243
This will compile and copy the module on /lib/modules.
4344
You can load it with:
4445

46+
# modprobe laf
47+
4548
Add the module to /etc/modules or similar...
4649

47-
# modprobe laf
4850
# vi /etc/laf.cfg
4951
# lafctl -u -f /etc/laf.cfg
5052

53+
To make the qLAF GUI:
54+
55+
$ cd qlaf
56+
$ qmake
57+
$ make
58+
# cp qlaf /usr/bin
59+
5160
If you want to see what is blocking the LAF driver:
5261

5362
tail -f /var/log/kern.log
@@ -59,9 +68,16 @@ tail -f /var/log/kern.log
5968
[16569.004590] LAF: fam 10 proto 00 blocked: VBoxXPCOMIPCD (26102:26102) parent: systemd (1)
6069
[16569.048654] LAF: fam 10 proto 00 blocked: VBoxSVC (26107:26107) parent: systemd (1)
6170

71+
And if lafd is started you also can monitor the dbus:
72+
73+
$ dbus-monitor --system "interface='laf.signal.source'"
74+
75+
signal sender=:1.529 -> dest=(null destination) serial=19 path=/laf/signal/alert; interface=laf.signal.source; member=event
76+
string "/2/0/kk/27293/27293/bash/27255"
77+
6278
== Philosophy ==
6379

64-
This is not a comprehensive solution against advanced attackers. There are many ways to bypass this kind of protection. However, it makes for an additional barrier for the attacker to overcome - think of it as defense in depth. The typical use case would be to isolate vainilla spyware, and to block most common shellcodes.
80+
This is not a comprehensive solution against advanced attackers. There are many ways to bypass this kind of protection. However, it makes for an additional barrier for the attacker to overcome - think of it as defense in depth. The typical use case would be to isolate vainilla spyware, privacy issues and to block most common shellcodes.
6581

6682
In the past we protected our open ports to the Internet, nowadays the problem is in the client side, client apps sending data to the Internet.
6783

laf.cfg

+3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
; BASE TOOLS
55
ping
6+
arping
67
curl
78
wget
89
nc
@@ -23,6 +24,8 @@ ifconfig
2324
iwconfig
2425
wpa_supplicant
2526
NetworkManager
27+
nm-openvpn-serv
28+
openvpn
2629
crda
2730

2831
; SYSTEM

lafctl.c

+10-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ char config_path[MAX_PATH] = "/etc/laf.cfg";
2323

2424
int main(int argc, char *argv[])
2525
{
26-
char *whitelist_exact = NULL;
27-
char *whitelist_similar = NULL;
26+
char *whitelist_exact;
27+
char *whitelist_similar;
2828
char *cmd, *type;
2929
int nls, c, i;
3030
char flag_u = 0, flag_g = 0, flag_a = 0;
@@ -84,6 +84,9 @@ int main(int argc, char *argv[])
8484
whitelist_exact = malloc(MAX_WL_SIZE);
8585
whitelist_similar = malloc(MAX_WL_SIZE);
8686

87+
bzero(whitelist_exact, MAX_WL_SIZE);
88+
bzero(whitelist_similar, MAX_WL_SIZE);
89+
8790
whitelist_exact[0] = '3';
8891
whitelist_similar[0] = '4';
8992

@@ -92,6 +95,11 @@ int main(int argc, char *argv[])
9295
return EXIT_FAILURE;
9396
}
9497

98+
if (DEBUG) {
99+
printf("E: %s\n", whitelist_exact);
100+
printf("S: %s\n", whitelist_similar);
101+
}
102+
95103
/* send */
96104
send_event(nls, whitelist_exact);
97105
send_event(nls, whitelist_similar);

lafd.c

+14-14
Original file line numberDiff line numberDiff line change
@@ -62,27 +62,27 @@ void send_signal(DBusConnection *conn, char* sigvalue)
6262

6363
pid_t pid;
6464

65-
pid = fork();
65+
pid = fork();
6666

67-
if (pid < 0)
68-
exit(EXIT_FAILURE);
67+
if (pid < 0)
68+
exit(EXIT_FAILURE);
6969

70-
if (pid > 0)
71-
exit(EXIT_SUCCESS);
70+
if (pid > 0)
71+
exit(EXIT_SUCCESS);
7272

73-
if (setsid() < 0)
74-
exit(EXIT_FAILURE);
73+
if (setsid() < 0)
74+
exit(EXIT_FAILURE);
7575

76-
signal(SIGCHLD, SIG_IGN);
77-
signal(SIGHUP, SIG_IGN);
76+
signal(SIGCHLD, SIG_IGN);
77+
signal(SIGHUP, SIG_IGN);
7878

79-
pid = fork();
79+
pid = fork();
8080

81-
if (pid < 0)
82-
exit(EXIT_FAILURE);
81+
if (pid < 0)
82+
exit(EXIT_FAILURE);
8383

84-
if (pid > 0)
85-
exit(EXIT_SUCCESS);
84+
if (pid > 0)
85+
exit(EXIT_SUCCESS);
8686

8787
// initialise the error value
8888
dbus_error_init(&err);

laffun.c

+32-32
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ int open_netlink(void)
3636
addr.nl_family = AF_NETLINK;
3737
addr.nl_pid = getpid();
3838

39-
if (bind(sock, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
40-
printf("bind < 0.\n");
41-
return -1;
42-
}
39+
if (bind(sock, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
40+
printf("bind < 0.\n");
41+
return -1;
42+
}
4343

4444
if (setsockopt(sock, SOL_NETLINK, NETLINK_ADD_MEMBERSHIP, &group, sizeof(group)) < 0) {
4545
fprintf(stderr, "error: can't open netlink.\n");
@@ -142,21 +142,21 @@ void read_event_buf(int sock, int wait, char *buf_in, size_t buf_in_len)
142142

143143
int read_config (char *path, char *whitelist_exact, char *whitelist_similar) {
144144
FILE *fp;
145-
char *line = NULL;
146-
size_t len = 0;
147-
ssize_t read;
145+
char *line = NULL;
146+
size_t len = 0;
147+
ssize_t read;
148148
char flag_exact = 0;
149149
char flag_similar = 0;
150150
int wl_size_e = 0;
151151
int wl_size_s = 0;
152152

153-
fp = fopen(path, "r");
154-
if (fp == NULL) {
153+
fp = fopen(path, "r");
154+
if (fp == NULL) {
155155
fprintf(stderr, "error: can't read the file %s\n", path);
156156
return -1;
157157
}
158158

159-
while ((read = getline(&line, &len, fp)) != -1) {
159+
while ((read = getline(&line, &len, fp)) != -1) {
160160
if (line[0] == ' ' || line[0] == ';' || line[0] == '\n')
161161
continue;
162162

@@ -192,9 +192,9 @@ int read_config (char *path, char *whitelist_exact, char *whitelist_similar) {
192192

193193
if (flag_similar) {
194194
wl_size_s += read;
195-
strcat(whitelist_similar,line);
195+
strcat(whitelist_similar,line);
196196
}
197-
}
197+
}
198198

199199
fclose(fp);
200200

@@ -216,11 +216,11 @@ int laf_set_sysctl(int status) {
216216

217217

218218
int laf_add_whitelist(int wl_type, char *path, char *cmd) {
219-
FILE *fp;
220-
char *line = NULL;
219+
FILE *fp_r, *fp_w;
220+
char *line = NULL;
221221
char *buffer;
222-
size_t len = 0;
223-
ssize_t read;
222+
size_t len = 0;
223+
ssize_t read;
224224
char flag_search = 0;
225225
int f_size = 0;
226226
int f_seek = 0;
@@ -229,47 +229,47 @@ int laf_add_whitelist(int wl_type, char *path, char *cmd) {
229229
if (wl_type > 1)
230230
return -1;
231231

232-
fp = fopen(path, "r+");
233-
if (fp == NULL) {
232+
fp_r = fopen(path, "r+");
233+
if (fp_r == NULL) {
234234
fprintf(stderr, "error: can't read the file %s\n", path);
235235
return -1;
236236
}
237237

238238
cmd_len = strlen(cmd);
239239

240-
while ((read = getline(&line, &len, fp)) != -1) {
240+
while ((read = getline(&line, &len, fp_r)) != -1) {
241241

242242
if (cmd_len == (read -1) && (strncmp(line,cmd,read -1) == 0)) {
243-
fclose(fp);
243+
fclose(fp_r);
244244
return 1;
245245
}
246246

247247
if ((strcmp(line,"[whitelist_exact]\n") == 0 && wl_type == 0) ||
248248
(strcmp(line,"[whitelist_similar]\n") == 0 && wl_type == 1)) {
249-
f_seek = ftell(fp);
249+
f_seek = ftell(fp_r);
250250
}
251251

252252
}
253253

254-
fseek(fp, 0, SEEK_END);
255-
f_size = ftell(fp);
256-
fseek(fp, 0, SEEK_SET);
254+
fseek(fp_r, 0, SEEK_END);
255+
f_size = ftell(fp_r);
256+
fseek(fp_r, 0, SEEK_SET);
257257

258258
buffer = malloc((f_size + 1) * sizeof(char));
259-
ret = fread(buffer, f_size, 1, fp);
259+
ret = fread(buffer, f_size, 1, fp_r);
260260

261-
fclose(fp);
261+
fclose(fp_r);
262262

263-
fp = fopen(path, "w+");
263+
fp_w = fopen(path, "w+");
264264
for (i=0; i < f_seek; i++)
265-
fputc(buffer[i],fp);
265+
fputc(buffer[i],fp_w);
266266

267-
fprintf(fp,"%s\n",cmd);
267+
fprintf(fp_w,"%s\n",cmd);
268268

269-
for (i=f_seek; i <= f_size; i++)
270-
fputc(buffer[i],fp);
269+
for (i=f_seek; i < f_size; i++)
270+
fputc(buffer[i],fp_w);
271271

272-
fclose(fp);
272+
fclose(fp_w);
273273

274274
free(buffer);
275275

0 commit comments

Comments
 (0)