internetwache / GitTools

A repository with 3 tools for pwn'ing websites with .git repositories available
MIT License
3.78k stars 612 forks source link

Error gitdumper.sh: line 25: declare: -n: invalid option #15

Closed voldedore closed 6 years ago

voldedore commented 6 years ago

I am experiencing this issue while running bash gitdumper.sh (no param)

It worked well on my other Fedora machine but on my macOS at work, it throws that error.

More details: macOS 10.12 sh used: zsh (changed to bash but the same occurred)

Full error information:

╰─ bash gitdumper.sh
###########
# GitDumper is part of https://github.com/internetwache/GitTools
#
# Developed and maintained by @gehaxelt from @internetwache
#
# Use at your own risk. Usage might be illegal in certain circumstances.
# Only for educational purposes!
###########

gitdumper.sh: line 25: declare: -n: invalid option
declare: usage: declare [-afFirtx] [-p] [name[=value] ...]
\e[33m[*] USAGE: http://target.tld/.git/ dest-dir [--git-dir=otherdir]\e[0m
        --git-dir=otherdir      Change the git folder name. Default: .git
gehaxelt commented 6 years ago

Hi,

that's because zsh does not have "declare". Afaik this is a bash feature [0].

You should try: $> bash gitdumper.sh

[0] https://stackoverflow.com/questions/10194861/bash-zsh-declare-oh-my

EDIT: Sorry, didn't carefully read the issue (I'm on vacation... :)). I'm not sure, why the bash gitdumper.sh does not work? Can you try to switch to a bash first and then running the script from there?

$zsh> bash
$bash> gitdumper.sh
voldedore commented 6 years ago

Hi, Thanks for your quick reply. As mentioned from my first post, I switched to bash first then bash gitdumper.sh (even ./gitdumper.sh) but the same error keeps occuring. My PC (with fedora) is running with the same Zsh settings as my mac at work but everything worked perfectly.

Will try again next Monday by your advice. I meant I will try with the command which is only gitdumper.sh

Edited: Hope this will help you to figure out about this issue. I tested on:

I chmodded u+x the shell file and do the command with the same user.

voldedore commented 6 years ago

Hi, I finally get it resolved.

The old version of Apple's built-in bash is the cause of all this.

╰─ /bin/bash --version
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin16)
Copyright (C) 2007 Free Software Foundation, Inc.

After installing new bash from homebrew, everything seems to properly work now.

brew install bash
╰─ /usr/local/bin/bash --version
GNU bash, version 4.4.12(1)-release (x86_64-apple-darwin16.3.0)
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
╰─ /usr/local/bin/bash gitdumper.sh
###########
# GitDumper is part of https://github.com/internetwache/GitTools
#
# Developed and maintained by @gehaxelt from @internetwache
#
# Use at your own risk. Usage might be illegal in certain circumstances.
# Only for educational purposes!
###########

[*] USAGE: http://target.tld/.git/ dest-dir [--git-dir=otherdir]
        --git-dir=otherdir      Change the git folder name. Default: .git