Skip to content

Commit

Permalink
C++11 port
Browse files Browse the repository at this point in the history
  • Loading branch information
EzoeRyou committed Mar 2, 2016
1 parent 681e525 commit 9b4a17c
Show file tree
Hide file tree
Showing 4 changed files with 116 additions and 82 deletions.
21 changes: 21 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
all : gmain cmain

clean :
rm -f gmain
rm -f cmain

grun : gmain
./gmain

crun : cmain
./cmain


gmain : main.cpp
g++ -Wall -O2 -std=c++11 -pthread -lrt -o gmain main.cpp

cmain : main.cpp
clang++ -Wall -O2 -std=c++11 -stdlib=libc++ -pthread -lrt -o cmain main.cpp


.PHONY : all clean run
26 changes: 22 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,31 @@ Publicly available documents already discuss exfiltration from secured systems u

How to Use It
------------------
Compile the problem using:
You need a decent C++11 implementation(GCC or Clang)
Compile the program by make:

gcc main.c -Wall -O2 -o main
If you have GCC:

And run it on an Apple MacBook Air (13-inch, Early 2015):
make gmain

If you have Clang:

make cmain

If you have both:

make

And run it on your computer:

For GCC:

make grun

For Clang:

make crun

./main

Then use a Sony STR-K670P radio receiver with the included antenna and tune it to 1580 kHz on AM.

Expand Down
78 changes: 0 additions & 78 deletions main.c

This file was deleted.

73 changes: 73 additions & 0 deletions main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
// SYSTEM BUS RADIO
// https://github.com/fulldecent/system-bus-radio
// Copyright 2016 William Entriken
// C++11 port by Ryou Ezoe

#include <iostream>
#include <iomanip>
#include <chrono>
#include <thread>
#include <atomic>

void square_am_signal(float time, float frequency)
{
using namespace std::chrono ;

std::cout << "Playing / " << time << " seconds / " << frequency << " Hz\n" ;

seconds const sec{1} ;
nanoseconds const nsec{ sec } ;
using rep = nanoseconds::rep ;
auto nsec_per_sec = nsec.count() ;

nanoseconds const period( static_cast<rep>( nsec_per_sec / frequency) ) ;

auto start = high_resolution_clock::now() ;
auto const end = start + nanoseconds( static_cast<rep>(time * nsec_per_sec) ) ;

while (high_resolution_clock::now() < end)
{
auto mid = start + period / 2 ;
auto reset = start + period ;
while (high_resolution_clock::now() < mid)
{
std::atomic<unsigned> x{0} ;
++x ;
}
std::this_thread::sleep_until( reset ) ;
start = reset;
}
}

int main()
{
while (1)
{
square_am_signal(0.400, 2673);
square_am_signal(0.400, 2349);
square_am_signal(0.400, 2093);
square_am_signal(0.400, 2349);
square_am_signal(0.400, 2673);
square_am_signal(0.400, 2673);
square_am_signal(0.790, 2673);
square_am_signal(0.400, 2349);
square_am_signal(0.400, 2349);
square_am_signal(0.790, 2349);
square_am_signal(0.400, 2673);
square_am_signal(0.400, 3136);
square_am_signal(0.790, 3136);
square_am_signal(0.400, 2673);
square_am_signal(0.400, 2349);
square_am_signal(0.400, 2093);
square_am_signal(0.400, 2349);
square_am_signal(0.400, 2673);
square_am_signal(0.400, 2673);
square_am_signal(0.400, 2673);
square_am_signal(0.400, 2673);
square_am_signal(0.400, 2349);
square_am_signal(0.400, 2349);
square_am_signal(0.400, 2673);
square_am_signal(0.400, 2349);
square_am_signal(0.790, 2093);
}
}

0 comments on commit 9b4a17c

Please sign in to comment.