-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 28db7b5
Showing
6 changed files
with
399 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
Copyright (c) 2015, Thinkst Applied Research | ||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: | ||
|
||
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. | ||
|
||
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. | ||
|
||
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
CC = gcc | ||
CFLAGS = | ||
LIBS = -lm | ||
#DEFINES="-DLOWPID" | ||
#DEFINES="-DDEBUG" | ||
|
||
all: | ||
$(CC) $(CFLAGS) $(DEFINES) -o canaryfy canaryfy.c base32.c $(LIBS) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
Canaryfy | ||
============= | ||
by Thinkst Applied Research | ||
|
||
Overview | ||
-------- | ||
Canaryfy is an example Linux file read monitor. It watches individual files or files in directories, and triggers a [Canarytoken](http://canarytokens.org/) when a read occurs. It relies on the inotify(7) API for firing on file reads. | ||
|
||
Building | ||
------------ | ||
Run `make` which will compile to a `canaryfy` binary. | ||
|
||
To get the version which searches for a low PID, uncomment the DEFINES line with `-DLOWPID` in the Makefile. | ||
|
||
|
||
Installation | ||
------------ | ||
Move the binary to an unexpected location (e.g. `/var/lib/mailmain/bin/bouncer`). | ||
|
||
Execution | ||
--------- | ||
```canaryfy <process_name> <dns_canarytoken> <path> [ <path> ,]``` | ||
where | ||
* `process_name` is what will appear in the `ps` listing. e.g. '[kswapd1]' | ||
* `dns_canarytoken` is a new token from [Canarytoken](http://canarytokens.org). | ||
* `path` is a full path to a file or directory | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
/* | ||
* Copyright (c) 2006-2009 Bjorn Andersson <[email protected]>, Erik Ekman <[email protected]> | ||
* Mostly rewritten 2009 [email protected] | ||
* | ||
* Permission to use, copy, modify, and distribute this software for any | ||
* purpose with or without fee is hereby granted, provided that the above | ||
* copyright notice and this permission notice appear in all copies. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
*/ | ||
|
||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <string.h> | ||
|
||
//#include "base32.h" | ||
|
||
static const char cb32[] = | ||
"abcdefghijklmnopqrstuvwxyz234567"; | ||
static const char cb32_ucase[] = | ||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"; | ||
static unsigned char rev32[256]; | ||
static int reverse_init = 0; | ||
|
||
int base32_encode(char *buf, size_t *buflen, const void *data, size_t size) | ||
/* | ||
* Fills *buf with max. *buflen characters, encoding size bytes of *data. | ||
* | ||
* NOTE: *buf space should be at least 1 byte _more_ than *buflen | ||
* to hold the trailing '\0'. | ||
* | ||
* return value : #bytes filled in buf (excluding \0) | ||
* sets *buflen to : #bytes encoded from data | ||
*/ | ||
{ | ||
unsigned char *udata = (unsigned char *) data; | ||
int iout = 0; /* to-be-filled output char */ | ||
int iin = 0; /* one more than last input byte that can be | ||
successfully decoded */ | ||
|
||
/* Note: Don't bother to optimize manually. GCC optimizes | ||
better(!) when using simplistic array indexing. */ | ||
|
||
while (1) { | ||
if (iout >= *buflen || iin >= size) | ||
break; | ||
buf[iout] = cb32[((udata[iin] & 0xf8) >> 3)]; | ||
iout++; | ||
|
||
if (iout >= *buflen || iin >= size) { | ||
iout--; /* previous char is useless */ | ||
break; | ||
} | ||
buf[iout] = cb32[((udata[iin] & 0x07) << 2) | | ||
((iin + 1 < size) ? | ||
((udata[iin + 1] & 0xc0) >> 6) : 0)]; | ||
iin++; /* 0 complete, iin=1 */ | ||
iout++; | ||
|
||
if (iout >= *buflen || iin >= size) | ||
break; | ||
buf[iout] = cb32[((udata[iin] & 0x3e) >> 1)]; | ||
iout++; | ||
|
||
if (iout >= *buflen || iin >= size) { | ||
iout--; /* previous char is useless */ | ||
break; | ||
} | ||
buf[iout] = cb32[((udata[iin] & 0x01) << 4) | | ||
((iin + 1 < size) ? | ||
((udata[iin + 1] & 0xf0) >> 4) : 0)]; | ||
iin++; /* 1 complete, iin=2 */ | ||
iout++; | ||
|
||
if (iout >= *buflen || iin >= size) | ||
break; | ||
buf[iout] = cb32[((udata[iin] & 0x0f) << 1) | | ||
((iin + 1 < size) ? | ||
((udata[iin + 1] & 0x80) >> 7) : 0)]; | ||
iin++; /* 2 complete, iin=3 */ | ||
iout++; | ||
|
||
if (iout >= *buflen || iin >= size) | ||
break; | ||
buf[iout] = cb32[((udata[iin] & 0x7c) >> 2)]; | ||
iout++; | ||
|
||
if (iout >= *buflen || iin >= size) { | ||
iout--; /* previous char is useless */ | ||
break; | ||
} | ||
buf[iout] = cb32[((udata[iin] & 0x03) << 3) | | ||
((iin + 1 < size) ? | ||
((udata[iin + 1] & 0xe0) >> 5) : 0)]; | ||
iin++; /* 3 complete, iin=4 */ | ||
iout++; | ||
|
||
if (iout >= *buflen || iin >= size) | ||
break; | ||
buf[iout] = cb32[((udata[iin] & 0x1f))]; | ||
iin++; /* 4 complete, iin=5 */ | ||
iout++; | ||
} | ||
|
||
buf[iout] = '\0'; | ||
|
||
/* store number of bytes from data that was used */ | ||
*buflen = iin; | ||
|
||
return iout; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
* Copyright (c) 2006-2009 Bjorn Andersson <[email protected]>, Erik Ekman <[email protected]> | ||
* | ||
* Permission to use, copy, modify, and distribute this software for any | ||
* purpose with or without fee is hereby granted, provided that the above | ||
* copyright notice and this permission notice appear in all copies. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
*/ | ||
|
||
#ifndef __BASE32_H__ | ||
#define __BASE32_H__ | ||
|
||
int base32_encode(char *, size_t *, const void *, size_t); | ||
|
||
#endif |
Oops, something went wrong.