altf4 / untwister

Seed recovery tool for PRNGs
GNU General Public License v3.0
359 stars 42 forks source link

cppunit/TestFixture.h file not found - Untwister #23

Closed NewtoCScience closed 9 years ago

NewtoCScience commented 9 years ago

Hello, hope all is well. I am new to C language and for me to learn more about testing I am attempting to mimic the Untwister with the provided files. I am using a Mac with Yosemite, Xcode, installed CPPunit, Brew installed and basically added all of the files as a new project using the command line option in Xcode.

Here is the error "/Users/Matt/Desktop/Untwister/untwister/tests/TestMt19937.h:11:10: 'cppunit/TestFixture.h' file not found":

ifndef TESTMT19937H

define TESTMT19937H

include <cppunit/TestFixture.h>

include <cppunit/extensions/HelperMacros.h>

include "../prngs/Mt19937.h"

class TestMt19937: public CPPUNIT_NS::TestFixture { CPPUNIT_TEST_SUITE(TestMt19937); CPPUNIT_TEST(initalizationTest); CPPUNIT_TEST(seedTest); CPPUNIT_TEST(randomTest); CPPUNIT_TEST_SUITE_END();

public: void setUp(void); void tearDown(void);

protected: void initalizationTest(); void seedTest(); void randomTest();

private:

};

endif /* TESTMT19937H */

A 2nd error or warning Check dependencies: warning: no rule to process file '/Users/Matt/Desktop/Untwister/untwister/Makefile' of type sourcecode.make for architecture x86_64

After searching online, not sure what the resolutions are for these two, any help is greatly appreciated.

moloch-- commented 9 years ago

Are you trying to build from within Xcode or from the command line? Untwister is built from the command line, open a terminal and cd to the untwister directory and run a make command to build untwister or make tests to build the unit tests. Since untwister is cross-platform we didn't want to rely on Xcode for compiling. However, you'll still need Xcode installed to build it since Xcode brings along the clang compiler tool chain.

NewtoCScience commented 9 years ago

Hello Moloch, thank YOU for getting back to me. Yes I was trying to make it work with Xcode, although I set the project up for command line tools. I now use the terminal only which is being responsive from your instructions. The cd (change directory) took me a day to get resolved and correctly acknowledged in the terminal. After that I tried, make tests, but received error, Makefile:8: ***missing separator.Stop.

After I did more research I inputted, od -t c Makefile and received Matrix style text back (maybe because the background is black and the text is green). I retyped all of the Makefile code in a text editor and used tab instead of the spacebar after I saw the madness, but no success still shows chaos. How can I get pass this to move on to run? Screenshots of Makefile within Xcode and a text editor are included.

Also I included a screenshot of how I set up the cpp,h, txt files in Xcode with the exact code in Github for each file. Is the setup a personal preference or if my set up is wrong, will that screw everything up?

screen shot 2015-03-04 at 6 45 12 pm screen shot 2015-03-04 at 6 45 26 pm screen shot 2015-03-04 at 6 46 28 pm screen shot 2015-03-04 at 6 38 40 pm screen shot 2015-03-04 at 6 54 01 pm

Thank you Moloch!

moloch-- commented 9 years ago

You want to run the make commands from the top level directory, for example:

$ pwd
/Users/moloch/git/untwister
$ make
g++ -std=gnu++11 -O3 -g3 -Wall -c -fmessage-length=0 -MMD -fPIC -MF"prngs/GlibcRand.d" -MT"prngs/GlibcRand.d" -o "prngs/GlibcRand.o" "./prngs/GlibcRand.cpp"
g++ -std=gnu++11 -O3 -g3 -Wall -c -fmessage-length=0 -MMD -fPIC -MF"prngs/Mt19937.d" -MT"prngs/Mt19937.d" -o "prngs/Mt19937.o" "./prngs/Mt19937.cpp"
g++ -std=gnu++11 -O3 -g3 -Wall -c -fmessage-length=0 -MMD -fPIC -MF"prngs/Ruby.d" -MT"prngs/Ruby.d" -o "prngs/Ruby.o" "./prngs/Ruby.cpp"
g++ -std=gnu++11 -O3 -g3 -Wall -c -fmessage-length=0 -MMD -fPIC -MF"prngs/LSBState.d" -MT"prngs/LSBState.d" -o "prngs/LSBState.o" "./prngs/LSBState.cpp"
g++ -std=gnu++11 -O3 -g3 -Wall -c -fmessage-length=0 -MMD -fPIC -MF"prngs/PRNGFactory.d" -MT"prngs/PRNGFactory.d" -o "prngs/PRNGFactory.o" "./prngs/PRNGFactory.cpp"
g++ -std=gnu++11 -O3 -g3 -Wall -c -fmessage-length=0 -MMD -fPIC -pthread -MF"Untwister.d" -MT"Untwister.d" -o "Untwister.o" "./Untwister.cpp"
g++ -std=gnu++11 -O3 -g3 -Wall -c -fmessage-length=0 -MMD -fPIC -pthread -MF"main.d" -MT"main.d" -o "main.o" "./main.cpp"
g++ -std=gnu++11 -O3 -pthread ./prngs/LSBState.o ./prngs/GlibcRand.o ./prngs/Mt19937.o ./prngs/Ruby.o ./prngs/PRNGFactory.o ./Untwister.o main.o -o untwister
clang: warning: argument unused during compilation: '-pthread'
$ ./untwister -h
Untwister - Recover PRNG seeds from observed values.
    -i <input_file> [-d <depth> ] [-r <prng>] [-g <seed>] [-t <threads>] [-c <confidence>]

    -i <input_file>
        Path to file input file containing observed results of your RNG. The contents
        are expected to be newline separated 32-bit integers. See test_input.txt for
        an example.
    -d <depth>
        The depth (default 1000) to inspect for each seed value when brute forcing.
        Choosing a higher depth value will make brute forcing take longer (linearly), but is
        required for cases where the generator has been used many times already.
    -r <prng>
        The PRNG algorithm to use. Supported PRNG algorithms:
         * glibc-rand (default)
         * mt19937
         * ruby-rand
    -u
        Use bruteforce, but only for unix timestamp values within a range of +/- 1 
    -b
        Always bruteforce, even if state inference attack is successful
        year from the current time.
    -g <seed>
        Generate a test set of random numbers from the given seed (at a random depth)
    -c <confidence>
        Set the minimum confidence percentage to report
    -t <threads>
        Spawn this many threads (default is 4)

$ make tests
g++ -std=gnu++11 -O3 -g3 -Wall -c -fmessage-length=0 -MMD -fPIC -MF"prngs/GlibcRand.d" -MT"prngs/GlibcRand.d" -o "prngs/GlibcRand.o" "./prngs/GlibcRand.cpp"
g++ -std=gnu++11 -O3 -g3 -Wall -c -fmessage-length=0 -MMD -fPIC -MF"prngs/Mt19937.d" -MT"prngs/Mt19937.d" -o "prngs/Mt19937.o" "./prngs/Mt19937.cpp"
g++ -std=gnu++11 -O3 -g3 -Wall -c -fmessage-length=0 -MMD -fPIC -MF"prngs/Ruby.d" -MT"prngs/Ruby.d" -o "prngs/Ruby.o" "./prngs/Ruby.cpp"
g++ -std=gnu++11 -O3 -g3 -Wall -c -fmessage-length=0 -MMD -fPIC -MF"prngs/LSBState.d" -MT"prngs/LSBState.d" -o "prngs/LSBState.o" "./prngs/LSBState.cpp"
g++ -std=gnu++11 -O3 -g3 -Wall -c -fmessage-length=0 -MMD -fPIC -MF"prngs/PRNGFactory.d" -MT"prngs/PRNGFactory.d" -o "prngs/PRNGFactory.o" "./prngs/PRNGFactory.cpp"
g++ -std=gnu++11 -O3 -g3 -Wall -c -fmessage-length=0 -MMD -fPIC -MF"./tests/TestRuby.d" -MT"./tests/TestRuby.d" -o "./tests/TestRuby.o" "./tests/TestRuby.cpp"
g++ -std=gnu++11 -O3 -g3 -Wall -c -fmessage-length=0 -MMD -fPIC -MF"./tests/TestMt19937.d" -MT"./tests/TestMt19937.d" -o "./tests/TestMt19937.o" "./tests/TestMt19937.cpp"
g++ -std=gnu++11 -O3 -g3 -Wall -c -fmessage-length=0 -MMD -fPIC -MF"./tests/TestPRNGFactory.d" -MT"./tests/TestPRNGFactory.d" -o "./tests/TestPRNGFactory.o" "./tests/TestPRNGFactory.cpp"
g++ -std=gnu++11 -O3 -g3 -Wall -c -fmessage-length=0 -MMD -fPIC -MF"./tests/TestUntwister.d" -MT"./tests/TestUntwister.d" -o "./tests/TestUntwister.o" "./tests/TestUntwister.cpp"
g++ -std=gnu++11 -O3 -g3 -Wall -c -fmessage-length=0 -MMD -fPIC -MF"./tests/runner.d" -MT"./tests/runner.d" -o "./tests/runner.o" "./tests/runner.cpp"
g++ -std=gnu++11 -O3 -pthread ./prngs/LSBState.o ./prngs/GlibcRand.o ./prngs/Mt19937.o ./prngs/Ruby.o ./prngs/PRNGFactory.o ./Untwister.o ./tests/runner.o ./tests/TestRuby.o ./tests/TestMt19937.o ./tests/TestPRNGFactory.o ./tests/TestUntwister.o -o untwister_tests -lcppunit
clang: warning: argument unused during compilation: '-pthread'
$ ./untwister_tests 
[*] Executing all unit tests, please wait....................

OK (17 tests)

You see the make command actually executes parts of the Makefile so in order for it to work the Makefile must be in teh CWD.

NewtoCScience commented 9 years ago

Hello Moloch, hope your week is going well. Thank you for the information above. My makefile is still all over the place as in the screenshots above, so I decided to use Linux/Ubuntu to see if it's successful. My issues for the Makefile may be because I copied and pasted the Makefile from Github.

Followed the information for Ubuntu and still working on it, using the terminal. For Linux/Ubuntu is there a specific program (similar to XCode) needed to work with the terminal to run tests?

Thank you Moloch.

NewtoCScience commented 9 years ago

Original inquiry resolved, thank you Moloch.