Add Windows OS detection
This commit is contained in:
@@ -42,6 +42,11 @@ def kali_linux?
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Determins if installed on Windows OS
|
||||||
|
def windows?
|
||||||
|
Gem.win_platform?
|
||||||
|
end
|
||||||
|
|
||||||
require 'environment'
|
require 'environment'
|
||||||
|
|
||||||
def escape_glob(s)
|
def escape_glob(s)
|
||||||
@@ -223,7 +228,11 @@ end
|
|||||||
#
|
#
|
||||||
# @return [ Integer ] The number of lines in the given file
|
# @return [ Integer ] The number of lines in the given file
|
||||||
def count_file_lines(file)
|
def count_file_lines(file)
|
||||||
`wc -l #{file.shellescape}`.split[0].to_i
|
if windows?
|
||||||
|
`findstr /R /N "^" #{file.shellescape} | find /C ":"`.split[0].to_i
|
||||||
|
else
|
||||||
|
`wc -l #{file.shellescape}`.split[0].to_i
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Truncates a string to a specific length and adds ... at the end
|
# Truncates a string to a specific length and adds ... at the end
|
||||||
|
|||||||
@@ -152,7 +152,7 @@ def main
|
|||||||
|
|
||||||
# Output runtime data
|
# Output runtime data
|
||||||
start_time = Time.now
|
start_time = Time.now
|
||||||
start_memory = get_memory_usage
|
start_memory = get_memory_usage unless windows?
|
||||||
puts info("URL: #{wp_target.url}")
|
puts info("URL: #{wp_target.url}")
|
||||||
puts info("Started: #{start_time.asctime}")
|
puts info("Started: #{start_time.asctime}")
|
||||||
puts
|
puts
|
||||||
@@ -440,12 +440,12 @@ def main
|
|||||||
|
|
||||||
stop_time = Time.now
|
stop_time = Time.now
|
||||||
elapsed = stop_time - start_time
|
elapsed = stop_time - start_time
|
||||||
used_memory = get_memory_usage - start_memory
|
used_memory = get_memory_usage - start_memory unless windows?
|
||||||
|
|
||||||
puts
|
puts
|
||||||
puts info("Finished: #{stop_time.asctime}")
|
puts info("Finished: #{stop_time.asctime}")
|
||||||
puts info("Requests Done: #{@total_requests_done}")
|
puts info("Requests Done: #{@total_requests_done}")
|
||||||
puts info("Memory used: #{used_memory.bytes_to_human}")
|
puts info("Memory used: #{used_memory.bytes_to_human}") unless windows?
|
||||||
puts info("Elapsed time: #{Time.at(elapsed).utc.strftime('%H:%M:%S')}")
|
puts info("Elapsed time: #{Time.at(elapsed).utc.strftime('%H:%M:%S')}")
|
||||||
|
|
||||||
rescue Interrupt
|
rescue Interrupt
|
||||||
|
|||||||
Reference in New Issue
Block a user