Merge branch 'hmage-master'

* hmage-master:
  move to _mm_stream_si128 folder
  Use absolute time as per PR#3.
  Fix compilation warning
  Compiles on both linux and mach
  add make clean target
  Fix compilation on 32bit
  Add makefile
This commit is contained in:
William Entriken 2016-03-04 17:32:01 -05:00
commit 1c15f939e0
4 changed files with 49 additions and 3 deletions

View File

@ -10,9 +10,9 @@ Publicly available documents already discuss exfiltration from secured systems u
How to Use It How to Use It
------------------ ------------------
Compile the program using: Compile the program using make:
gcc main.c -Wall -O2 -o main make
And run it on an Apple MacBook Air (13-inch, Early 2015): And run it on an Apple MacBook Air (13-inch, Early 2015):

View File

@ -0,0 +1,8 @@
CPPFLAGS=-Wall -O2 -msse2
main: main.c
.PHONY: clean
clean:
rm -f main

BIN
Using _mm_stream_si128/main Executable file

Binary file not shown.

View File

@ -4,10 +4,46 @@
#include <stdio.h> #include <stdio.h>
#include <emmintrin.h> #include <emmintrin.h>
#include <inttypes.h>
#include <time.h>
#ifdef __MACH__
#include <mach/mach_traps.h> #include <mach/mach_traps.h>
#include <mach/mach_time.h> #include <mach/mach_time.h>
#endif
#include <math.h> #include <math.h>
#ifndef NSEC_PER_SEC
#define NSEC_PER_SEC 1000000000ull
#endif
#ifndef __MACH__
#define TIME_ABSOLUTE CLOCK_REALTIME
typedef struct timespec mach_timespec_t;
typedef unsigned int mach_port_t;
static inline uint64_t mach_absolute_time(void) {
mach_timespec_t tp;
int res = clock_gettime(CLOCK_REALTIME, &tp);
if (res < 0) {
perror("clock_gettime");
exit(1);
}
uint64_t result = tp.tv_sec * NSEC_PER_SEC;
result += tp.tv_nsec;
return result;
}
// non-conformant wrapper just for the purposes of this application
static inline void clock_sleep_trap(mach_port_t clock_port, int sleep_type, time_t sec, long nsec, mach_timespec_t *remain) {
mach_timespec_t req = { sec, nsec };
int res = clock_nanosleep(sleep_type, TIMER_ABSTIME, &req, remain);
if (res < 0) {
perror("clock_nanosleep");
exit(1);
}
}
#endif // __MACH__
__m128i reg; __m128i reg;
__m128i reg_zero; __m128i reg_zero;
__m128i reg_one; __m128i reg_one;
@ -35,14 +71,16 @@ static inline void square_am_signal(float time, float frequency) {
int main() int main()
{ {
#ifdef __MACH__
mach_timebase_info_data_t theTimeBaseInfo; mach_timebase_info_data_t theTimeBaseInfo;
mach_timebase_info(&theTimeBaseInfo); mach_timebase_info(&theTimeBaseInfo);
puts("TESTING TIME BASE: the following should be 1 / 1"); puts("TESTING TIME BASE: the following should be 1 / 1");
printf(" Mach base: %u / %u nanoseconds\n\n", theTimeBaseInfo.numer, theTimeBaseInfo.denom); printf(" Mach base: %u / %u nanoseconds\n\n", theTimeBaseInfo.numer, theTimeBaseInfo.denom);
#endif
uint64_t start = mach_absolute_time(); uint64_t start = mach_absolute_time();
uint64_t end = mach_absolute_time(); uint64_t end = mach_absolute_time();
printf("TESTING TIME TO EXECUTE mach_absolute_time()\n Result: %lld nanoseconds\n\n", end - start); printf("TESTING TIME TO EXECUTE mach_absolute_time()\n Result: %"PRIu64" nanoseconds\n\n", end - start);
reg_zero = _mm_set_epi32(0, 0, 0, 0); reg_zero = _mm_set_epi32(0, 0, 0, 0);
reg_one = _mm_set_epi32(-1, -1, -1, -1); reg_one = _mm_set_epi32(-1, -1, -1, -1);