w4b-file 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/w4b-file +2 -3
- data/lib/w4b_file/cli.rb +177 -0
- data/lib/w4b_file/version.rb +3 -0
- data/lib/w4b_file.rb +2 -0
- data/w4b-file.gemspec +1 -1
- metadata +4 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3b52d52d15b4fe0ac4a5153535db040e0b53d8b17a497d7404c54e8c7cb72090
|
4
|
+
data.tar.gz: c06dda2ee353bb0c284feeb5990f4c24e47d75382a166d3eca160670c4c5ef9f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b5f3e689e5168ea855a40da42a6f412eb620e53206b447de4ac98ebca9709d16f23340c88824ba9ba0e33bcd958687a8102a6cbdac089be6cd65d6fdda31134c
|
7
|
+
data.tar.gz: '0802219fc1b1032e56669b5dfd02e2cfe593d2ba6a1779aa412b258701b02cb26b77954cdaa5d5b3b9014dceeddad8b269d44c682d1d44b86a309daf26e03db4'
|
data/bin/w4b-file
CHANGED
data/lib/w4b_file/cli.rb
ADDED
@@ -0,0 +1,177 @@
|
|
1
|
+
#!/bin/ruby
|
2
|
+
############################################################################
|
3
|
+
# © 2023 Tony-Linux. All Rights Reserved. #
|
4
|
+
# For inquiries regarding this project, kindly reach out to: #
|
5
|
+
# Email: mrhunter5@proton.me #
|
6
|
+
# #
|
7
|
+
# This content is protected by copyright law and may not be replicated #
|
8
|
+
# or altered without the explicit written consent of the copyright #
|
9
|
+
# holder. #
|
10
|
+
############################################################################
|
11
|
+
|
12
|
+
require 'uri'
|
13
|
+
require 'net/http'
|
14
|
+
require 'openssl'
|
15
|
+
|
16
|
+
module W4bFile
|
17
|
+
class CLI
|
18
|
+
def self.validate_and_sanitize_url(url)
|
19
|
+
uri = URI.parse(url)
|
20
|
+
return nil unless uri.scheme == 'http' || uri.scheme == 'https'
|
21
|
+
|
22
|
+
uri.to_s
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.scan_website(url)
|
26
|
+
uri = URI.parse(url)
|
27
|
+
response = Net::HTTP.get_response(uri)
|
28
|
+
|
29
|
+
return [] unless response.is_a?(Net::HTTPSuccess)
|
30
|
+
|
31
|
+
response.body.scan(/href="([^"#]*)"|\ssrc="([^"#]*)"/).flatten.compact
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.display_files(files, type, base_url)
|
35
|
+
return if files.empty?
|
36
|
+
|
37
|
+
puts "\e[37m [\e[32m+\e[37m]\e[32m #{type} files :"
|
38
|
+
files.each do |file|
|
39
|
+
display_url = URI.join(base_url, file).to_s
|
40
|
+
puts "\e[37m [\e[32m+\e[37m]\e[32m Link : #{display_url}"
|
41
|
+
end
|
42
|
+
puts
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.scan_hidden_files(url)
|
46
|
+
uri = URI.parse(url)
|
47
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
48
|
+
http.use_ssl = (uri.scheme == 'https')
|
49
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
50
|
+
|
51
|
+
request = Net::HTTP::Get.new(uri)
|
52
|
+
request['User-Agent'] = 'Googlebot'
|
53
|
+
response = http.request(request)
|
54
|
+
|
55
|
+
hidden_files = []
|
56
|
+
if response.is_a?(Net::HTTPSuccess)
|
57
|
+
response.body.scan(/href="([^"#]*)"/).flatten.compact.each do |file|
|
58
|
+
hidden_files << file if file.start_with?(".") || file.include?("/.")
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
hidden_files
|
63
|
+
end
|
64
|
+
|
65
|
+
def self.check_files(type, url)
|
66
|
+
resources = scan_website(url)
|
67
|
+
files = resources.grep(/\.(#{type})$/i)
|
68
|
+
display_files(files, type.upcase, url) if !files.empty?
|
69
|
+
files
|
70
|
+
end
|
71
|
+
|
72
|
+
def self.check_all_files(url)
|
73
|
+
resources = scan_website(url)
|
74
|
+
display_files(resources, "All", url) if !resources.empty?
|
75
|
+
resources
|
76
|
+
end
|
77
|
+
|
78
|
+
def self.run_checks(check_type, website_url)
|
79
|
+
case check_type
|
80
|
+
when "videos"
|
81
|
+
files_found = check_files("mp4|avi", website_url)
|
82
|
+
if files_found.empty?
|
83
|
+
puts "\e[37m [\e[31m+\e[37m]\e[31m No video files found."
|
84
|
+
end
|
85
|
+
when "images"
|
86
|
+
files_found = check_files("jpg|jpeg|png", website_url)
|
87
|
+
if files_found.empty?
|
88
|
+
puts "\e[37m [\e[31m+\e[37m]\e[31m No image files found."
|
89
|
+
end
|
90
|
+
when "zip"
|
91
|
+
files_found = check_files("zip", website_url)
|
92
|
+
if files_found.empty?
|
93
|
+
puts "\e[37m [\e[31m+\e[37m]\e[31m No zip files found."
|
94
|
+
end
|
95
|
+
when "pdf"
|
96
|
+
files_found = check_files("pdf", website_url)
|
97
|
+
if files_found.empty?
|
98
|
+
puts "\e[37m [\e[31m+\e[37m]\e[31m No PDF files found."
|
99
|
+
end
|
100
|
+
when "document"
|
101
|
+
files_found = check_files("doc|docx|txt", website_url)
|
102
|
+
if files_found.empty?
|
103
|
+
puts "\e[37m [\e[31m+\e[37m]\e[31m No document files found."
|
104
|
+
end
|
105
|
+
when "--check hidden"
|
106
|
+
hidden_files = scan_hidden_files(website_url)
|
107
|
+
display_files(hidden_files, "Hidden", website_url) if !hidden_files.empty?
|
108
|
+
else
|
109
|
+
puts "\e[37m [\e[31m+\e[37m]\e[31m Invalid check type. Available options: videos, images, zip, pdf, document, --check hidden"
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
def self.start(argv)
|
114
|
+
website_url = argv[0]
|
115
|
+
check_type = argv[1]
|
116
|
+
|
117
|
+
if website_url.nil?
|
118
|
+
puts "w4b-file : is a powerful tool that scans sites for files. It finds file types and shows hidden files. Examples: PDFs, images, videos, or all site files.\nLINK : https://github.com/Tony-Linux/w4b-file\nUsage : w4b-file <website_url> [--check <file_type>]\n\nOptions:\n <website_url> The URL of the website to scan for files.\n --check <file_type> Specify the type of files to check (pdf, image, video, php, zip, doc, hidden).\n w4b-file <website_url> Check and display all files on the website.\n\nExamples:\n w4b-file https://example-url.co.vias --check pdf # Check all PDF files on the website.\n w4b-file https://example-url.co.vias --check image # Check all image files on the website.\n w4b-file https://example-url.co.vias --check zip # Check all ZIP files on the website.\n w4b-file https://example-url.co.vias --check document # Check all document files on the website.\n w4b-file https://example-url.co.vias --check videos # Check Video files on the website."
|
119
|
+
exit 1
|
120
|
+
end
|
121
|
+
|
122
|
+
website_url = validate_and_sanitize_url(website_url)
|
123
|
+
if website_url.nil?
|
124
|
+
puts "\e[37m [\e[31m+\e[37m]\e[31m Invalid URL format."
|
125
|
+
exit 1
|
126
|
+
end
|
127
|
+
|
128
|
+
if check_type == "--check"
|
129
|
+
file_type = argv[2]
|
130
|
+
run_checks(file_type, website_url) if file_type
|
131
|
+
elsif check_type == "--check all"
|
132
|
+
check_all_files(website_url)
|
133
|
+
elsif check_type == "--check hidden"
|
134
|
+
run_checks(check_type, website_url)
|
135
|
+
else
|
136
|
+
pdf_files = scan_website(website_url).grep(/\.pdf$/i)
|
137
|
+
image_files = scan_website(website_url).grep(/\.(jpg|jpeg|png)$/i)
|
138
|
+
video_files = scan_website(website_url).grep(/\.(mp4|avi)$/i)
|
139
|
+
php_files = scan_website(website_url).grep(/\.php$/i)
|
140
|
+
zip_files = scan_website(website_url).grep(/\.zip$/i)
|
141
|
+
doc_files = scan_website(website_url).grep(/\.(doc|docx|txt)$/i)
|
142
|
+
|
143
|
+
case check_type
|
144
|
+
when "images"
|
145
|
+
if image_files.empty?
|
146
|
+
puts "\e[37m [\e[31m+\e[37m]\e[31m No image files found."
|
147
|
+
else
|
148
|
+
display_files(image_files, "Image", website_url)
|
149
|
+
end
|
150
|
+
when "pdf"
|
151
|
+
if pdf_files.empty?
|
152
|
+
puts "\e[37m [\e[31m+\e[37m]\e[31m No PDF files found."
|
153
|
+
else
|
154
|
+
display_files(pdf_files, "PDF", website_url)
|
155
|
+
end
|
156
|
+
when "videos"
|
157
|
+
if video_files.empty?
|
158
|
+
puts "\e[37m [\e[31m+\e[37m]\e[31m No video files found."
|
159
|
+
else
|
160
|
+
display_files(video_files, "Video", website_url)
|
161
|
+
end
|
162
|
+
else
|
163
|
+
display_files(image_files, "Image", website_url) if !image_files.empty?
|
164
|
+
display_files(pdf_files, "PDF", website_url) if !pdf_files.empty?
|
165
|
+
display_files(video_files, "Video", website_url) if !video_files.empty?
|
166
|
+
display_files(php_files, "PHP", website_url) if !php_files.empty?
|
167
|
+
display_files(zip_files, "ZIP", website_url) if !zip_files.empty?
|
168
|
+
display_files(doc_files, "Document", website_url) if !doc_files.empty?
|
169
|
+
|
170
|
+
if image_files.empty? && pdf_files.empty? && video_files.empty? && php_files.empty? && zip_files.empty? && doc_files.empty?
|
171
|
+
puts "\e[37m [\e[31m+\e[37m]\e[31m No files found."
|
172
|
+
end
|
173
|
+
end
|
174
|
+
end
|
175
|
+
end
|
176
|
+
end
|
177
|
+
end
|
data/lib/w4b_file.rb
ADDED
data/w4b-file.gemspec
CHANGED
@@ -3,7 +3,7 @@ lib = File.expand_path('lib', __dir__)
|
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
4
|
Gem::Specification.new do |spec|
|
5
5
|
spec.name = 'w4b-file'
|
6
|
-
spec.version = '1.0.
|
6
|
+
spec.version = '1.0.4'
|
7
7
|
spec.authors = ['MrFidal']
|
8
8
|
spec.license = 'MIT'
|
9
9
|
spec.required_ruby_version = '>= 3.0'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: w4b-file
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- MrFidal
|
@@ -51,6 +51,9 @@ files:
|
|
51
51
|
- lib/w4b-file/cli.rb
|
52
52
|
- lib/w4b-file/scanner.rb
|
53
53
|
- lib/w4b-file/version.rb
|
54
|
+
- lib/w4b_file.rb
|
55
|
+
- lib/w4b_file/cli.rb
|
56
|
+
- lib/w4b_file/version.rb
|
54
57
|
- w4b-file.gemspec
|
55
58
|
homepage: https://github.com/Tony-Linux/w4b-file
|
56
59
|
licenses:
|