Ich habe ein Programm, das offene Proxies zu erzeugen versucht, werde ich dieses Programm als Pentesting-Tool verwenden und sind dabei auf einen Fehler in letzter Zeit kommen:Erstellen eines varible mit einer Reihe
proxygen.rb:134:in `<=': comparison of Fixnum with nil failed (ArgumentError)
from proxygen.rb:134:in `check_for_amount_of_proxies'
from proxygen.rb:153:in `<main>'
Was geschieht, ist I haben eine Variable @file_size
und eine Variable @amount
, die Variable wird verwendet, um zu bestimmen, wie viele mögliche IP-Adressen erstellt werden und @file_size
wird verwendet, um festzustellen, ob das Programm die erforderliche Anzahl von Proxys gefunden und in einer Datei gespeichert hat.
Quelle:
#!/usr/local/bin/env ruby
require 'colored'
require 'timeout'
require 'net/ping'
require 'proxies-scanner'
require 'etc'
LOGIN = Etc.getlogin
PATH = Dir.pwd
def fatal(input)
t = Time.now
puts "\n[[#{t.hour}:#{t.min}:#{t.sec} FATAL]]#{input}".red.bold
end
def notice(input)
t = Time.now
puts "\n[#{t.hour}:#{t.min}:#{t.sec} NOTICE]#{input}\n".blue.bold
end
def err(input)
t = Time.now
puts "[#{t.hour}:#{t.min}:#{t.sec} ERROR]#{input}".red.bold
end
def info(input)
t = Time.now
puts "[#{t.hour}:#{t.min}:#{t.sec} INFO]#{input}".green.bold
end
def success(input)
t= Time.now
puts "[#{t.hour}:#{t.min}:#{t.sec} [SUCCESS]#{input}".green.bold
end
def warn(input)
t = Time.now
puts "[#{t.hour}:#{t.min}:#{t.sec} WARNING]#{input}".yellow.bold
end
def self.windows?
return File.exist? "c:/WINDOWS" if RUBY_PLATFORM == 'java'
RUBY_PLATFORM =~ /mingw32/ || RUBY_PLATFORM =~ /mswin32/
end
def self.linux?
return File.exist? "/usr" if RUBY_PLATFORM == 'java'
RUBY_PLATFORM =~ /linux/
end
def self.os
return :linux if self.linux?
return :windows if self.windows?
nil
end
def check_os
notice("Hello #{LOGIN}, it appears that #{os.capitalize} is your OS, path has been switched to #{PATH}")
end
def check_file
if File.exist?("proxies.txt")
File.truncate("proxies.txt", 0)
notice("File exists in system, resuming process.")
else
notice("File proxies.txt created successfully.")
File.new("proxies.txt")
end
end
def choose_proxy_amount
print "Enter proxy amount: ".yellow.bold
@amount = gets.chomp.to_i
notice("Amount is measure in KB")
case @amount
when @amount >= 100
@file_size = 0..2154
when @amount <= 101
@file_size = 2166..21618
else
end
end
def create_possibles
notice("Attempting to ping generated IP addresses.")
ports = %w(80 443 1935 2222 3128 3130 7808 8080 8081 8085 8089
8090 8102 8104 8106 8118 8119 8123 8888 8898 9000
9090 9797 9999 10000 10052 10053 10059 10088 12345
18000 18001 18008 37564 40080 55336 59998
)
@amount.times do
@ip = Array.new(4){rand(256)}.join('.')
begin
Timeout::timeout(5) do
if Net::Ping::ICMP.new(@ip).ping?# == true
success("Possible proxies created for IP: #{@ip}")
File.open("proxies.txt", "a+") do |proxy|
ports.each { |port| proxy.puts("#{@ip}:#{port}") }
end
else
err("IP failed to ping: #{@ip}")
end
end
rescue Timeout::Error
warn("IP timed out: #{@ip}")
next
end
end
end
def check_for_amount_of_proxies
if File.size("proxies.txt") <= @file_size
notice("Proxies created, attempting connection")
system("proxies-scanner -f proxies.txt")
warn("Truncating file: proxies.txt")
else
notice("File doesn't contain enough proxies, restarting IP finding proccess.")
create_possibles
end
end
begin
check_file
check_os
choose_proxy_amount
create_possibles
check_for_amount_of_proxies
rescue RuntimeError => e
fatal("This program requires Adminstration access to run, please switch to admin terminal.")
end
Also das Programm fehlschlägt, wenn er versucht, die Größe der Datei in die Variable @file_size
zu vergleichen. Meine Frage ist, gibt es eine Möglichkeit, diese Variable in einen Bereich zu erstellen?
Willkommen bei Stack Overflow. Es sagt Ihnen mehr als "Vergleich von Fixnum mit nil failed (ArgumentError)", es sollte Ihnen die Zeilennummer mitteilen, die für uns wichtig ist. Bitte lesen Sie "[mcve]". Wir benötigen ein minimales Beispiel für den Problemcode, zusammen mit minimalen Eingabedaten, die das Problem demonstrieren, und der erwarteten Ausgabe. –
@theTinMan Korrigiert, dass sollte genauer sein. Die Zeilennummer ist nicht entscheidend für das Problem. – 13aal
Vielen Dank für die Änderung, aber es hilft uns nicht, den Code auszuführen, um festzustellen, wo das Problem liegt. Wenn die Zeilennummer nicht wichtig ist, wenn Sie dann eine Ausnahme erhalten? –