Advertisement
unknowns-mm

auto_priv_exploit.sh

Sep 30th, 2016
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.96 KB | None | 0 0
  1. #/bin/bash
  2.  
  3. usage(){
  4. echo "[*] Usage: $0 VERSION_OF_KERNEL";
  5. echo "[*] Example: root~> $0 2.6";
  6. exit 1;
  7. }
  8.  
  9. download(){
  10.  
  11. base="/usr/share/exploitdb/platforms"
  12. echo "[*] The base directory is $base"
  13.  
  14. [ -d "linux_$version" ] || mkdir linux_$version # make directory if not exist
  15.  
  16. for file in $file_list; do
  17. # TODO get rid of the first . if exist in file path
  18. # TODO if not exist then do the way it did
  19. echo "[*] Copying $base$file to $PWD/linux_$version/$file"
  20. cp $base$file linux_$version/ # copy the file from exploitdb to the current directory with linux_$version
  21.  
  22. file_extension=$(echo $file | cut -d '.' -f 2) # extract the file extension
  23.  
  24. # Count the file for summary
  25. case $file_extension in
  26. "c" ) c_file_count=$((c_file_count+1));;
  27. "rb" ) rb_file_count=$((rb_file_count+1));;
  28. "txt" ) txt_file_count=$((txt_file_count+1));;
  29. "py" ) py_file_count=$((py_file_count+1));;
  30. "pl" ) pl_file_count=$((pl_file_count+1));;
  31. esac
  32. done
  33. }
  34.  
  35. compile(){
  36. for file in $file_list; do
  37. file_extension=$(echo $file | cut -d '.' -f 2) # extract the file extension
  38. file_name=$(echo $file | cut -d '/' -f 4) #extrac the file name
  39. if [ "$file_extension" == "c" ]; then
  40. gcc linux_$version/$file_name -o linux_$version/"$file_name.exe" 2>/dev/null
  41. fi
  42. done
  43. }
  44.  
  45. version=$1
  46. file_list=$(searchsploit $version linux| grep local | grep -i privilege | cut -d '|' -f 2 | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
  47.  
  48. py_file_count=0
  49. txt_file_count=0
  50. rb_file_count=0
  51. c_file_count=0
  52. pl_file_count=0
  53.  
  54. main(){
  55. echo -e "[*] Possible Exploit\n"
  56. searchsploit $version linux | grep local | grep -i privilege
  57. if [ -z $file_list ]; then
  58. echo "No possible exploit. Please use another version."
  59. exit 1
  60. fi
  61.  
  62. echo "[*] Do you wish to download all the exploit script to current directory and compile if possible?"
  63. select yn in "Yes" "No"; do
  64. case $yn in
  65. Yes ) download;break;;
  66. No ) exit 1;;
  67. esac
  68. done
  69. echo "[*] Do you wish to compile all the exploit script written in C?"
  70. select yn in "Yes" "No"; do
  71. case $yn in
  72. Yes ) compile;break;;
  73. No ) break;;
  74. esac
  75. done
  76. exe_file_count=$(ls linux_$version | grep .exe -c)
  77.  
  78. echo "[*] Do you want to make a tar ball of the linux_$version? (For convinient file transfer)"
  79. select yn in "Yes" "No"; do
  80. case $yn in
  81. Yes ) tar -cf linux_$version.tar linux_$version;break;;
  82. No ) break;;
  83. esac
  84. done
  85.  
  86. echo "[*] Auto Privilege Exploit Summary"
  87. echo "C file in $PWD/linux_$version has $c_file_count files"
  88. echo "Python file in $PWD/linux_$version has $py_file_count files"
  89. echo "Perl file in $PWD/linux_$version has $pl_file_count files"
  90. echo "Ruby file in $PWD/linux_$version has $rb_file_count files"
  91. echo "TXT file in $PWD/linux_$version has $txt_file_count files"
  92. echo ""
  93. echo "[*] Successfully Compiled $exe_file_count executable located in linux_$version"
  94.  
  95. }
  96.  
  97.  
  98. if [ $# -ne 1 ]; then
  99. usage
  100. fi
  101. main
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement