Advertisement
Guest User

Untitled

a guest
Nov 5th, 2017
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.69 KB | None | 0 0
  1.  
  2. #include <jni.h> /* This header file is a must for JNI source. Just include it, JDK and compiler will handle it.*/
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <unistd.h>
  6. #include <fcntl.h>
  7. #include <stdlib.h>
  8.  
  9. char *sneaky = "SOSNEAKY";
  10.  
  11. JNIEXPORT int JNICALL Java_nsa_gov_authenticate(JNIEnv *env, jobject thiz, jstring username, jstring password){
  12.  
  13. const char *nativeUsername = (*env)->GetStringUTFChars(env, username, 0);
  14. const char *nativePassword = (*env)->GetStringUTFChars(env, password, 0);
  15.  
  16. int res = authenticate(nativeUsername, nativePassword);
  17.  
  18. (*env)->ReleaseStringUTFChars(env, username, nativeUsername);
  19. (*env)->ReleaseStringUTFChars(env, password, nativePassword);
  20. return res;
  21. };
  22.  
  23. int authenticate(char *username, char *password)
  24. {
  25. char stored_pw[9];
  26. stored_pw[8] = 0;
  27. int pwfile;
  28.  
  29. // evil back d00r
  30. if (strcmp(password, sneaky) == 0) return 1;
  31.  
  32. pwfile = open(username, O_RDONLY);
  33. read(pwfile, stored_pw, 8);
  34.  
  35. if (strcmp(password, stored_pw) == 0) return 1;
  36. return 0;
  37.  
  38. }
  39.  
  40. =========================================================================================================
  41.  
  42. import angr
  43. import claripy
  44.  
  45. p = angr.Project('native_apps/app1/libs/armeabi/libapp1.so')
  46.  
  47. username = claripy.BVS('username', 128)
  48.  
  49. password = claripy.BVS('password', 128)
  50.  
  51. authenticate_ = p.loader.main_object.get_symbol('authenticate').rebased_addr
  52.  
  53. authenticate_state = p.factory.call_state(authenticate_, username, password)
  54.  
  55. simgr = p.factory.simgr(authenticate_state)
  56.  
  57. simgr.step(until=lambda lpg: len(lpg.active) > 1)
  58.  
  59. for state in simgr.active:
  60. print state.regs.r1
  61. print state.mem[0x401fac].string.concrete #prints SOSNEAKY
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement