{"id":18563597,"url":"https://github.com/ishanoshada/lfi","last_synced_at":"2025-04-10T03:32:58.106Z","repository":{"id":231930010,"uuid":"783032275","full_name":"Ishanoshada/LFI","owner":"Ishanoshada","description":"A side note about LFI and Leaking the php source of some sites","archived":false,"fork":false,"pushed_at":"2024-04-13T11:13:38.000Z","size":402,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-24T16:03:41.266Z","etag":null,"topics":["blue-team","cyber-security","cybersecurity","lfi","owasp","web-attack"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Ishanoshada.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-04-06T18:45:57.000Z","updated_at":"2024-04-27T15:06:40.000Z","dependencies_parsed_at":"2024-04-06T22:22:29.949Z","dependency_job_id":"85a3badc-d41f-4c30-9a01-da691774cc07","html_url":"https://github.com/Ishanoshada/LFI","commit_stats":null,"previous_names":["ishanoshada/lfi"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ishanoshada%2FLFI","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ishanoshada%2FLFI/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ishanoshada%2FLFI/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ishanoshada%2FLFI/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Ishanoshada","download_url":"https://codeload.github.com/Ishanoshada/LFI/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248151480,"owners_count":21056110,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["blue-team","cyber-security","cybersecurity","lfi","owasp","web-attack"],"created_at":"2024-11-06T22:13:00.322Z","updated_at":"2025-04-10T03:32:57.489Z","avatar_url":"https://github.com/Ishanoshada.png","language":"PHP","readme":"# 🛡️ LFI Vulnerability Repository\n\n\nWelcome to the LFI Vulnerability  repository! This comprehensive guide will provide you with everything you need to understand, explore, and mitigate Local File Inclusion (LFI) vulnerabilities in web applications. Whether you're a cybersecurity enthusiast, a web developer, or simply curious about web security, this repository is your ultimate resource.\n\nGive us a ⭐️ if you find this project helpful!\n\n## 🚀 Dive into the World of LFI Vulnerabilities\n\nLocal File Inclusion (LFI) is a critical security vulnerability that occurs when a web application improperly includes files on a server through the web browser. This oversight can lead to severe consequences, including unauthorized access to sensitive files, execution of malicious code, and compromise of the entire web application.\n\n## 🎯 What's Inside?\n\n1. **Example Vulnerable Code**: Get hands-on experience with real-world vulnerable PHP code, showcasing how LFI vulnerabilities can be exploited.\n\n2. **Mitigation Strategies**: Learn best practices for mitigating LFI vulnerabilities, including input validation, whitelisting, and secure coding practices.\n\n3. **Advanced LFI Methods**: Explore advanced techniques used by attackers to exploit LFI vulnerabilities, such as directory traversal and PHP wrapper manipulation.\n\n4. **Example Usage**: Test your skills by using example URLs to exploit LFI vulnerabilities in simulated web applications.\n\n5. **Vulnerable Websites**: Explore real websites with LFI vulnerabilities, along with example URLs for testing and learning purposes.\n\n## 🛠️ Example Vulnerable Code\n\n```php\n\u003c?php\n$file = $_GET['file'];\nheader(\"Cache-Control: public\");\nheader(\"Content-Description: File Transfer\");\nheader(\"Content-Type: application/octet-stream\");\nheader(\"Content-Transfer-Encoding: binary\");\nheader(\"Content-disposition: attachment; filename=$file\");\nreadfile($file);\n?\u003e\n```\n\n```php\n\u003c?php\n$file = $_GET['file'];\n$allowed_files = array(\"down.php\", \"config.php\", \"index.php\"); // Define an array of allowed files\n$file_path = \"./files/{$file}\"; // Assuming files are stored in a directory called \"files\"\n\n// Check if the requested file is in the allowed list and exists\nif (in_array($file, $allowed_files) \u0026\u0026 file_exists($file_path)) {\n    // Check if the requested file is within the \"files\" directory to prevent directory traversal attacks\n    if (strpos(realpath($file_path), realpath('./files')) === 0) {\n        // Set appropriate headers for file download\n        header(\"Cache-Control: public\");\n        header(\"Content-Description: File Transfer\");\n        header(\"Content-Type: application/octet-stream\");\n        header(\"Content-Transfer-Encoding: binary\");\n        header(\"Content-disposition: attachment; filename={$file}\");\n        \n        // Output the file content\n        readfile($file_path);\n        exit; // Terminate the script after file download\n    } else {\n        echo \"Access Denied.\"; // Output an error message if file path is outside the allowed directory\n    }\n} else {\n    echo \"Invalid file requested.\"; // Output an error message if the requested file is not allowed or doesn't exist\n}\n?\u003e\n\n```\n\nIn the updated code, we have introduced an array `$allowed_files` containing the names of files that are allowed to be accessed. Before serving the requested file, we check if it exists in the `$allowed_files` array. If it does, the file is served; otherwise, an error message is displayed. This approach helps mitigate the risk of LFI vulnerabilities by restricting access to only whitelisted files.\n\n\n## 🛡️ Mitigation Strategies\n\nImplement robust mitigation strategies to safeguard your web applications against LFI vulnerabilities:\n\n- Validate and sanitize user input rigorously.\n- Whitelist allowed file paths to restrict access.\n- Utilize file system permissions and access controls.\n- Implement Content Security Policies (CSP) to mitigate risks.\n\n## 🔍 Advanced LFI Methods\n\nDiscover advanced techniques employed by attackers to exploit LFI vulnerabilities:\n\n1. **Directory Traversal**: Navigate through file systems to access sensitive files.\n2. **Null Byte Injection**: Bypass file extension checks using null byte injections.\n3. **PHP Wrapper Manipulation**: Exploit PHP wrappers to include remote files or execute arbitrary code.\n\n## 🚀 Example Usage\n\nExplore LFI vulnerabilities in action:\n\n```\nhttp://example.com/download.php?file=/etc/passwd\n```\n\n## 🌐 Vulnerable Websites\n\nDiscover real-world websites with LFI vulnerabilities for testing and learning:\n\n```\n    /bmes.lk/...\n    /daph.cp.gov.lk/...\n    /idcards.ru/...\n    /transfer78.ru/...\n    /ijcrt.org/...\n    /gsmtech.in/...\n    /lepide.com/...\n    /shafriri.co.il/...\n    /boat.rides.lk/...\n      --/taxi.rides.lk/...\n    /minams.edu.pk/...+ db\n    /woomyoung.co.kr/...\n    \n\n```\n\nExplore the source code of these vulnerable websites to understand how LFI vulnerabilities can be present in real-world web applications. Remember to use them for educational and research purposes only.\n\n🔍 **Google Dorks**: [intitle:\"Index of /\" + \"download.php\"](https://github.com/Ishanoshada/GDorks/tree/main/LFI)\n\nUse Google Dork to discover more websites with potential LFI vulnerabilities. However, exercise caution and adhere to ethical guidelines when exploring and testing vulnerable websites.\n\n## 🤝 Contributing\n\nContributions are welcome! If you have additional examples, mitigation strategies, or improvements, feel free to submit a pull request and join the community effort to enhance web security awareness.\n\n## 📝 License\n\nThis repository is licensed under the  GPL-3.0 license. See the [LICENSE](LICENSE) file for details.\n\n---\n\n**Repository Views** ![Views](https://profile-counter.glitch.me/LFI/count.svg)\n\nThank you for exploring the LFI Vulnerability Examples repository. Let's work together to strengthen web security and protect against cyber threats. Happy coding and stay secure! 🛡️🌐\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fishanoshada%2Flfi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fishanoshada%2Flfi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fishanoshada%2Flfi/lists"}