Benutzer-Werkzeuge

Webseiten-Werkzeuge


metasploit

Unterschiede

Hier werden die Unterschiede zwischen zwei Versionen angezeigt.

Link zu dieser Vergleichsansicht

Beide Seiten der vorigen Revision Vorhergehende Überarbeitung
Nächste Überarbeitung
Vorhergehende Überarbeitung
metasploit [2025/11/14 22:09]
admin [Auxiliary]
metasploit [2025/11/14 22:42] (aktuell)
admin [Sonstige]
Zeile 30: Zeile 30:
 =====Ein Modul schreiben===== =====Ein Modul schreiben=====
  
 +Eine Ruby Datei unter
 +
 +<code>
 +.msf4/modules/<type>/<name>
 +</code>
 +
 +Danach 
 +
 +<code>
 +reload_all
 +</code>
 ====Auxiliary==== ====Auxiliary====
  
Zeile 228: Zeile 239:
       {       {
         'RPORT' => 80,         'RPORT' => 80,
-        'RHOSTS' => '192.168.0.157'+        'RHOSTS' => '192.168.0.157', 
 +        'URI' => '/'
       },       },
       'DefaultTarget'  => 0))       'DefaultTarget'  => 0))
Zeile 331: Zeile 343:
 </code> </code>
  
 +<code ruby>
 +require 'msf/core'
  
 +class MetasploitModule < Msf::Auxiliary
 +  include Msf::Exploit::Remote::HttpClient
 +
 +  def initialize(info = {})
 +    super(update_info(info,
 +      'Name'        => 'Test URL Fetcher',
 +      'Description' => %q{
 +        Dieses Modul ruft eine beliebige URI von einem HTTP-Server ab.
 +        Nützlich zum Lernen, Testen und Debuggen eigener Module.
 +      },
 +      'Author'      => ['mbrain'],
 +      'License'     => MSF_LICENSE
 +    ))
 +
 +    register_options(
 +      [
 +        Opt::RHOSTS(nil),
 +        Opt::RPORT(80),
 +        OptString.new('URI', [ true, 'Pfad/URL, die abgerufen werden soll', '/' ])
 +      ]
 +    )
 +  end
 +
 +  def run
 +    print_status("Rufe http://#{rhost}:#{rport}#{datastore['URI']} ab...")
 +
 +    begin
 +      res = send_request_cgi({
 +        'method' => 'GET',
 +        'uri'    => datastore['URI']
 +      })
 +
 +      if res
 +        print_good("Status: #{res.code}")
 +        print_good("Server-Header: #{res.headers['Server']}") if res.headers['Server']
 +
 +        print_line("")
 +        print_line("=== Inhalt der Antwort ===")
 +        print_line(res.body || "<kein Inhalt>")
 +      else
 +        print_error("Keine Antwort erhalten.")
 +      end
 +
 +    rescue ::Rex::ConnectionError
 +      print_error("Verbindung fehlgeschlagen")
 +    end
 +  end
 +end
 +</code>
 +
 +
 +<code ruby>
 +# MySampleModule
 + 
 +class MetasploitModule < Msf::Exploit::Remote
 +  Rank = NormalRanking
 + 
 +  include Msf::Exploit::Remote::Tcp
 + 
 +  def initialize(info = {})
 +    super(update_info(info,
 +      'Name'           => 'My sample Exploit',
 +      'Description'    => %q{
 +        This file illustrates how to write a module.
 +      },
 +      'License'        => 'UnLicense',
 +      'Author'         => ['mbrain'],
 +      'References'     =>
 +        [
 +          [ 'CVE', '1234-5678' ],
 +        ],
 +      'Payload'        =>
 +        {
 +          'Space'    => 1000,
 +          'BadChars' => "\x00",
 +        },
 +      'Targets'        =>
 +        [
 +          [
 +            'Windows XP/Vista/7/8',
 +            {
 +              'Platform' => 'win',
 +              'Ret'      => 0x41424344
 +            }
 +          ],
 +        ],
 +      'DisclosureDate' => 'Apr 1 2013',
 +      'DefaultOptions' =>
 +        {
 +          'RPORT'  => 80,
 +          'RHOSTS' => '192.168.0.157'
 +        },
 +      'DefaultTarget'  => 0
 +    ))
 + 
 +    register_options(
 +      [
 +        Opt::RPORT(4444) # Beispieloption für den Remote-Port
 +      ]
 +    )
 +  end
 + 
 +  # Usually this includes code for checking
 +  def check
 +    CheckCode::Vulnerable
 +  end
 + 
 +def exploit
 +  print_status("Baue TCP-Verbindung zu #{rhost}:#{rport} auf...")
 +  connect
 +
 +  uri = '/'
 +  print_status("Sende langsamen HTTP GET Request an #{rhost}:#{rport}#{uri} ...")
 +
 +  # 1) Request-Line
 +  sock.put("GET #{uri} HTTP/1.1\r\n")
 +  sleep(1)  # 1 Sekunde Pause – nur Demo
 +
 +  # 2) Host-Header
 +  sock.put("Host: #{rhost}\r\n")
 +  sleep(1)
 +
 +  # 3) User-Agent
 +  sock.put("User-Agent: SlowDemoMetasploit\r\n")
 +  sleep(1)
 +
 +  # 4) Connection-Header
 +  sock.put("Connection: close\r\n")
 +  sleep(1)
 +
 +  # 5) Leere Zeile zum Abschließen des Headers
 +  sock.put("\r\n")
 +
 +  print_status("Request komplett geschickt, warte auf Antwort...")
 +
 +  # Antwort lesen (einmalig)
 +  response = sock.get_once(-1, 5)  # bis zu 5 Sekunden warten
 +
 +  if response
 +    print_good("Antwort erhalten:")
 +    print_line(response)
 +  else
 +    print_warning("Keine Antwort erhalten (Timeout).")
 +  end
 +
 +  disconnect
 +end
 +end
 +</code>
 =====Links===== =====Links=====
  
metasploit.1763154553.txt.gz · Zuletzt geändert: 2025/11/14 22:09 von admin