├── covert_channel_eval ├── run.sh ├── Makefile ├── README.md ├── validate.py ├── main.c └── recv.txt ├── website_classify ├── requirements.txt └── classify2.py ├── Intel-umwait ├── Makefile ├── README.md └── hist.c ├── comparison ├── fr │ ├── Makefile │ └── main.c ├── pp │ ├── Makefile │ ├── eviction.h │ ├── main.c │ └── eviction.c ├── ps │ ├── Makefile │ ├── eviction.h │ ├── main.c │ └── eviction.c ├── naive-tsx │ ├── Makefile │ └── main.c ├── umwait │ ├── Makefile │ └── main.c └── README.md ├── spectral ├── Makefile ├── test.sh ├── README.md ├── main.c └── cacheutils.h ├── timed_mwait_feat ├── run.sh ├── Makefile ├── enable-msr.sh ├── README.md └── hello.c ├── aes_example ├── umwait │ ├── Makefile │ └── main.cpp ├── fr │ ├── Makefile │ └── spy.cpp ├── calibration │ ├── Makefile │ ├── README.md │ ├── pad.c │ └── main.c ├── pp │ ├── eviction.h │ ├── Makefile │ ├── spy.cpp │ └── eviction.c └── README.md ├── irq_monitor ├── arm │ ├── Makefile │ ├── README.md │ └── main.c └── x86 │ ├── Makefile │ ├── README.md │ └── main.c ├── website_fingerprinting ├── plot.py ├── run.sh ├── collect.sh ├── list_15.txt ├── Makefile ├── README.md ├── find_core.py ├── list.txt ├── main.c └── list_500.txt ├── trigger-tester ├── enable-msr.sh ├── Makefile ├── README.md ├── r0e.h ├── hist.c └── cacheutils.h ├── README.md └── LICENSE /covert_channel_eval/run.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | make 3 | ./main 4 | ./validate.py 5 | -------------------------------------------------------------------------------- /website_classify/requirements.txt: -------------------------------------------------------------------------------- 1 | sklearn 2 | sktime 3 | pandas 4 | tikzplotlib 5 | -------------------------------------------------------------------------------- /Intel-umwait/Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | gcc hist.c -Os -lpthread -o hist 3 | clean: 4 | rm -f hist -------------------------------------------------------------------------------- /comparison/fr/Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | gcc main.c -o test -Os -pthread 3 | clean: 4 | rm -f test 5 | -------------------------------------------------------------------------------- /comparison/pp/Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | gcc *.c -o test -Os -pthread -lm 3 | clean: 4 | rm -f test 5 | -------------------------------------------------------------------------------- /comparison/ps/Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | gcc *.c -o test -Os -pthread -lm 3 | clean: 4 | rm -f test 5 | -------------------------------------------------------------------------------- /comparison/naive-tsx/Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | gcc main.c -o test -Os -pthread 3 | clean: 4 | rm -f test 5 | -------------------------------------------------------------------------------- /comparison/umwait/Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | gcc main.c -o main -Os -pthread 3 | clean: 4 | rm -f main 5 | -------------------------------------------------------------------------------- /covert_channel_eval/Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | gcc main.c -Os -lpthread -o main 3 | clean: 4 | rm -f main 5 | 6 | -------------------------------------------------------------------------------- /spectral/Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | gcc main.c -lpthread -o main -static -lm -O3 3 | clean: 4 | rm -f main 5 | 6 | -------------------------------------------------------------------------------- /timed_mwait_feat/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | sudo ./enable-msr.sh 3 | make 4 | sudo insmod hello.ko && sleep 1 && sudo rmmod hello 5 | 6 | sudo dmesg | grep "Avg:" 7 | -------------------------------------------------------------------------------- /covert_channel_eval/README.md: -------------------------------------------------------------------------------- 1 | # Covert Channel 2 | 3 | Creates a simple covert channel with umonitor 4 | 5 | Run using `./run.sh` to evaluate the covert channel. 6 | -------------------------------------------------------------------------------- /aes_example/umwait/Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | g++ -std=gnu++11 main.cpp -O0 -lpthread -o main -g -I/home/rzhang/openssl/include/openssl/ -L/home/rzhang/openssl/ -lcrypto 3 | clean: 4 | rm -f main 5 | 6 | -------------------------------------------------------------------------------- /aes_example/fr/Makefile: -------------------------------------------------------------------------------- 1 | all: spy 2 | clean: 3 | rm -f *.o spy 4 | spy: spy.cpp ../cacheutils.h 5 | g++ -std=gnu++11 -O2 -o $@ $< -I/home/rzhang/openssl/include/openssl/ -L/home/rzhang/openssl/ -lcrypto 6 | -------------------------------------------------------------------------------- /timed_mwait_feat/Makefile: -------------------------------------------------------------------------------- 1 | obj-m += hello.o 2 | 3 | KVERSION = $(shell uname -r) 4 | 5 | all: 6 | make -C /lib/modules/$(KVERSION)/build M=$(PWD) modules 7 | clean: 8 | make -C /lib/modules/$(KVERSION)/build M=$(PWD) clean -------------------------------------------------------------------------------- /irq_monitor/arm/Makefile: -------------------------------------------------------------------------------- 1 | all: umonitor monitorx 2 | 3 | umonitor: 4 | gcc main.c -Os -lpthread -o main -pthread -lrt -DUMONITOR 5 | monitorx: 6 | gcc main.c -Os -lpthread -o main -pthread -lrt -DMONITORX 7 | 8 | clean: 9 | rm -f main 10 | 11 | -------------------------------------------------------------------------------- /aes_example/calibration/Makefile: -------------------------------------------------------------------------------- 1 | all: pad Ttable 2 | 3 | pad: 4 | gcc pad.c -Os -lpthread -o pad 5 | Ttable: 6 | gcc main.c -Os -lpthread -o Ttable -g -I/home/rzhang/openssl/include/openssl/ -L/home/rzhang/openssl/ -lcrypto 7 | clean: 8 | rm -f pad Ttable 9 | 10 | -------------------------------------------------------------------------------- /Intel-umwait/README.md: -------------------------------------------------------------------------------- 1 | # UMONITOR/UMWAIT Test 2 | 3 | Tests if the `umonitor/umwait` instructions work on the current processor. 4 | 5 | Run using `./hist`. Press `return` to start the trigger thread on a different CPU. The number of wakeups per second should increase if this intruction pair works. -------------------------------------------------------------------------------- /website_fingerprinting/plot.py: -------------------------------------------------------------------------------- 1 | import matplotlib.pyplot as plt 2 | import sys 3 | 4 | legends = [] 5 | for p in sys.argv[1:]: 6 | d = [ int(x) for x in open(p).read().strip().split("\n") ] 7 | plt.plot(d) 8 | legends.append(p) 9 | plt.legend(legends) 10 | plt.show() 11 | 12 | -------------------------------------------------------------------------------- /website_fingerprinting/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | count=10 3 | 4 | while read -r line 5 | do 6 | domain=$(echo "$line" | awk -F/ '{print $3}' | sed 's/\./ /g' | awk '{print $2}') 7 | echo "Collecting $domain ($line)" 8 | ./collect.sh "$line" "$domain" $count 9 | done < results/list.txt 10 | -------------------------------------------------------------------------------- /comparison/pp/eviction.h: -------------------------------------------------------------------------------- 1 | #ifndef EVICTION_H 2 | #define EVICTION_H 3 | 4 | typedef struct elem 5 | { 6 | struct elem *next; 7 | struct elem *prev; 8 | int set; 9 | size_t delta; 10 | char pad[32]; // up to 64B 11 | } Elem; 12 | 13 | Elem* evset_find(void* addr); 14 | 15 | #endif /* EVICTION_H */ 16 | -------------------------------------------------------------------------------- /comparison/ps/eviction.h: -------------------------------------------------------------------------------- 1 | #ifndef EVICTION_H 2 | #define EVICTION_H 3 | 4 | typedef struct elem 5 | { 6 | struct elem *next; 7 | struct elem *prev; 8 | int set; 9 | size_t delta; 10 | char pad[32]; // up to 64B 11 | } Elem; 12 | 13 | Elem* evset_find(void* addr); 14 | 15 | #endif /* EVICTION_H */ 16 | -------------------------------------------------------------------------------- /timed_mwait_feat/enable-msr.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #enable and make performance counters available, run it with sudo 4 | modprobe msr 5 | echo "2" > /sys/devices/cpu/rdpmc 6 | 7 | #enable timed Mwait 8 | sudo bash -c 'modprobe msr; CUR=$(rdmsr 0xe2); ENABLED=$(printf "%x" $((0x$CUR | 2147483648))); wrmsr -a 0xe2 0x$ENABLED' 9 | -------------------------------------------------------------------------------- /trigger-tester/enable-msr.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #enable and make performance counters available, run it with sudo 4 | modprobe msr 5 | echo "2" > /sys/devices/cpu/rdpmc 6 | 7 | #enable timed Mwait 8 | sudo bash -c 'modprobe msr; CUR=$(rdmsr 0xe2); ENABLED=$(printf "%x" $((0x$CUR | 2147483648))); wrmsr -a 0xe2 0x$ENABLED' 9 | -------------------------------------------------------------------------------- /aes_example/pp/eviction.h: -------------------------------------------------------------------------------- 1 | #ifndef EVICTION_H 2 | #define EVICTION_H 3 | 4 | typedef struct elem 5 | { 6 | struct elem *next; 7 | struct elem *prev; 8 | int set; 9 | size_t delta; 10 | char pad[32]; // up to 64B 11 | } Elem; 12 | 13 | //Elem* evset_find(void* addr); 14 | 15 | #endif /* EVICTION_H */ 16 | -------------------------------------------------------------------------------- /spectral/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | rm -f log.txt log.csv 4 | touch log.txt log.csv 5 | for to in $(seq 20000 1000 200000); 6 | do 7 | echo $to 8 | echo ": $to" >> log.txt 9 | sudo wrmsr -a 0xe1 $(printf "0x%x" $to) 10 | ./main 3 | tee res.txt 11 | cat res.txt >> log.txt 12 | echo $to,$(tail -1 res.txt) >> log.csv 13 | done 14 | sudo wrmsr -a 0xe1 0x186a0 15 | -------------------------------------------------------------------------------- /irq_monitor/x86/Makefile: -------------------------------------------------------------------------------- 1 | all: umonitor monitorx monitor 2 | 3 | umonitor: 4 | gcc main.c -Os -lpthread -o intel-umonitor -pthread -lrt -DUMONITOR 5 | monitorx: 6 | gcc main.c -Os -lpthread -o amd-monitorx -pthread -lrt -DMONITORX 7 | monitor: 8 | gcc main.c -Os -lpthread -o monitor -pthread -lrt -DMONITOR 9 | 10 | clean: 11 | rm -f intel-umonitor amd-monitorx monitor 12 | 13 | -------------------------------------------------------------------------------- /aes_example/calibration/README.md: -------------------------------------------------------------------------------- 1 | # UMWAIT Calibration for AES T-table Attacks 2 | 3 | Find an appropriate padding for distinguishing cache hits from cache misses by `./pad` 4 | 5 | Then update the length of padding in `main.c T_INIT` 6 | 7 | Find T-table addresses by `./Ttable` 8 | 9 | Execute `export LD_LIBRARY_PATH=/home/rzhang/openssl:$LD_LIBRARY_PATH` before finding T-table Addresses 10 | -------------------------------------------------------------------------------- /irq_monitor/arm/README.md: -------------------------------------------------------------------------------- 1 | # Interrupt detection on ARMv8 2 | 3 | Detects hardware interrupts using `wfi`. 4 | 5 | Set `CORE_VICTIM` to the core that handles network interrupts (check `/proc/interrupts`). 6 | Run `./main`. In parallel, on any (other) core, run `bash -c 'while [ 1 ]; do curl localhost; done'`. 7 | You should see **increases in wakeups** while the network card handles the connection. 8 | -------------------------------------------------------------------------------- /aes_example/pp/Makefile: -------------------------------------------------------------------------------- 1 | CXX = g++ 2 | CXXFLAGS = -std=gnu++11 -I/home/rzhang/openssl/include/openssl/ -L/home/rzhang/openssl/ -lcrypto 3 | CC = gcc 4 | CCFLAGS = -lm 5 | OBJS = spy.o eviction.o 6 | 7 | all: spy 8 | clean: 9 | rm -f *.o spy 10 | spy : $(OBJS) 11 | $(CXX) -o $@ $(OBJS) $(CXXFLAGS) 12 | 13 | %.o : %.cpp 14 | $(CXX) -c $(CXXFLAGS) $< 15 | 16 | %.o : %.c 17 | $(CC) -c $(CCFLAGS) $< 18 | -------------------------------------------------------------------------------- /trigger-tester/Makefile: -------------------------------------------------------------------------------- 1 | all: umonitor monitor monitorx monitor-intel 2 | 3 | umonitor: 4 | gcc hist.c -Os -lpthread -o test-umonitor -DUMONITOR 5 | monitor: 6 | gcc hist.c -Os -lpthread -o test-monitor -DMONITOR 7 | monitorx: 8 | gcc hist.c -Os -lpthread -o test-monitorx -DMONITORX 9 | monitor-intel: 10 | gcc hist.c -Os -lpthread -o test-monitor-intel -DMONITOR_INTEL 11 | 12 | 13 | clean: 14 | rm -f hist 15 | 16 | -------------------------------------------------------------------------------- /website_fingerprinting/collect.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | function usage { 4 | echo "collect