Skip to content

Commit 344521a

Browse files
author
rsundahl
committed
Added developer tools; nullhook.so and noophook.so.
1 parent 1974b97 commit 344521a

4 files changed

Lines changed: 17 additions & 16 deletions

File tree

Dockerfile

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,6 @@
1-
#FROM alpine:3.7
2-
#RUN apk update
3-
#RUN apk del musl-dev
4-
#RUN apk add bash curl gcc git libc-dev
5-
61
FROM centos:7.4.1708
72
RUN yum update -y
8-
RUN yum install -y bash curl gcc git libc6-dev
9-
10-
#FROM ubuntu:xenial-20180123
11-
#RUN apt-get update -y
12-
#RUN apt-get install -y curl gcc git libc6-dev
3+
RUN yum install -y bash curl gcc libc6-dev
134

145
WORKDIR /readhook
156
COPY src src
@@ -26,6 +17,8 @@ RUN ar -cvq lib/utilhook.a obj/*.o
2617
RUN mkdir ./dll
2718
RUN gcc -std=gnu99 -fstack-protector-all -fPIC -Fpie -pie src/basehook.c -Wl,-z,relro,-z,now -shared -lc -ldl lib/utilhook.a -o dll/basehook.so
2819
RUN gcc -std=gnu99 -fstack-protector-all -fPIC -Fpie -pie src/fullhook.c -Wl,-z,relro,-z,now -shared -lc -ldl lib/utilhook.a -o dll/fullhook.so
20+
RUN gcc -std=gnu99 -fstack-protector-all -fPIC -Fpie -pie src/noophook.c -Wl,-z,relro,-z,now -shared -lc -ldl lib/utilhook.a -o dll/noophook.so
21+
RUN gcc -std=gnu99 -fstack-protector-all -fPIC -Fpie -pie src/nullhook.c -Wl,-z,relro,-z,now -shared -lc -ldl lib/utilhook.a -o dll/nullhook.so
2922

3023
RUN mkdir ./app
3124
RUN gcc -std=gnu99 -fPIC -Fpie -pie -DFULLHOOK_MAIN=1 src/fullhook.c lib/utilhook.a -Wl,-z,relro,-z,now -lc -ldl -o app/fullhook

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Red-team tool to hook libc read syscall with a buffer overflow vulnerability.
33

44
## Building
5-
Readhook is a set of two "hook" routines that can be injected into an application to create an intentional buffer overflow vulnerability. The two "hook" routines can be injected individually or as a chain using LD_PRELOAD. Both "hooks" insert themselves in front of the libc->read() system call and watch for magic strings to pass. Basehook.so contains the overflow enpoint alone, while fullhook.so adds helpful endpoints that assist in generating valid shellcode that can then be turned around and used in basehook.so for the actual overflow (fullhook.so also contains . Use the following command line in the context of the OS in which you would like to hook the read syscall:
5+
Readhook consists of a set of shared libraries that can be injected into an application to create an intentional buffer overflow vulnerability. The hook routines basehook.so and fullhook.so can be injected individually or as a chain using LD_PRELOAD. Both hooks insert themselves in front of the libc->read() system call and watch for magic strings to pass. Basehook.so contains the overflow endpoint alone, while fullhook.so adds helpful endpoints that assist in generating valid shellcode that can then be turned around and used by basehook.so for the actual overflow (fullhook.so also contains an overflow endpoint for convenience). (Additionally, there are two helper hooks for developers; nullhook.so which does nothing, and noophook.so which injects itself before the libc->read() function and simply passes the request through.)
66
```
77
./build.sh
88
```

assets.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
declare -r repository=polyverse/readhook
3-
declare -r -a assets=(basehook.so fullhook.so)
3+
declare -r -a assets=(dll/basehook.so dll/fullhook.so dll/noophook.so dll/nullhook.so)
44
declare tag=$1
55

66
# If no tag is given, use the jenkins release assets

build.sh

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
#!/bin/bash
2+
# Delete the old artifacts
3+
rm -r app dll
4+
5+
# Build readhook
26
docker build --no-cache -t readhook .
37

4-
# Extract the library from the container
5-
docker run -d --rm --name readhook readhook sleep 10
6-
docker cp readhook:/readhook/dll/basehook.so $PWD/basehook.so
7-
docker cp readhook:/readhook/dll/fullhook.so $PWD/fullhook.so
8+
# Run readhook and just sleep while we copy the build artifacts
9+
docker run -d --rm --name readhook readhook sleep 60
10+
11+
# Extract the buld artifacts
12+
docker cp readhook:/readhook/dll/ $PWD/dll/
13+
docker cp readhook:/readhook/app/ $PWD/app/
14+
15+
# We're done so kill it since it's just sleeping
816
docker kill readhook

0 commit comments

Comments
 (0)