MrSlippery

Run KLEE on Einstein's Enigma

Nov 22nd, 2015
368
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.35 KB | None | 0 0
  1. # Compile the program for use with KLEE (generating LLVM bytecode).
  2. user@machine:~/einstein$ clang -I../klee/include -emit-llvm -c einstein.c
  3. einstein.c:128:3: warning: implicit declaration of function '__assert_fail' is invalid in C99 [-Wimplicit-function-declaration]
  4.   klee_assert(!(
  5.   ^
  6. ../klee/include/klee/klee.h:96:6: note: expanded from macro 'klee_assert'
  7.    : __assert_fail (#expr, __FILE__, __LINE__, __PRETTY_FUNCTION__))    \
  8.      ^
  9. 1 warning generated.
  10.  
  11. # Run KLEE on the bytecode
  12. user@machine:~/einstein$ klee --libc=uclibc --posix-runtime einstein.bc
  13. KLEE: NOTE: Using klee-uclibc : /home/user/klee/Release+Asserts/lib/klee-uclibc.bca
  14. KLEE: NOTE: Using model: /home/user/klee/Release+Asserts/lib/libkleeRuntimePOSIX.bca
  15. KLEE: output directory is "/home/user/einstein/klee-out-1"
  16. KLEE: WARNING: undefined reference to function: klee_posix_prefer_cex
  17. KLEE: WARNING ONCE: calling external: syscall(16, 0, 21505, 51755536)
  18. KLEE: WARNING ONCE: calling __user_main with extra arguments.
  19. KLEE: ERROR: (location information missing) ASSERTION FAIL: !( norwegian_first_house() && brit_house_red() && swede_pet_dog() && dane_drink_tea() && g_near_w() && green_drink_coffee() && n_near_c() && pall_pet_birds() && yellow_smoke_dunhill() && center_drink_milk() && german_smoke_prince() && n_near_w() && n_near_b() && h_near_d() && masters_drink_beer() && someone_pet_fish() )
  20. KLEE: NOTE: now ignoring this error at this location
  21.  
  22. KLEE: done: total instructions = 1776493
  23. KLEE: done: completed paths = 26958
  24. KLEE: done: generated tests = 26957
  25.  
  26. # A violation of the assertion that no solution exists was found - therefore a solution does exist, so let's see it.
  27. user@machine:~/einstein$ ls klee-last/*.assert.err
  28. klee-last/test024010.assert.err
  29. user@machine:~/einstein$ ktest-tool klee-last/test024010.ktest
  30. ktest file : 'klee-last/test024010.ktest'
  31. args       : ['einstein.bc']
  32. num objects: 2
  33. object    0: name: 'model_version'
  34. object    0: size: 4
  35. object    0: data: '\x01\x00\x00\x00'
  36. object    1: name: 'e'
  37. object    1: size: 25
  38. object    1: data: 'nycwddbhtnbrbmpswdbmggfcr'
  39.  
  40. # Let's break the result down into lines for each person.
  41. # n y c w d
  42. # d b h t n
  43. # b r b m p
  44. # s w d b m
  45. # g g f c r
  46. #     ^
  47. # The last line contains the answer: the German ('g') lives in the green ('g') house, has a pet fish ('f'), drinks coffee ('c'), and smokes Prince ('r').
Advertisement
Add Comment
Please, Sign In to add comment