Newer
Older
CHaS / PEaS.pl
root on 7 May 2019 8 KB Initial commit
  1. #!/usr/bin/perl
  2. # By NaN
  3. #
  4. # Requirements:
  5. # aha https://github.com/masukomi/aha
  6. # sslscan https://github.com/rbsec/sslscan
  7. # testssl https://github.com/drwetter/testssl.sh
  8. # securityheaders https://github.com/juerkkil/securityheaders
  9. # nmap https://nmap.org
  10. # nikto https://github.com/sullo/nikto
  11. # dirb https://sourceforge.net/projects/dirb/files/
  12. # wig https://github.com/jekyc/wig
  13. # davtest https://github.com/cldrn/davtest
  14. # wafw00f https://github.com/EnableSecurity/wafw00f
  15. # whatweb https://github.com/urbanadventurer/whatweb
  16. # metagoofil https://github.com/kurobeats/metagoofil
  17. # spaghetti https://github.com/m4ll0k/Spaghetti
  18.  
  19. use Socket;
  20. use URI;
  21.  
  22. # command or path to pentest tools
  23. # comment out to disable - e.g. nmap
  24. my $sslscan = "sslscan"; # sslscan
  25. my $testssl = "testssl"; # testssl.sh
  26. my $headers = "/opt/securityheaders/securityheaders.py"; # securityheaders
  27. #my $nmap = "nmap"; # nmap
  28. my $nikto = "nikto"; # nikto
  29. #my $dirb = "dirb"; # dirb
  30. my $wig = "/opt/wig/wig.py"; # wig
  31. my $davtest = "davtest"; # davtest
  32. my $wafw00f = "wafw00f"; # wafw00f
  33. my $whatweb = "whatweb"; # whatweb
  34. #my $metagoo = "metagoofil"; # metagoofil
  35. #my $spaghet = "/opt/Spaghetti/spaghetti.py"; # spaghetti
  36.  
  37. # misc
  38. my $aha = "aha"; # aha
  39. my $browser = "thunar"; # your file browser - remove to disable
  40.  
  41. if($#ARGV < 1){
  42. print "Pre-Pentest Enumeration and Scanning v0.1\n";
  43. print "Usage: ./PEaS.pl </full/directory/path> <https://www.url.com>\n";
  44. exit(-1);
  45. }else{
  46. my $dir = $ARGV[0];
  47. my $url = $ARGV[1];
  48. my @children_pids;
  49.  
  50. if($url =~ /^(?:(?:http?|s))/i){}else{
  51. die "[!] Not a valid URL!\n";
  52. }
  53.  
  54. print "[i] Directory: $dir \n";
  55. print "[i] URL: $url \n";
  56.  
  57. my $uri = URI->new( $url );
  58. my $ip_addr = gethostbyname( $uri->host );
  59. $ip_addr = inet_ntoa( $ip_addr );
  60. print "[i] IP address: $ip_addr \n";
  61.  
  62.  
  63. print "[+] Creating Directory\n";
  64. unless(mkdir($dir, 0755)) {
  65. die "[!] Unable to create!\n";
  66. }
  67.  
  68. if(defined($sslscan)){
  69. my $pid = fork();
  70. if( $pid == 0 ){
  71. push @children_pids, $pid;
  72. if($url =~ /https/){
  73. print "[+] Launching SSLScan\n";
  74. system("$sslscan $url | aha >$dir/sslscan.html");
  75. print "[+] Finished SSLScan\n";
  76. }else{
  77. print "[-] Skipping SSLScan\n";
  78. }
  79. exit 0;
  80. }
  81. }
  82.  
  83. if(defined($testssl)){
  84. my $pid2 = fork();
  85. if( $pid2 == 0){
  86. push @children_pids, $pid2;
  87. if($url =~ /https/){
  88. print "[+] Launching testssl.sh\n";
  89. system("$testssl $url | aha >$dir/testssl.html");
  90. print "[+] Finished testssl.sh\n";
  91. }else{
  92. print "[-] Skipping testssl.sh\n";
  93. }
  94. exit 0;
  95. }
  96. }
  97.  
  98. if(defined($headers)){
  99. my $pid3 = fork();
  100. if( $pid3 == 0 ){
  101. push @children_pids, $pid3;
  102. print "[+] Checking Headers\n";
  103. system(" echo \"curl -Is --insecure $url\n\" > $dir/headers.txt");
  104. system("curl -Is --insecure $url >> $dir/headers.txt");
  105. system("python $headers $url | aha >$dir/headers.html");
  106. print "[+] Finished Headers\n";
  107. exit 0;
  108. }
  109. }
  110.  
  111. if(defined($nmap)){
  112. my $pid4 = fork();
  113. if( $pid4 == 0 ){
  114. push @children_pids, $pid4;
  115. print "[+] Launching nmap\n";
  116. system("$nmap -p- -A -Pn -sT -oA $dir/nmap $ip_addr >/dev/null");
  117. print "[+] Finished nmap\n";
  118. exit 0;
  119. }
  120. }
  121.  
  122. if(defined($nikto)){
  123. my $pid5 = fork();
  124. if( $pid5 == 0 ){
  125. push @children_pids, $pid5;
  126. print "[+] Launching nikto\n";
  127. system("$nikto -nointeractive -output $dir/nikto.txt -host $url >/dev/null");
  128. print "[+] Finished nikto\n";
  129. exit 0;
  130. }
  131. }
  132.  
  133. if(defined($dirb)){
  134. my $pid6 = fork();
  135. if( $pid6 == 0 ){
  136. push @children_pids, $pid6;
  137. print "[+] Launching dirb\n";
  138. system("$dirb $url -o $dir/dirb.txt >/dev/null");
  139. print "[+] Finished dirb\n";
  140. exit 0;
  141. }
  142. }
  143.  
  144. if(defined($wig)){
  145. my $pid7 = fork();
  146. if( $pid7 == 0 ){
  147. push @children_pids, $pid7;
  148. print "[+] Launching wig\n";
  149. system("python3 $wig -q $url | aha >$dir/wig.html");
  150. print "[+] Finished wig\n";
  151. exit 0;
  152. }
  153. }
  154.  
  155. if(defined($davtest)){
  156. my $pid8 = fork();
  157. if( $pid8 == 0 ){
  158. push @children_pids, $pid8;
  159. print "[+] Launching davtest\n";
  160. system("$davtest -cleanup -quiet -url $url >$dir/davtest.txt");
  161. print "[+] Finished davtest\n";
  162. exit 0;
  163. }
  164. }
  165.  
  166. if(defined($wafw00f)){
  167. my $pid9 = fork();
  168. if( $pid9 == 0 ){
  169. push @children_pids, $pid9;
  170. print "[+] Launching wafw00f\n";
  171. system("$wafw00f $url >$dir/wafw00f.txt");
  172. print "[+] Finished wafw00f\n";
  173. exit 0;
  174. }
  175. }
  176.  
  177. if(defined($whatweb)){
  178. my $pid10 = fork();
  179. if( $pid10 == 0 ){
  180. push @children_pids, $pid10;
  181. print "[+] Launching whatweb\n";
  182. system("$whatweb --no-errors -a 3 $url | aha >$dir/whatweb.html");
  183. print "[+] Finished whatweb\n";
  184. exit 0;
  185. }
  186. }
  187.  
  188. if(defined($metagoo)){
  189. my $pid11 = fork();
  190. if( $pid11 == 0 ){
  191. push @children_pids, $pid10;
  192. print "[+] Launching metagoofil\n";
  193. print "[+] Creating Directory\n";
  194. mkdir("$dir/downloaded_docs", 0755);
  195. system("$metagoo -d $url -t pdf,doc,xls,ppt,docx,xlsx,pptx -l 100 -h yes -o $dir/downloaded_docs -f $dir/metagoofil.html");
  196. print "[+] Finished metagoofil\n";
  197. exit 0;
  198. }
  199. }
  200.  
  201. if(defined($spaghet)){
  202. my $pid12 = fork();
  203. if( $pid12 == 0 ){
  204. push @children_pids, $pid3;
  205. print "[+] Launching spaghetti\n";
  206. system("python $spaghet -u $url | aha >$dir/spaghetti.html");
  207. print "[+] Finished spaghetti\n";
  208. exit 0;
  209. }
  210. }
  211.  
  212. my $loop = 1;
  213. $SIG{CHLD} = 'DEFAULT'; # turn off auto reaper
  214. $SIG{INT} = $SIG{TERM} = sub {$loop = 0; kill -15 => @children_pids};
  215. while ($loop && getppid() != 1) {
  216. my $child = waitpid(-1, 0);
  217. last if $child == -1;
  218. }
  219.  
  220. if( length $browser ){
  221. print "[!] Launching file browser\n";
  222. system("$browser $dir &");
  223. }else{
  224. print "[!] Complete\n";
  225. }
  226. exit();
  227. }
  228.  
Buy Me A Coffee