aboutsummaryrefslogtreecommitdiff
path: root/libtokencap
diff options
context:
space:
mode:
authorDavid Carlier <devnexen@gmail.com>2019-10-29 15:06:20 +0000
committerDavid Carlier <devnexen@gmail.com>2019-10-29 15:06:20 +0000
commitc87210820c1566c74bf08ab4345679598cabd71b (patch)
tree6ca4ff5ea768c16e5416240822d0d2533747d43a /libtokencap
parentee9b2522a37e4ca70891674619c107e8a32e7324 (diff)
downloadAFLplusplus-c87210820c1566c74bf08ab4345679598cabd71b.tar.gz
libtokencap update proposal
- bcmp interception. - FreeBSD using default argument to get current pid for the mapping data gathering, getpid seems to cause some issues under certain conditions (getenv call).
Diffstat (limited to 'libtokencap')
-rw-r--r--libtokencap/libtokencap.so.c28
1 files changed, 24 insertions, 4 deletions
diff --git a/libtokencap/libtokencap.so.c b/libtokencap/libtokencap.so.c
index 7e55963c..2fe9ae63 100644
--- a/libtokencap/libtokencap.so.c
+++ b/libtokencap/libtokencap.so.c
@@ -115,7 +115,7 @@ static void __tokencap_load_mappings(void) {
#elif defined __FreeBSD__ || defined __OpenBSD__ || defined __NetBSD__
#if defined __FreeBSD__
- int mib[] = {CTL_KERN, KERN_PROC, KERN_PROC_VMMAP, getpid()};
+ int mib[] = {CTL_KERN, KERN_PROC, KERN_PROC_VMMAP, -1};
#elif defined __OpenBSD__
int mib[] = {CTL_KERN, KERN_PROC_VMMAP, getpid()};
#elif defined __NetBSD__
@@ -134,9 +134,7 @@ static void __tokencap_load_mappings(void) {
#endif
buf = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0);
- if (!buf) {
- return;
- }
+ if (buf == MAP_FAILED) return;
if (sysctl(mib, miblen, buf, &len, NULL, 0) == -1) {
@@ -354,6 +352,28 @@ int memcmp(const void* mem1, const void* mem2, size_t len) {
}
+#undef bcmp
+
+int bcmp(const void* mem1, const void* mem2, size_t len) {
+
+ if (__tokencap_is_ro(mem1)) __tokencap_dump(mem1, len, 0);
+ if (__tokencap_is_ro(mem2)) __tokencap_dump(mem2, len, 0);
+
+ const char *strmem1 = (const char *)mem1;
+ const char *strmem2 = (const char *)mem2;
+
+ while (len--) {
+
+ int diff = *strmem1 ^ *strmem2;
+ if (diff != 0) return 1;
+ strmem1++;
+ strmem2++;
+
+ }
+
+ return 0;
+}
+
#undef strstr
char* strstr(const char* haystack, const char* needle) {