• Home
  • News
  • Software
  • Knowledge
  • MMO
  • Tips
  • Security
  • Network
  • Office
AnonyViet - English Version
  • Home
  • News
  • Software
  • Knowledge
  • MMO
  • Tips
  • Security
  • Network
  • Office
No Result
View All Result
  • Home
  • News
  • Software
  • Knowledge
  • MMO
  • Tips
  • Security
  • Network
  • Office
No Result
View All Result
AnonyViet - English Version
No Result
View All Result

The dangers of the .git . directory

AnonyViet by AnonyViet
May 26, 2023
in Security
0

Have you tried browsing to http://yoursite.com/.git/ ? If you get a 403 error, that’s normal. Because directory browsing has blocked this access, this is a basic security feature. However, many files in the directory .git/ still accessible. So it is extremely dangerous, in this article, I will demo how to exploit the .git directory for you to see.

Join the channel Telegram belong to AnonyViet ???? Link ????

The dangers of the .git . directory

The dangers of the .git . directory

Anyone can use automated scanning tools like githacker to load your source code and see the full git history. Git It’s also a file system that follows some rules, so it’s easy to guess directories and files.

Most projects use masteror mainas the main branch, so you can easily guess the hidden path in the directory /.git/. This tool can even brute force branches and tags.

If the scan is successful, you will get the folderresulton your machine (you can customize the folder name with the option --output-dir).

Do not deloy or block access to the .git . directory

Folder .git/can contain a lot of information, including source code as well as name, email and in the worst case information accuracy encrypted (e.g. database, token, key).

You should completely block public access to that folder. Modern CI/CD and deployment solutions are relatively easy to configure and can remove directories that have nothing to do with production environments.

Some web hosting providers also block access to this directory for security reasons, but they do not always do so and it is not the default configuration. . So you need to double check your system configuration before deloying anything.

You can perform the following solutions to make your system more secure:

  1. Turn off directory public access .git/ by default
  2. Add a rule that forbids access to directories in the source code, e.g. Apache configuration files .htaccess
  3. Do not deploy such folders in public folders

Should return 404 for directory.git/in server configuration or file .htaccess:

RedirectMatch 404 /\.git

You should add both rules if possible, as two layers of security. In case someone modifies.htaccessand delete the rule, there is still the backup rule in the directory .git/. But as far as I know, the use of file .htaccess will slow down apache http server.

Demo how to exploit the .git . directory

I created 2 virtual machines, Ubuntu (Server) and Kali (Attacker). In the server, I use nginx to do the webserver, I create the file index.php and commit the first time to git.

The dangers of the .git 11 directory

The dangers of the .git 12 . directory

Then create a file conn.php containing the password as sensitive data and add this file to git and then stash this change.

The dangers of the .git 13 directory

When accessing the .git path, we will be blocked due to nginx’s security mechanism.

The dangers of the .git 14 . directory

That’s the basic setup on the server. Now we will proceed to exploit this bug.

On kali, you run the following command to install GitHacker:

python3 -m pip install -i https://pypi.org/simple/ GitHacker

As you can see in the image below, gitHacker will be installed in the path /home/user/.local/bin.

The dangers of the .git 15 . directory

You access this path and run the command. Replace IP-SERVER with the ip of your server.

python3 githacker --url http://IP-SERVER/.git/ --output-folder result

Go to the result directory, you will see the server’s commit.

The dangers of the .git 16 . directory

Check logs and stash.

The dangers of the .git 17 . directory

Restore the previously saved stash and we will have a conn.php file.

The dangers of the .git 18 . directory

So I have successfully exploited it, don’t for the sake of convenience to pull the repo on production but always deloy the .git directory.

Rate this post

Tags: .gitdangersDirectory
Previous Post

How to create a simple Virus scanner using Virus Total’s API

Next Post

3 ways to save chat history with ChatGPT

AnonyViet

AnonyViet

Related Posts

How to implement Shellcode Injection attack technique with Autoit
Security

How to implement Shellcode Injection attack technique with Autoit

March 14, 2025
How to exploit the holy hole of Hijacking on Windows
Security

How to exploit the holy hole of Hijacking on Windows

March 8, 2025
Hamamal: Shellcode execution technique from afar to overcome Antivirus's discovery
Security

Hamamal: Shellcode execution technique from afar to overcome Antivirus's discovery

February 10, 2025
Snov.io Email Finder: Search emails with only company name/domain name/LinkedIn profile
Security

Snov.io Email Finder: Search emails with only company name/domain name/LinkedIn profile

December 14, 2024
Capsolver: Automatic solution solution for business
Security

Capsolver: Automatic solution solution for business

December 12, 2024
Seekr: Collect & manage OSINT data
Security

Seekr: Collect & manage OSINT data

November 22, 2024
Next Post
3 ways to save chat history with ChatGPT

3 ways to save chat history with ChatGPT

0 0 votes
Article Rating
Subscribe
Login
Notify of
guest

guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments

Recent News

[Godot Shooter] #2: Creating characters & shooting bullets

[Godot Shooter] #2: Creating characters & shooting bullets

June 7, 2025

Tải App 89Bet Để Trải Nghiệm Không Giới Hạn

June 6, 2025
What do you need to learn game programming? Is it difficult? How long does it take?

What do you need to learn game programming? Is it difficult? How long does it take?

June 6, 2025
Guide to search law with AI quickly and accurately

Guide to search law with AI quickly and accurately

June 6, 2025
[Godot Shooter] #2: Creating characters & shooting bullets

[Godot Shooter] #2: Creating characters & shooting bullets

June 7, 2025

Tải App 89Bet Để Trải Nghiệm Không Giới Hạn

June 6, 2025
What do you need to learn game programming? Is it difficult? How long does it take?

What do you need to learn game programming? Is it difficult? How long does it take?

June 6, 2025
AnonyViet - English Version

AnonyViet

AnonyViet is a website share knowledge that you have never learned in school!

We are ready to welcome your comments, as well as your articles sent to AnonyViet.

Follow Us

Contact:

Email: anonyviet.com[@]gmail.com

Main Website: https://anonyviet.com

Recent News

[Godot Shooter] #2: Creating characters & shooting bullets

[Godot Shooter] #2: Creating characters & shooting bullets

June 7, 2025

Tải App 89Bet Để Trải Nghiệm Không Giới Hạn

June 6, 2025
  • Home
  • Home 2
  • Home 3
  • Home 4
  • Home 5
  • Home 6
  • Next Dest Page
  • Sample Page

©2024 AnonyVietFor Knowledge kqxs hôm nay xem phim miễn phí SHBET https://kubet88.yoga/ bj88

No Result
View All Result
  • Home
  • News
  • Software
  • Knowledge
  • MMO
  • Tips
  • Security
  • Network
  • Office

©2024 AnonyVietFor Knowledge kqxs hôm nay xem phim miễn phí SHBET https://kubet88.yoga/ bj88

wpDiscuz
0
0
Would love your thoughts, please comment.x
()
x
| Reply